Skip to content
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

Erasing all items #47

Open
ryan-summers opened this issue Apr 22, 2024 · 4 comments · May be fixed by #49
Open

Erasing all items #47

ryan-summers opened this issue Apr 22, 2024 · 4 comments · May be fixed by #49

Comments

@ryan-summers
Copy link
Contributor

ryan-summers commented Apr 22, 2024

Currently, there's a remove_item() API, but there's no way to clear out the entire flash buffer without worrying about the key.

One can do this by erasing the whole range that was given to sequential-storage blindly, but this is often overkill and can be much more flash than actually needs erasing, which can result in unnecessarily long erase times.

As an example, in Stabilizer, we use the second flash bank (1MB) to store our settings, but the settngs themselves are less than a handful of bytes each. The resulting bank erase takes several seconds (~10 or so), when in reality it could likely be done much more quickly.

It seems like it would be a desirable to have a function like remove_all_items(f: &mut Flash, range: Range<u32>) that scans through the range for all sequential-storage items and erases only the flash memory that contains sequential-storage items.

Thoughts?


This came up in quartiq/stabilizer#884 (comment) while discussing a firmware change for reference.

@diondokter
Copy link
Collaborator

Ah yeah, I feel like this can be done! Should be the same as the current remove function but without the key check.
It still wouldn't be fast, but perhaps faster. And for internal flash it wouldn't lock up.

Good idea! I think I can work on this a bit later this week. But feel free to drop a PR if you feel sufficiently self-nerd-sniped :P

@ryan-summers
Copy link
Contributor Author

I'll take a look at implementing this over the next day or two and submit a PR :)

@jordens
Copy link

jordens commented Apr 22, 2024

erases only the flash memory that contains sequential-storage items

Shouldn't it use its own "overwriting" key-invalidation mechanism instead? I feel like it should only ever need to page-erase when running out of space during store.

@diondokter
Copy link
Collaborator

diondokter commented Apr 22, 2024

erases only the flash memory that contains sequential-storage items

Shouldn't it use its own "overwriting" key-invalidation mechanism instead? I feel like it should only ever need to page-erase when running out of space during store.

Yes, that's what the remove function does. It 'erases' the items by setting the CRC field to 0. No actual erases are done.

@ryan-summers ryan-summers linked a pull request Apr 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants