cancel
Showing results for 
Search instead for 
Did you mean: 

How to add firmware version in binary image file and validate the version in bootloader.

guptaniks
Associate

Hi,

I am creating an application where firmware version will be verified before flashing in the MCU flash using custom bootloader.

Would like to understand, do we have any feature in STM32CubeIDE to append a header/ some dedicated data at the end of binary image while generating the .bin file for firmware.

If not, can you please suggest some method to append firmware version in binary image, which can then be verified by bootloader before flashing the image in application area.

1 ACCEPTED SOLUTION

Accepted Solutions

The linker scripts can add data, and symbols. You can use sections in startup.s the linker can place. You can put size and version fields in unused vector entries.

If you're familiar with C programming and STDIO file functions, you can read, manipulate, write file data content in binary files. The .HEX and .ELF file formats are well documented too. This would probably be the route if you want to package the image, compress, encrypt, or whatever.

The use of CRC's is pretty good for integrity, hashing and signing is also an option.

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

View solution in original post

3 REPLIES 3

The linker scripts can add data, and symbols. You can use sections in startup.s the linker can place. You can put size and version fields in unused vector entries.

If you're familiar with C programming and STDIO file functions, you can read, manipulate, write file data content in binary files. The .HEX and .ELF file formats are well documented too. This would probably be the route if you want to package the image, compress, encrypt, or whatever.

The use of CRC's is pretty good for integrity, hashing and signing is also an option.

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

Thank you!

I am able to add firmware header at a particular section of flash in the linker script and its correctly visible in binary image at the particular section of flash.

But i also tried to add the version at unused vector entry in startup file, but not able to get it as a macro or variable. May be i don't know enough of startup script. But can you help, on how to add variable/macro for version in startup script. 

It's obviously working when direct value is written to an unused vector, which i can see in binary image. But need to have it configurable using a variable or macro. Can you please define?

 

If you have a specific method for incrementing or sequencing the version data you could perhaps generate an include file in a Pre-Build step

If you use .S instead of .s the file will be run through the C pre-processor first, as  I recall

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