~ruther/qmk_firmware

720c676403660eacb880528f04a5c1d328b84650 — xyzz 4 years ago 4b630c4
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.
1 files changed, 5 insertions(+), 3 deletions(-)

M tmk_core/common/chibios/flash_stm32.c
M tmk_core/common/chibios/flash_stm32.c => tmk_core/common/chibios/flash_stm32.c +5 -3
@@ 161,9 161,11 @@ FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) {
 * @retval None
 */
void FLASH_Unlock(void) {
    /* Authorize the FPEC Access */
    FLASH->KEYR = FLASH_KEY1;
    FLASH->KEYR = FLASH_KEY2;
    if (FLASH->CR & FLASH_CR_LOCK) {
        /* Authorize the FPEC Access */
        FLASH->KEYR = FLASH_KEY1;
        FLASH->KEYR = FLASH_KEY2;
    }
}

/**