Creating a new Embedded C project in STM32CubeIDE

Edition: An empty project without hardware abstraction layer.

G Bharathraj
5 min readApr 15, 2020

Step I: Collecting the primary details:

So before getting started with the course, make sure you are aware of the details of your development board.

Name of the board : e.g: NUCLEO-F446RE
Microcontroller used in the board : e.g: STM32F446RE (Refer Appendix A1)

Does my board have on-board ST-LINK debugger : All Nucleo and Discovery board from ST microelectronics have on-board debugger (To know about the board w/o debugger refer Appendix A2)

Step II: Creating a new project for any STM32 MCU:

First, let us create a new STM32 project,

Steps to be followed to create a new project!
Call the STM32 Project Menu

Let us choose the MCU by giving the appropriate MCU model in the search,
e.g, STM32F446RE, and select the exact MCU from the list and click next.

MCU Selection Menu

NOTE: The Board Selector is NOT used, since the IDE is creating problem when “Empty Project” is being selected in some development boards.

Enter the name of your project and choose empty as target project type and click finish.

Hurrah!! We have successfully created the project. Now it’s time for few more configuration steps to make the system more reliable.

Step III: Configuration of project’s properties:

Now, open the properties of the project, right click on the project and click properties.

In all our project, in order to make the course uniform, the Floating Point Unit FPU as “None” and ABI is set to be “Software Implementation”.

Step IV: Compilation and Debug:

Compiling the project

So, once your are done creating and configuring your project, it’s now time for compilation. Click 🔨 symbol from the toolbar or right click the project and click build project.

Successful build completion

Debugging the project

Now, let us create the debug configuration to flash and debug the code on the target. Right click on the project and select the “debug as”and click STM32 Cortex C / C++

Make sure the application .elf files is properly selected and the respective project folder is selected.

Make sure all the mentioned configuration are set properly in the debugger tab. ( The ITM mode is not used in this case ) and click OK. The debugging will begin.

All done! You are good to debug the application.

Are you facing problem like this ?

Error Message!

Here are possible ways to resolve this issue!

Ensuring all the drivers required by the desktop are available:

Download and install all the necessary driver from the ST Microelectronics website. Driver Download Link: https://www.st.com/en/development-tools/stsw-link009.html

Ensuring the hardware functionality:

*Make sure the hardware is connected to the computer.*

ST-Link Utility Software: https://www.st.com/en/development-tools/stsw-link004.html

In order to ensure the development board’s functionality, we can make use of this utility tool. Click the connect button, and the details of the MCU has to be popped up. This is a good sign that the MCU is functional and also the drivers are installed correctly.

Ensuring the latest ST-LINK firmware been upgraded:

The ST-LINK utility has a built-in firmware upgradation tool for ST-LINK debuggers.

ST-LINK Firmware Update Tool

Once the tool pops up, click the device connect button and click yes. It will take some seconds to get it done.

Progress bar of the firmware up-gradation

Alternative Solution - OpenOCD:

Though all the above mentioned passes, but still if you are facing the ST_LINK DLL error, then ideally the MCU you are using should be a clone one! In that case, you can try to go with change in the gdb server to OpenOCD!

Appendix A0:

The following problems can be resolved by following these instruction properly:

  • PB1: Stuck at infinite loop / default handler
  • PB2: Execution stops at __libc_init_array
  • PB3: Floating Point Unit (FPU) warning
  • PB4: ST-LINK DLL driver error

Appendix A1:

Finding difficulties in finding out your microcontroller?

It is just a simple process, by googling the board name: You will end up in manufacturer’s page.

On the page, you can clearly identify the MCU model number and it’s datasheet.

Appendix A2:

What is STLINK on our development board?

The ST-LINK is an in-circuit debugger and programmer for the STM8 and STM32 microcontroller families. The single wire interface module (SWIM) and JTAG/serial wire debugging (SWD) interfaces are used to communicate with any STM8 or STM32 microcontroller located on an application board.

Does all the development boards have an on-board STLINK ?

Not all the development boards have STLINK debugger! Only the STM32 Nucleo / Discovery boards integrate an ST-Link debugger on-board.

Other boards mostly doesn’t equip an on-board debugger. One such example is the most famous STM32 Blue Pill, and you require an additional debugger for this board.

What are the alternate debugging tools available ?

The most common and affordable debugger for STM32 microcontroller is the ST-LINK/V2 in-circuit debugger and programmer from ST Microelectronics.

An alternate solution is SEGGER J-Link EDU Mini which is bit expensive but it support MCU from different manufacturer like TI, ST, NXP, etc.

--

--