diff options
author | xyzz <1065521+xyzz@users.noreply.github.com> | 2021-08-02 00:27:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-02 14:27:57 +1000 |
commit | 720c676403660eacb880528f04a5c1d328b84650 (patch) | |
tree | 6beb1e84a7d91ecf2e634209cfb3eb0aff41b010 /tmk_core/common | |
parent | 4b630c46fed48f8a82641438029b628ec0dd5150 (diff) | |
download | qmk_firmware-720c676403660eacb880528f04a5c1d328b84650.tar.gz qmk_firmware-720c676403660eacb880528f04a5c1d328b84650.zip |
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.
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/chibios/flash_stm32.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tmk_core/common/chibios/flash_stm32.c b/tmk_core/common/chibios/flash_stm32.c index e8b3dc4bc..66f2b1376 100644 --- a/tmk_core/common/chibios/flash_stm32.c +++ b/tmk_core/common/chibios/flash_stm32.c | |||
@@ -161,9 +161,11 @@ FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) { | |||
161 | * @retval None | 161 | * @retval None |
162 | */ | 162 | */ |
163 | void FLASH_Unlock(void) { | 163 | void FLASH_Unlock(void) { |
164 | /* Authorize the FPEC Access */ | 164 | if (FLASH->CR & FLASH_CR_LOCK) { |
165 | FLASH->KEYR = FLASH_KEY1; | 165 | /* Authorize the FPEC Access */ |
166 | FLASH->KEYR = FLASH_KEY2; | 166 | FLASH->KEYR = FLASH_KEY1; |
167 | FLASH->KEYR = FLASH_KEY2; | ||
168 | } | ||
167 | } | 169 | } |
168 | 170 | ||
169 | /** | 171 | /** |