Difference between revisions of "How to debug a user space application with STM32CubeIDE"

[unchecked revision] [quality revision]
m
m
 

This article provides guidelines to setup environment for developing and debugging a user space application using STM32CubeIDE.

1 Prerequisites[edit]

Minimum hardware

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

Minimum software

  • STM32CubeIDE v1.4.2 installed and
    • STM32MP15 project created
    • Yocto SDK installed thanks to "Setup OpenSTLinux" Cortex-A contextual menu

Screenshots, illustrating this article, have been taken using STM32CubeIDE v1.4.2. In same way, examples of paths correspond to STM32CubeIDE v1.4.2.

2 Create a "user space" project[edit]

  • Open new C Project wizard: File -> New -> Project... C Project.
  • In first window, choose OpenSTLinux SDK
New C Project wizard
  • then Next and Advanced settings...
New C Project wizard
  • Setup SDKPATH variable into Project Properties > C/C++ Build > Environment
    • select first the configuration you want to use Debug or Release,
    • then Edit variable > Variables
SDKPATH variable setup
  • If SDK installation is embedded inside STM32CubeIDE then toolchain is located under (e.g. with STM32CubeIDE v1.4.2) :<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 :
SDKPATH setup - local disk
  • To populate this project with "main.c" file, select project, right click: New -> File -> main.c and fill it with some C code.

3 Build[edit]

  • Select your project, right-click and then Build Project.
User space project build


4 Preparing Debug Configuration[edit]

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

MPU SSH connection

5 Debug Configuration[edit]

  • Select your project, right-click Debug as... > Debug Configurations.
  • Then create a C/C++ Remote Application debug configuration, double clicking on it.

5.1 Main tab[edit]

  • Fill a destination directory, for example: /tmp/UserSpaceExe
  • Select a connection: MPU SSH 
Debug configuration - main

5.2 Debugger tab[edit]

Now set-up GDB Client with SDK one

  • For SDK embedded and installed inside STM32CubeIDE (e.g. with STM32CubeIDE v1.4.2) :<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
Debug configuration - debugger


6 Debug[edit]

Click Debug :

  1. Executable is downloaded to the target,
  2. GDBServer is launched on the target,
  3. GDBClient is launched on the workstation and can exchange via network with GDBServer,
User space debug
Info white.png Information
in case of error; please check if GDBServer is still running on the target.
This article provides guidelines to setup environment for developing and debugging a user space application using STM32CubeIDE.

==Prerequisites==
'''Minimum hardware'''
* STM32MP15x-based board
* Linux console
* Ethernet (or Ethernet over USB) for connection to Linux<sup>&reg;</sup> Cortex<sup>&reg;</sup>-A 

'''Minimum software'''
* STM32CubeIDE v1.4.2 installed and
** STM32MP15 project created 
** Yocto SDK installed thanks to "Setup OpenSTLinux" Cortex-A contextual menu

''Screenshots, illustrating this article, have been taken using STM32CubeIDE v1.4.2. In same way, examples of paths correspond to STM32CubeIDE v1.4.2.''

==Create a "user space" project==
*Open new C Project wizard: ''File -> New -> Project... C Project''. <br>


*In first window, choose '''''OpenSTLinux SDK'''''
[[File:CubeIDE-UserSpace-CreatePrj1.png|frame|center|'''New C Project wizard''' ]]
*then '''''Next''''' and '''''Advanced settings...'''''
[[File:CubeIDE-UserSpace-CreatePrj2.png|frame|center|'''New C Project wizard''']]

*Setup '''''SDKPATH''''' variable into  ''Project Properties > C/C++ Build > Environment'' 
**select first the configuration you want to use ''Debug'' or ''Release'', 
**then  ''Edit variable > Variables''

[[File:CubeIDE-UserSpace-CreatePrj3.png|frame|center|'''SDKPATH variable setup''']]

*If SDK installation is embedded inside STM32CubeIDE then toolchain is located under (e.g. with STM32CubeIDE v1.4.2) :<InstallDir>/plugins/com.st.openstlinux.sdk.openstlinux_5.4_dunfell_mp1_20_06_24_5.4.0.202007020712/tools/ <br>


*In case SDK is installed on your disk, give its installation path :
[[File:CubeIDE-UserSpace-CreatePrj4.png|frame|center|'''SDKPATH setup - local disk''' ]]{{ReviewsComments|-- MCC 15/Dec~<br />SDKPATH must be set for all configurations release and debug }}

*To populate this project with "'''main.c"''' file, select project, right click: ''New -> File ->'' main.c and fill it with some C code.

==Build==
*Select your project, right-click and then '''''Build Project'''''.
[[File:CubeIDE-UserSpace-Build1.png|frame|center|'''User space project build''']]<br>


==Preparing ''Debug Configuration''==
Your target must be Linux booted and network connected. In order to check it, please, start '''''Target Status''''' widget on the bottom right.
[[File:CubeIDE-UserSpace-Debug1.png|200px|frame|center|'''Target Status - green''']]

''Target Status''  widget creates '''''MPU SSH''''' in '''''Connections''''' view (Window > Show View > Other… Connections > Connections) to be used in '''''Debug Configuration'''''
[[File:CubeIDE-UserSpace-Debug2.png|frame|center|'''MPU SSH connection''' ]]

==''Debug Configuration''==
*Select your project, right-click ''Debug as... > Debug Configurations''. <br>

*Then create a '''''C/C++ Remote Application''''' debug configuration, double clicking on it.

===Main tab===
*Fill a destination directory, for example: '''''/tmp/UserSpaceExe''''' <br>

*Select a connection: '''''MPU SSH''''' 
[[File:CubeIDE-UserSpace-Debug3.png|frame|center|'''Debug configuration - main''']]{{ReviewsComments|-- MCC 15/Dec~<br />Can you highlight with red rectangles drawing on the picture the fields to be updated  }}

===Debugger tab===
Now set-up ''GDB Client'' with SDK one
* For SDK embedded and installed inside STM32CubeIDE (e.g. with STM32CubeIDE v1.4.2) :<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|frame|center|'''Debug configuration - debugger''']]

==Debug==
Click '''''Debug''''' :
# Executable is downloaded to the target,
# ''GDBServer'' is launched on the target,
# ''GDBClient'' is launched on the workstation and can exchange via network with ''GDBServer'',

[[File:CubeIDE-UserSpace-Debug5.png|frame|center|'''User space debug''']]

{{Info| in case of error; please check if ''GDBServer'' is still running on the target.}}
<noinclude>

[[Category:STM32CubeIDE|42]]</noinclude>
Line 32: Line 32:
 
*In case SDK is installed on your disk, give its installation path :
 
*In case SDK is installed on your disk, give its installation path :
 
[[File:CubeIDE-UserSpace-CreatePrj4.png|frame|center|'''SDKPATH setup - local disk''' ]]
 
[[File:CubeIDE-UserSpace-CreatePrj4.png|frame|center|'''SDKPATH setup - local disk''' ]]
{{ReviewsComments|-- MCC 15/Dec~<br />SDKPATH must be set for all configurations release and debug }}
 
   
 
*To populate this project with "'''main.c"''' file, select project, right click: ''New -> File ->'' main.c and fill it with some C code.
 
*To populate this project with "'''main.c"''' file, select project, right click: ''New -> File ->'' main.c and fill it with some C code.
Line 56: Line 55:
 
*Select a connection: '''''MPU SSH''''' 
 
*Select a connection: '''''MPU SSH''''' 
 
[[File:CubeIDE-UserSpace-Debug3.png|frame|center|'''Debug configuration - main''']]
 
[[File:CubeIDE-UserSpace-Debug3.png|frame|center|'''Debug configuration - main''']]
{{ReviewsComments|-- MCC 15/Dec~<br />Can you highlight with red rectangles drawing on the picture the fields to be updated  }}
 
   
 
===Debugger tab===
 
===Debugger tab===