apache / mynewt-core

An OS to build, deploy and securely manage billions of devices
https://mynewt.apache.org/
Apache License 2.0
825 stars 369 forks source link

Fatfs + mynewt_glue + mmc issue if we write data addressed above 4GB in memory #1995

Open FabienLep opened 5 years ago

FabienLep commented 5 years ago

Hi, I've been doing some tests writing (a lot of) data to an SD card using mynewt_glue.c. I found a bug the corrupts the entire FS if we cross the 4GB addressing space. The issue: in mynewt_glue.c:

One solution would be to change mmc_write() and mmc_read() to expect a 64bits address (and change mynewt_glue accordingly). Or to just remove this addr*512 and addr/512 parts (which is not very optimized...)

I can do the modifications myself and PR as soon as we agree on which way to fix this issue. Thanks!

utzig commented 5 years ago

One solution would be to change mmc_write() and mmc_read() to expect a 64bits address (and change mynewt_glue accordingly).

That would be a correct change I think. It would also need to change the interfaces in fs/disk and possibly other places.

Or to just remove this addr*512 and addr/512 parts

This would assume that MMC and FAT are glued, while the idea is to have separation, because we might want to use other FS (eg NFFS) on a MMC card.

I can do the modifications myself and PR as soon as we agree on which way to fix this issue.

I'll think a bit more about it and can suggest changes later.