LPC1788 bootloader can't jump to user code correctly

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

LPC1788 bootloader can't jump to user code correctly

784 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan Sylvan on Tue Nov 12 01:40:47 MST 2013
Hi all!
I'm trying to use bootloader in LPC1788.
BL writes code into the flash memory correctly but it can't jump to user code. I need to jump to 0x2000 but actually it is about 0x680.
What did i do wrong?
Can anybody advice where to get information of how to construct bootloader in LPC1788? As i can see in AN10866_2.pdf for LPC1768 i need to load new VTOR and move SP, PC to new location. And that's it. But i know some people stop PLL, clear INTs and so on in LPC1788. Why? Where can i read about it?
Thanks in advance.

my code (Keil)
__asm void boot_jump( uint32_t address ){
   LDR SP, [R0];Load new stack pointer address
   LDR PC, [R0, #4];Load new program counter address
}

void execute_user_code(void)
{
uint8_t tmp;

NVIC->ICER[0] = 0xFFFFFFFF;//Disable all interrupts 
NVIC->ICER[1] = 0x00000001;
 
NVIC->ICPR[0] = 0xFFFFFFFF;//Clear all pending interrupts 
NVIC->ICPR[1] = 0x00000001;
for(tmp = 0; tmp < 32; tmp++)// Clear all interrupt priority 
{
NVIC->IP[tmp] = 0x00;
}

LPC_SC->CCLKSEL = 0x01; // set sysclk (12MHz) as clock source
LPC_SC->PLL0CON = 0; // disable PLL
LPC_SC->PLL0FEED = 0xAA;
LPC_SC->PLL0FEED = 0x55;

SCB->VTOR = (0x2000) & 0x1FFFFF80;
boot_jump(0x2000);
}

Labels (1)
0 Kudos
5 Replies

641 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan Sylvan on Tue Nov 12 02:48:47 MST 2013
Dear Capiman and Pacman, thank you very much for your help! I really appreciate you.
:-)
0 Kudos

641 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Tue Nov 12 02:42:07 MST 2013
Exactly.
To be more precise: Your exception vectors must be placed at address 0x2000 by your linker script.
That means... Your bootloader-code would work (I still recommend disabling and clearing the extra interrupts).
But you need a different linker-script for the program you're bootloading.

So: Keep your linker-script as it is for your bootloader.
For the program you'll be bootloading: Move the exception vector table.
0 Kudos

641 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Tue Nov 12 02:31:33 MST 2013
Thats the problem.
You jump to an address below 0x2000 instead of an address above 0x2000.
Your jump does not go to application, but back to bootloader.

I assume your linker script for application is wrong.
You just can't move the application from 0 to 0x2000 without changing the content.
It is not position independent.
0 Kudos

641 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ivan Sylvan on Tue Nov 12 02:27:43 MST 2013

Quote: Pacman

... It seems there are 8 interrupts you're not disabling/clearing pending bit for.
(UM10470, section 5.5.3, 5.5.7; page 82/83, 86/87)

...Can you read the contents of address 0x2000 and address 0x2004 ?


Thank you Pacman. But changes in NVIC->ICER, NVIC->ICPR did not help me.
This is a content of the flash memory:
0x2000 - 0x1000aa20
0x2004 - 0x0000066d
0 Kudos

641 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Tue Nov 12 02:16:35 MST 2013
This will probably not fix your problem, but why not do this...
NVIC->ICER[0] = 0xFFFFFFFF;//Disable all interrupts 
NVIC->ICER[1] = 0x000001FF;

NVIC->ICPR[0] = 0xFFFFFFFF;//Clear all pending interrupts 
NVIC->ICPR[1] = 0x000001FF;

... It seems there are 8 interrupts you're not disabling/clearing pending bit for.
(UM10470, section 5.5.3, 5.5.7; page 82/83, 86/87)

...Can you read the contents of address 0x2000 and address 0x2004 ?
0 Kudos