GD32 flash workaround

Addressing #181

At least some GD32 devices seem to require unlocking the flash twice. As the unlock function exits with `HAL_OK` if the flash is already unlocked, STM32 devices can run the same code without issues.
This commit is contained in:
M-Byte 2022-06-08 09:42:54 +02:00
parent b718295423
commit c6cd49d913

View File

@ -60,6 +60,11 @@ void Stm32Platform::commitToEeprom()
return;
for (uint16_t i = 0; i < _eepromSize; ++i)
eeprom_buffered_write_byte(i, _eepromPtr[i]);
// For some GD32 chips, the flash needs to be unlocked twice
// and the first call will fail. If the first call is
// successful, the second one (inside eeprom_buffer_flush)
// does nothing.
HAL_FLASH_Unlock();
eeprom_buffer_flush();
}