summaryrefslogtreecommitdiff
path: root/lib/oofatfs/ff.c
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2019-11-29 08:15:29 -0600
committerJeff Epler <jepler@gmail.com>2019-12-10 14:03:06 -0600
commita484a93b290806d01850e58905d65bc798b4cd91 (patch)
tree277620af379cd80264d740bd89fa50bae7c1367f /lib/oofatfs/ff.c
parent387ab6c87eac8481934a7ffc4a96395fe5f34747 (diff)
nRF: disk_read must be 4-byte aligned
.. a requirement that oofatfs needs to be taught to respect. This problem can be demonstrated with the following snippet, except that the related file ("test.bin") must also be contiguous on the filesystem. You can ensure this by reformatting your device's filesystem before testing, then copying any single file bigger than 4kB to test.bin. f = open("test.bin", "rb") f.seek(2048) b = bytearray(2048) v = memoryview(b) f.readinto(v[909:]) Closes: #2332
Diffstat (limited to 'lib/oofatfs/ff.c')
-rw-r--r--lib/oofatfs/ff.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/oofatfs/ff.c b/lib/oofatfs/ff.c
index b0984756b..71bd19702 100644
--- a/lib/oofatfs/ff.c
+++ b/lib/oofatfs/ff.c
@@ -3382,7 +3382,11 @@ FRESULT f_read (
if (!sect) ABORT(fs, FR_INT_ERR);
sect += csect;
cc = btr / SS(fs); /* When remaining bytes >= sector size, */
- if (cc) { /* Read maximum contiguous sectors directly */
+ if (cc
+#if _FS_DISK_READ_ALIGNED
+ && (((int)rbuff & 3) == 0)
+#endif
+ ) {/* Read maximum contiguous sectors directly */
if (csect + cc > fs->csize) { /* Clip at cluster boundary */
cc = fs->csize - csect;
}