2023-11-23 01:17 AM
Hi all.
With build project I can obtain .bin, .hex and .elf file.
I need to manipulate the file to add a CRC in determinate position. SO I use .bin (easiest), then convert in .hex and .elf file using:
arm-none-eabi-objcopy -I binary -O ihex --change-section-address .data=0x08000000 crc_FlashTest.bin crc_FlashTest.hex
arm-none-eabi-objcopy -I ihex -O elf32-little FlashTest.hex FlashTestX.elf
The elf file doesn't work: on CUBE programmer (latest version) I got "crc_FlashTestX.elf is an invalid ELF file"
Change elf option on conversion doesn't solve (elf32-littlearm elf32-littlearm-fdpic elf32-bigarm elf32-bigarm-fdpic elf32-little elf32-big). Still the same file.
Hex file is correct. Even Iif I try to convert bin (hex) file without my manipulation the conevrtion doesn't match and doesn't work.
Have someone a suggestion?
Thanks!
Solved! Go to Solution.
2023-11-27 12:41 AM
Hello @TheRaprus,
A HEX file only contains raw data without any additional information about the program structure. On the other hand, an ELF file contains detailed information about the program structure, including program headers, section headers, symbol tables, and relocation information. When you convert a HEX file to an ELF file using "objcopy", the resulting ELF file will contain only the basic program structure information, such as section headers.
So I think without the additional information, STM32CubeProgrammer will not be able to determine the memory layout of the program and will generate an error when you try to use the file.
Maryem.
2023-11-27 12:41 AM
Hello @TheRaprus,
A HEX file only contains raw data without any additional information about the program structure. On the other hand, an ELF file contains detailed information about the program structure, including program headers, section headers, symbol tables, and relocation information. When you convert a HEX file to an ELF file using "objcopy", the resulting ELF file will contain only the basic program structure information, such as section headers.
So I think without the additional information, STM32CubeProgrammer will not be able to determine the memory layout of the program and will generate an error when you try to use the file.
Maryem.
2023-11-27 12:47 AM
Thanks Maryem.
I supposed it: CUBE programmer can save in bin/hex/sre format but not in elf! I thought this info can be added in "someway" just for the programmer, that don't need it.
Based on your knowledge, it is possible modify a .elf file to add a CRC in a particular memory zone, ad I do in hex/bin (and sre) file?
Thanks again.
2023-11-27 11:41 PM
Hello again @TheRaprus,
I'm not entirely sure, but I think you can calculate the CRC of the binary code using a CRC algorithm of your choice, and then add a new section which contains the calculated CRC value to the .elf file in the desired memory zone.
Maryem.