Keil Logo

ARM: LPCxxxx: Flashing Application Breaks Custom Bootloader


Information in this knowledgebase article applies to:

  • Keil MDK and NXP LPCxxxx devices

SYMPTOM

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?

CAUSE

One possible reason is, that the default startup file shipped with Keil MDK 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 manual.
However, in the startup file you should find code like this:

                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.

RESOLUTION

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 ... -> Asm -> Conditional Assembly Control Symbols -> Define.

MORE INFORMATION

Last Reviewed: Friday, November 13, 2020


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.