Open Oakchris1955 opened 5 months ago
This is intended behavior. Implementation assumes IO has some kind of buffering and allows reading/writing arbitrary number of bytes at unaligned addresses.
In your case it probably makes sense to add a buffer that has size of exactly one sector to your Flash
struct and use it in Read
and Write
trait implementations. You can take https://github.com/rafalh/rust-fscommon/blob/master/src/buf_stream.rs as example although it doesn't seem to care about address alignment.
This is intended behavior.
In that case, shouldn't this behavior be documented somewhere in the docs, especially considering that this is the only FATFS library in crates.io
?
I have written a
Flash
struct that implements theRead
,Write
andRead
traits for the Raspberry Pico's flash memory. I am trying to format the volume usingfatfs::format_volume
with the following options:and after a while, my
write
function returns an error that "The cursor is not aligned to SECTOR_SIZE" (that error type is mine). Furthermore, it seems like this specific error occurs after the library zeroes a bunch of memory at the beginning of the flash, when it tries to write the buffer[255, 255]
to the address4097
, just 1 byte off from the start of the 2nd sector.Additional info
alloc
feature, but that doesn't seem to change the program's behaviourCode