cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Bootloader - Not able to jump on the specific location on flash

shubmane
Associate

Hi team,

We are working on the custom bootloader on stm32u073RC. not able to jump on the specific location.

#define APPLICATION_PARTITION_1     0x0801D000


void jump_to_application_partition_1(void)
{
    /* Disable Interrupts */
    __disable_irq();

    /* Get the stack pointer and reset vector from the backup application section */
    uint32_t app_stack_pointer_1 = *(volatile uint32_t *) APPLICATION_PARTITION_1;
    uint32_t app_reset_vector_1 = *(volatile uint32_t *) (APPLICATION_PARTITION_1 + 4);

    /* Mapping of the backup application reset vector */
    pfunction app_entry_1 = (pfunction) app_reset_vector_1;

    /* Setting of the vector table to backup application */
    SCB->VTOR = APPLICATION_PARTITION_1;

    /* Setting MSP - (Main Stack Pointer) */
    __set_MSP(app_stack_pointer_1);

    /* Enable Interrupts */
    __enable_irq();

    /* Jump to backup application */
    app_entry_1();
}

 Thanks,

Shubham

3 REPLIES 3
shubmane
Associate

No source available for "__udivmoddi4() at 0x80003ce"

shubmane_2-1749116128052.png

 

 

TDK
Super User

Step through the code, what happens after the call to app_entry_1?

It would be better to disable interrupts as in the example code.

How to jump to system bootloader from application ... - STMicroelectronics Community

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Super User

Your variables app_stack_pointer_1, app_reset_vector_1, app_entry_1 may be located on the stack.

Line 20 (__set_MSP) moves the stack pointer. What do you think happens to the variables on the stack?