Skip to content

Conversation

reitermarkus
Copy link
Contributor

Add SDMMC support, including implementations for embedded_sdmmc as well as fatfs.

src/sdmmc.rs Outdated
Comment on lines 955 to 958
let mut block = [0; 512];
self.sdmmc.read_block(addr, &mut block)?;
buf[0..len].copy_from_slice(&block[offset..(offset + len)]);
self.pos += len as u64;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reitermarkus i wonder.. are reads and writes always going to be within a single block? or.. do you need to allow for reads across block boundaries and reads are longer than 512?

It looks like the [fscommon::BufStream[(https://github.com/rafalh/rust-fscommon/blob/89706258032efff88689f6083510ed34b845fe46/src/buf_stream.rs#L97-L109) impl expects that the reads/writes might exceed the block size (512)..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for read it's guaranteed since we can choose freely how much to read and return the read size. The caller has to ensure to read again if it's not enough, which is why the default implementation of read_exact is implemented as a loop over read.

For read_exact on the other hand we would have to ensure we read across boundaries since read_exact only succeeds when the given buffer is filled completely.

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 this pull request may close these issues.

2 participants