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

Computation of #ID checksum

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



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

Computation of #ID checksum
PostPosted: Mon Nov 21, 2011 10:48 am     Reply with quote

This is for those, like myself, who are using #ID checksum to a validate code at runtime.

I know a lot has been written about the rather confused and often mysterious world of including checksums and CRCs in code. This is about a specific instance only: #ID checksum

I have spent much of today debugging code that ran perfectly when compiled with PCHW 4.107 but which stopped working when I upgraded to 4.124. I have already sorted out one issue relating to indexing of strings, which mucked up timecoding my code. I put it to one side and stuck with 4.107 for existing code, using 4.12x for new code.

I've just updated to 4.127 and decided to get to the bottom of the second problem.

At some point between 4.107 and 4.124 (the file dates suggest 16 Oct 2010) the algorithm for computing the checksum by #ID checksum changed. ex_checksum.c appears to have changed to reflect the change, so use ex_checksum.c as a guide to generating new code.

The change itself is that previously the 16 bit checksum on PCH was calculated as the sum of 16 bit program words mod 2^16. In other words the checksum is an unsigned int16 into which the words are simply added ignoring any overflows.

After the change the 16 bit checksum on PCH is calculated as the sum of 8 bit program bytes mod 2^16. In other words the checksum is an unsigned int16 into which each byte, low byte first (though ordering is not important) of the code words are simply added ignoring any overflows.

A worked example: 0xFFFF 0xFFFF 0xFFFF 0xFFFF used to sum to 0xFFFC. Now it sums to 0x07F8.

The effect is that my code checksum stuff broke :-(

I can't comment on other methods of checksum/CRC labelling, such as #rom checksum, which uses a DIFFERENT algorithm to #ID checksum as well as placing the result in a different place in memory. And no, as far as I know, no one has ever got any of the CRCs to work.

RF Developer
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Nov 21, 2011 5:18 pm     Reply with quote

THANK YOU for sharing that !!!!!

OUCH indeed.
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