Getting Started¶
This section describes how to install the full STM32 development environment on a personal computer and walks through programming and debugging the SDK’s Blinky application example.
Required Hardware and Software¶
A pair of SPARK EVK boards
STM32CubeIDE, the official STMicroelectronics integrated development environment
STM32 microcontroller debug probe
STM32CubeIDE is completely free to use and provides everything a developer needs to edit, program and debug code for STM32 microcontrollers. It is available for Windows, Linux and MacOS. It can be downloaded here: https://www.st.com/en/development-tools/stm32cubeide.html. It is recommended to use v1.8.0 as this version was the latest available when this SDK was released. Therefore, using newer (or older) versions may cause compatibility issues.
A debug probe is necessary to program and debug STM32 microcontrollers. We suggest using the ST-Link V3 mini for a simple and cost-effective solution. Visit https://www.st.com/en/development-tools/stlink-v3mini.html for more details.
Steps¶
Install STM32CubeIDE with the default options.
Open STM32CubeIDE and choose a workspace.
Under the Project Explorer tab, click on Import projects….
Under General, select Existing Projects into Workspace and click Next.
Click Browse… and select the SDK software package you want to use. All STM32CubeIDE projects within the package are listed under Projects. Click Finish to import them all into your workspace.
Once the import is done, all applications should appear under the Project Explorer tab. Note that depending on the SDK you are using, the list of applications may differ.
You can now build an application by selecting it under the Project Explorer tab (e.g., Blinky) and by clicking on the downward arrow next to the build icon (Hammer). Then, a list will pop-up to select which board to build the application for.
Once you select the desired build configuration, the build process will start and compile all the source files required to create the executable file. The build process will have successfully finished once “Build Finished” in blue appears under the Console tab.
Repeat the build step but this time, use the other build configuration. If you selected “Debug-Board1” previously, use “Debug-Board2” and vice versa.
Once the build process for Board1 and Board2 has finished, you should see under the Blinky project under the Project Explorer tab two new folders (Debug-Board1 and Debug-Board2). The executable files are located inside those folders.
Now that the executable files are created, two debug configurations must be created to program the boards and to debug them. To do so, click on the downward arrow next to the Bug icon and select Debug Configurations….
On the left pane, double click on the STM32 Cortex-M C/C++ Application entry to create a new debug configuration. For Board1, enter the information as shown on the following figure under the Main tab. More specifically, modify the Project name, C/C++ Application and Build Configurations fields.
Once done, create another one for Board2. You can duplicate Board1’s debug configuration by right clicking on Blinky Debug-Board1 and selecting Duplicate and then change every instance of Board1 for Board2.
You can then select the desired debug configuration and click Debug to program the board and start debugging. Make sure you have your ST-Link debug probe connected to the board and that it is turned on before trying to debug.
Once the binary has been programmed on the board, STM32CubeIDE will display the debug view and the debugger will start code execution and stop at the main function. Click the Resume button (yellow and green play/pause symbol) to resume code execution.
Now that your first board is running, do the same for the other board. Make sure to use the other debug configuration or else the two boards will have the same firmware programmed and the application will not work. Also, if you have only one debug probe, make sure it has been connected to the other board.
(Optional) If you have two debug probes, you can go in the Debugger tab of the Debug Configuration to assign a specific debug probe to a board. In the GDB Connection Settings section, set the Port number to a different non-consecutive one for each of the Debug Configurations. For example, if Debug-Board1 uses 61234, use 61236 for Debug-Board2. Also, in the Interface section, check ST-LINK S/N and press the Scan button. The list of serial numbers of all connected ST-Link probes will be displayed. Make sure you choose the right one for a given board.
Once both boards are programmed and running, you should see a blinking LED on both of them.