stm32l0/stm32lx_nvm_busy_wait: Check for errors only after busy is released.

While busy, EOP(end of operation) is not yet set. But check for communication errors.
This commit is contained in:
Uwe Bonnes 2022-09-03 11:04:14 +02:00 committed by Rachel Mant
parent c0b7d4e2c4
commit 2922539772
1 changed files with 2 additions and 3 deletions

View File

@ -326,11 +326,10 @@ static bool stm32lx_nvm_busy_wait(target *t, uint32_t nvm)
uint32_t sr;
do {
sr = target_mem_read32(t, STM32Lx_NVM_SR(nvm));
if ((sr & STM32Lx_NVM_SR_ERR_M) || !(sr & STM32Lx_NVM_SR_EOP) || target_check_error(t))
if (target_check_error(t)) /* Check for communication errors */
return false;
} while (sr & STM32Lx_NVM_SR_BSY);
return true;
return (!((sr & STM32Lx_NVM_SR_ERR_M) || !(sr & STM32Lx_NVM_SR_EOP)));
}
/** Erase a region of program flash using operations through the debug