Hello,
for an integrity check of the program code for small controller (8051 derivatives), I am looking for an efficient checksum method.
The code size will be max. 32k, and a standard 8051 (X2) should manage to calculate the checksum in a reasonable time (no significant delay at power-up, say max. 500 ms). Faster devices (like the LPC900) will have some advantage here, additionally due to the smaller code memory...
Just adding (or XORing) the code bytes to a 16/24/32-bit sum is simple and fast, but not too reliable in case of multi-bit errors at the same bit position.
For calculating a CRC with 16 or more bits, the required table would need too much code memory - or doing it by shifting would take too much time.
I now thought of calculating two different sums. One by simply adding all code bytes to a 16 bit sum, the other by adding the byte and then shifting the sum one bit. This would reduce the probability of not finding a two-bit error to 1/16 compared to a single sum.
Are there other methods (easy to implement in small code, fast and reliable) I should consider?
Thanks, Tilmann