Skip to content

Commit

Permalink
flash_loader: preventing unpredictable behavior when disabling interr…
Browse files Browse the repository at this point in the history
…upts
  • Loading branch information
Ant-ON committed Mar 19, 2021
1 parent 76f1530 commit bc9062c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2731,7 +2731,11 @@ int stm32l1_write_half_pages(

int stlink_flashloader_start(stlink_t *sl, flash_loader_t *fl) {

// force halt and disable interrupt
// According to DDI0419C, Table C1-7 firstly force halt
stlink_write_debug32(sl, STLINK_REG_DHCSR, STLINK_REG_DHCSR_DBGKEY |
STLINK_REG_DHCSR_C_DEBUGEN |
STLINK_REG_DHCSR_C_HALT);
// and only then disable interrupts
stlink_write_debug32(sl, STLINK_REG_DHCSR, STLINK_REG_DHCSR_DBGKEY |
STLINK_REG_DHCSR_C_DEBUGEN |
STLINK_REG_DHCSR_C_HALT |
Expand Down

0 comments on commit bc9062c

Please sign in to comment.