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 Hello World application example.

Required Hardware and Software

  1. A pair of SPARK EVK boards

  2. STM32CubeIDE, the official STMicroelectronics integrated development environment

  3. 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.9.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

  1. Install STM32CubeIDE with the default options.

  2. Open STM32CubeIDE and choose a workspace.

  3. When you open STM32CubeIDE for the first time, you will first see the Information Center tab. Close it and restore the project explorer tab.

  4. Under the Project Explorer tab, click on Import projects….

    Empty project explorer

    Figure 1: Import Projects link in the Project Explorer sidebar.

  5. Under General, select Existing Projects into Workspace and click Next.

    Import existing projects

    Figure 2: Import an existing project with the project import wizard.

  6. Click Browse… and select the SDK software package you want to use as shown in the figure below. All STM32CubeIDE projects within the package are listed under Projects. Click Finish to import them all into your workspace.

    List of projects to import

    Figure 3: Complete project importation with default selection.

    Once the import is done, all applications should appear under the Project Explorer tab. Note that depending on the SDK version you are using, the list of applications may differ.

    Project explorer with imported projects

    Figure 4: Newly added projects in the Project Explorer sidebar.

  7. You can now build an application by selecting it under the Project Explorer tab (e.g., Hello World) and clicking on the downward arrow next to the build icon (Hammer). Then, a list will pop-up to select which device to build the application for.

    Hello World build configuration selection

    Figure 5: Selection of the build configuration.

    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.

    Hello World build finished

    Figure 6: Build completion logs.

    Repeat the build step but this time, use the other build configuration. If you selected “Debug-Coordinator” previously, use “Debug-Node” and vice versa.

    Once the build process for Coordinator and Node has finished, you should see under the Hello World project in the Project Explorer tab two new folders (Debug-Coordinator and Debug-Node). The executable files are located inside those folders.

    Hello World project files

    Figure 7: Hello World project’s content.

  8. Now that the executable files are generated, two debug configurations must be created to program the boards and debug them. To do so, click on the downward arrow next to the Bug icon and select Debug Configurations….

    Debug configuration menu

    Figure 8: Debug options context menu.

    On the left pane, double click on the STM32 Cortex-M C/C++ Application entry to create a new debug configuration. Give it a name, such as Hello World Debug-Coordinator for the Coordinator. In the Main tab, modify the Project name, C/C++ Application and Build Configurations fields.

    Once done, create another one for the Node. You can duplicate Coordinator’s debug configuration by right clicking on Hello World Debug-Coordinator and selecting Duplicate and then change every instance of Coordinator for Node.

    Hello World debug configuration settings

    Figure 9: Debug Configuration window.

    (Optional) If you have two debug probes, connect them both and go in the Debugger tab of the Debug Configuration to assign a specific debug probe to each 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-Coordinator uses 61234, use 61236 for Debug-Node. 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 to choose the right one for a given board.

    Multiple debuggers settings

    Figure 10: Debugger tab in the configuration window of a specific Debug Configuration.

  9. 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 flashed 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.

    Hello World debug session

    Figure 11: Play button in the debugging view.

    Now that your first board is running, do the same for the other board. Make sure to use the other debug configuration, otherwise 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.

  10. Once both boards are programmed and started, see Hello World application documentation for more details about its behavior.