With KDS Kinetis Design Studio (KE06Z processor) we've created a boot loader that verifies the main execution code with a checksum, before running it. However the tool that computes the checksum and adds it to the binary file, can't run till the linker has finished - and therefore the checksum cannot be in the linker output file that the debugger uses.
On KDS we have a solution using the "specify additional ELF file" feature which sets the debugger to load a checksum file in addition to the main (elf) debug code - see screenshot. I think I got this from Erich Styger / MCUonEclipse (but I can't find it there today).
We're planning to use MCUXpresso for our next project (KE18F processor) and it appears there is no similar feature to load additional files into the debugger image.
Has anyone got a solution for this problem? Either a way to force a checksum into the MCUXpresso debug (axf) file, or to get the debugger to load more than one file.
It ought to be possible to do something similar by adding a pre-launch command to the Debugger tab of the launch configuration editor to program the flash (which can either be a .bin or .axf). See section 14.2.1, "Editing a Launch Configuration" of the MCUXpresso IDE v10.0.0 User Guide.
The command to use can be manufactured by using the LinkServer GUI Flash Programmer - see section 10.5, "Using the LinkServer flash programmer" of the User Guide for more info on this.
MCUXpresso IDE Support
There's no reason why you can't use your own utility in a post processing step to embed an image checksum at a pre-determined offset.
The LPC parts use a checksum word located at a specific offset in the vector table. This is simply a two's complement of the first 7 vector entries. The LPC boot loaders use this word to determine whether a valid user image exists before it loads the reset context. The LPC parts mostly use vector 7 (offset 0x1C), an unused vector location to store the checksum word. There were exceptions. If this is sufficient for your purposes, you'll find the checksum.exe utility in the MCUXpresso installation. Otherwise, it's a fairly trivial matter to write your own utility.
Thanks and regards,
We would like to embed some additional information in the binary image.
We already post-process the binary and embed our own checksum at address 0x1C (Cortex-M4 MCU), but we would also like to embed the size of the image - to calculate the checksum in the secondary bootloader with the correct size.
Where should we do this? I can see in the Vector Table that 0x20 is for ECRP.
0x24 and 0x28 are reserved. Can we use those?
Or can we make additional entries in the end of the Vector Table itself?
What is the standard way of doing this?
We could make our own header to the entire binary itself, but that seems a bit tedious...