This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Last byte of used flash memory

The reason I need the last byte of used memory is so that my application can compute a checksum value of ONLY the used flash memory.

I have considered just calculating the checksum over the entire flash memory, used and unused data, but I ran into a problem. The flash memory is spread over two different flash chips (Infineon XC161 internal flash) and an ST external flash chip. Both flash chips erase to different values. XC161 to $00 and ST to $FF. When I am computing the checksum from the *.bin file (created using hex2bin), the unused areas of flash image in the bin file are either $00 or $FF which means I cannot calculate the checksum accurately over the entire flash memory space.

After programming, the flash memory looks like this:

XX XX XX XX XX FF FF FF YY YY YY YY YY 00 00 00
Where
XX is used data in the external flash
FF is unused data in the external flash
YY is used data in the internal flash
00 is unused data in the internal flash

And the bin file (created with hex2bin) looks like this:
XX XX XX XX XX 00 00 00 YY YY YY YY YY 00 00 00

Notice the FF's are 00 in the bin file.
I could set the fill byte to FF in which case the bin file would look like this:
XX XX XX XX XX FF FF FF YY YY YY YY YY FF FF FF

But in both cases the bin file doe snot accurately represent what will be programmed into the flash memory. So any checksum calculated on the entire bin file will be incorrect.

I really need to calculate the checksum on ONLY the used bytes:
XX XX XX XX XX and YY YY YY YY YY which means I need to know where the last used byte is in each flash memory area.

I have written my own hex2bin program that allows me to specify which fill character to use based on address ranges. However, I would prefer not to compute the checksum over the entire address range. I really would like to find a way to compute the checksum over only the used bytes.

I have seen this thread and others like it, that allow you to specify (LAST) for a segment address:
http://www.keil.com/forum/docs/thread5659.asp
I need something similar, but the (LAST) address specification that is shown in this thread does not seem to work within the XC161 linker.

Regards
Paul

0