Question
flash CRC integrity
Posted on January 15, 2014 at 21:14
Hello,
I know this has been discussed before, but reading through it all, I am still unable to grasp the solution of my problem: What I am trying to do is check the integrity of the flash (code) on the STM32L1xx chip at startup. Since I need to calculate the CRC only at startup, I have decided not to use the built in CRC peripheral (mostly because of the 4 bytes step). So instead I used 1 byte step CRC with lookup table using the same polynomial (reversed actually, i.e. 0xEDB88320) to calculate the CRC of the .hex file. Now, I am trying to insert the calculated CRC in the .hex file to upload it to stm32 and perform the check. My questions are: 1.) How can I insert the CRC to a specific address, so that I will be able to access the same address via the code/function in the program? Can I do it simply in a hex editor? 2.) The flash address (default) begins at 0x08000000 and ends at 0x0801FFFF. My code is shorter. How can I calculate the CRC only for the code portion and not the entire flash at runtime? If I calculate the CRC for the entire flash it would be different right? I was thinking about moving the flash start address for 4 bytes forward and write the CRC in the blank spot, so the address would be known. Any suggestions please? Thank you and best regards, K #i-accept-paypal