ARM: LPCxxxx: flashing application breaks custom bootloader
Information in this knowledgebase article applies to:
For my project based on an NXP LPCxxxx device I have developed a custom bootloader that starts the application program. The start address of the application was moved accordingly to not conflict with the bootloader area. And when I flash the application before the bootloader, the system starts as expected. The problem is that the boot process fails when the bootloader is flashed before the application. What is the reason for this?
One possible reason is, that the default startup file shipped with
MDK-ARM or the device family pack, e. g. startup_LPC17xx.s, will
place the Code Read Protection (CRP) at the required absolute address
in the image. For more detail about the CRP, see the device
IF :LNOT::DEF:NO_CRP AREA |.ARM.__at_0x02FC|, CODE, READONLY CRP_Key DCD 0xFFFFFFFF ENDIF
Even if the base address for the application image was moved, this CRP object is still output at this absolute address. If then such an application image is flashed to its moved address, this CRP object will also be flashed causing the flash sector it is in to be erased as well. This also erases parts of the previously flashed bootloader, which is the reason for the boot failure.
The creation of the CRP value needs to be prevented in this case. This can be done by adding NO_CRP in Options for Target ... -> Conditional Assembly Control Symbols -> Asm -> Define.
Last Reviewed: Tuesday, April 4, 2017
of your data.