Skip to content

Commit b8ef783

Browse files
committed
extmod: Fix getting sector size when the max and min sizes are the
same. Also switch the max size back to 512 for atmel-samd to save ram.
1 parent 9eb86e8 commit b8ef783

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

atmel-samd/mpconfigport.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@
7070
#define MICROPY_FATFS_VOLUMES (4)
7171
#define MICROPY_FATFS_MULTI_PARTITION (1)
7272
#define MICROPY_FSUSERMOUNT (1)
73-
#define MICROPY_FATFS_MAX_SS (4096)
73+
// Only enable this if you really need it. It allocates a byte cache of this
74+
// size.
75+
// #define MICROPY_FATFS_MAX_SS (4096)
7476

7577
#define FLASH_BLOCK_SIZE (512)
7678

extmod/vfs_fat.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ STATIC mp_obj_t fat_vfs_statvfs(mp_obj_t vfs_in, mp_obj_t path_in) {
278278

279279
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL));
280280

281-
t->items[0] = MP_OBJ_NEW_SMALL_INT(fatfs->csize * fatfs->ssize); // f_bsize
281+
#if _MIN_SS != _MAX_SS
282+
t->items[0] = MP_OBJ_NEW_SMALL_INT(fatfs->csize * fatfs->ssize); // f_bsize
283+
#else
284+
t->items[0] = MP_OBJ_NEW_SMALL_INT(fatfs->csize * _MIN_SS); // f_bsize
285+
#endif
282286
t->items[1] = t->items[0]; // f_frsize
283287
t->items[2] = MP_OBJ_NEW_SMALL_INT((fatfs->n_fatent - 2) * fatfs->csize); // f_blocks
284288
t->items[3] = MP_OBJ_NEW_SMALL_INT(nclst); // f_bfree

0 commit comments

Comments
 (0)