We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I write a bootloader to update the flash,but when the bootloader update the ?c?LIB_CODE,the MCU(C8051F005) always jump to another incorrect place. So I put the ?c?LIB_CODE into boot-area when linking. (BTW,my bootloader and app are compiled together.)
But I am afraid the ?c?LIB_CODE will increase when I use some new function in the newer applcation.then the app will be wrong if I do not update the ?c?LIB_CODE.
Any one has good ideas?
Avoid the simplest checksum method (just summing all bytes with overflow) since it fails quite a number of errors.
High-end methods often make use of crc16, crc32, md5 or similar, but they take quite a lot of code and processor time.
A very easy to implement checksum that is still very reliable with a minimum of processor requirements is adler16 or adler32. The Adler algorithm not just computes a sum, but also a sum of sums, which means that swapped bytes are detected. It is also affected by the length of the summed area, so there are no constant memory value that will represent a "null operation" when evaluating the checksum.
Here is a link for Adler32: en.wikipedia.org/.../Adler-32
It's quite easy to deduce a smaller Adler sum, if you don't want to use 32-bit integers. I think USB makes use of Adler-4 or Adler-8...