tweedegolf / sequential-storage

A crate for storing data in flash memory with minimal need for erasing pages
Apache License 2.0
97 stars 9 forks source link

`store_item<>` caused an internal panic #8

Closed ryan-summers closed 9 months ago

ryan-summers commented 9 months ago

When attempting to call store_item<>, I got an internal panic due to indexing in sequential-storage:

panicked at C:\Users\rsummers\.cargo\registry\src\index.crates.io-6f17d22bba15001f\sequential-storage-0.5.0\src\lib.rs:159:20:
range end index 32 out of range for slice of length 16

For reference, the calling FlashSettings::save() is what's doing this in the following PR https://github.com/quartiq/stabilizer/pull/811

ryan-summers commented 9 months ago

It looks like sequential-storage is using an internal buffer of 16-bytes, but my flash chip as a write size of 32-bytes.

I think the fix is to size the buffer based on S::WRITE_SIZE instead of 16 bytes

diondokter commented 9 months ago

Ah! Ok, yeah that's annoying. I thought 16 bytes was a decent upper limit. I guess STM does indeed use 256-bit words. Annoying. I'll up it for the next release.

diondokter commented 9 months ago

Closed by #9