summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-03-27 14:21:06 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-03-27 14:21:06 +0300
commit651a18829932cbbf9bcd312f11cf40252dca7f1c (patch)
tree50c8cd04e7042fe39c27ad8ff887e41f753abc25
parent13394a632dda24298e80ec034dd13903059b4a4b (diff)
downloadmicropython-651a18829932cbbf9bcd312f11cf40252dca7f1c.tar.gz
micropython-651a18829932cbbf9bcd312f11cf40252dca7f1c.zip
extmod/vfs_fat_diskio: Actually support sectors != 512 with Python blockdevs.
-rw-r--r--extmod/vfs_fat_diskio.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/extmod/vfs_fat_diskio.c b/extmod/vfs_fat_diskio.c
index 7acdc82972..3f1902b2e0 100644
--- a/extmod/vfs_fat_diskio.c
+++ b/extmod/vfs_fat_diskio.c
@@ -40,6 +40,12 @@
#include "lib/fatfs/diskio.h" /* FatFs lower layer API */
#include "extmod/fsusermount.h"
+#if _MAX_SS == _MIN_SS
+#define SECSIZE(fs) (_MIN_SS)
+#else
+#define SECSIZE(fs) ((fs)->ssize)
+#endif
+
STATIC fs_user_mount_t *disk_get_device(uint id) {
if (id < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) {
return MP_STATE_PORT(fs_user_mount)[id];
@@ -122,7 +128,7 @@ DRESULT disk_read (
}
} else {
vfs->readblocks[2] = MP_OBJ_NEW_SMALL_INT(sector);
- vfs->readblocks[3] = mp_obj_new_bytearray_by_ref(count * 512, buff);
+ vfs->readblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), buff);
mp_call_method_n_kw(2, 0, vfs->readblocks);
// TODO handle error return
}
@@ -159,7 +165,7 @@ DRESULT disk_write (
}
} else {
vfs->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(sector);
- vfs->writeblocks[3] = mp_obj_new_bytearray_by_ref(count * 512, (void*)buff);
+ vfs->writeblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), (void*)buff);
mp_call_method_n_kw(2, 0, vfs->writeblocks);
// TODO handle error return
}