[arm-gnu] NXP LPC1788 checksum

Martin Velek martin.velek at gmail.com
Thu Jul 19 09:01:54 UTC 2012


Hello,

I am using the NXP LPC1788. However the NXP has a checksum feature,
after reset the ROM Bootloader sums  first 7 * 4 bytes and checks if
the sum is equal to zero. If not a special programm is called.

I would like not to rely on a JTAG (segger jlink) which probably does
the checksum or any other external tool. My idea is to add a magic
stuff to startup file or a linker to be generated automatically.

Adding  .long	__cs3_stack + __cs3_reset + ...... +
__cs3_isr_usage_fault@ = __cs3_lpc17xx_checksum led to
../lpc17xx-vector.S:29: Error: invalid operands (*UND* and *UND*
sections) for `+'

So that I have modified the linker script and added
PROVIDE(__cs3_lpc17xx_checksum = (0x0 - (__cs3_stack + __cs3_reset +
__cs3_isr_nmi + __cs3_isr_hard_fault + __cs3_isr_mpu_fault +
__cs3_isr_bus_fault + __cs3_isr_usage_fault)) - 0x6);
The six at the end is due to adding 0x1 as a function pointer (thumb)
while the linker probably counts with 0x0 at the end.

My question is if this solution is clear. It works but maybe there is
more fancy solution.

Thank you for your help

Regards,
Martin

---- From datasheet ----------
The reserved Cortex-M3 exception vector location 7 (offset 0x001C in
the vector table)
should contain the 2’s complement of the check-sum of table entries 0
through 6. This
causes the checksum of the first 8 table entries to be 0. The boot
loader code checksums
the first 8 locations in sector 0 of the flash. If the result is 0,
then execution control is
transferred to the user code.



More information about the arm-gnu mailing list