Revision as of 15:05, 4 September 2023 by Registered User (Change wording for more general approach, to be suitable for different MCUs or IDEs - added references to those.)

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 STM32CubeMX

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

  • Download STM32CubeMX[3]

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.

2. Install an IDE

Clock.png 10min
Download and install your preferred IDE. Options supported by STM32CubeMX are: STM32CubeIDE[4], Keil uVision[5], IAR EW[6], Microsoft VSCode[7] with the STM32 extension[8].
Follow the instructions on the product's webpage.
Below are the instructions for STM32CubeIDE.

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!

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

  • Open STM32CubeMX
  • 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 run 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 mode

  • 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

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
  • 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 NUCLEO-L476RG, use its CN1 connector to connect it with a computer through an USB Type-A to Mini-B cable.

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)

6. References



Arrow right.png Next step