I trying to implement a secondary bootloader for LPC11U34. I save my app on a AT45DB041 and when the lpc boot I detect a new firmware on SPIFlash and copy the content for lpc flash. This is running ok. On my Keil project I modified my app ROM to run from 0x1000 to 0xA000 , RAM from 0x10000200 and I realoccated the vector table for RAM(0x10000000). But when I call loadApp(); the SBL dont jump to my app and crash. I based my SBL in the AN11257 and AN11961. I tried others way to execute my code but all crash. Anybody can help me?
for SBL
#define SBL_SLV_FIRMWARE_START 0x1000
__asm void loadApp(int addr)
{
ldr r1, [r0] ; Get SP value
msr msp, r1 ; load SP
ldr r1, [r0, #4] ; Get app reset vector
cpsie i
BX r1
}
for App
#define VCT_TBL_SIZE 512
#define APP_FLASH_START_ADDR ((uint8_t *)0x1000)
#define APP_RAM_START_ADDR ((uint8_t *)0x10000000)
void Vector_TBL_Relocate(void){
uint32_t i;
/* Copy interrupt vector table from Flash to RAM */
for(i = 0; i < VCT_TBL_SIZE; i++){
*(APP_RAM_START_ADDR + i) = *(APP_FLASH_START_ADDR + i);
}
/* Interrupt vectors mapped to user RAM*/
LPC_SYSCON->SYSMEMREMAP = 0x1;
}
Thanks
Fernando Maesso
When compile I get this error. I´m using Keil UV5 with default compiler.
Hi, Fernando,
Regarding your issue, I think the api function has issue:
__asm void loadApp(int addr)
{
ldr r1, [r0] ; Get SP value
msr msp, r1 ; load SP
ldr r1, [r0, #4] ; Get app reset vector
cpsie i
BX r1
}
Pls try to modify it as:
__asm void loadApp(int addr)
{
ldr r1, [r0] ; Get SP value
msr msp, r1 ; load SP
ldr r1, [r0, #4] ; Get app reset vector
add r1,r1,#1 ;the lsb of PC must be 1 for thumb instruction
cpsie i
BLX r1
}
Pls have a try
BR
XiangJun Rong
HI xiangjun_rong,
Thank for your reply. I added the line but i had a error A1859E: Flag preserving form of this instruction not available. Have other way to set the bit?
Hi,
Can you tell us what gives the error message "A1859E: Flag preserving form of this instruction not available."?
BR
XiangJun Rong
Hi,
I have tried with my MCUXpresso tools, I can pass the compilation with the code:
void loadApp(int addr)
{
__asm("ldr r1, [r0]"); // Get SP value
__asm("msr msp, r1"); // load SP
__asm("ldr r1, [r0, #4]"); // Get app reset vector
__asm("add r1,r1,#1"); //the lsb of PC must be 1 for thumb instruction
__asm("cpsie i");
__asm("BLX r1");
}
BR
XiangJun Rong