caius
caius

Reputation: 3

STM32F2 bootloader issue

I have write a bootloader to jump into my app. First I have try with a simple blinky-led app => I am able to jump into the app from the bootloader.

Now I want to jump into my real app. The app is working well alone but when I jump into it from my bootloader the app crash as soon as the interrupts are enabled, my jumping code :

__disable_irq();
 SCB->VTOR = (uint32_t)0x0800BA00;
 JumpAddress = *(__IO uint32_t*) (0X0800BA04);
 JumpToApplication = (pFunction) JumpAddress;
__set_MSP(*(__IO uint32_t*) 0X0800BA00);
 JumpToApplication();

I don't know what is wrong and why the activation of interruptions crash the app.

Thank you for your help

Upvotes: 0

Views: 1755

Answers (2)

amit
amit

Reputation: 1

set clock setting of boot code & application code same

Upvotes: 0

Freddie Chopin
Freddie Chopin

Reputation: 8870

Before you jump to the application, you should deinitialize everything that you've initialized in the bootloader. If your bootloader uses USART with interrupts, you should disable this USART (for example using RCC->AHBxRST/RCC->APBxRST registers) and disable its interrupts. You should also jump to your application with interrupts enabled. Your application should get the chip just as it would be after a normal reset.

If your application uses this crap code from ST called SPL or HAL, then make sure that this code does NOT reset SCB->VTOR back to 0 or 0x8000000, because normally it does that in SystemInit(), which is called from Reset_Handler(), before main().

BTW - are you absolutely sure about the address of your application? You usually put the application at the page boundary, while your code does not indicate that - 0x800ba00 (46.5kB) is pretty far from the closest page boundaries 32kB and 48kB...

Upvotes: 3

Related Questions