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
This commit is contained in:
parent
387ab6c87e
commit
a484a93b29
@ -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;
|
||||
}
|
||||
|
@ -343,6 +343,12 @@
|
||||
/ SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
|
||||
/ included somewhere in the scope of ff.h. */
|
||||
|
||||
// Set to nonzero if buffers passed to disk_read have a word alignment
|
||||
// restriction
|
||||
#ifndef _FS_DISK_READ_ALIGNED
|
||||
#define _FS_DISK_READ_ALIGNED 0
|
||||
#endif
|
||||
|
||||
/* #include <windows.h> // O/S definitions */
|
||||
|
||||
|
||||
|
@ -106,6 +106,7 @@ CFLAGS += -Wno-undef
|
||||
CFLAGS += -Wno-cast-align
|
||||
|
||||
NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
|
||||
NRF_DEFINES += -D_FS_DISK_READ_ALIGNED=1
|
||||
CFLAGS += $(NRF_DEFINES)
|
||||
|
||||
CFLAGS += \
|
||||
|
Loading…
Reference in New Issue
Block a user