Seems like this subject comes around and never seems to get a good answer.
Compiler version 5.1 for the HCS12.
The documentation for the use of generating firmware checksums via the PRM and storing it in a flash address is not very comprehensive and leaves more questions than answers.
I am using the 9sS12A64 device, although I think that matters little. Ideally I want to generate a CRC32 if all 4 flash pages and save the result in a specified flash position. Off cause the chksum location is omitted from the calculation.
My PRM setup is as follows:-
OF READ_ONLY 0x3C8000 TO 0x3CBFFF
OF READ_ONLY 0x3D8000 TO 0x3DBFFF
OF READ_ONLY 0x3e8004 TO 0x3eBFFF // omit the checksum storage from calc
OF READ_ONLY 0x3F8000 TO 0x3FBFFF
INTO READ_ONLY 0x4000 SIZE 4
The unused flash bytes in each page have been FILLED with 0x3F, so I think the "UNDEFINED 0x3F" statement is not really needed.
It generates a chksum but a manual calculation fails to match. The manual calculation used a std CRC32 calc with a polynomial of 0x04C11DB7 using Big Endian style.
Here the documentation is poor and does not define how to implement the CRC32 to match that of the compiler.
It also does not specify how to define access to the pages for calculation, eg for the top page, the physical address is FC000-FFFFF, or 3F8000-3FBFFF, or C000-FFFF.
I decided to experiment as see if the compiler matches the checksum which ever way you use. So I compiled the same code 3 times, on a single page, using the three different page descriptions and looked at the chksum it produced. I expected it to produce the same chksum each time, as we are looking at the same page each time, wrong!!!!!!!!
I found the same checksum for the Physical and the Paged methods but the non banked access was different. **bleep**... which one is right???? No wonder I can't get a good checksum.
Is it just a waste of time trying to use this auto chksum generation??
Anybody tell me what I'm doing wrong???
Living in hope