1

I am using PIC32MZ2048EFH064, MPLABx3.40, XC32 V1.42, Harmony V2.01b. And my PC app is using MS Visual C++ 2010 Express. Instead of using microchip's Pic32 downloader I want to build my own downloader and, I want to download my custom encrypted firmware using PC host application. Now problem is, I am able to connect and download the bootloader firmware using my custom app, but CRC verification (i.e. program verification) is failed. Because the CRC calculated (and sent) by firmware doesn't matches to the CRC calculated by my custom app for the hex file. Now my observations are :

Both are using same address range and same program length over which CRC is calcuated.
Address range is : 0x9FC00000 - 0x9FC0FFF4.
Both are using same CRC table, CRC routine to calculate CRC.

I want to ask that, whether calculating CRC should include config register area also?

JRE
  • 67,678
  • 8
  • 104
  • 179
Ravi C
  • 101
  • 1
  • 11

1 Answers1

2

Usually your program image would only have its verification CRC computed across the image and not any of the configuration registers in the MCU. But be aware that CRC calculations can have many variables even with the same CRC acceleration table. Some of these factors:

  1. Are the CRC bytes locations in the image itself included in the calculation?
  2. Do you start the CRC calculation loop with a seed of 0x0000 or 0xFFFF?
  3. The order you store the CRC bytes in the image needs to be comprehended.
  4. The CRC table is typically 16-bits wide for MCU type application. It makes a difference if you take the high table byte first into the computation loop or the low byte.
  5. Sometimes the final computed CRC is logically inverted before having its value stuffed into the image.

It is strongly recommended that you prototype your CRC generator and checker routines in a PC C language environment to ensure the algorithms encode and decode the same way. If you are trying to put your own algorithm up against that generated/decoded by another tool it is especially important to test it thoroughly before you ever try to make it work on a live embedded system where it can be more difficult to test and debug.

Michael Karas
  • 56,889
  • 3
  • 70
  • 138
  • Thanks @Michael Karas, Excluding the address space of config registers over which I was trying to calculate CRC have solved my problem. – Ravi C Aug 07 '17 at 06:32