-
-
Notifications
You must be signed in to change notification settings - Fork 40.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EEPROM: Don't erase if we don't have to. Adding eeprom_driver_format abstraction. #18332
EEPROM: Don't erase if we don't have to. Adding eeprom_driver_format abstraction. #18332
Conversation
Optionally, I could remove the (bool erase) argument, and make eeprom_driver_format() always do the absolute minimum necessary. If the user wants to erase the content, then they can always call eeprom_driver_erase(), which doesn't (currently) require _format() to be called before it. |
Thank you for your contribution! |
Thank you for your contribution! |
d18f222
to
0ca6208
Compare
I have rebased, I fixed the conflicts, and I updated the commit message to better reflect new names. Please remove the stale label, and please review. |
…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
0ca6208
to
a51882c
Compare
After some internal discussion, we're moving this to a 2024q2 merge candidate, with an intention to merge into |
Thank you for your contribution! |
Description
Make eeprom driver behaviour more uniform. Adding eeprom_driver_format 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:
In particular this results in speed improvements when using STM32L0, i2c, and spi EEPROMs
Types of Changes
Issues Fixed or Closed by This PR
Checklist