This article proposes to manage a shared library, dynamically linked with a Linux® user space application on STM32 MPU.
{ReviewsComments|-- Registered User (-) 11:38, 13 February 2023 (CET)
above, what do you mean by "manage" ?}}
[edit source]
In the Cortex®-A7 sub-project context, named here MP157C-DK2_CA7, right-click and select Create a userspace Project...
![User space project wizard shortcut User space project wizard shortcut](/stm32mpu/nsfr_img_auth.php/8/8d/UserSpaceShortCut.png)
A Shared Library project type, in C language, is selected. Note that the user space project uses by default the SDK version associated to the Cortex®-A7 sub-project.
![User space shared library creation User space shared library creation](/stm32mpu/nsfr_img_auth.php/5/51/CubeIDEUserSpaceSharedLibCreation.png)
2. Build[edit source]
- Select your project, right-click and then Build Project.
![Shared library build Shared library build](/stm32mpu/nsfr_img_auth.php/2/2e/CubeIDEUserSpaceSharedLibBuild.png)
[edit source]
Hereafter is an updated code for main() to call mySharedLib function say_hello().
You must also reference mySharedLib project inside myExe properties: C/C++ General > Paths and Symbols > References, as depicted below.
![Executable source & properties update Executable source & properties update](/stm32mpu/nsfr_img_auth.php/1/12/CubeIDEUserSpaceSharedLibExeBuild.png)
4. Preparing Debug Configuration[edit source]
You can check boot messages via Linux® console opened with butterfly icon, but remember this console cannot be shared outside STM32CubeIDE (minicom,...).
In order to debug user space application, your target must be Linux® booted and network connected.
In order to check network connection, start the Target Status widget in the bottom right corner of the window.
![Target Status - green Target Status - green](/stm32mpu/nsfr_img_auth.php/2/2b/CubeIDE-UserSpace-Debug1.png)
Check also How to set up proxy and P2P Ethernet connection with STM32CubeIDE if you are in that case.
5. Linux® deployment configuration[edit source]
To run or debug the executable myExe and its shared library mySharedLib, it is required to download the shared library object (.so) to the STM32MP15xx device.
Select the shared library project, right-click Run as... > Run Configurations, then select STM32 Cortex-A Linux Deployment'.
![Run configuration shortcut Run configuration shortcut](/stm32mpu/nsfr_img_auth.php/e/ef/CubeIDEUserSpaceSharedLibRun.png)
![Linux deployment configuration Linux deployment configuration](/stm32mpu/nsfr_img_auth.php/a/a8/CubeIDEUserSpaceSharedLibRunSetup.png)
6. Debug Configuration[edit source]
Select your project, right-click Debug as... > Debug Configurations, then select STM32 Cortex-A Remote Application'.
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.
For the executable myExe to load the mySharedLib dynamic library, a setup of LD_LIBRARY_PATH with the path to mySharedLib is needed before starting debug.
![Debug configuration setup Debug configuration setup](/stm32mpu/nsfr_img_auth.php/5/5d/CubeIDEUserSpaceSharedLibExeDebugSetup.png)
[edit source]
Click Debug :
- Executable 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.
![User space shared library debug User space shared library debug](/stm32mpu/nsfr_img_auth.php/f/f8/CubeIDEUserSpaceSharedLibExeDebug.png)
![]() |
In case of error; stop any GDBServer running on the target before launching a new debug session. |