Difference between revisions of "How to debug a user space application with STM32CubeIDE/User space GTK library project"

[quality revision] [checked revision]
m
m
 

This article proposes to address the creation of a simple hello-world application with STM32CubeIDE.

BackToNavigationTree button.png

1 Create GtkHelloWorld user space project[edit]

In context of Cortex®-A7 sub-project context, named here MP157C-DK2_CA7 here, right-click and select Create a userspace Project...

User space project wizard shortcut

We select here Here, an Executable project type , in C language is selected. Note that our the user space project will use uses by default the SDK version associated to the Cortex®-A7 sub-project.


User space project creation wizard'


2 Update GtkHelloWorld project sources & and properties[edit]

Hereafter we update Below, the main.c source code is updated with gtk_hello_world.c as defined in article Create a simple hello-world application article.


Proposal in order The proposal to reference the Gtk library is to use the pkg-config command to update the compiler & and linker flags, just like it is done in the Makefile of article Create a simple hello-world application. This properties update is done inside menu GtkHelloWorld properties: C/C++ Build > Settings > Tool Settings.

  • main.c update and C flag: `pkg-config --cflags gtk+-3.0`
GtkHelloWorld project source & properties update


  • linker Linker flags update: `pkg-config --libs gtk+-3.0`
GtkHelloWorld project source & properties update


  • Now you can build GtKHelloWorld project, : right-click on it and then Build Project.
GtkHelloWorld project source & properties update

3 Preparing Debug Configuration[edit]

Your target must be Linux® booted and network connected. Please, start Target Status widget on the inthe bottom right corner and check for the green light. Remember that the Linux® console cannot be shared outside STM32CubeIDE: butterfly icon.


Target Status - green


Please also Also check How to set up proxy and P2P Ethernet connection with STM32CubeIDE if you are in that case.

4 Debug Configuration[edit]

Select your project, right-click Debug as... > Debug Configurations, then select STM32 Cortex-A Remote Application'.

Debug configuration shortcut

In the main tabulation Main tab, the default Connection connection proposed is "MPU SSH", corresponding to the target IP address discovered by the Target Status widget. The default destination directory is /home/root.

Debug setup

5 Debug launch[edit]

Click Debug :

  1. GtkHelloWorld is downloaded to the target,
  2. GDBServer is launched on the target,
  3. GDBClient is launched on the workstation and can exchange via the network with GDBServer,.
GtkHelloWorld debug
Info.png in In case of error; please , stop any GDBServer running on the target before launching a new debug session.


BackToNavigationTree button.png



This article proposes to address the [[Create a simple hello-world application| creation of a simple hello-world application]] with STM32CubeIDE.<br>
<br>

[[ImageFile:BackToNavigationTree button.png|200px|link=How to debug a user space application with STM32CubeIDE]]

==Create GtkHelloWorld user space project==
In context of Cortex<sup>®</sup>-A7 sub-project,  context, named here '''MP157C-DK2_CA7''' here, right -click and select '''''Create a userspace Project...'''''<br>
<br>


[[File:UserSpaceShortCut.png|400px|thumb|link=|center|'''User space project wizard shortcut''']]
We select here Here, an ''Executable'' project type,   in C language is selected. Note that ourthe user space project will use uses by default the SDK version associated to the Cortex<sup>®</sup>-A7 sub-project.<br>


[[File:CubeIDEUserSpaceGtkCreation.png|400px|thumb|link=|center|''User space project creation wizard''']]
<br>


==Update GtkHelloWorld project sources &and properties==Hereafter we update Below, the main.c source code is updated with gtk_hello_world.c as defined in article [[Create_a_simple_hello-world_application|Create a simple hello-world application]] article.<br>
Proposal in order to reference 

{{ReviewsComments | [[User:Ludovic Bergonzi|Ludovic Bergonzi]] ([[User talk:Ludovic Bergonzi|talk]]) 18:42, 28 May 2021 (CEST) <br /> gtk (appears as GTK, Gtk, gtk) should be wrtten in a consistent way.}}

The proposal to reference the Gtk library is to use the '''''pkg-config''''' command to update the compiler &and linker flags, just like it is done in the Makefile of article [[Create_a_simple_hello-world_application|Create a simple hello-world application]]. This properties update is done inside menu GtkHelloWorld properties: ''C/C++ Build'' > ''Settings'' > ''Tool Settings''.<br><br> 

* main.c update and C flag: ''''' `pkg-config --cflags gtk+-3.0` '''''<div class="res-img">

[[File:CubeIDEUserSpaceGtkBuildSetup.png|link=|center|'''GtkHelloWorld project source & properties update''']]</div>
<br>

* linkerLinker flags update: ''''' `pkg-config --libs gtk+-3.0` '''''<div class="res-img">

[[File:CubeIDEUserSpaceGtkBuildSetup2.png|link=|center|'''GtkHelloWorld project source & properties update''']]</div>
<br>

* Now you can build GtKHelloWorld project,: right-click on it and then '''''Build Project'''''.<div class="res-img">

[[File:CubeIDEUserSpaceGtkBuild.png|link=|center|'''GtkHelloWorld project source & properties update''']]</div>


==Preparing ''Debug Configuration''==
Your target must be Linux<sup>®</sup> booted and network connected. Please, start '''''Target Status''''' widget on the inthe bottom right corner and check for the green light.
Remember that the Linux<sup>®</sup> console cannot be shared outside STM32CubeIDE: butterfly icon.
[[{{ReviewsComments | [[User:Ludovic Bergonzi|Ludovic Bergonzi]] ([[User talk:Ludovic Bergonzi|talk]]) 18:36, 28 May 2021 (CEST) <br /> I do not catch this warning. What is the butterfly about? By the way, if it is an STM32Cube tool logo, there is no butterfly since the 2020 ST branding.}}

[[File:CubeIDE-UserSpace-Debug1.png|200px|thumb|link=|center|'''Target Status - green''']]<br>
Please also Also check [[How to set up proxy and P2P Ethernet connection with STM32CubeIDE|How to set up proxy and P2P Ethernet connection with STM32CubeIDE]] if you are in that case. <br>


==''Debug Configuration''==
Select your project, right-click ''Debug as... > Debug Configurations'', then select '''STM32 Cortex-A Remote Application''''.  <br>


[[File:CubeIDEUserSpaceDebugShortCut.png|400px|thumb|link=|center|'''Debug configuration shortcut''']]

In the main tabulation, the default Connection''Main'' tab, the default connection proposed is "MPU SSH", corresponding to the target IP address discovered by the Target Status widget. The default destination directory is ''/home/root''. <br>
<div class="res-img">

[[File:CubeIDEUserSpaceGtkDebugSetup.png|link=|center|'''Debug setup''']]</div>

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

<div class="res-img">

[[File:CubeIDEUserSpaceGtkDebug.png|link=|center|'''GtkHelloWorld debug''']]</div>


{{Info| inIn case of error; please , stop any ''GDBServer'' running on the target before launching a new debug session.}}<br>

[[ImageFile:BackToNavigationTree button.png|200px|link=How to debug a user space application with STM32CubeIDE]]

<noinclude>

{{PublicationRequestId | 19680 (LudovicB)  |2021-04-20 }}</noinclude>
(7 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
<br>
 
<br>
 
<br>
 
<br>
[[Image:BackToNavigationTree button.png|200px|link=How to debug a user space application with STM32CubeIDE]]
+
[[File:BackToNavigationTree button.png|200px|link=How to debug a user space application with STM32CubeIDE]]
   
 
==Create GtkHelloWorld user space project==
 
==Create GtkHelloWorld user space project==
In context of Cortex-A7 sub-project, '''MP157C-DK2_CA7''' here, right click and select '''''Create a userspace Project..'''''<br>
+
In Cortex<sup>®</sup>-A7 sub-project context, named here '''MP157C-DK2_CA7''', right-click and select '''''Create a userspace Project...'''''<br>
 
<br>
 
<br>
   
 
[[File:UserSpaceShortCut.png|400px|thumb|link=|center|'''User space project wizard shortcut''']]
 
[[File:UserSpaceShortCut.png|400px|thumb|link=|center|'''User space project wizard shortcut''']]
   
We select here ''Executable'' project type, in C language. Note that our user space project will use by default the SDK version associated to Cortex-A7 sub-project.
+
Here, an ''Executable'' project type in C language is selected. Note that the user space project uses by default the SDK version associated to the Cortex<sup>®</sup>-A7 sub-project.
 
<br>
 
<br>
   
Line 19: Line 19:
 
<br>
 
<br>
   
==Update GtkHelloWorld project sources & properties==
+
==Update GtkHelloWorld project sources and properties==
Hereafter we update main.c source code with gtk_hello_world.c as defined in [[Create_a_simple_hello-world_application|Create a simple hello-world application]] article.<br>
+
Below, the main.c source code is updated with gtk_hello_world.c as defined in article [[Create_a_simple_hello-world_application|Create a simple hello-world application]].<br>
Proposal in order to reference Gtk library is to use '''''pkg-config''''' command to update compiler & linker flags, just like it is done in Makefile of article [[Create_a_simple_hello-world_application|Create a simple hello-world application]]. This properties update is done inside menu GtkHelloWorld properties: C/C++ Build > Settings > Tool Settings.<br><br>  
+
 
  +
{{ReviewsComments | [[User:Ludovic Bergonzi|Ludovic Bergonzi]] ([[User talk:Ludovic Bergonzi|talk]]) 18:42, 28 May 2021 (CEST) <br /> gtk (appears as GTK, Gtk, gtk) should be wrtten in a consistent way.}}
  +
 
  +
The proposal to reference the Gtk library is to use the '''''pkg-config''''' command to update the compiler and linker flags, just like it is done in the Makefile of article [[Create_a_simple_hello-world_application|Create a simple hello-world application]]. This properties update is done inside menu GtkHelloWorld properties: ''C/C++ Build'' > ''Settings'' > ''Tool Settings''.<br><br>  
 
* main.c update and C flag: ''''' `pkg-config --cflags gtk+-3.0` '''''
 
* main.c update and C flag: ''''' `pkg-config --cflags gtk+-3.0` '''''
 
<div class="res-img">
 
<div class="res-img">
Line 27: Line 30:
 
</div>
 
</div>
 
<br>
 
<br>
* linker flags update: ''''' `pkg-config --libs gtk+-3.0` '''''
+
* Linker flags update: ''''' `pkg-config --libs gtk+-3.0` '''''
 
<div class="res-img">
 
<div class="res-img">
 
[[File:CubeIDEUserSpaceGtkBuildSetup2.png|link=|center|'''GtkHelloWorld project source & properties update''']]
 
[[File:CubeIDEUserSpaceGtkBuildSetup2.png|link=|center|'''GtkHelloWorld project source & properties update''']]
 
</div>
 
</div>
 
<br>
 
<br>
* Now you can build GtKHelloWorld project, right-click on it and then '''''Build Project'''''.
+
* Now you can build GtKHelloWorld project: right-click on it and then '''''Build Project'''''.
 
<div class="res-img">
 
<div class="res-img">
 
[[File:CubeIDEUserSpaceGtkBuild.png|link=|center|'''GtkHelloWorld project source & properties update''']]
 
[[File:CubeIDEUserSpaceGtkBuild.png|link=|center|'''GtkHelloWorld project source & properties update''']]
Line 38: Line 41:
   
 
==Preparing ''Debug Configuration''==
 
==Preparing ''Debug Configuration''==
Your target must be Linux booted and network connected. Please, start '''''Target Status''''' widget on the bottom right and check for the green light.
+
Your target must be Linux<sup>®</sup> booted and network connected. Please, start '''''Target Status''''' widget inthe bottom right corner and check for the green light.
Remember that Linux console cannot be shared outside STM32CubeIDE: butterfly icon.
+
Remember that the Linux<sup>®</sup> console cannot be shared outside STM32CubeIDE: butterfly icon.
  +
 
  +
{{ReviewsComments | [[User:Ludovic Bergonzi|Ludovic Bergonzi]] ([[User talk:Ludovic Bergonzi|talk]]) 18:36, 28 May 2021 (CEST) <br /> I do not catch this warning. What is the butterfly about? By the way, if it is an STM32Cube tool logo, there is no butterfly since the 2020 ST branding.}}
   
 
[[File:CubeIDE-UserSpace-Debug1.png|200px|thumb|link=|center|'''Target Status - green''']]
 
[[File:CubeIDE-UserSpace-Debug1.png|200px|thumb|link=|center|'''Target Status - green''']]
 
<br>
 
<br>
Please also check [[How to set up proxy and P2P Ethernet connection with STM32CubeIDE|How to set up proxy and P2P Ethernet connection with STM32CubeIDE]] if you are in that case. <br>
+
Also check [[How to set up proxy and P2P Ethernet connection with STM32CubeIDE|How to set up proxy and P2P Ethernet connection with STM32CubeIDE]] if you are in that case.<br>
   
 
==''Debug Configuration''==
 
==''Debug Configuration''==
Select your project, right-click ''Debug as... > Debug Configurations'', then select '''STM32 Cortex-A Remote Application''''. <br>
+
Select your project, right-click ''Debug as... > Debug Configurations'', then select '''STM32 Cortex-A Remote Application''''. <br>
   
 
[[File:CubeIDEUserSpaceDebugShortCut.png|400px|thumb|link=|center|'''Debug configuration shortcut''']]
 
[[File:CubeIDEUserSpaceDebugShortCut.png|400px|thumb|link=|center|'''Debug configuration shortcut''']]
   
In the main tabulation, the default Connection proposed is "MPU SSH", corresponding to the target IP address discovered by Target Status. The default destination directory is ''/home/root''.  
+
In the ''Main'' tab, the default connection proposed is "MPU SSH", corresponding to the target IP address discovered by the Target Status widget. The default destination directory is ''/home/root''.  
 
<br>
 
<br>
 
<div class="res-img">
 
<div class="res-img">
Line 59: Line 64:
 
# GtkHelloWorld is downloaded to the target,
 
# GtkHelloWorld is downloaded to the target,
 
# ''GDBServer'' is launched on the target,
 
# ''GDBServer'' is launched on the target,
# ''GDBClient'' is launched on the workstation and can exchange via network with ''GDBServer'',
+
# ''GDBClient'' is launched on the workstation and can exchange via the network with ''GDBServer''.
   
 
<div class="res-img">
 
<div class="res-img">
Line 65: Line 70:
 
</div>
 
</div>
   
{{Info| in case of error; please stop any ''GDBServer'' running on the target before launching a new debug session.}}
+
{{Info| In case of error, stop any ''GDBServer'' running on the target before launching a new debug session.}}
 
<br>
 
<br>
[[Image:BackToNavigationTree button.png|200px|link=How to debug a user space application with STM32CubeIDE]]
+
[[File:BackToNavigationTree button.png|200px|link=How to debug a user space application with STM32CubeIDE]]
  +
 
  +
 
  +
<noinclude>
  +
{{PublicationRequestId | 19680 (LudovicB)  |2021-04-20 }}
  +
</noinclude>