Skip to main content
Visitor II
October 22, 2020
Question

How to jump to bootloader from application on STM32F103

  • October 22, 2020
  • 2 replies
  • 911 views

Hi there,

I'm trying to jump from my application to the bootloader on a STM32F103.

The bootloader address is 0x1FFFF000

This is my code, but unfortunately, it doesn't work:

void (*f_boot_jump)();

f_boot_jump = (void (*)(void)) (*((uint32_t *)(0x1FFFF000 + 4)));

HAL_RCC_DeInit();

SysTick->CTRL = 0;

SysTick->LOAD = 0;

SysTick->VAL = 0;

__disable_irq();

__DSB();

SCB->VTOR = (uint32_t) 0x1FFFF000;

__DSB();

__ISB();

__set_MSP(*(__IO uint32_t*) 0x1FFFF000);

f_boot_jump();

I tried some variations of this code, but they didn't work either.

There is one code that I found using the function:

__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();

But the compiler says "undefined reference" to this function.

Any ideas? Thanks for your help!

    This topic has been closed for replies.

    2 replies

    Graduate II
    October 22, 2020

    You can't remap the zero page memory on the F1.

    Who reenables the interrupts you disable?​

    Use the debugger, step the code, see where it goes..​

    MarkobarAuthor
    Visitor II
    October 22, 2020

    I made some progress. Following clive1 advice, I used the debugger:

    Setting a breakpoint just before the f_boot_jump() function and then resuming the execution, it works!

    But running the program with no breakpoint (even in debug session), it doesn't work.

    I tried adding some __NOP() functions, but it doesn't help. I'm close, but I still don't know what the problem is.