Other Parts Discussed in Thread: MSPM0G1106
Tool/software:
Hi,
Our application uses the MSPM0G1106 microcontroller, and we are developing with Code Composer Studio 12 (CCS12).
I’m currently working on implementing a firmware integrity check using a CRC32 value and would like to ask if there is a known or recommended approach for doing this reliably.
Here is the method I’ve been trying:
-
Custom Linker Script: I reserved the last 4 bytes of the flash memory to store the CRC32 value.
-
Post-Build Step: I added a Python script that calculates the CRC32 over the entire flash memory range, excluding the reserved 4 bytes. The script then writes the computed CRC32 into the reserved section. (I verified that the CRC value is correctly inserted into the last 4 bytes of the
.out
file, and I can also see it in the CCS memory browser after flashing.) -
Runtime Check: In the firmware, I implemented a function that recalculates the CRC32 over the same region in flash and compares it with the stored CRC32.
However, the runtime CRC never matches the stored CRC value. Upon closer inspection, I found that the .out
file appears to have all unused memory padded with 0x00
, whereas when the image is loaded to flash, the unused memory appears to be filled with 0xFF
. (Presumably, this is due to flash memory being erased to 0xFF
by default before programming.)
Given this, is the approach I’m using viable for a reliable firmware integrity check? Or is there a better way to ensure consistency between the build-time CRC and the runtime verification?
Any advice or insight from experienced developers would be greatly appreciated.
For context, this is part of a Functional Safety feature required for certification (IEC 60730 / IEC 61508 Class B).
Requested for https://www.ti.com/tool/MSPM0-DIAGNOSTIC-LIB but it's been pending for a while.
Best regards,
Kyungjae Lee