Skip to main content
MImda.1
Associate II
February 11, 2021
Solved

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

  • February 11, 2021
  • 5 replies
  • 2175 views

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?

    This topic has been closed for replies.
    Best answer by Piranha

    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!

    5 replies

    Uwe Bonnes
    Chief
    February 11, 2021

    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
    MImda.1Author
    Associate II
    February 11, 2021

    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
    Chief
    February 11, 2021

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

    Piranha
    PiranhaBest answer
    Principal III
    February 11, 2021

    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
    MImda.1Author
    Associate II
    February 12, 2021

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