cancel
Showing results for 
Search instead for 
Did you mean: 

Custom bootloader jump to application in STM32H7A3

lbapplem
Associate II

hello,

     I use STM32CubeIDE 1.16.0 and working on a custom bootloader to jump to application at address 0x08100000, here're the jump code below:

    

void jump_to_application(uint32_t flash_address)

 

{

 

void (*app_reset_handler)(void);

 

uint32_t main_stack_pointer_value = *(volatile uint32_t *)flash_address;

 

__HAL_RCC_GPIOC_CLK_DISABLE();

__HAL_RCC_GPIOD_CLK_DISABLE();

__HAL_RCC_GPIOB_CLK_DISABLE();

__HAL_RCC_GPIOA_CLK_DISABLE();

HAL_RCC_DeInit();

HAL_DeInit();

SysTick->CTRL = 0;

SysTick->LOAD = 0;

SysTick->VAL = 0;

 

/**

* Step: Disable all interrupts

*/

__disable_irq();

 

__set_MSP(main_stack_pointer_value);

 

uint32_t reset_handler = *(volatile uint32_t *)(flash_address + 4);

 

app_reset_handler = (void*) reset_handler;

 

app_reset_handler();

 

}

And I change the ld file of application:

MEMORY

{

ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K

FLASH (rx) : ORIGIN = 0x08100000, LENGTH = 2048K

DTCMRAM1 (xrw) : ORIGIN = 0x20000000, LENGTH = 64K

DTCMRAM2 (xrw) : ORIGIN = 0x20010000, LENGTH = 64K

RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 1024K

RAM_CD (xrw) : ORIGIN = 0x30000000, LENGTH = 128K

RAM_SRD (xrw) : ORIGIN = 0x38000000, LENGTH = 32K

}

And in application, it'll start up with turning on 3 LEDs, each delay by using HAL_Delay(100) like

below:

HAL_GPIO_TogglePin(LED1_GPIO_PORT, LED1_PIN);
HAL_Delay(100);
printf("LED1 on, Delay trail\n");
// HAL_GPIO_TogglePin(LED2_GPIO_PORT, LED2_PIN);
HAL_Delay(100);
printf("LED2 on, Delay trail\n");
// HAL_GPIO_TogglePin(LED3_GPIO_PORT, LED3_PIN);
HAL_Delay(100);

but I found after jumping to application, only LED1 is turned on, seems stuck in HAL_Delay(if remove HAL_Delay, all LEDs will turn on), can you help me to check if the jump_to_application() is correct? What else do I need to do in application?

Thank you very much!

Bill

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

seems stuck in HAL_Delay(if remove HAL_Delay

Do not forget to assign the vector table base register (VTOR). It must point to the vector table in the app. Align it properly (0x400 for H7)

View solution in original post

4 REPLIES 4
Pavel A.
Evangelist III

seems stuck in HAL_Delay(if remove HAL_Delay

Do not forget to assign the vector table base register (VTOR). It must point to the vector table in the app. Align it properly (0x400 for H7)

Imen.D
ST Employee

Hello @lbapplem ,

Try configuring the VTOR register as recommended by @Pavel A. 

Please have a look at these FAQs, which may be helpful for you:

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
SirineST
ST Employee

Hello @lbapplem,

It is clear that you have disabled the systick in jump_to_application() function, so, automatically HAL_Delay() will not work, could you please try to re-enable the systick by adding HAL_Init() at the beginning of your application. 

With regards

If your question is answered, please close this topic by clicking "Accept as Solution"

hi,Pavel:

    Thanks, issue resolved.

Bill