• AVR Freaks

Boot Loader CRC Utility

Author
Jim Nickerson
User 452
  • Total Posts : 6019
  • Reward points : 0
  • Joined: 2003/11/07 12:35:10
  • Location: San Diego, CA
  • Status: offline
2014/10/07 09:23:57 (permalink)
5 (1)

Boot Loader CRC Utility

I use a bootloader for my PIC32MX based board.
I started with AN1388 (DS01388B) when it had the EXTENDED_HEXFILE_SUPPORT option in boot_config.h
This recognized an intel hex record type 0x12 as a "Check Error Detection Accumulator (csum, CRC, MD-5, etc)".
I wanted to be able to read in the first sector of the boot image from the SD card and check to see if the image in flash was different from the image on the SD card.
I wanted to make use of the Microchip Example DMA CRC calculation to check the code in flash.
After some research about CRC generation I came to the conclusion there are quite a few opinions as to the "correct" method of calculating the CRC, in particular about adding 16 zero bits (augmentation).
The 16 bit CRC calculated by XHexAdd matches that produced by the Microchip example DMA CRC code from "C:\Program Files (x86)\Microchip\xc32\v1.32\docs\pic32-lib-help\Microchip PIC32MX Peripheral Library.chm"  in the "DmaDoCrcExample"
There is one difference:
"CrcConfigure(0x11021, 16, 0xffff);        // initial seed set to 0xffff
"
Has become "CrcConfigure(0x1021, 16, 0xffff); " as the 2nd argument (16) specifies to only use 16 bits.
I tested with the code from  http://srecord.sourceforge.net/crc16-ccitt.html#source and I added the option to add the Zero bits (Augmentation) if one chooses however the Microchip DMA code must also be adjusted if Augmentation is used.
I found if I was using IPE I had to move my comment lines to the end, after the EOF record to avoid IPE complaining about a bad hex file.
I included the option to add comments to the hex file.
This is a console application I call if from my Mplab X project using the "Execute this line after build" option. I also check the "Normalize hex file" option.
This is an example of my Execute line.

 
 
 
C:\Users\Jim.Nickerson\Documents\VisualStudioExpress2013\XHexAdd\Release\XHexAdd verbose=true InDir=${ProjectDir} InFileHex=${ImagePath} DirOut=${ProjectDir}  OutFile=image.hex LDir=${ProjectDir} LogFile=XHexAddLog.txt  Min=0x1d010000 CrcAddMcDma Comment=";SourceHexFile ${ImageName}" Comment=";ConfigurationName ${ConfName}" POUT=DateTime PLOG=DateTime AAEOF=true
 
 
 

Help/Usage is available if XHexAdd.exe is started with no arguments from a cmd window.
I use this in WIindows 8.1 x64.
I have attached a zip of the exe.
As this is a Windows Utility it is an exe it may not permitted on this site, it may be downloaded from my web site http://www.jimnickerson.com/XHexAdd/XHexAdd.exe
No doubt your virus scanner/browser will block downloading an exe in which case this file may be downloaded and renamed to .exe http://www.jimnickerson.com/XHexAdd/XHexAdd.exe.abc
This is my original code I am using.
Constructive comments/suggestions are welcome.
Edit: It seems I have been permitted to upload and attach a zip of an exe. Please run it from a cmd window to see any results.
This is a "Beta" release.
Typo correction
post edited by JANickerson - 2014/10/07 09:28:17
#1

0 Replies Related Threads

    Jump to:
    © 2019 APG vNext Commercial Version 4.5