2021-07-06 11:56 PM
I need to be able to import the .elf file into my STMCubeIDE and perform debugging and run the code. The (.elf) file is generated in Jenkins through nightly builds. Can i know the procedure for this?
2021-07-12 09:58 AM
Hello @AJali.1 ,
To be able to flash the elf file, it needs to be flattened to a .bin or .hex file. It can be done using objcopy (arm-none-eabi-objcopy.exe) with the following parameters:
arm-none-eabi-objcopy -O ihex file_name.elf file_name.hex
You can then use the STM32CubeProgrammer CLI to flash the file (see section 3.2.3 of the STM32CubeProgrammer User manual).
Debugging the code, on the other hand, needs that you enter debug mode in CubeIDE without erasing or loading the binary, and loading the debugging symbols from the elf file (which should be compiled with debug information) through the GDB console using the following command:
add-symbol-file file_name.elf
Another possible way is to copy the elf file to the binary output directory (debug for example), rename it, and make sure its last modification date is more recent than all the source files. This could trick CubeIDE into loading the binary and debugging normally provided the source files match the binary.
Note: I haven't tried these steps on CubeIDE, but I've already done it using other toolchains/developement environements. So take these steps with a grain of salt and let me know if there's an issue. Perhaps one of the CubeIDE guys would chime in and provide more insight.
Best regards,
@SBEN .2