Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make eeprom driver behaviour more uniform. Adding eeprom_driver_forma…
…t abstraction. Before this change, we used to call epprom_driver_erase(), if we detected that the eeprom content did not have the necessary magic number, but only of it was implemented as an "eeprom_driver". This is sometimes necessary, and sometimes not. We used to make the decision based on whether the eeprom_driver_erase() function has been implemented or not, but that is not really the best way to decide. Erase in necessary for example when eeprom emulation/wear leveling is in use. This is because the actual backing store also contains metadata that needs to start out in a clean state. It is not necessary to erase I2C and SPI EEPROMs before use, however we used to do it. The new eeprom_driver_format(erase=false) call will allow each eeprom driver to decide what is the minimum amount of initialization/erasure that must be done to make the eeprom usable. This also leaves open the door for future optimizations for eeprom emulation/wear leveling drivers to only erase a subset of the backing store. eeprom_driver_format(erase=true) will also make sure that the content of the eeprom is erased. This change replaces calls from eeconfig to eeprom_driver_erase() to eeprom_driver_format(). As a result the following behavioral changes will happen: |Platform | Behavioral Change (if no magic number is found in EEPROM) | |----------------------------------------------------|------------------------------------------------------------------------------------------------| |EEPROM_DRIVER=custom | No Change (Always Erase, in case eeprom_driver_format is not implemented by the custom driver) | |EEPROM_DRIVER=wear_leveling | No Change (Always Erase) | |EEPROM_DRIVER=i2c | Erase -> Don't Erase | |EEPROM_DRIVER=spi | Erase -> Don't Erase | |EEPROM_DRIVER=legacy_stm32_flash | Doesn't work, references inexistent file. If corrected, then No Change -> (Always Erase) | |EEPROM_DRIVER=transient | Erase -> Don't Erase (Not necessary to erase because the backing store is in the .bss section) | |EEPROM_DRIVER=vendor (AVR) | No Change (Don't erase) | |EEPROM_DRIVER=vendor (STM32 072xB 042x6 - legacy) | No Change (Always Erase) | |EEPROM_DRIVER=vendor (STM32 using wear_leveling) | No Change (Always Erase) (same as EEPROM_DRIVER=wear_leveling) | |EEPROM_DRIVER=vendor (STM32_L0_L1 true eeprom) | Erase -> Don't Erase | |EEPROM_DRIVER=vendor (RP2040) | No Change (Always Erase) (same as EEPROM_DRIVER=wear_leveling) | |EEPROM_DRIVER=vendor (Kinetis Flexram (KL2x, K20x)) | No Change (EEPROM_DRIVER macro is not defined) | |EEPROM_DRIVER=vendor (other chibios=transient) | Erase -> Don't Erase (Not necessary to erase because the backing store is in the .bss section) | |EEPROM_DRIVER=vendor (ARM_ATSAM) | No Change (EEPROM_DRIVER macro is not defined) | In particular this results in speed improvements when using STM32L0, i2c, and spi EEPROMs
- Loading branch information