38.3.2.3 Checksum
The pre-calculated checksum must be present at the end of the section to be scanned. The checksum must be stored in the last bytes of the BOOT section to check the BOOT section and similarly for the APPCODE and APPDATA sections. The checksum for CRC32 has opposite endianness compared to CRC16. Table 1-2 and Table 1-3 show explicitly how to store the checksum for the different sections. For additional information on partitioning the Flash section. Refer to the Configuration of Scan Region section.
Section to Check | CHECKSUM[15:8] | CHECKSUM[7:0] |
---|---|---|
BOOT | BOOTEND - 1 | BOOTEND |
APPCODE | APPEND - 1 | APPEND |
APPDATA | FLASHEND - 1 | FLASHEND |
Section to Check | CHECKSUM[7:0] | CHECKSUM[15:8] | CHECKSUM[23:16] | CHECKSUM[31:24] |
---|---|---|---|---|
BOOT | BOOTEND - 3 | BOOTEND - 2 | BOOTEND - 1 | BOOTEND |
APPCODE | APPEND - 3 | APPEND - 2 | APPEND - 1 | APPEND |
APPDATA | FLASHEND - 3 | FLASHEND - 2 | FLASHEND - 1 | FLASHEND |
Defining the Pre-Calculated Checksum
The pre-calculated checksum can be determined by using a CRC algorithm and the parameters specified in Table 1-4. The calculation should start at the region start and end at the address before the pre-calculated checksum’s placement. Manual mode can be used to compare the checksum at the end of a region with known data, ensuring correctly configured calculation.
CRC Selected | Polynomial | Initial Value | Width | XOR Value |
---|---|---|---|---|
CRC16 | 0x1021 | 0xFFFF | 2 | N/A |
CRC32 | 0x4C11DB7 | 0xFFFF_FFFF | 4 | 0xFFFF_FFFF |
For more information on Checksum calculation and use, refer to the Hexmate section in the MPLAB® XC8 C Compiler User’s Guide for PIC® MCU document.