title: STM32F103 Cannot jump to bootloader from app
body: <p>I'd like to do a jump to bootloader from application on STM32 Blue Pill STM32F103C8T6.
  My approach looks that:
  - Write to BKP->DR1 any value;
  - Do a reset (NVIC_SystemReset());
  - A the beginning of main, check if BKP->DR1 != 0, than set it to 0 and jump to boot;</p>
  
  <p>Dubugging shows, that core jumps far away (0xfffffffe) and nothing happens.
  My code:</p>
  
  <pre><code>/*
   * bootloader.c
   *
   *  Created on: 28.03.2020
   *      Author: Admin
   */
  
  #include "stm32f10x.h"
  #include "../Logger/logger.h"
  #include "core_cm3.h"
  
  #define ADDR 0x1FFFF000
  
  void (*f_boot_jump)();
  
  void boot_jump_to_boot ()
  {
  
      f_boot_jump = (void (*)(void)) (*((uint32_t *)(ADDR + 4)));
      __disable_irq();
      __DSB();
      SCB-&gt;VTOR = (uint32_t) ADDR;
      __DSB();
      __ISB();
      __set_MSP(*(__IO uint32_t*) ADDR);
      f_boot_jump();
  
  }
  
  void boot_init()
  {
      RCC-&gt;APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN;
      PWR-&gt;CR |= PWR_CR_DBP;
  
      if (BKP-&gt;DR1 != 0) //DR != 0 means, that boot request has been sent
      {
          BKP-&gt;DR1 = 0;
          RCC-&gt;APB1ENR &amp;= ~RCC_APB1ENR_PWREN;
          RCC-&gt;APB1ENR &amp;= ~RCC_APB1ENR_BKPEN;
          PWR-&gt;CR &amp;= ~PWR_CR_DBP;
          RCC-&gt;CFGR &amp;= ~RCC_CFGR_SW;
          RCC-&gt;CR &amp;= ~RCC_CR_PLLON;
          RCC-&gt;CR &amp;= ~RCC_CR_HSEON;
          boot_jump_to_boot();
      }
  
  }
  
  void boot_write_boot_request()
  {
      BKP-&gt;DR1 = 0x1;
      NVIC_SystemReset();
  }
  </code></pre>
  
  <p>SS from IDE:
  <a href="https://i.stack.imgur.com/2RuiN.png" rel="nofollow noreferrer">memory</a>
  <a href="https://i.stack.imgur.com/oATcO.png" rel="nofollow noreferrer">registers</a></p>
  
  <p>I have no idea why it does not work.
  More over, before jump memory in the area of 0x1FFFF000 looks ok:
  <a href="https://i.stack.imgur.com/DBktS.png" rel="nofollow noreferrer">Before jump</a></p>
  
  <p>and here is after failing jump to boot:
  <a href="https://i.stack.imgur.com/jicq8.png" rel="nofollow noreferrer">after jump</a>
  Maybe my chip is fake? ST Utility shows correct values (Device ID, flash size, MediumDensity), but it can means nothing.
  When I'm using the BOOT pins, the bootloader is loaded properly and STM flashloader recognize it.
  Even if my chip is a fake, the embedded bootloader works so I can't figure out the reason, why jump from application does not work.</p>