| ARM Technical Support Knowledge Articles | |
Applies to: General Topics
Information in this article applies to:
I need to validate the ROM in a DS80C320 based system at boot time. Is there any way to automatically generate a checksum of any kind in the code image that I could compare the actual code to?
Yes. You can easily add a ROM checksum to your program.
unsigned char calc_checksum (
unsigned char *start_addr,
unsigned int len)
{
unsigned char checksum = 0;
for (; len > 0; len--, start_addr++)
{
checksum += *start_addr;
}
return (checksum);
}
The checksum should equate to 0x00 or 0xFF typically. CHECK8 lets you force the checksum to be anything that you want.
The Check8 program takes the following parameters:
USAGE: CHECK8 [/options] filename
/Sstart set starting offset of checksum calculation /Eend set ending offset of checksum calculation /Pposition set position to write checksum byte /Vvalue set checksum adjustment value /H Display additional help text
filename name of binary file for checksum calculation
Example: check8 project.bin /s0x0000 /e0x3FFE /p0x3FFF /v0x80
Generate a checksum for the range 0x0000-0x3FFE, of the binary "project.bin", add 0x80 to the result, and store the checksum at address 0x3FFF.
Refer to this Checksum Example Program found in the Download Area on the Keil web site.
This example creates a program that checks the ROM checksum from 0x0000 to 0x3FFF and prints a message if the checksum is valid or not.
Pay special attention to the GENCSUM.BAT file as well as the DEBUG.INI file.
When you create a ROM checksummed file using the above technique, you cannot simply debug the absolute object module. You must debug the cooked Intel HEX file. To do this, in Options for Target/Debug turn off Load Application at Startup for the emulator. Start the debugger and in the Command window, type the command:
LOAD CHECKA.HEX NORESET
This loads your cooked file into the device. After it loads, type the command:
LOAD CHECK NORESET
This loads the OMF-51 file for the debugger to use.
Then, start the program
G, MAIN
and debug normally.
Article last edited on: 2007-03-27 11:18:33
Did you find this article helpful? Yes No
How can we improve this article?