CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Verify file .hex

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
microlo75



Joined: 13 Apr 2010
Posts: 23

View user's profile Send private message

Verify file .hex
PostPosted: Sun Nov 27, 2011 12:24 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 27, 2011 12:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 27, 2011 1:35 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 27, 2011 2:41 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 27, 2011 2:42 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 27, 2011 3:24 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 27, 2011 5:08 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 27, 2011 6:44 pm     Reply with quote

Check out:

http://en.wikipedia.org/wiki/Intel_HEX
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Nov 28, 2011 12:20 am     Reply with quote

Quote:
Check out

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

View user's profile Send private message

PostPosted: Mon Nov 28, 2011 1:57 am     Reply with quote

my bad. sorry
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
microlo75



Joined: 13 Apr 2010
Posts: 23

View user's profile Send private message

solved
PostPosted: Mon Nov 28, 2011 3:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Nov 28, 2011 3:36 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group