How to write BootLoader on Mbed LPC1768

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to write BootLoader on Mbed LPC1768

2,727 Views
bzyjj
Contributor I

Hi :

 

I am currently practicing a topic to update firmware via UART, and I chose the Mbed LPC1768 to implement it. I expected to write a BootLoader program and a program that simply controls the LED light. My thoughts are as follows:

 

  1. At boot time, the BootLoader will first check the Flash for a specific location (update firmware Flag). If it is not updated, it will execute the control LED1 flashing program, and at the same time receive the UART to check if there is any firmware to be updated. If so, set up the update firmware Flag, then reboot.

 

  1. BootLoader checks the Flash for a specific location (update firmware Flag), if it needs to be updated, download the new control LED light program through the UART, clear the Flag after completion, and restart the new control LED2 flashing program.

 

My question is: After I put my BootLoader program on the Mbed LPC1768 via USB, how do I write the LED1 flashing program in to flash? And how do I make the BootLoader program jump to execute the LED1 flashing program?

 

Thank you.

Labels (1)
0 Kudos
1 Reply

1,924 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Jun Zhe Yang ,

1. Regarding to your description, I think you mean to make a secondary bootloader.

About your question 1 "how do I write the LED1 flashing program in to flash?"

-> After finished your UART secondary bootloader , receive application through UART, then use IAP command

to flash it , a detailed description of the IAP commands can be found in the chip user manual.

About second question" And how do I make the BootLoader program jump to execute the LED1 flashing program?"

->Execution of the user application is performed by updating the stack pointer (SP) and program counter (PC) registers. The first two 32-bit words of a binary image contain new SP and PC values that are to be loaded into their respective registers.The SP points to the new location where the user application has allocated the top of its stack (the stack grows downwards in memory). The PC on the other hand contains the location of the first executable instruction in the user application. The code just like below :

pastedImage_1.png

About the detail about  secondary bootloader on LPC17xx, there is a application note and code about  based on USB ,

while the processing is the same with UART, you can have a look : AN10866 

2. By the way,  there is ISP in lpc1768, The ISP routines are located in the primary bootloader. can be used to flash the microcontroller while it is in the end-user system. The ISP protocol consists of commands that are sent in ASCII format via the UART0 interface. So maybe you can use it . A detailed description of the ISP commands can be found in the chip user manual.

3. And about when enter into bootloader code or application code , there are not only one option, yours is right , also can

check one pin , if low when reset , we can run into bootloader . Also you can refer  to  AN10866 .

Hope it helps,


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos