diff --git a/lib/fatfs/ffconf.h b/lib/fatfs/ffconf.h index 27e73e2b3f..7bfb03add2 100644 --- a/lib/fatfs/ffconf.h +++ b/lib/fatfs/ffconf.h @@ -217,7 +217,11 @@ #define _MIN_SS 512 +#ifdef MICROPY_FATFS_MAX_SS +#define _MAX_SS (MICROPY_FATFS_MAX_SS) +#else #define _MAX_SS 512 +#endif /* These options configure the range of sector size to be supported. (512, 1024, / 2048 or 4096) Always set both 512 for most systems, all type of memory cards and / harddisk. But a larger value may be required for on-board flash memory and some diff --git a/stmhal/diskio.c b/stmhal/diskio.c index 14eb9e297e..9a4efd1a4d 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;