Loading...
 
Skip to main content

System Workbench for STM32


new to ST in general... actually new to ARM

Hi, I am very new to this, we have a simple project and I would like to familiarize myself with ST, there is a tonne of material all over the place and I am not sure where to look, I tried looking for simple instructions on how to blink an LED, can anyone help me by pointing me to the right direction?

I think I understand how to create a new project, I downloaded the libraries, but I could use a tutorial on making a new project too.

also a small thing, does AC6 have any form of predictive texts? as in if I start typing a declared variable, is there a way of a drop list to pop up while typing? just a beginners questions, all other IDEs ive worked with has this feature

thanks

Hi,

You can find this kind of examples on ST HAL library examples. Please find below more details.

ST groups their MCUs in families:
STM32F0 - Entry-level ARM Cortex-M0, 16-256 KB Flash, 4-32kB RAM, 48MHz
STM32F1 - Cortex-M3, 16KB-1MB Flash, 4-96kB RAM, 24-72MHz
STM32F2 - Cortex-M3, 128KB-1MB Flash, 64k-128kB RAM, 120MHz
STM32F3 - Cortex-M4 (DSP+FPU), 16KB-512KB Flash, 10k-80kB RAM, 72MHz
STM32F4 - Cortex-M4 (DSP+FPU), 128KB-2048KB Flash, 64k-384kB RAM, 84-180MHz
STM32F7 - Cortex-M7, 512KB-1024KB Flash, 320kB RAM, 216MHz
And Low Power families not listed here

For more details check this page: http://www.st.com/web/en/catalog/mmc/FM141/SC1169?sc=stm32

ST provides three kind of boards for starting using their microcontrollers: Discovery, Eval boards and Nucleo boards. From this, Discovery and Nucleo are very affordable. Eval boards are more complex, permits to full explore the microcontroller but are more expensive.

For reference I will use STM32F3 Discovery board: http://eu.mouser.com/ProductDetail/STMicroelectronics/STM32F3DISCOVERY/?qs=sGAEpiMZZMtw0nEwywcFgJyZJO1S2AOEurn3dv8g1%2fA%3d
This board costs around 10 EUR and has the debugger (STLINK-V2) on-board, so there is no need to buy a separate hardware debugger.

Download STM32CubeMX software from ST. This application is a graphical software configuration tool that allows generating C initialization code using graphical wizards.
Link is here (go to the end of the page in section Get Software): http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1533/PF259242?sc=stm32cube
After installing STM32CubeMX, from this application you can download and install ST HAL libraries. For the above mentioned board/microcontroller you have to install "STM32CubeF3".
(If you need more detailes let me know.)

If you prefer, it is possible to download only the HAL library without STM32CubeMX. On the page above check "Related Tools and Software" section.

Once you have download and installed the library check the Examples folder:
\ST_Cube_Library\Repository\STM32Cube_FW_F3_V1.2.0\Projects\STM32F3-Discovery\Examples\GPIO\GPIO_IOToggle
In the above path directory "ST_Cube_Library" is where I choose to download and install the library and the rest of the path is created by installer (and will be the same for all systems). Then you should go to SW4STM32 - this is the project for OpenSTM32 toolchain. Import this project in System Workbench, build and try to debug.

ST examples are organised as below:
>Projects
>>>>Board_Name
>>>>>>Examples - simple examples demonstrating each peripheral
>>>>>>Demonstrations - the example that runs on board from factory (the most complex example)
>>>>>>Applications - demonstrating FreeRTOS, USB, FAT and other middlewares


Another possibility is to generate the code from CubeMX software, then import this code on System Workbench. The only line that should be added here manually (after the code is imported in SW) is the HAL_GPIO_TogglePin() function.
You have to select you board when start the CubeMX and then Clock and GPIO are correct configured.
At this link is described how to import a CubeMX generated project into System Workbench: http://www.openstm32.org/Importing+a+STCubeMX+generated+project

AH! brilliant, thank you so much for the links and showing me the right direction, im going straight to blinking an LED and hopefully rs232 comms by the end of the night!

I should mention that I have a nucleo f401re board,

I managed to download the HAL libraries for the nucleo board and found the projects you enlisted, I spent quite some time trying to figure out how to get the example projects imported to ac6, but I cant seem to build it, how do you import those projects like GPIO into your current workspace and build it? every time I build, I dont get any errors, but when I try to debug, I get an error saying that I dont have a build. I tried following the instructions from this link:

http://www.openstm32.org/Importing+a+STCubeMX+generated+project?structure=Documentation

but I get stuck at the step 3, I dont understand the part where your project must not contain STM32CubeMX,

I dont know if I am doing something wrong around this.

I tried ignoring it and just try import the project. the issue is that in that link, it was possibly for an older version of ac6, the current version of ac6 asks what kind of a project you want to import. i tried to import a C++ or C but the window from step 4 is not the one they offer. however, if I select General>Existing projects into workspace and click next, I get the same window shown in the link step 4.

still the problem persists when I select the right directory, and the "configuration" part is not visible in the selection where the tick box is. and also the tick box is disabled, so I can not select it. tried refreshing, cant finish the import cause I cant select.

is there something I missed? how do I import an example project from cube to work on ac6 and then upload it on my nucleo and begin debugging?

thanks for the help


For the examples use (File->Import General>Existing projects into workspace) as you already have tried.


The Import from ST Cube documentation works if you generate the project from CubeMX but the examples are not CubeMX generated.

It is a little tricky when you do this for the first time with Eclipse, but after you know how to do it is not so complicated.

I have the board that you mention and I can make few screen shots to help you to start with example project. I just receive the board 3 days ago so I did not have time to load something on this board - so I will try this example for the first time.
I will try to do the screen shots until tomorrow afternoon (but I don't promise you).


The example (GPIO toggle) is building without errors and I created Debug Configuration. Not downloaded the code to board yet because I don't have right now the board.
I take 17 screens shots while I import/build/create debug configuration.


I think I may be messing around with the workspace idea, I havent worked on eclipse before, I dont have a clear enough idea of how a workspace works.

so I made myself a folder in C:/ called black box, I went on eclipse and file>switch workspace and then set my workspace to this folder (c:/black box/)

in this folder I saw eclipse immediately makes 2 folders with configurations because I noticed the theme changed back to the bright white theme.

next I copied the GPIO example folder into this black box of mine and imported, built, and then I noticed the error in the bottom and it could not find the one header file stm32f4xx_hal.h and realized thats why the project was not building properly.

so I started looking for it in the project pane on the left (STM32F4xx-Nucleo>Drivers>STM32F4xx_HAL_Driver>stm32f4xx_hal.h) where I tried opening the file and it gave me an error saying that this file was missing.

upon checking this files properties, the project showed the location of this file to being: PROJECT_LOC\..\..\..\..\..\..\..\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c
and then this file location, when resolved, comes up to being in : C:\Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c
but my computer did not have this Drivers folder in C:/ to begin with.

I check in the example folder for nucleo, turns out that the drivers are in the repository folder where I downloaded the HAL libraries (c:\Users\ovi2wise\STM32Cube\Repository\STM32Cube_FW_F4_V1.8.0\Drivers\STM32F4xx_HAL_Driver\).

so I tried copying the Drivers folder from the repository straight to C:/ which opened another can of worms, it solved some of the problems but another 400 popped up, so it was clearly not a solution.

so then I gutsied up and just decided to do what my gut was telling me and decided to import the example straight from the repsitory instead of copying the GPIO example into another folder.

turns out that solved the problems of missing libraries and incl files everywhere. yet, the build would not complete, there are no errors, the build takes some time and there are no messages at the bottom indicating that something went wrong. however, when I go to run>debug as>ac6 stm32 c/c++ application, I get an error saying that it can not find binaries and I should build first.

now im completely lost, any help there?

France

Yes, due to the way the example programs projects are generated, you must import them in your workspace, without copying them. If you really want to copy them in your workspace, then copy the whole firmware tree in your workspace, then import the example project you need.

Regarding your last error it's a known bug in the IDE on which we are working and that should be corrected in a forthcoming release.

However there is a very simple workaround: you just have to right-click on your project in the project explorer pane and then select Refresh...; then you will be able to debug your program.

Sorry for the inconvenience,

Bernard

Hi Bernard. its a small trick, easy tweak. I will keep my ears open for the next version and look forward to the fix. thank you for the workaround. it helped

I did not have time to finish the step by step example but here it is an incomplete version.

Try to make a Refresh (F5) on project after build (right click on project, Refresh) - you should see the .elf file if the build was sucessfully. This is the binary file you should download to target board.
But before to be able to do that you have to create a new debug configuration (AC6 debug configuration).

Check files attached.

For AC6 Debug Configuration - see pictures
Don't forget to "Refresh" the project after Build phase (else you should locate your ELF file manualy)



"yet, the build would not complete, there are no errors, the build takes some time and there are no messages at the bottom indicating that something went wrong"
=> Did you check Console window. Here is the place where Eclipse will print the output. You have to select manually this windows, it is not like in other IDEs where when Build is started Output is automatically shown.

ah! it worked!

not exactly the way I wanted it to work though, I would like to use a differenc space as a workspace since I dont like poluting source files like project examples such as that.

I added a document where you can view my last attempt to import the project into a separate workspace and it ends in an error.

but nonetheless, I am pleased that I finally managed to program my Nucleo and it works and is happily blinking away.

but now, if I were to make this blinking project from scratch, in my own workspace and all, how should I start this?

I am thinking I should start by using the black box as my work space and create a new project? what files should I look at copying into my project? I dont completely understand the structure of the project. can you give me a quick outline on it?

thank you very much for your help this far, it is a lot to ask for more, I appreciate the assistance and look forward to more replies from you.
Kind regards
Ovi

Very glad that you succeed. This is a big step, further you can create projects with you own layout.

====

"not exactly the way I wanted it to work though, I would like to use a differenc space as a workspace since I dont like poluting source files like project examples such as that"

=> consider this as the first test (quick test). Anyway for a project you can't use this layout.
Regarding the polution of ST HAL libray, I have two copies of the libraries one is for this kind of tests and one I use for CubeMX (untouched). Normally I download the zip package of the library (e.g. stm32cube_fw_f7_v110.zip) then if something go wrong I delete the HAL folder and unzip it again. The only problem is that I will lose some of the projects already compiled but when need I import again the project - after a while seems just few clicks.

__For information - you can manage in few different ways (4 maybe) HAL libraries (HAL libraries = the directory structure that contains code provided by ST or other parts for using with ST MCUs)
- CubeMX provides a way to install/update HAL libs. You can choose the location on system
- STM32CubeUpdater - a standalone application (use also by CubeMX?) that can manage HAL libs. Using this app a separate directory from where CubeMX library are installed can be created and managed
- by downloading and unzipping libraries from ST website.
- System Workbench can download (if required) his own copy__


"but now, if I were to make this blinking project from scratch, in my own workspace and all, how should I start this?"

=> it is possible to recreate the project from scratch whit your own layout.
I did this with my projects - it take me few afternoons, deleting the project and start again few times. But if you understand the structure it is not complicated.

Regarding the document GPIO first project:
1) If you use System Workbench ignore TrueStudio. It is a commercial toolchain, Eclipse based and also using gcc as compiler (this is why you see both).

2) I don't know internals of System Workbench, but I think doing this you did not import all the necessary structure (I think dautrevaux mentioned this). The project paths are not correct anymore.


===
Few words about stating from scratch:
If you want to start from scratch (but keep in mind that exist also other ways like generating project from CubeMX, or using SW and ask at the project creation to add HAL)
create a new directory YourProject. Create a directory for SW project like SW4STM32 inside YourProject.
From HAL library you will need this directories Drivers and Middlewares (are on the same level as Projects directory). This are big you need only few files from here - delete later not now.
Then from GPIO_IOToggle project copy Inc and Src directory - this are project source code files.
Start System Workbench (I think you can keep default path for WA) then File > New > C Project > AC6 STM32 MCU Project
Enter a name
and don't use default location -> navigate and choose SW4STM32 folder.

When ask choose "No firmware"

There are much more to say about this, but this is the idea.


France

Nice explanation Ciprian,

Note that creating the proper layout and getting the latest supported firmware from ST can be done simply through System Workbench for STM32:

  1. Create an empty directory for your workspace to be sure you start from a clean environment
  2. Create a new C or C++ Ac6 STM32 MCU Project targeting your MCU
  3. Choose the firmware you want (HAL for example)
  4. Select the "Extract all firmware in separate folder" check box
    • This will creta a generic project, with the wole content of the ST firmware
      • This project is by default created closed
      • You must open it (right click >> Open project) to look at its content
    • This is not a compilable C or C++ project, just a set of files
    • Use it to browse through the ST provided files and copy the ones you may need in your own project
  5. Select the "As sources" radio button
    • Then the needed firmware elements will be added to your project, not to an external library project
    • This may simplify adapting the code and configuration to your needs
    • Otherwise the ST firmwares will be loaded in a separate library project, automatically linked to your project
      • This will allow to reuse the same library project for several projects
      • However some firmwares (notably FreeRTOS) may be copied in your project anyway, as project-specific configuration may be needed
      • Currently, as not all additional firmwares are fully configured by System Workbench, the first solution may be simpler to use
  6. Select the additional components you want to have in your project
    • You may also, later on, add more just by draging and dropping from the firmware reference project to your project


Then you project structure will look like the one you manually created and most (if not yet all) include and library paths will be set up automatically.

Bernard



Thanks Bernard for explanation, and for work on System Workbench project.


Good Day

thank you for your replies, my apologies for a slow reply, I had to continue with other work and resumed recently.

I tried what ciprian said, I created a new project and added the libraries as shown in the tree view and instead of how dautra explained, I chose the "no firmware" option in the project creation place where they offer to use the HAL libraries.
(would you please explain in simple terms exactly what happens in that page? the one where you chose HAL libraries or no firmware)

I attached a log of what I did, its pretty long to read, but at the end of the day, I copied all the folders as ciprian explained, but when building, I kept getting errors of functions not being defined, and I investigated and found .h files that were missing, and then copied them into the inc or src folders and refreshed project and then got a whole lot more functions that were missing, this problem looped a few times and I realized there has to be a better solution for this.

Ciprian, would you be able to please share your project folder directly to me for me to study its structure better? the tree view is a bit complex, I cant seem to find all the files. I realize that the drivers and other folders are quite large. please let me know if you would be able to share these files in a zip file or rar file through google drive or some form of file sharing method.

I am trying again to build the project, this time I will pay better attention to the tree structure given by ciprian, then my next option is to try and combine what dautre explained. I will keep you guys posted


Hi,

1. It is ok for you if I will add the project on github and post a link to the github project here?.
I will make the project public, then anyone can clone the project. (I use SourceTree application to manage git projects).

2. After copy the files/directories necessary for the project you will have only a bunch of files in some directories - this IS NOT a System Workbench project. You should not try to compile this bunch of files yet. There is one more big step to do.

Here is what I have done after the structure of the project was created (copy file part):
- add required paths to project (see picture Include_paths.png).
You can check the example project to know what you have to add to project paths.

- add required c source files to the project (you can add here also complete directories if you need). You can see in the second picture. I added all that c files one by one. As Bernard suggest there is a better way to do this.
To know what source files you have to add check the example project. In SW/Project Explorer check the files that you need.

Refresh the project and Rebuild the index. If all necessary include paths and all sources are in place the build should succeed.

I suggest you to delete the project and start from this point again. You can keep the folders structure.


ok, ive tried to do this according to ciprian and deutraveaux, I dont understand why this is so complicating to just blink an LED? I understand that copying files would be pretty simple, but so far ST on eclipse is pretty weird coming from an atmel environment.

deutraveaux,

please explain the following:

on point 4,
what do you mean that this project will be created closed?
what kind of files would I require as base requirements for a simple blinking project? what are the files that I should have in every project? at some point, I must do an RS 232 coms part, what files would I require for that kind of comms?

on point 5,

what is an external library project?
how do I configure? what do you mean by configure?

Ciprian,

thank you for your explanations, I appreciate it. please load your workspace folder anyway you feel comfortable, something that I can just paste on my C:/ drive and use as my workspace, if there are huge folders that I already have, then leave them out, I will copy them from my HAL zip files.

so far, if I import the SW4STM32 project folder into my workspace from the GPIO example in the repository in users/.../STM32... the project builds for the GPIO project, as for the UART project, if I try the same thing, I get the weirdest error, please check attached image.

there is a lot of information flying around in this post, I really am looking to just blink an LED and then go onto the next step, would it be alright for you guys to give me a step by step instruction that even illiterate people would understand (^^,)

thank you guys again for the assist



Hi,

Related to your screenshot:
- your include paths (that with STM32Cube) does't look good. i think those includes are not known by IDE - probably the paths are wrong (see attached file on how the paths should look)
- (not so relevant, due to previous point) The "Console" window have more relevant information related to errors. There is no helpful message in that error ("make: ***").

When did you import the UART example did you follow the steps described in document "Importing ST HAL examples into OpenSTM32 System Workbench.pdf" ?
You should create a new workspace in the UART example\SW4STM32.

I have created a minimal project for blinking the LD2 LED on Nucleo F401RE. The project has 8 .c source file and 24 headers files. I copy only what was necessary.
I made screenshots during project creation. I will add a directory with the screen-shoots (in order) and hope that will be enough for beginning. I can add this files
in few days to bitbucket or github. This project is small (few megabytes).


Here is a link to one project that uses HAL library and is created from scratch (the project used as example in previous posts). There is a readme file.
You can Clone the project or download as zip file from site.
https://bitbucket.org/csalageanu/429i-w.git
If you clone, you should wait 2-3 minutes until it finishes.


Hi Ciprian,

I see what you mean, I did snoop around a bit on the downloads and updates in software, I saw some things were buggy, missing header files and some other issues.

good news is that I managed to get my LED to blink all by itself, without the example project (still used parts of the main.c file)

I uninstalled system workbench and cube mx, system workbench had some issues with the HAL library, I think something may have been corrupt or not downloaded properly, I remember a small error when updating and i might have clicked ignore, I forget

so... from the beginning, the idiot proof instructions:

this is what I did.

1) download and install both system work bench and cubemx (already had them)
2) install cubemx, go to help>install new libraries>(select firmware to download, since im using the nucleo STM32F401RE, I downloaded the latest F4 firmware package {v1.8.0})
3) then after installing AC6, select a workspace, any empty folder you want, I have the following: C:/blackbox (I got a tip from a friend to not use any spaces)
4) on AC6, after selecting new work space, go to file>new>C++ project
5) this part is weird, im sure ther are better ways to do this, I just havent figured out how to do it, but make a project name (any name, this will get discarded)
6) select AC6 under executables, keep the default location, doesnt matter really, click next
7) click next on the "select configurations" page, leave it unchanged
8) on the MCU configurations page, since I have a nucleo board (this instruction set is for nucleo!), i select the F401RE nucleo in boards, its configurations are already there, then click next
9) this part is where the updates kick in, the firmware required should get downloaded, click on standard peripheral library, then click on the "download target firmware",(downloading took me a while) DONT CLICK NEXT
10) now select the Cube HAL libraries radio button, click "download target firmware", (this also takes some time)
11) click cancel, discard the project, now your AC6 is updated!

then I wandered off into Cubemx, what a nifty little program

12) open cubemx, since you already downloaded the F4 firmware (see step 2), you can use this program to build yourself a project.
13) click on new project
14) at the top, there is a tab for "board selector", since using nucleo is so easy, there are settings waiting for you, select the type of board (nucleo for me), then select the MCU series (STM32F4), select on your board in the list (STM32F401RE)
15) a picture of a MCU opens up and you you can edit the pins according to the datasheet if you want, but all the pins are setup according to your board, so you dont need to change anything if all you want is to blink an LED
16) go to project>generate code
17) name your project (blinky), under "toolchain" select SW4STM32, I selected C:/blackbox as the folder for my project, your code should be generated without fail
18) go back to system workbench AC6, go to file>import
19) go to general>existing projects into workspace, click next
20) select the root directory, the project folder that you just created (blinky) and click ok
21) and then click finish, voilla, a clean project with all the files you need for your nucleo
22) read up the example folder in your repository for HAL libraries, the GPIO example, using that code you can type in your own code, all the settings are already setup for inputs and outputs, all you need to do is blink an LED.

I added my main.c file if anyone needs to copy code

now that I have figured out how to blink an LED, I can further investigate how to initialize my MCU, from these codes and the project examples, I can also build a working UART mcu, step one for now is complete.

I thank you guys for the assistance, specially ciprian, thank you for putting some effort in helping me understand ST, I look forward to more posts from you.


 
Collapse/expand modules below