How to debug a user space application with STM32CubeIDE

Revision as of 17:07, 23 November 2020 by Registered User

This article provides guidelines to setup environment for developing and debugging User Space application within STM32CubeIDE version 1.4 or 1.5.

1. Prerequisites[edit source]

Minimum hardware:

  • STM32MP15x-based board
  • Linux console
  • Ethernet (or Ethernet over USB) for connection to Linux CA7

Minimum software:

  • STM32CubeIDE 1.4.2 installed
    • STM32MP15 project created
    • Yocto SDk installed thanks to "Setup OpenSTLinux" CA7 contextual menu

2. Create User Space project[edit source]

Open new C Project wizard: File -> New -> Project... C Project.
In first window choose OpenSTLinux SDK

then Next and Advanced settings...

Purpose is to setup SDKPATH variable: Project Properties > C/C++ Build > Environment > Edit variable > Variables
Here SDK Installation is Embedded inside STM32CubeIDE, toolchain is located under <InstallDir>/plugins/com.st.openstlinux.sdk.openstlinux_5.4_dunfell_mp1_20_06_24_5.4.0.202007020712/tools/

In case SDK is installed on your disk, give its installation path.

File:CubeIDE-UserSpace-CreatePrj4.png
SDKPATH setup - local disk

Populate this project with main.c file: select project, right click: New -> File -> main.c Fill it with some C code.

3. Build[edit source]

Select your project, right-click and then Build Project.

File:CubeIDE-UserSpace-Build1.png
User Space project Build


4. Preparing Debug Configuration[edit source]

Your target must be Linux booted and network connected, in order to check it please start Target Status widget on the bottom right.

Target Status - green

Target Status widget creates “MPU SSH” in Connections view (Window > Show View > Other… Connections > Connections) to be used in Debug Configuration

5. Debug Configuration[edit source]

5.1. Main tab[edit source]

Need to fill a destination directory, for example: /tmp/UserSpaceExe
& select Connection: MPU SSH 

File:CubeIDE-UserSpace-Debug3.png
debug configuration - main

5.2. Debugger tab[edit source]

Need to set-up GDB Client with SDK one:

  • For SDK Embedded installed : <Stm32CubeIDEInstallDir>/plugins/com.st.openstlinux.sdk.openstlinux_5.4_dunfell_mp1_20_06_24_5.4.0.202007020712/tools/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-gdb
  • For SDK installed on disk : <SdkInstallDir>/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-gdb
File:CubeIDE-UserSpace-Debug4.png
debug configuration -debugger


6. Debug[edit source]

  1. Executable is downloaded to the target
  2. GDBServer is launched on the target
  3. GDBClient is launched on the workstation, and exchange via network w/ GDBServer

Note: in case of error; please check if GDBServer is still running on the target.