flash_stm32: don't unlock flash if already unlocked (#13841)
On stm32f4 after reboot from DFU it was observed that the flash is already unlocked. In that case, attempting to unlock it again causes a data abort.master
parent
4b630c46fe
commit
720c676403
|
@ -161,10 +161,12 @@ FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) {
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void FLASH_Unlock(void) {
|
void FLASH_Unlock(void) {
|
||||||
|
if (FLASH->CR & FLASH_CR_LOCK) {
|
||||||
/* Authorize the FPEC Access */
|
/* Authorize the FPEC Access */
|
||||||
FLASH->KEYR = FLASH_KEY1;
|
FLASH->KEYR = FLASH_KEY1;
|
||||||
FLASH->KEYR = FLASH_KEY2;
|
FLASH->KEYR = FLASH_KEY2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Locks the FLASH Program Erase Controller.
|
* @brief Locks the FLASH Program Erase Controller.
|
||||||
|
|
Loading…
Reference in New Issue