on 2025-06-26 6:00 AM
This article provides a quick guide on debugging an application using its external *.ELF file. It includes instructions and explanations on how to implement the file into the STM32CubeIDE interface and enter debug mode, enabling the user to verify externally generated code. This example can be tailored to any STM32 microcontroller.
An *.ELF file (Executable and Linkable Format) is a standard file format used in embedded systems development, including microcontroller applications. It is the output of the compilation and linking process and contains all the necessary information for the microcontroller to execute the application. It includes the executable code, initialized and uninitialized data used by the application, symbols, addresses, and other metadata useful for debugging. Finally, information about how the program is mapped into the microcontroller's memory.
In this article, a blank project is created so the STM32CubeIDE interface has the proper configurations to read and debug the *.ELF file.
Special thanks to @BSter.1 and @Cartu38 OpenDev for their helpful post on the STM32CubeIDE forum board, which can be accessed here.
This article assumes you have installed:
The hardware used to showcase is the STM32N6570-DK, but this example can be tailored to any STM32 microcontroller.
The *.ELF file chosen for this demonstration can be found in the STM32N6’s “Examples” >> “UART” >> “UART_HyperTerminal_IT” Repository, or under the default installation path:
C:\Users\%username%\STM32Cube\Repository\STM32Cube_FW_N6_V1.1.1\Projects\STM32N6570-DK\Examples\UART\UART_HyperTerminal_IT
The example performs the following operations:
Make sure to open the project using your STM32CubeIDE and rebuild it to generate the *.ELF file.
Create a new project using the STM32CubeMX integration inside the STM32CubeIDE, by clicking [File][New][STM32 Project], under the [MCU Selector] section for your desired microcontroller, in this case [STM32N657X0H3Q]. Once the project is created, press [Ctrl+S] to save the blank project, and the base code is generated.
Place the *.ELF file you wish to debug inside the directory of the project generated in the blank project.
Back to the blank project, right-click on the Project name and then [Debug As] >> [Debug Configurations…].
OBS.: If your current project does not show up under the “STM32 C/C++ Application”, you can just select the “New launch configuration” button and then choose your current project:
Change "C/C++ Application" to your external *.elf with the absolute path (the path from the project generated in Step 2), click [Apply] and then [Debug]:
Ensure that your board is properly connected to your PC, then click [Resume] icon or press the [F8] Key.
Note that a message claiming main.c was not found might appear, but it should not affect your debugging session. The ELF file does contain the location of the original project’s file. This message only appears if the original project that generated the ELF is no longer at the same path.
To verify the debugging, use terminal emulator software, such as Tera Term or the embedded software available in STM32CubeIDE, with the following configuration:
After setting it up, the code executes as it was intended to:
Debugging an application is a critical step in ensuring its reliability, functionality, and performance. By leveraging tools like STM32CubeIDE and STM32CubeMX, developers gain access to a robust and user-friendly environment for application validation and debugging. These tools are particularly valuable as they allow effective debugging even in scenarios where the application's source code is unavailable.