Skip to main content
SBurg.1
Associate II
January 14, 2021
Solved

How to Debug a Release Version with CubeIDE and the given Options ?

  • January 14, 2021
  • 3 replies
  • 2725 views

Hello,

Is there a way to generate releasecode to release to the public without Debugging information in the File. But to debug the Code with some exta Debug Files later?

I would like to build a seperate Hex/Bin and Debug file.

In other IDEs or in GNU Compiles you can split Debug Information and the executable in 2 Different files, to Release the Executable to the Public but still Debug it (with help of the debug Files) if you need to.

e.g. the tools objcopy and strip from the buildutils are made for this. But they are unable to work with the STM .elf format.

Here is a described example: https://stackoverflow.com/questions/866721/how-to-generate-gcc-debug-symbol-outside-the-build-target

But I am unable to set somthing similar up in the CubeIDE.

Does somebody have a Idear, how to generate debuggable release build without publishing the Debug Information ?

This topic has been closed for replies.
Best answer by KnarfB

The arm-none-eabi-* toolset does what you want, i.e. arm-none-eabi-objcopy and so on.

You find a copy in the plugins folder of STM32CubeIDE installation.

You can debug in-house with the .elf and ship the stripped file.

Btw: a .hex/.bin is a flash image and does not contain debug info.

3 replies

KnarfB
KnarfBBest answer
Super User
January 14, 2021

The arm-none-eabi-* toolset does what you want, i.e. arm-none-eabi-objcopy and so on.

You find a copy in the plugins folder of STM32CubeIDE installation.

You can debug in-house with the .elf and ship the stripped file.

Btw: a .hex/.bin is a flash image and does not contain debug info.

Cartu38 OpenDev
Graduate II
January 15, 2021

If STM32CubeIDE created project at least you have by default x2 build configurations promoted by default. They are called quite explicitly ie. "Debug" and "Release". Main diff is compiler optimization setup. One is keeping debugger required data, second is leading to most optimal binary. Up to you to refine what's most optimal means (size, speed, ... optimization) if you want.

0693W000007BN2KQAW.jpg 

SBurg.1
SBurg.1Author
Associate II
January 15, 2021

Thank you for your help. I tested and played around a bit with the Information you gave me.

So my initial plan, to strip the Debug information can be done with the mentioned arm-none-eabi-* tools.

I came up with this post build line:

arm-none-eabi-objcopy --only-keep-debug ${ProjName}.elf ${ProjName}_Debug.elf ; 
arm-none-eabi-strip --strip-debug --strip-unneeded ${ProjName}.elf ; 
arm-none-eabi-objcopy -O ihex ${ProjName}.elf ${ProjName}.hex ; 
arm-none-eabi-objcopy --add-gnu-debuglink=${ProjName}_Debug.elf ${ProjName}.elf 

(If you want to use this, just remove the New Line feeds to make a oneliner and it workes in CubeIDE)

To make the Debugging Process work you have to edit your debug Configuration in the following way:

0693W000007BNkCQAW.pngSo you load the Symbols from the unstripped File.

So it worked that way and was nice but than I checked the Hex Files.

And as KnarfB pointed out, there is no Debuginformation in the .hex or .bin File.

I also checked this with the script created Hex file above, the Normaly created Hex File in "MCU Post build objects" and additionally in a Build with maximum and none Debug information. They were all the same.

So Year... I will just revert the Project changes and use the .hex/.bin and everything is fine.