cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4: Bootloader jump to application without reseting

Dennis.Heim
Associate II

Good day ladies and gentlemen,

my currenct setup: I want to write a custom bootloader for the STM32F413, so I do the initialization made by CubeMX (HAL_init, SystemConfig etc.), after that i want to jump right into the application with the following:

Bootloader: 0x08000000

Application: 0x08004000 (PAL_FLASH_APP_START_ADDRESS)

  __disable_interrupt();
  pApplication = (void(*)(void))(*((__IO uint32_t*)(PAL_FLASH_APP_START_ADDRESS+4)));
  __set_MSP(*((__IO uint32_t*)(PAL_FLASH_APP_START_ADDRESS)));
  __set_CONTROL(0);
 
  SCB->VTOR = (FLASH_BASE | 0x4000); 
  pApplication();

Which works perfectly fine so far. My problem now is that i have to reduce the time needed for the complete initialization of bootloader and application.

I want to do the Clock-Config etc. only once at the beginning of the bootloader because I have an external crystal (set to 8 MHz), don't deinitialize and jump in the application and directly use my functions.

The problem is that the jump ends in the Reset_Handler of the application, which obviously resets the config and puts my ext. setup back to 16MHz and crashes my program.

What would be the best way to get around this problem? I can't seem to get around the startup_stm32f413xx.s that causes this behaviour.

Kind regards.

1 ACCEPTED SOLUTION

Accepted Solutions

You probably don't want SysTick firing into an uninitialized application.

I would check that code in the apps SystemInit() function isn't undoing your RCC clock and PLL settings.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4

> The problem is that the jump ends in the Reset_Handler of the application,

That's just a program, too. Write your own.

JW

Dennis.Heim
Associate II

Thanks for your response. That's the way i already tried, but i can't seem to find a "macro" or easy way to directly jump into the main function instead of the typical needed startup. Any ideas?

You probably don't want SysTick firing into an uninitialized application.

I would check that code in the apps SystemInit() function isn't undoing your RCC clock and PLL settings.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Dennis.Heim
Associate II

Thanks again.

Both of your answers led me into the right direction, I must have been blind the last 2 hours... Your options are both worth as answer.

Option 1 (waclawek.jan): I just had to remove some functions called in the startup and direct it to the main start address.

Option 2 (Clive Two.Zero): I also could have removed the RCC reset done by the SystemInit as mentioned by you.

Thanks to both of you for your fast and helpful replies.