View previous topic :: View next topic |
Author |
Message |
microlo75
Joined: 13 Apr 2010 Posts: 23
|
Verify file .hex |
Posted: Sun Nov 27, 2011 12:24 pm |
|
|
Hi forum,
before doing a firmware update with bootloader,
how do I verify a file. hex?
I would check that the CRC is correct, how do I calculate it?
....
....
:1082400002003700094EE20004003A0010C0B300FB
:1082500006FFB700608A02000100000089D2AE006C
:1082600002003700FE99020001000000C20CAE00BF
:10827000020037000ABE02000100000012C0040024
:10828000010000004F037800CF02780000000600D4
:00000001FF
;PIC24FJ256GB110
;CRC=F6B9 CREATED="15-nov-11 17:30"
how to calculate the CRC=F6B9???
I did many tests in visual basic but I can not get the result ..
thanks for the help
Alex |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Sun Nov 27, 2011 12:31 pm |
|
|
The CRC should be of the data portion of the file, not the ascii file you are looking at (you will have to look at the data portion only to get the same CRC). Take a look at page 3 of this note for the format of the hex file:
http://ww1.microchip.com/downloads/en/AppNotes/91024a.pdf
That said, I would expect the file was created correctly. If you want to validate the entire file later to make sure it was not corrupted, probably the easiest way is to stuff it in a .zip file for example for storage since .zip can include a CRC of the files it stores. You could also use something like an MD5 sum or one of the other formats that people publish along with files you can download to make it easy to verify the download was correct. It depends whether you are trying to validate the data portion of the hex file or verify the entire hex file is valid/has not been altered.
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 27, 2011 1:35 pm |
|
|
Quote: | how do I verify a file. hex?
|
Import it into MPLAB. If it has a CRC error, MPLAB will tell you.
Do this with the File / Import menu in MPLAB. |
|
|
microlo75
Joined: 13 Apr 2010 Posts: 23
|
|
Posted: Sun Nov 27, 2011 2:41 pm |
|
|
PCM programmer wrote: | Quote: | how do I verify a file. hex?
|
Import it into MPLAB. If it has a CRC error, MPLAB will tell you.
Do this with the File / Import menu in MPLAB. |
tks for reply,
my clients .... "before doing a firmware update of my product with bootloader"
my program has to check the crc of the file... |
|
|
microlo75
Joined: 13 Apr 2010 Posts: 23
|
|
Posted: Sun Nov 27, 2011 2:42 pm |
|
|
gpsmikey wrote: | The CRC should be of the data portion of the file, not the ascii file you are looking at (you will have to look at the data portion only to get the same CRC). Take a look at page 3 of this note for the format of the hex file:
http://ww1.microchip.com/downloads/en/AppNotes/91024a.pdf
That said, I would expect the file was created correctly. If you want to validate the entire file later to make sure it was not corrupted, probably the easiest way is to stuff it in a .zip file for example for storage since .zip can include a CRC of the files it stores. You could also use something like an MD5 sum or one of the other formats that people publish along with files you can download to make it easy to verify the download was correct. It depends whether you are trying to validate the data portion of the hex file or verify the entire hex file is valid/has not been altered.
mikey |
tks for reply,
for. zip ok, but I should do more operations since the update is automatic via ftp ..
I hope to understand how to calculate the crc .... |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Nov 27, 2011 3:24 pm |
|
|
The Code Library has efficient code examples for calculating CRC-8 and CRC-16.
CRC-8 wouldn't be safe enough in my opinion, but CRC-16 should do the trick. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Nov 27, 2011 5:08 pm |
|
|
I'm not aware of a specification how the CRC16 in CCS hexfiles is calculated, means, which part of the image is used for it.
That's not obvious because the hex files are ususally not continuous.
The said CRC is CCS-specific and not checked by MPLAB.
Code: | CRC=F6B9 CREATED="15-nov-11 17:30" |
|
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Nov 28, 2011 12:20 am |
|
|
Please read the original post thoroughly. It's not about the Intel hex 8-Bit checksum but the CCS private CRC16 in hex files.
There's no CRC involved with Intel hex. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Mon Nov 28, 2011 1:57 am |
|
|
my bad. sorry _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
microlo75
Joined: 13 Apr 2010 Posts: 23
|
solved |
Posted: Mon Nov 28, 2011 3:23 am |
|
|
thanks for the help,
I solved by checking the crc of each line, instead of CRC ccs.
Alex |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Nov 28, 2011 3:36 am |
|
|
It would be interesting anyway to know the algorithm used by CCS. As a first point, you need to know if it's a file
CRC or a flash image CRC (e.g. with 0xff filling of unused locations). I guess, the former.
Most likely, you have to ask CCS. |
|
|
|