[arm-gnu] NXP LPC1788 checksum
Carlos O'Donell
carlos_odonell at mentor.com
Thu Jul 19 14:39:27 UTC 2012
On 7/19/2012 5:01 AM, Martin Velek wrote:
> 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.
That is *already* a fancy solution :-)
There is no easy way to do this and in the past I've always post-processed
the ELF file to write in the checksum.
Your method is significantly more elegant than a post-processing step
with special tools.
Cheers,
Carlos.
--
Carlos O'Donell
Mentor Graphics / CodeSourcery
carlos_odonell at mentor.com
carlos at codesourcery.com
+1 (613) 963 1026
More information about the arm-gnu
mailing list