Comsytec s.r.o.'s Projects :Return to Projects
Developing STM32 Embedded Applications in Code: Blocks IDE
For those who have decided to develop STM32 embedded application, but still do not know how to start, now you can get insight. For this purpose, we will use Code: Blocks IDE equipped with Embedded Plugin Suite. The Code::Blocks IDE is an open source free IDE and the Embedded Plugin Suite is a special set of plugins and scripts extending the basic Code::Blocks IDE suite. Embedded Plugin Suite includes GCC ARM toolset for building the projects and also debugger plugin support almost all STM32 devices via ST-Link/V2 in-circuit debug adapter.
For those who have decided to develop STM32 embedded application, but still do not know how to start, now you can get insight. For this purpose, we will use Code::Blocks IDE equipped with Embedded Plugin Suite. The Code::Blocks IDE is an open source free IDE and the Embedded Plugin Suite is a special set of plugins and scripts extending the basic Code::Blocks IDE suite. Embedded Plugin Suite includes GCC ARM toolset for building the projects and also debugger plugin support almost all STM32 devices via ST-Link/V2 in-circuit debug adapter.
You need to install three things to start the development process:
Also you need eval board, e.g., STM32 Discovery series will be the best choice for beginners. In this tip, we will use STM32F3Discovery. This board also includes the debug adapter so you don’t need to buy extra one.
The Project Wizard
After launching the Code::Blocks IDE, select File > New > Project … menu item. This starts showing series of wizard windows guiding you through the project creation process. In the first window, select STM32 Project and confirm your selection.
The second window just shows some welcome message.
In the third window, enter the project title and choose its location.
The fourth allows you to select the target hardware platform and some libraries used in project creation process and also the roamable file format. As mentioned above, our target board now is STM32F3-Discovery. Choosing some eval board gives more options to application skeleton to select from. If you choose Custom design which means project from scratch and then just basic application skeleton will be available.
Fifth window serves for entering of some settings regarding linking. Personally, I recommend not to change these settings if you are not familiar with GNU linker scripts. Values selected or entered here will be reflected in generated linker script. One comment: the linked script name is not target.ld as mentioned in the text at the top, rather project_name>.ld. All requested changes to final memory layout can be achieved via editing of this file later.
Now select the project skeleton. Here it is better to select some ready made project to avoid trouble with building. Also you can try many of these projects and later customize some of them. The edit box below gives some description of the created project.
If you want not to just build the project but to improve it, test it then selecting the right hardware debugger ensures method how to board into work. Here you can for now just select only the ST-Link/V2.
The final step is the toolset selection and build target selection. To allow to debug our project, check Create “Debug” configuration. After changing preselected toolset (compiler) STM32 GCC Compiler can happen that the project will require some manual adjustments due to different compiler options. Perform them in dialog shown after selecting Project > Build options menu item if necessary. Clicking on Finish button launches project creation project. All files will be copied to the directory selected in the third step.
Building the Project
Now our project is ready for build. Launch compiling and linking by pressing Ctrl-F9 or choosing the menu item shown below. More complex project can consist from more build targets. Each of them is compiled and linked separately but with respect of dependence order. Some of the build targets are so called virtual targets which define this dependence.
After the building process is complete, look at Build log to make sure there are no build errors.
Debugging the Project
Now the project is built. It’s time to get it into target board memory. While there can be many different build targets, only some of them embody the complete target code. Others can be some helper or auxiliary build targets. The build targets names entered in final wizard step always meet this requirements. Following explanation describes how to start debugging just shortly.
Activate the connection with ST-Link/V2 in-circuit debug adapter. Do not forget to plug its host USB cable into some of USB ports. Also, you need to connect the target side cable JTAG/SWD cable with target board. This is not the case of STM32 Discovery boards. The new boards has settled jumpers ensuing this at proper position.
Before first time connection, you can observe this dialog requesting to confirm current settings state.
You can keep defaults. Later, you may change this by selecting Debug > Target settings … menu item.
The EPS Debugger log window collects debugger messages, Here will be logged if some trouble occurs during the connection. Now all is ok.
After successful connection, we can send (download) our project code into target board.
Before resetting our board, look again into EPS Debugger log window to see if no error occurred during the download process. To reset (set PC to default initial address) the board, click Debug > Reset menu item.
Now we can start testing what we created. The yellow line shows the current PC (program counter) location.
Describing debugging techniques is beyond the boundaries of this guide.
|File Name||File Size|
|Code::Blocks IDE (EPS edition) net installer||825.48 KB|
|Discussed project source code||997.52 KB|