STM32 write flash and jump to address

I'm moving my bootloader for STM32 from C to Rust.

  1. How to write to the stm32f1 flash on Rust? That's easy on C using FLASH_Unlock()->FLASH_ErasePage()->FLASH_ProgramHalfWord()->FLASH_Lock(); but i didn't find similar on Rust.

  2. How to jump from app of bootloaader to the main app? Example of C:

typedef  void (*pFunction)(void);
pFunction Jump_To_Application;
uint32_t JumpAddress;

JumpAddress = *(uint32_t*) (APPLICATION_BEGIN + 4);
Jump_To_Application = (pFunction) JumpAddress;
//	Initialize user application's Stack Pointer
__set_MSP(*(vu32*) APPLICATION_BEGIN);
  1. How to set location of constant static variable if FLASH?
struct DeviceInfo{
 v1: u8,
 v2: u32,

static const device_info: DeviceInfo... // how to set location?

What crates are you using? What have you tried so far? Please give us some information to work with.

If you are using the stm32f1 crate, you can get the FLASH peripheral and do the same as in c.

Jumping to a certain address should be fairly easy as well, just transmute an address to a extern "C" fn() and you should be good to go:

fn jump_to_main() {
    let addr = 0x8000;
    unsafe {
        (std::mem::transmute::<_, extern "C" fn()>(addr))();