Skip to content

Commit

Permalink
stm32f4: Fixes erase_mass command return error.
Browse files Browse the repository at this point in the history
The final erase_mass command check is looking for the EOP (End of
OPeration) bit to be set. This bit is only set when the EOP interrupts
(EOPIE = 1) are enabled. We are not enabling those on the target so this
bit will never get set. As we are monitoring the BSY flag to make sure
the erase_mass operation is still ongoing and finished it is enough if
we just check the error flags.
  • Loading branch information
esden committed Jul 14, 2022
1 parent 34696c0 commit 1cf1ba1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/target/stm32f4.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int stm32f4_flash_erase(struct target_flash *f, target_addr addr,
static int stm32f4_flash_write(struct target_flash *f,
target_addr dest, const void *src, size_t len);

/* Flash Program ad Erase Controller Register Map */
/* Flash Program and Erase Controller Register Map */
#define FPEC_BASE 0x40023C00
#define FLASH_ACR (FPEC_BASE+0x00)
#define FLASH_KEYR (FPEC_BASE+0x04)
Expand Down Expand Up @@ -503,11 +503,8 @@ static bool stm32f4_cmd_erase_mass(target *t, int argc, const char **argv)
tc_printf(t, "\n");

/* Check for error */
uint32_t sr = target_mem_read32(t, FLASH_SR);
if ((sr & SR_ERROR_MASK) || !(sr & SR_EOP))
return false;

return true;
const uint32_t result = target_mem_read32(t, FLASH_SR);
return !(result & SR_ERROR_MASK);
}

/* Dev | DOC |Rev|ID |OPTCR |OPTCR |OPTCR1 |OPTCR1 | OPTCR2
Expand Down

0 comments on commit 1cf1ba1

Please sign in to comment.