comsytec_sro

Comsytec s.r.o.

Comsytec s.r.o.'s Projects :

Return to Projects

Developing STM32 Embedded Applications in Code: Blocks IDE

Project Summary

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.

Project Description

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:

  1. Code::Blocks IDE
  2. Embedded Plugin Suite
  3. ST-Link/V2 driver

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.

Figure:1

Figure 1 

The second window just shows some welcome message.

Figure:2

Figure 2 

In the third window, enter the project title and choose its location.

Figure:3

Figure 3 

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.

Figure:4

Figure 4 

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.

Figure:5

Figure 5 

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.

Figure:6

Figure 6 

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.

Figure:7

Figure 7 

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.

Figure:8

Figure 8 

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.

Figure:9

Figure 9 

After the building process is complete, look at Build log to make sure there are no build errors.

Figure:10

Figure 10 

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.

Figure:11

Figure 11 

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.

Figure:12

Figure 12 

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.

* Ano = Yes * Ne = No
Figure:13

Figure 13 

The EPS Debugger log window collects debugger messages, Here will be logged if some trouble occurs during the connection. Now all is ok.

Figure:14

Figure 14 

After successful connection, we can send (download) our project code into target board.

Figure:15

Figure 15 

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.

Figure:16

Figure 16 

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.

Figure:17

Figure 17 

Project Files

File NameFile Size
Code::Blocks IDE (EPS edition) net installer825.48 KB
Discussed project source code997.52 KB
Tags: Microcontrollers, Debugger, IDE, Embedded Design

Comments on this Project:

There are currently no comments.

Login or Register to post comments.
x
Like free stuff? Enter Here!
EEWeb Weekly Giveaway Sponsored by Mouser This Week: Phoenix Contact WIREFOX 10 Cutting/Stripping tool
Enter Here
Login and enter if you're already a member.
Click Here