2025-09-23 3:55 PM
I am developing a bootloader for the STM32H563 that is stored at the beginning of internal Flash (0x08000000) and the application is stored at 0x08020000. The application runs fine when I program/start from STM32CubeIDE once I changed the linker script to set the appropriate Flash address and the VEC_TAB_ADDRESS to be 0x20000 in system_stm32h5xx.c, so the application runs fine on its own from the new 0x08020000 address.
In the bootloader I am executing the following code the should work fine as I've used similar before in a project with the STM32H743.
__disable_irq();
SCB->VTOR = (uint32_t)EuiFlashFile_loadAddress;
__set_MSP(*(__IO uint32_t*) EuiFlashFile_loadAddress);
void (*app_reset_handler)(void);
app_reset_handler = (void (*)(void))(*(__IO uint32_t*)(EuiFlashFile_loadAddress + 4U));
app_reset_handler();
The app_reset_handler is set to the correct Reset_Handler address stored at 0x08020004 (0x0802FC3D)...
....but after the app_reset_handler() is called I used the debugger to attach to the application .elf and it was in the hard fault handler. I tried to step through again and once it jumped I detached and attached to application debugger and it seemed to be stuck in the HAL_Delay()...so not sure what is happening.
Any ideas or advice would be appreciated!