...enable code read protection (LPC2000)
The LPC2000 user guide states that I can enable code read protection by programming location 0x000001FC with the value 0x87654321. How can I do this in CrossStudio?
You can do this by adding the following code to the end of the .vectors section in the Philips_LPC210X_Startup.s (LPC21xx, LPC22xx) or Philips_LPC230X_Startup.s (LPC23xx, LPC24xx) file:
.org 0x000001FC .word 0x87654321
Warning: With code read protection enabled the JTAG port will be disabled which means that you will no longer be able download and debug over JTAG, see your LPC2000 user guide for more information.
Note that some versions of the LPC2000 bootloader appear to disable the JTAG as soon as the code read protection word is written which means that if you're downloading over JTAG subsequent download or verification operations will fail. If this is the case then you can do one of the following:
- Generate a .hex file (by setting the Linker > Additional Output Format project property to hex and building your application) and then download the application containing the code read protection enable word over serial port using the Philips ISP loader.
- Rather than embedding the code read protection enable word in your program text, write it programatically either from the application itself or from a seperate RAM application. Obviously if you do this you will still need to reserve the word at 0x000001FC so that the program text is not overwritten.
-
I can't get this to work. When I write ANY value to address 0x1fc, my app doesn't work properly, like so:
_vectors:
ldr pc, [pc, #reset_handler_address - . - 8] /* reset */
ldr pc, [pc, #undef_handler_address - . - 8] /* undefined instruction */
ldr pc, [pc, #swi_handler_address - . - 8] /* swi handler */
ldr pc, [pc, #pabort_handler_address - . - 8] /* abort prefetch */
ldr pc, [pc, #dabort_handler_address - . - 8] /* abort data */
#ifdef VECTORED_IRQ_INTERRUPTS
.word 0xB9206E58 /* boot loader checksum */
ldr pc, [pc, #-0x120] /* irq handler */
#else
.word 0xB8A06F60 /* boot loader checksum */
ldr pc, [pc, #irq_handler_address - . - 8] /* irq handler */
#endif
ldr pc, [pc, #fiq_handler_address - . - 8] /* fiq handler */
.org 0x000001fc
.word 0xa5a5a5a5I can see via the debugger that address 0x1fc does contain the value I gave it, but this causes my app to crash for some reason. I am guessing this is because I overwrote some code that was there? How do I reserve address 0x1fc? Do I need to do this in a linker file? If I remove those last two lines above, everything is hunky dory except that I need code protection.
Please sign in to leave a comment.
Comments
2 comments