Troubleshooting checksum calculation
If the two checksums do not match, there are several possible causes. These are some troubleshooting hints:
If possible, start with a small example when trying to get the checksums to match.
Verify that the exact same memory range or ranges are used in both checksum calculations.
To help you do this,
ielftoollists the ranges for which the checksum is calculated onstdoutabout the exact addresses that were used and the order in which they were accessed.Make sure that all checksum symbols are excluded from all checksum calculations.
Compare the checksum placement with the checksum range and make sure they do not overlap. You can find information in the Build message window after
ielftoolhas generated a checksum.Because pointers declared
__nearimplicitly have some of the most significant bits set, make sure that the checksum calculated by your application uses a__farpointer instead of a__nearpointer.Verify that the checksum calculations use the same polynomial.
Verify that the bits in the bytes are processed in the same order in both checksum calculations, from the least to the most significant bit or the other way around. You control this with the Bit order option (or from the command line, the
-mparameter of the‑‑checksumoption).If you are using the small variant of CRC, check whether you need to feed additional bytes into the algorithm.
The number of zeros to add at the end of the byte sequence must match the size of the checksum, in other words, one zero for a 1-byte checksum, two zeros for a 2-byte checksum, four zeros for a 4-byte checksum, and eight zeros for an 8-byte checksum.
Carefully consider the number of bits in pointers when crossing 64-Kbyte boundaries.
For example, if the pointer
0xFFFFis incremented by one, this typically results in the pointer0x0(and not0x10000) if the pointer is 16 bits.Any breakpoints in flash memory change the content of the flash. This means that the checksum which is calculated by your application will no longer match the initial checksum calculated by
ielftool. To make the two checksums match again, you must disable all your breakpoints in flash and any breakpoints set in flash by C-SPY internally. The stack plugin and the debugger option Run to both require C-SPY to set breakpoints. Read more about possible breakpoint consumers in Breakpoint consumers.By default, a symbol that you have allocated in memory by using the linker option
‑‑place_holderis considered by C-SPY to be of the typeint. If the size of the checksum is different than the size of anint, you can change the display format of the checksum symbol to match its size.In the C-SPY Watch window, select the symbol and choose Show As from the context menu. Choose the display format that matches the size of the checksum symbol.
If your application is linked with address translation (see logical directive), make sure that any checksums are calculated using explicit physical checksum ranges, see Checksums of address-translated ranges.