aboutsummaryrefslogtreecommitdiff
path: root/stmhal
diff options
context:
space:
mode:
authorDamien George2016-02-09 14:31:26 +0000
committerDamien George2016-02-10 08:59:58 +0000
commit13a4c120ce2cdeb5aa1c210d9426d31e02898486 (patch)
tree9628c421a90678e336f315dfd3e6c1e114bf2e25 /stmhal
parentc33ad60a676d46cb18883beedd6c383d6fae9dd8 (diff)
lib/fatfs: Add support for sector sizes larger than 512 bytes.
If MICROPY_FATFS_MAX_SS is defined to power of 2 value between 1024 and 4096, support for dynamic sector size in FatFs will be enabled. Note that FatFs reserves static buffer of MICROPY_FATFS_MAX_SS size for each filesystem in use, so that value should be set sparingly. Initial patch provided by @pfalcon.
Diffstat (limited to 'stmhal')
-rw-r--r--stmhal/diskio.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/stmhal/diskio.c b/stmhal/diskio.c
index 14eb9e297..9a4efd1a4 100644
--- a/stmhal/diskio.c
+++ b/stmhal/diskio.c
@@ -44,6 +44,7 @@
//#define BP_IOCTL_DEINIT (2) // unused
#define BP_IOCTL_SYNC (3)
#define BP_IOCTL_SEC_COUNT (4)
+#define BP_IOCTL_SEC_SIZE (5)
/*-----------------------------------------------------------------------*/
/* Initialize a Drive */
@@ -273,6 +274,15 @@ DRESULT disk_ioctl (
return RES_OK;
}
+ case GET_SECTOR_SIZE: {
+ vfs->u.ioctl[2] = MP_OBJ_NEW_SMALL_INT(BP_IOCTL_SEC_SIZE);
+ vfs->u.ioctl[3] = MP_OBJ_NEW_SMALL_INT(0); // unused
+ mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->u.ioctl);
+ *((WORD*)buff) = mp_obj_get_int(ret);
+ vfs->u.ioctl[3] = MP_OBJ_SENTINEL; // indicate new protocol
+ return RES_OK;
+ }
+
case GET_BLOCK_SIZE:
*((DWORD*)buff) = 1; // erase block size in units of sector size
return RES_OK;
@@ -292,6 +302,10 @@ DRESULT disk_ioctl (
return RES_OK;
}
+ case GET_SECTOR_SIZE:
+ *((WORD*)buff) = 512; // old protocol had fixed sector size
+ return RES_OK;
+
case GET_BLOCK_SIZE:
*((DWORD*)buff) = 1; // erase block size in units of sector size
return RES_OK;