STM32 MPU Family - MCU Support Debug configuration |
To debug an application, the debugger requires additional information to make the associations between the source code, the binaries generated from that original source and some other information. This information is included by default when the project is built using the "Debug" build configuration. The SystemWorkbench debugger used is Arm GDB.
More details about GDB are available here: GDB documentation.
In order to align the debug session with the source code, it is recommended to avoid any code optimization at compiler level. This can be adjust in the project Properties > C/C++ Build > Settings, in Tool Settings tab then select, MCU GCC Compiler > Optimization then Optimization Level is set to None (-O0)
A dedicated Debug Configuration is provided in order to handle Hybrid STM32. Indeed on the type of STM32 which typically run Linux or Android on the Cortex-A part, the MCU (i.e. the Cortex-M) is seen as a co-processor managed by Linux kernel side.
This means in order to Debug Cortex-M (MCU) in "Production Mode" we need the Linux kernel to load the Cortex-M image.
Note that an "Engineering Mode" is also proposed for Cortex-M preliminary debug. In that mode the Cortex-M (MCU) image is loaded via JTAG/SWD.
For the first time the user debug a program, a debug launch configuration must be created.
To create a debug configuration, use the following procedure:
Main
Debugger
If not relying on openOCD script Automated Generation, make sure that the Script File is the good one.
It must contains the name of the board to use to debug the application.
Startup
Engineering mode - Load thru JTAG/SWD
This mode could be used in case of preliminary MCU (Cortex-M) debug.
Thanks to its boot pins, STM32MP1 device boots in a specific mode where MPU Cortex-A is not started and JTAG/SWD access the MCU Cortex-M.
Production mode - Load from Embedded Linux remoteproc
This mode provides debug for MCU (Cortex-M) when running in exact production mode.
Here STM32MP1 device boots following the target product boot mode, MPU Cortex-A is up and running.
It is in charge of overall clock management and of MCU (Cortex-M) firmware load.
In order to download Cortex-M firmware to the Embedded Linux it uses serial link also used for the Linux Console.
Both can not be used at the same time and you need to close any Console View when starting debugging in this mode.
Note that when debugging in Debug perspective, you have access to the Linux Console again.
Network Usage
If a network connection is available, the corresponding IP address is proposed.
This is the recommended solution.
It is not possible to set breakpoints before launching the image in that mode (Set breakpoint at: option). The image is indeed loaded by the Embedded Linux and we are running the Debugger in "attached mode". Note that after its attachment, the Debugger can take the control and set breakpoints. An infinite loop with variable test can be added at the very begin of the firmware in case of issue when integrating it into Linux framework.
If any change is made, click on Apply to save the configuration.
For more information about C/C++ development tools in Eclipse, please see C/C++ Development User Guide.