STM32 linker script offset address and conversion to hex file

I am an absolute beginner so this may be a stupid question. I am working on writing custom firmware for a pre-existing product. I have two requirements:

  1. I need to use the existing bootloader, meaning I need an offset address of 0X08004400.
  2. I need to upload a hex file to the existing bootloader.

I am using a postscript to convert the ELF file to a hex file (The basic one posted a few places on this forum already) I am also going to copy the existing ldscript and modify the offset there.

Finally the question, will the offset address be effected by the post script?

The post script you referenced will just convert the ELF into HEX format. The ELF is what’s already built using all object files and the linker script. So if that uses the correct linker script, the ELF will have the correct starting flash address, and so will the HEX file.

Thanks for the quick reply! Do you know what linker script would be used for genericSTM32F103C6? I am having a hard time finding it.

That depends on the used framework. For example, Arduino:

Arduino is a special case because it is already dynamically generated and uses the LD_FLASH_OFFSET variable, which in PlatformIO is influencable without modifying the linker script (board_build.flash_offset = 0x5000 e.g. per script).

For other frameworks, check out the currently used linker script first. After project task → Clean, then Advanced → Verbose Build, a .ld file should be referenced in the final linker command with the -Wl,-T <ld file path> flag.

1 Like

This worked, thanks a ton!