cancel
Showing results for 
Search instead for 
Did you mean: 

The size of the firmware .bin file is always divisible by 4 in stm32 devices. isn't it?

MImda.1
Associate III

I am developing a custom bootloader for OTA purposes. I successfully did this under one assumption, that the .bin file is divisible by 4. which means since it is 32 bit even the last part will be inside one full memory cell. Is it correct?

1 ACCEPTED SOLUTION

Accepted Solutions
Piranha
Chief II

The basic padding depends on your linker script and the default linker script should pad to 4 bytes. But take a note that bootloader has to be capable of dealing with corrupted or malicious files. If those are not acceptable, it still has to fail in a sensible controlled way!

View solution in original post

5 REPLIES 5
Uwe Bonnes
Principal III

You can not assume that. It may depend on linker and linker script. For a known set of linker and linker scripts that will hold however.

MImda.1
Associate III

how can I make sure about it? thank you.

for verification purposes, I went through many .bin files and they were divisible by 4!!!

Uwe Bonnes
Principal III

So recheck if your setup changes. But you always have to pad to a sensible size, so where is your problem?

Piranha
Chief II

The basic padding depends on your linker script and the default linker script should pad to 4 bytes. But take a note that bootloader has to be capable of dealing with corrupted or malicious files. If those are not acceptable, it still has to fail in a sensible controlled way!

MImda.1
Associate III

got it. thank you. I have total control over the linker script while doing an OTA for deployed devices. So yeah it solves.