problem with executing new firmware through bootloader

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

problem with executing new firmware through bootloader

1,315 Views
alinikfarjam
Contributor II

hi everybody,

i am designing an ethernet bootloader for LPC1768 keil. so far i wrote a code that recieve new firmware over TCP\Ip and store it in flash memory using IAP, then by setting new sp and pc jump to the address of new firmware.

i tested a simple blinky example which i wrote myself with using this code to jump and it works,

 

void execute_user_code(void)

{

   void (*user_code_entry)(void);
    unsigned *p; 

    __disable_irq();
    SCB->VTOR = (IMG_START_SECTOR & 0x1FFFFF80); 
    p = (unsigned *)(IMG_START_SECTOR+4 );
    user_code_entry = (void (*)()) *p;
    user_code_entry();
}

i tested sample blinky from keil ,it didn't work and i just enabled interrupt before jumping ( __enable_irq(); ) then it worked.

but for any other little bigger firmwares ,after jumping and executing , program hangs. i looked at the memory of address, which programms hangs on it and most of them are same ( its somthing like EF E7 E7 E7 EF E7 ... )

can anybody tell me please what can be a problem?

thank you all

3 Replies

829 Views
alinikfarjam
Contributor II

hi , thanks for the replies. i have already tested this function which Tyler suggested but same result.

i think prolem has something with interrupt to do, because as i said program works with my own blinky code without enabling interrupt and for keil sample blinky with enabling intterupt. for any other firmwares program hangs in both cases. thanks for any further suggestions.

0 Kudos

829 Views
tyler_drazich
Contributor III

Hi Ali,

I don't see where in your code the stack pointer is being set before jumping to the new firmware. I use the following function for executing a firmware application on LPC17xx in Keil. It sets the stack pointer to the value at offset 0, then jumps to the application address at offset 4.

__asm void ExecuteApp(uint32_t address) 
{ 
      LDR SP, [R0, #0] 
      ISB 
      LDR PC, [R0, #4] 
}

Regards,

Tyler

829 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Many customers also have the similar issue, and main cause of the issue is the system clock incompatibly.

The initial system clock configuration of the application demo should keep consistent with the bootlaoder demo, or the application definitely hangs after jumps from the bootloader.

I'd also like to suggest that you can try the jump function which is from the Tyler.
Have a great day,
Ping

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