I’m dealing a lot with bootloaders recently (see “Flash-Resident USB-HID Bootloader with the NXP Kinetis K22 Microcontroller“), and bootloaders are sometimes very picky about what file format they are able to consume. So what if I have a binary (see “S-Record, Intel Hex and Binary Files“) file and I need to convert it into the Intel Hex format?
Using the ‘SRecord‘ tool it is actually very simple:
srec_cat.exe srcFile.bin -binary -output dstFile.hex -Intel
With the -binary option I load the binary file and with the -Intel option used with the -output I can convert the file.
Below it shows a binary and its converted version in Eclipse (see “5 Best Eclipse Plugins: #4 (EHEP)“).
Done :-).
Happy Hexing π
hex format is what is needed for a boot loader for the most part. They have horizontal checksums on each line which makes sure you’re reading each line correctly. What this particular one is lacking is vertical checksums.
There needs to be chain of custody when updating code like that in the field and the file itself should have some sort of checksum to it so that when you tell the processor to go ahead and reboot, it can compare what it has written with you think it should be before you go ahead and brick it.
LikeLike
Absolutely true. And I’m using a (vertical) CRC32 here: https://mcuoneclipse.com/2018/03/05/tutorial-crc32-checksum-with-the-kboot-bootloader/
π
LikeLike
Eric
Take a look at the uTasker conversion tools too: http://www.utasker.com/forum/index.php?topic=1445.0
These allow combining boot loaders with applications, converting formats (including Motorola Binary which older CW tools produced, rather than raw binary), or converting binary file, images, web pages etc. into arrays for including in programs.
They also allow authenticating/encrypting applications for working with secure boot loaders.
Basically they are utilities which have evolved over the years to do thing that are always needed again and again in real-world embedded projects to avoid the need to search for various tools to do the different jobs.
Regards
Mark
LikeLike
Pingback: Generating Intel Hex Files with a given Length using srec_cat | MCU on Eclipse
Thank you very much π π π
LikeLike
I use srec_cat all the time to create my bootloader+firmware secure srec files. One important option is the -offset parameter which allows you to shift the starting address +- as opposed to the default of 0. The unfill option is also useful for removing large holes in the code which makes for a smaller file. happy S19ing.
LikeLiked by 1 person
I have not used the unfill option, good to know!
LikeLike