stm32 – calculate and embed crc of bin in bin

Sysprogs forums Forums VisualGDB stm32 – calculate and embed crc of bin in bin

This topic contains 3 replies, has 3 voices, and was last updated by  support 1 week, 1 day ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28250

    dabramson
    Participant

    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?

    #28258

    support
    Keymaster

    Hi,

    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.

    #30978

    tajen
    Participant

    And how would I then access this checksum from the code?

    #30983

    support
    Keymaster

    Hi,

    You can use the same techniques that would work for any other IDE or a directly built project. VisualGDB does not change anything from that perspective.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.