2024-08-08 03:00 AM
Hi All,
I am implementing a custom bootloader on a STM32U575QII6, but it is not jumping to my program.
I have my bootloader in bank 1, and I have written my program to Flash at address 0x08014000 - within the same bank.
I have tried multiple things and followed different posts etc but nothing is working for me. There is nothing specific around the U5 series.
#define APPLICATION_ADDRESS 0x08014000
void (*pFunction)(void) = (void(*)(void)) APPLICATION_ADDRESS + 4;
HAL_RCC_DeInit();
HAL_DeInit();
__disable_irq();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
SCB->VTOR = (uint32_t)APPLICATION_ADDRESS;
__set_MSP(*(uint32_t*) APPLICATION_ADDRESS);
__DSB();
__ISB();
__enable_irq();
(*pFunction)();
Any help would be appreciated, thanks!
2024-08-08 03:07 AM
I had simmilar problem while making jump to app function. I found out in stm32u575 I had to disable MX_ICACHE_Init() or comment in main app before jumping to the flash destinated addres.
MX_ICACHE_Init();
2024-08-08 03:28 AM
Thank you for the reply.
I have tried commenting out MX_ICACHE_Init() and running it again but it does not work. It jumps to HAL_RCC_OscConfig instead even though the function pointer is set up correctly.
2024-08-08 03:41 AM
#define APPLICATION_ADDRESS 0x08014000
void (*pFunction)(void) = (void(*)(void)) (*(uint32_t*)(APPLICATION_ADDRESS + 4));
HAL_RCC_DeInit();
HAL_DeInit();
__disable_irq();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
SCB->VTOR = (uint32_t)APPLICATION_ADDRESS;
__set_MSP(*(uint32_t*) APPLICATION_ADDRESS);
__DSB();
__ISB();
__enable_irq();
(*pFunction)();
Maybe try this
2024-08-08 03:57 AM
I gave this a try and it sets the function pointer to 0x08017c1d when I would want it to be 0x08014000.
Not sure why it sets it incorrectly though.
2024-08-08 04:16 AM
Hard pressed to believe it's not actually jumping.
I wouldn't put the address in a local and change the stack, but it should branch some place. Instrument better so you have visibility as to what happens and sanity check the pointers and values.
On the application side, make sure SystemInit sets the right address into VTOR.
Do something early in Reset_Handler so you can confirm arrival there.
2024-08-08 04:18 AM
0x8014000 is an address of a table, not executable code.
You want to be jumping to Reset_Handler on the application side. Check address via .MAP file output by Linker
2024-08-08 06:47 AM
See example jump to bootloader code here:
How to jump to system bootloader from application ... - STMicroelectronics Community
In particular note this line:
> SysMemBootJump = (void (*)(void)) (*((uint32_t *) ((BootAddr[MCU] + 4))));
What happens when you debug and step through? Should be straightforward to diagnose.
Could also be due to not disabling interrupts so one gets triggered when __enable_irq happens but now the vector table is wrong.