democloid / picoTracker

BSD 3-Clause "New" or "Revised" License
187 stars 17 forks source link

use a filessystem for onboard flash #171

Open maks opened 3 months ago

maks commented 3 months ago

While its convenient to use the onboard flash via its memory mapping as he code currently does, if instead we used a filesystem, this would make it more convenient to add features such as storing project data there as well as samples, allowing for instant loading of last project state and I think allow for writing to flash even during playback.

But most importantly it will help with preserving the health of the flash by doing wear leveling.

This is what the LittleFS docs have to say on the subject:

Wear leveling - Writing to flash is destructive. If a filesystem repeatedly writes to the same block, eventually that block will wear out. Filesystems that don't take wear into account can easily burn through blocks used to store frequently updated metadata and cause a device's early death.

So I would suggest looking to use LittleFS for this, though there are several other small filesystem implementations that are intended for this kind of use as well.

Using a FS will introduce some overhead, but it should still be fast enough for sample playback, though this will require moving to using streaming playback for all sample playback instead of current in-memory playback. On the flipside, this would be the preliminary work required to eventually implement (if possible) SDcard audio sample streaming.