Jump issue with custom bootloader (STM32H7)
Hello,
I've made several bootloader in the past without so much problem in the past with F2, F4, F7, but this time, I have some serious troubles with a STM32H743BI :)
The bootloader (using the first sector, 128kb) reads a bin file from the SD card and program the rest of the flash sectors.
Everything works well if : I have flashed the main application one time minimum, thanks to my j-link debugger. Entering the bootloader erase the main app sector, then flash the .bin code, then jump. No issue at all.
But if the main application has never been flashed with "manually" with j-link, the jump fail (no error/hardfault, the uC is just lost after jump).
Also, when everything works (first case), if I flash "manually" the main application starting on the first sector (VECT_TAB_OFFSET = 0, instead of VECT_TAB_OFFSET = 0x020000) : after a bootloader erase/flashing, same issue = jump fails.
It looks like flashing "manually" does configure some hidden registers, and after that the bootloader is able to successfully jump?
This is the code I use for the jump :
void JumpToApplication()
{
uint32_t JumpAddress = *(__IO uint32_t*)(app_address);
pFunction Jump = (pFunction)JumpAddress;
// __disable_irq(); // tested, do not change anything
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
SCB->VTOR = app_address;
HAL_RCC_DeInit();
// HAL_DeInit(); // tested, do not change anything
// tested, do not change anything
// for(uint8_t i = 0; i < 5; i++)
// {
// NVIC->ICER[i] = 0xFFFFFFFF;
// NVIC->ICPR[i] = 0xFFFFFFFF;
// }
// __enable_irq(); //tested, do not change anything
__set_MSP(*(__IO uint32_t*)app_address);
Jump();
}On the side of the main application :
#define VECT_TAB_OFFSET 0x020000ULDo you have idea on what is going wrong?
Thanks!
Jean
