I have a request to calculate a checksum of a binary file and embed that checksum as part of the firmware file that is flashed to the chip. Upon startup it the code would calculate the checksum and do a comparison to the one stored. The catch is that the checksum that is embedded in the firmware file is to be calculated and embedded in the build process. I’m at a loss for how to go about doing this, is there anything in VGDB that could help?
VisualGDB itself doesn’t provide any special tools for calculating checksums, however it should be relatively straight-forward to code a simple tool that would do that. You can use VisualGDB Project Properties -> Custom Build Steps page to invoke the custom tool that will patch the .bin file generated by VisualGDB.
Then you can convert the .bin file back to ELF as shown below:
Note that the new ELF file will not contain any debugging symbols, so it should not replace the original ELF file. Instead, please add the following command to Additional GDB Startup Commands (before connecting to target);
This will make sure that VisualGDB uses the contents of <file>-patched.elf to program the FLASH memory, but still uses the regular ELF file to load the symbols.