I am developing an application with reliablilty specifications requiring the target device (an ATmega8) to periodically verify that the entire contents of its Flash ROM (both constant data AND code), and its EEPROM data, are valid.
If, over the life of the system, the EEPROM data becomes corrupt, it would prompt the user to reset all calibration info. If the Flash ROM becomes corrupt, it would lock the system and raise an alarm that reliability had been compromised.
I figure that the best way to achieve this would be to compute some sort of checksum or CRC. One for the flash, and one for the EEPROM.
I have two concerns:
Firstly, how can I automatically generate the value that this checksum / CRC should evaluate to? Ideally, any user should just be able to 'make all' and the resulting hex files for downloading should already contain a correct checksum for the Flash, and an initial valid checksum for the EEPROM. (Of course, as the user modifies the EEPROM calibration, the EEPROM checksum would be modified on-the-fly. I can manage that part of it.)
Secondly, how can I make sure that the Flash checksum value gets placed in a well-known location in Flash so that software knows how to find it?