cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U575QII6 custom bootloader not jumping to my program

joeSD
Associate III

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!

6 REPLIES 6
korek1222
Associate

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();

 

 

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. 

korek1222
Associate

#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

 

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.

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.

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

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

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