cancel
Showing results for 
Search instead for 
Did you mean: 

Are .bin outputs byte-aligned for the boards flash size?

TakenTheBacon
Associate III

Board: STM32WB55

Software: STM32CubeIDE

Background: I am experimenting with a Custom Bootloader to enable USB and BLE updates to my firmware. I'm getting the IDE to export .bin and .hex files on build, so I can pass my main application into the bootloader by an application to replace the current main application stored in Flash memory. The STM32WB55 needs to write to on-board Flash with a 64-bit Double Word (8 Bytes).

Issue: Is the .bin file that is created by the IDE aligned to this size? Is there a way to ensure that? I do not know if simply padding the end of the .bin file with 0's to make the last 8 bytes / padding each .hex line as needed with 0s is a safe (and memory efficient!) option? I am relatively fresh to this area.

Any advice much appreciated,

Thank you

1 REPLY 1

The front is typically aligned with whatever address you given the Linker, so usually ends with several zeros, ie 0x08001000

Data on the back end, perhaps less so, you could use the ALIGN keywords in the Linker Script. More generally your Loader code could.round up the size to an 8-byte boundary to ensure compliance. Pad with 0xFF or 0x00

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