View previous topic :: View next topic |
Author |
Message |
stevev Guest
|
Anybody understand #ID CHECKSUM? |
Posted: Sun Feb 23, 2003 3:38 pm |
|
|
Does anyone know how to calculate a value at run time for a 16F877 which computes a ROM checksum which matches the value set by #ID CHECKSUM?
There are some old posts to c-code at Microchip but those links are broken. Here is what I'm trying to do, but the 'id' and 'calculated checksums don't match.
Thanks -steve-
verifyRom()
{
int16 romChecksum, flashChecksum;
int16 flash;
// -- get checksum from ID bits (set by compiler/linker at build time)
romChecksum = getenv("ID");
flashChecksum = 0;
// -- compute checksum of FLASH program ROM to verify program good
for (flash=0; flash
flashChecksum += read_program_eeprom(flash);
flashChecksum &= 0x7ff;
// -- show error message and halt if checksum's don't match!!
if (flashChecksum != romChecksum)
{
printf("BAD CHECKSUM");
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 12040 |
|
|
Tomi Guest
|
Re: Anybody understand #ID CHECKSUM? |
Posted: Mon Feb 24, 2003 9:32 am |
|
|
<font face="Courier New" size=-1>I think your problem is that you can not read ID locations at runtime (they are out of the normal memory address space).
:=Does anyone know how to calculate a value at run time for a 16F877 which computes a ROM checksum which matches the value set by #ID CHECKSUM?
:=
:=There are some old posts to c-code at Microchip but those links are broken. Here is what I'm trying to do, but the 'id' and 'calculated checksums don't match.
:=
:=Thanks -steve-
:=
:=verifyRom()
:={
:= int16 romChecksum, flashChecksum;
:= int16 flash;
:=
:= // -- get checksum from ID bits (set by compiler/linker at build time)
:= romChecksum = getenv("ID");
:=
:= flashChecksum = 0;
:=
:= // -- compute checksum of FLASH program ROM to verify program good
:= for (flash=0; flash<getenv("PROGRAM_MEMORY"); ++flash)
:= flashChecksum += read_program_eeprom(flash);
:=
:= flashChecksum &= 0x7ff;
:=
:= // -- show error message and halt if checksum's don't match!!
:= if (flashChecksum != romChecksum)
:= {
:= printf("BAD CHECKSUM");
:= }
:=}
___________________________
This message was ported from CCS's old forum
Original Post ID: 12056 |
|
|
stevev Guest
|
Re: Anybody understand #ID CHECKSUM? |
Posted: Tue Feb 25, 2003 1:39 pm |
|
|
I know that the config word for my fuses is 0x3F7E (at the bottom of the asm listing), so I tried subtracting (and adding too!) that from my checksums. I also have masked to 14-bits the sum, taken 1s complement and masked again to 14-bits ( as suggested by the MicroChip tech note) but this STILL doesn't give any values that match #ID CHECKSUM.
Does anybody verify their flash ROM contents match what was compiled? Doing this is a requirement for our product certification.
I'd appreciate any ideas or alternative methods that people are using to verify their ROMs.
Thanks again, -steve-
:=<font face="Courier New" size=-1>I think your problem is that you can not read ID locations at runtime (they are out of the normal memory address space).
:=
:=:=Does anyone know how to calculate a value at run time for a 16F877 which computes a ROM checksum which matches the value set by #ID CHECKSUM?
:=:=
:=:=There are some old posts to c-code at Microchip but those links are broken. Here is what I'm trying to do, but the 'id' and 'calculated checksums don't match.
:=:=
:=:=Thanks -steve-
___________________________
This message was ported from CCS's old forum
Original Post ID: 12091 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Anybody understand #ID CHECKSUM? |
Posted: Tue Feb 25, 2003 1:53 pm |
|
|
:=I know that the config word for my fuses is 0x3F7E (at the bottom of the asm listing), so I tried subtracting (and adding too!) that from my checksums. I also have masked to 14-bits the sum, taken 1s complement and masked again to 14-bits ( as suggested by the MicroChip tech note) but this STILL doesn't give any values that match #ID CHECKSUM.
:=
:=Does anybody verify their flash ROM contents match what was compiled? Doing this is a requirement for our product certification.
:=
:=I'd appreciate any ideas or alternative methods that people are using to verify their ROMs.
--------------------------------------------------------------
Here is a MicroChip appnote on checksums. It requires running
an external DOS program to modify the HEX file. The program
is also available on the following page.
<a href="http://www.microchip.com/1000/suppdoc/appnote/all/tb026/index.htm" TARGET="_blank">http://www.microchip.com/1000/suppdoc/appnote/all/tb026/index.htm</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12093 |
|
|
|