This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

in application programming does not jump to user app

Hi there,

I tried to execute the IAP code (AN3965) on a f4 discovery board. I can say that the loader reads an writes binarys perfectly, it was testet with flash loader demonstrator.
But jumping to user app does not work. I tried the following pieces of code, I get everytimes a hard fault at the command 'Jump_To_Application();'

What is wrong?

code one:

/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
Jump_To_Application();

code two:

volatile uint32_t JumpAddress;
void (*Jump_To_Application)(void) = 0;
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
/* Jump to user application */
Jump_To_Application = (void (*)(void)) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
Jump_To_Application();

Parents
  • It's possible to have a boot loader that not turn off interrupts - it's just a question of what the target application does, i.e. in which order and how completely it reinitializes stack, interrupt controller, ...

    But there is a huge advantage to have the boot loader try to deactivate interrupt handling etc to make the hw state as close to a real hardware reset as possible.

Reply
  • It's possible to have a boot loader that not turn off interrupts - it's just a question of what the target application does, i.e. in which order and how completely it reinitializes stack, interrupt controller, ...

    But there is a huge advantage to have the boot loader try to deactivate interrupt handling etc to make the hw state as close to a real hardware reset as possible.

Children
  • Can you explain the issue with the interrupt disable?
    Can you send me an example of the jumping with the interrupt disable?

    Thanks
    Arik

  • No, I can obviously not do that since my code is for _my_ processors. And since I avoid having code that does "fake reset".

    But realize that the startup code you get with the compiler is intended to run on a processor directly after a reset. So the startup code may assume that it can first configure a peripherial. Then specify what function to call when the interrupt happens. Then turn on interrupts. After a fake reset, the interrupts are already enabled. So when the code initializes the peripherial, an interrupt can happen. But the installed interrupt handler will not point to the interrupt handler in your program but into the interrupt handler of whatever was running before the fake reset. Or the interrupt may happen when the interrupt vector was only halfway assigned, making the interrupt vector point to some "random" location.

    Startup code that assumes the processor came from a real reset state is smaller/cheaper than startup code that assumes every single register in the processor are at some unknown/random state.