Checksum Help

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Checksum Help

2,147 Views
rhb3
Contributor II
Currently, I'm using the automatic method to have the linker calculate checksums.  I'm concerned for two reasons:
 
1)  Notice that I'm using banked and I have a ROM_FLASH sector.  This is an area inteneded for saving variables that may indeed change.  As it is READ_ONLY is the linker using this area?  Can I mark it to not be used.  Also, the linker ignores any area in a segment that uses the default fill value defined for that segment, right?
 
2) I have this:  while (__CHECKSUM_IS_OK == FALSE) {}
...at the beginning of my program to ensure all is well or reset and try again.  My "end game" is to display a 4 hexadecimal character checksum through the UI.  How do I access the structure to report this informatio to the user who might call in to service and need to report the version of firmware they are running, etc.
 
Thanks!
 
Code:
/* This is a linker parameter file for the MC9S12E128 */NAMESENDSECTIONS      /* List of all sections specified on the "Build options" tab */      RAM        = READ_WRITE 0x002000 TO 0x003FFF FILL 0xAA 0x55;   /* unbanked FLASH ROM */      ROM_FLASH  = READ_ONLY  0x3E8000 TO 0x3E83FF FILL 0x00;      ROM_4400   = READ_ONLY  0x004400 TO 0x007FFF FILL 0x3F;      ROM_C000   = READ_ONLY  0x00C000 TO 0x00FEFF FILL 0x3F;   /* banked FLASH ROM */      PAGE_38    = READ_ONLY  0x388000 TO 0x38BFFF FILL 0x3F;      PAGE_39    = READ_ONLY  0x398000 TO 0x39BFFF FILL 0x3F;      PAGE_3A    = READ_ONLY  0x3A8000 TO 0x3ABFFF FILL 0x3F;      PAGE_3B    = READ_ONLY  0x3B8000 TO 0x3BBFFF FILL 0x3F;      PAGE_3C    = READ_ONLY  0x3C8000 TO 0x3CBFFF FILL 0x3F;      PAGE_3D    = READ_ONLY  0x3D8000 TO 0x3DBFFF FILL 0x3F;ENDPLACEMENT      SSTACK, DEFAULT_RAM             INTO RAM;      CHIMERA_FLASH                   INTO ROM_FLASH;      DEFAULT_ROM                     INTO ROM_4400, PAGE_3C, PAGE_3D, PAGE_38, PAGE_39, PAGE_3A, PAGE_3B;      RTOS, _PRESTART, STARTUP,      ROM_VAR, STRINGS,      NON_BANKED, COPY, .checksum     INTO ROM_C000;ENDINIT _EntryPoint   /* The entry point of the application. This function is generated into the CPU module. */STACKSIZE 0x0200

 
Labels (1)
0 Kudos
3 Replies

443 Views
CompilerGuru
NXP Employee
NXP Employee
There is a NO_CHECKSUM keyword which can be used to exclude certain segments from the automatic linker generated checksums. Note that it does NOT affect the prm file based checksums.
>
> MY_ROM = READ_ONLY 0xE020 TO 0xF7FF FILL 0xFF;
> MY_ROM2 = READ_ONLY 0xF800 TO 0xFEFF FILL 0xAA NO_CHECKSUM;
>

To your second question, well, you could use the same data structure as the code called with __CHECKSUM_IS_OK does.
Or, alternatively, use the prm file based checksum for this (or use explicit version for this purpose, for example based on the date).

Daniel
0 Kudos

443 Views
rhb3
Contributor II
Thanks.  Just to clarify, only READ_ONLY segments would need the NO_CHECKSUM as RAM segements will automatically be ignored, right?  Also, the linker will automatically handle all of the pages (even the ones not visible)?
 
 
0 Kudos

443 Views
CompilerGuru
NXP Employee
NXP Employee
The checksum if over READ_WRITE (and CODE) section types only, READ_WRITE, NO_INIT and PAGED areas are not checked.

With "not visible" pages, I guess you mean banked code.
I'm actually not sure, I guess that you at least have to define a macro so that the code uses far pointers.
(according to checksum.h, I would add -D_CHECKSUM_USE_FAR_PTR)

This way, checksum.c will use far pointers.
As far pointers are not especially efficient for a HC12. If you need faster performance you would have to change checksum.c to manually set PPAGE and to relocate the code outside of the 0x8000..0xBFFF area. But this is only an optimization.

Daniel
0 Kudos