Skip to content

Commit

Permalink
stm32: Remove bootloader entry protocol based on BKP registers. Not u…
Browse files Browse the repository at this point in the history
…sed.
  • Loading branch information
keirf committed Nov 3, 2019
1 parent fa88a2d commit 5898b04
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
1 change: 0 additions & 1 deletion inc/stm32f10x.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ extern uint32_t vector_table[];

/* System */
void stm32_init(void);
void stm32_bootloader_enter(void);
void system_reset(void);

/* Clocks */
Expand Down
36 changes: 0 additions & 36 deletions src/stm32f10x.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,6 @@ void EXC_unexpected(struct extra_exception_frame *extra)
system_reset();
}

static void bootloader_maybe_enter(void)
{
static void (* const system_bootloader)(void) = (void *)0x1ffff001;
bool_t bootloader_enter;

/* Power up the backup-register interface and allow writes. */
rcc->apb1enr |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN;
pwr->cr |= PWR_CR_DBP;

/* Has bootloader been requested via magic numbers in the backup regs? */
bootloader_enter = ((bkp->dr1[0] == 0xdead) && (bkp->dr1[1] == 0xbeef));

/* Clean up backup registers and peripheral clocks. */
bkp->dr1[0] = bkp->dr1[1] = 0;
rcc->apb1enr = 0;

/* Jump to the bootloader if requested. */
if (bootloader_enter)
(*system_bootloader)();
}

static void exception_init(void)
{
/* Initialise and switch to Process SP. Explicit asm as must be
Expand Down Expand Up @@ -160,27 +139,12 @@ static void peripheral_init(void)

void stm32_init(void)
{
bootloader_maybe_enter();
exception_init();
clock_init();
peripheral_init();
cpu_sync();
}

void stm32_bootloader_enter(void)
{
/* Power up the backup-register interface and allow writes. */
rcc->apb1enr |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN;
pwr->cr |= PWR_CR_DBP;

/* Indicate to early startup that we want system bootloader. */
bkp->dr1[0] = 0xdead;
bkp->dr1[1] = 0xbeef;

/* Reset everything (except backup registers). */
system_reset();
}

static void fpec_wait_and_clear(void)
{
while (flash->sr & FLASH_SR_BSY)
Expand Down

0 comments on commit 5898b04

Please sign in to comment.