Revision as of 15:43, 13 September 2023 by Registered User

Tools installation and first testClock.png 45min

Target description
Teach how to install the main tools for programming the STM32:

  • STM32CubeMX, a tool to set and graphically program all STM32 boards and products
  • STM32CubeIDE, the free IDE to develop the STM32 software
  • STM32CubeProg, a tool to load/spy software in the STM32 memory
  • An MCU software package with embedded examples, based on the selected device, e.g. STM32CubeL4, STM32CubeWBA, etc.

Having completed this tutorial, you should be able to open the STM32 professional ecosystem.
You should also manage to bring applications from the ecosystem onto the NUCLEO board.
Finally, you will be able to run the blinking LED example in debug mode.

Prerequisites

  • Computer with Windows 7 (or higher)
  • Java installed
  • web access

Hardware

  • A Nucleo board or a Development kit, e.g.:
    • NUCLEO-L476RG[1] board (64-pin)
    • NUCLEO-WBA52CG[2] board (48-pin)
  • USB Type-A to Mini-B cable

1. Install an IDE

Clock.png 10min
Download and install your preferred IDE. Currently supported options are: STM32CubeIDE[3], Keil uVision[4], IAR EW[5], Microsoft VSCode[6] with the STM32 extension[7].
Follow the instructions on the product's webpage. In case you are using this IDE, you can skip the installation of STM32CubeMX in the following section. With other IDEs, it is necessary to additionally install STM32CubeMX.
Below are the instructions for installing STM32CubeIDE.

1.1. Install CubeIDE

STM32CubeIDE is the Integrated Development Environment to develop STM32 software.

  • Download STM32CubeIDE.

Stepbystep Download STM32CubeIDE.png

  • Register on www.st.com web site if necessary.
  • Unzip the downloaded file and launch the STM32CubeIDE-xxx corresponding to your OS.

STM32CubeIDE is now installed on your computer, enjoy!

1.2. Install another IDE

Please follow the instructions on the product's webpage for installation of other IDEs.

2. (Optional) Install STM32CubeMX

Info white.png Information
This is step is only necessary in case you are using an IDE other than CubeIDE.

Clock.png 10min
STM32CubeMX is the tool to graphically program the STM32.

  • Download STM32CubeMX[8].

Stepbystep Download STM32CubeMX.png

  • Register on www.st.com web site if necessary.
  • Unzip the downloaded file and launch the SetupSTM32CubeMX-xxx corresponding to your OS.

STM32CubeMX is now installed on your computer.

3. Install STM32CubeProg

Clock.png 5min
STM32CubeProgrammer is a tool load/spy software in STM32.

  • Download STM32CubeProg[9].

Download STM32CubePROG.png

  • Unzip the downloaded file and launch the SetupSTM32CubeProgrammer-xxx.exe corresponding to your OS, and follow the instructions.

STM32 USB driver and STM32CubeProg are now installed on your computer.

4. Download firmware package for your device

Clock.png 10min

  • In case you are using STM32CubeIDE, use the built-in version of STM32CubeMX - open STM32CubeIDE.
  • Otherwise, open STM32CubeMX.
  • In both cases, click Manage embedded software packages in Help.
  • Check the last release version of the correct package, e.g. STM32CubeL4, STM32CubeWBA, etc.
  • Click Install (it may take a long time).

Stepbystep Download STM32CubeL4.png

  • Now the chosen libraries and examples are installed at the following location C:\Users\myname\STM32Cube\Repository\STM32Cube_FW_XX_Vx.xx.x (where XX is the MCU series, e.g. L4, WBA, etc.).

5. Launch the IDE and load my first program

Clock.png 10min
Launch your preferred IDE and follow the necessary steps to debug a program on the MCU.
Below are the steps for STM32CubeIDE. Directory path to the example project applies to other IDEs as well.

Use the debug configuration

  • Launch STM32CubeIDE.
  • If STM32CubeIDE asks, select the default workspace.
  • In File STM32CubeIDE menu, click on Open Projects from File System.

Stepbystep Import Project.png

  • In the window, click Directory and select C:\Users\myname\STM32Cube\Repository\STM32Cube_FW_XX_Vx.xx.x\Projects\YYYY\Examples_LL\GPIO\GPIO_InfiniteLedToggling (where XX is the MCU series, e.g. L4, WBA, etc. and YYYY is the board name).
Info white.png Information
The path may be different depending on the product
  • Select the project file inside folder
    • \STM32CubeIDE for more recent projects
    • \SW4STM32\YYYY (where YYYY is the board name) for older projects
  • In case of an older project, accept the popup, asking for conversion.

Project Converter.png

  • Click on Build icon to build the project.


Info white.png Information
Ensure that the CN2 jumper is on, so there would not be any hardware problem.
Ensure also that the ST-Link driver is well installed.

Now your project is under STM32CubeIDE

  • Default STM32CubeIDE settings are adequate for this tutorial.

6. Debug my first program

  • Click on Debug icon to launch and debug the project.

Stepbystep Debug STM32CubeIDE.png

  • Please ensure to click on “Shared ST-Link” option on Debug configurations and Debugger tab.
  • Click Resume icon to continue the program execution.

Stepbystep Resume STM32CubeIDE.png

Info white.png Information
To power the board, use its CN1 connector to connect it with a computer through an USB Type-A to Mini-B cable.

7. Other useful tools

For further development, you can also obtain additional tools:

  • A serial terminal program to monitor output / send commands to programs running on the MCU. E.g. TeraTerm[10].
  • ST BLE Toolbox mobile application - useful for interfacing with WB/WBA Bluetooth examples. There is a version for Android[11] and for iOS[12].

Now you are able to:

  • find STM32 libraries
  • open a project (example)
  • load a project in STM32CubeIDE
  • execute a project in debug mode
  • make a LED blink

Now you have on your computer:

  • libraries for your selected MCU
  • examples for your selected MCU
  • STM32CubeProg (to communicate with the MCU)
  • STM32CubeMX (to graphically generate your project)
  • STM32CubeIDE (to code)

8. References



Arrow right.png Next step