Second bootloader

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

Second bootloader

785 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by andy22 on Sun Dec 16 19:42:50 MST 2012
Hi,
  My project need a second bootloader to update new firmware code through a SW tool.
  The LPC11U14 chip has 8 sectors and I will use the first and second sectors to store my bootloader,and in bootlader code ,i will download my firmware through the USB interface.My firmware code will store from sector 2 to 5. When reset the MCU, the code will always excute from the bootloader,and then judge if the code jump to firmware or update the firmware.
  I use the function to jump to my firmware:
void nsAPI_Flash_Jump2AppSector(void)
{
typedef void Jump2BootloaderSector(void);
Jump2BootloaderSector *_Jump_ ;
_Jump_ = (Jump2BootloaderSector *)(0x00002000|0xc1);
_Jump_();
}
  What the question is i can't jump to it.After i called the function,my system will out of work.
  Whether the address I jump to is wrong? But when i change it to 0x0 or 0x00002000,it doesn't work as the same,what should i do?
  Please give me some advice,I am now very anxious!
Labels (1)
0 Kudos
Reply
4 Replies

736 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by andy22 on Wed Dec 19 06:30:58 MST 2012
Hi Daniel Widyanto,
   I have tried what you suggesting,the same result as I jump the pointer to 0x000020c1. When excute the code you provided,the whole system will die.
0 Kudos
Reply

736 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Daniel Widyanto on Tue Dec 18 23:33:24 MST 2012
Hi,

Refer to AN10995 - LPC1100 secondary bootloader (with software) (http://www.nxp.com/documents/application_note/AN10995.zip).

You need to get the Reset_Handler() address in 0x2004, and set the MSP according to address in 0x2000.
<code>
/* Load main stack pointer with application stack pointer initial value,
   stored at first location of application area */
asm volatile("ldr r0, =0x2000");
asm volatile("ldr r0, [r0]");
asm volatile("mov sp, r0");

/* Load program counter with application reset vector address, located at
   second word of application area. */
asm volatile("ldr r0, =0x2004");
asm volatile("ldr r0, [r0]");
asm volatile("mov pc, r0");
</code>
0 Kudos
Reply

736 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by andy22 on Mon Dec 17 18:15:38 MST 2012
Hi wmues,
Thanks for your suggestion. I tried to change it to 0xc0,but it seems doesn't work.
  I use the ULINK2 debugger and MDK development ,but the USB enumreration need host,and when i use the ULINK,it would communicate failure.
0 Kudos
Reply

736 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Mon Dec 17 02:21:07 MST 2012
Try to replace the 0xc1 with 0xc0.
The missing "1" (==thumb code flag) may be added by the compiler.

Why don't you use a debugger to look at your code?
0 Kudos
Reply