STM32F4: Bootloader jump to application without reseting
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.