cancel
Showing results for 
Search instead for 
Did you mean: 

Does Cube-IDE support launching executables that aren't ELF?

n2wx
Senior

An oldie but still needed, CRC in the last word of the FLASH segment. So I'm fine up until I get to the point when I tell TrueStudio my application is other than an .ELF because at Properties / Run/Debug Settings/ Edit / TrueStudio is hobbled by supporting only elf applications.

Does Cube-IDE remove this limitation or is it also handicapped by an inability to launch anything but .elf files?

I suspect the answer is no because ST. But might as well ask, maybe a miracle happened.

There's a taunting file - STM32Cube_FW_ClassB_V2.3.0 - with examples for IAR, Keil, and even System Workbench. Nada for ST's own product. It's like every time I turn around ST shoots me in the head. Thanks guys! Keep pushing me back to windows.

EDIT so someone else already dealt with this and posted a solution to the elf problem here https://community.st.com/s/question/0D50X0000AlflsxSQA/how-to-convert-hex-file-to-elf-file .

1 ACCEPTED SOLUTION

Accepted Solutions

This sounds absolutely perfect because it'll preserve the debug symbols.

I've added a new section "CRC" that sits at the end of the existing FLASH section. Is that close to what you're doing?

May I ask what file format your CRC is in? Is it like a mini .elf file or a .hex with the CRC? And are you finding the debug symbols from the original elf are preserved with your approach?

> I loathe eclipsoids but this is a normal part of post-link script if they enable to do something like that.

Affirmative on the loathing. Every new guy on the block shows up with an eclipse front end and dashes all of our hopes. What surprised me was to find someone (segger) charging a fortune for their eclipse tool. I think it's just like all the others, a front end to the gnu stuff. For ST this is now two elipses in a row and the third will not be a charm.

View solution in original post

16 REPLIES 16
KnarfB
Principal III

Why not using .elf for that? Add few lines to the linker description file:

 .crc : {
  	LONG(CRC);
  } > FLASH

as the last item that goes into flash. When linking, you get a linker error saying "symbol CRC is undefined".

Define it as an additional miscellaneous linker option:

-Xlinker --defsym=CRC=0xDEADBEEF

Now, linking completes and you find the CRC bytes at the end (in little endian).

The rest is script magic done as a post-build step: link once with an invalid CRC, calc CRC, link again.

CRC calculation could be done on a .bin file generated from the first .elf.

hth

KnarfB

Wait where do you get the executable's CRC from? I'm trying to coerce srec_cat into working through a chain of objcopy -> srec_cat -> ojbcopy to effect translation from elf to padded and crc'd binary and then back to elf with arm-none-eabi-objdump -O elf-littlearm . Do you printf it out of a debug port? I'll not have one of those available on the real product but I'll have JlinkRTT viewer available.

Pavel A.
Evangelist III

So, miracle!

Looks like the debugger of CubeIDE can load image from one file (.bin) and symbols from other file (.elf).

Now, connect the points...

-- pa

That's a pretty neat trick. Is the magic in the Run/debug settings / Launch config / Startup scripts?

I'm stuck on TrueStudio 9.3.0 until our contractor is done. And he's going to be dropping back the Cube ide drivers from 1.6.0 to 1.3.0 thanks to the borked ethernet and I don't know where that's going to leave me

Or have a tool that walks the .ELF and patches the CRC

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

Cube IDE drivers? which drivers?

The CubeMX drivers brought in by the configurator

I have a roundabout way to do that with srecord. I have screcord ingesting the executable, padding it out, generating the CRC which shocked the hell out of me when if finally worked. srec can append this crc to my hex and then objcopy can convert it into a hobbled .elf but I'm not sure how to tell TrueStudio to use the hobbled .elf: Does TrueStudio try to flash the .elf before or after it runs the post-build script?

After it runs the post-build script.

I'm using STM32CubeIDE for a while now, but think TrueStudio was the same: In the Debug/Run configuration there is a "build before launching" section. That is activated by default. And, if you give the 2nd elf a different name and specify that in the Debug/Run config, you cannot fail.