Skip to content

Instantly share code, notes, and snippets.

@sidprice
Created April 9, 2018 21:22
Show Gist options
  • Save sidprice/a0bb92305d16e498d12671bc82e50c91 to your computer and use it in GitHub Desktop.
Save sidprice/a0bb92305d16e498d12671bc82e50c91 to your computer and use it in GitHub Desktop.
void (*SysMemBootJump)(void);
volatile uint32_t addr = 0x1FFF0000;
/* Jump to the built in bootloader by mapping System flash */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_SYSCFGEN);
SYSCFG_MEMRM &= ~3;
SYSCFG_MEMRM |= 1;
/*
set the jump address
*/
SysMemBootJump = (void (*)(void)) (*((uint32_t *) (addr + 4)));
/*
set up the stack for the bootloader
*/
asm ("ldr sp, =addr");
/*
Jump ...
*/
SysMemBootJump ();
while ( 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment