-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
esp32: make use of wear levelling from IDF #4999
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
esp32: make use of wear levelling from IDF #4999
Conversation
This is a rework of loboris' wear leveling patch micropython/micropython-esp32#126 Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
May conflict with #4987 |
@@ -26,9 +27,8 @@ def ioctl(self, op, arg): | |||
return self.SEC_SIZE | |||
|
|||
size = esp.flash_size() | |||
if size < 1024*1024: | |||
if size < 512*1024: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you including the wear level size here? I'm not sure I see that.
#3576 (comment)
https://www.esp32.com/viewtopic.php?t=1897
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uhm... not really sure... but I guess this should be the minimum partition size, so this should be 528k... have to check this again, to be really sure
Thanks for the contribution. But I guess this will no longer work if #5027 is merged. Because that patch removes calls to the Do you know how to make wear levelling work with the IDF partition interface? |
I see that |
Actually, looking at the high level API, https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/storage/wear-levelling.html#high-level-api-reference, it seems this is very much supported. Should be able to implement wear levelling as a Partition object that uses the high level API provided here as a middleware. Edit: WL doesn't explicitly mention anything about Flash Encryption. Its my assumption that it would be handled transparently if the partition table for a fatfs partition was tagged with Last thought: It would be my preference that wear levelling just works and just happens whenever a read/write partition is mounted. |
Yes, a partition must be "mounted as wearlevel partition".
The problem here is that we DO NOT use the highlevel API / espressif's vfs but instead build on our own fatfs and vfs implementation. This means no, we can not use that. The partitions must be mounted explicitely through the mid level API (wl*). @dpgeorge's code uses
Wear levelling is completely transparent, as is encryption. You can mount an unencrypted or an encrypted partition as wearlevelling partition: spi flash <- partition (encrypted or unencrypted) <- wear levelling <- <mapped blocks / partition> <- filesystem
This is NOT possible with wear levelling currently as esptool writes directly to flash. You must create a wear levelling partition image and flash that. There's a tool for this: https://github.com/TobleMiner/mk_esp32fat
The right way would be dropping our own vfs and fatfs and instead build on espressif's vfs and fatfs which both natively support encryption and wear levelling. This would even make it possible to easily use spiffs or anything else that is getting added to esp-idf in later versions. |
Thanks for taking the time to write up the detailed reply, clears a lot of thoughts. 👍 |
#5027 (use of Partition class as the FS block device) was merged in 31de447, so this PR would need to be reworked against that.
I understand the sentiments here, but the idea is that MicroPython is consistent across many different ports/boards/architectures/SoCs/MCUs/etc and so in that light it's important to use the MicroPython-supplied VFS (eg then you can mount custom filesystems the same way on all ports). Well, it may be possible to merge both worlds by using the |
ESP32S2: Fix PWM timer leak and variable frequency conflicts
This is a rework of loboris' wear leveling patch
micropython/micropython-esp32#126
Signed-off-by: Michael Niewöhner foss@mniewoehner.de
Tested and running productive on my device