From 6ff58fd94af5cf0aa03bae5c1d021b892d4df2d4 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 17 Mar 2023 09:37:15 -0500 Subject: [PATCH 1/3] re-enable mkfs for >4GB filesystems whenver FULL_BUILD --- py/circuitpy_mpconfig.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index a514b6a160..641da7814f 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -255,6 +255,10 @@ typedef long mp_off_t; #define MICROPY_FATFS_EXFAT (CIRCUITPY_FULL_BUILD) #endif +#ifndef MICROPY_FF_MKFS_FAT32 +#define MICROPY_FF_MKFS_FAT32 (CIRCUITPY_FULL_BUILD) +#endif + // LONGINT_IMPL_xxx are defined in the Makefile. // #ifdef LONGINT_IMPL_NONE From 5569f101a7ed92ca7242e0d3e86b22442b939dc6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 17 Mar 2023 10:50:07 -0400 Subject: [PATCH 2/3] Document that storage.VfsFat.mkfs() is a @staticmethod --- shared-bindings/storage/__init__.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 8e2eee6511..5e8f32f17e 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -266,6 +266,7 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { //| This property cannot be changed, use `storage.remount` instead.""" //| ... //| +//| @staticmethod //| def mkfs(self) -> None: //| """Format the block device, deleting any data that may have been there""" //| ... From ca292f342795ee36de7263f1024bee166a1415d3 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 17 Mar 2023 12:18:24 -0400 Subject: [PATCH 3/3] Turn off mkfs FAT32 on all SAMD21 builds; note in doc --- ports/atmel-samd/mpconfigport.h | 4 +++- shared-bindings/storage/__init__.c | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 9d4ddd7134..887748c7a0 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -60,7 +60,9 @@ X(EISDIR) \ X(EINVAL) \ -#define MICROPY_FATFS_EXFAT 0 +#define MICROPY_FATFS_EXFAT (0) +// FAT32 mkfs takes about 500 bytes. +#define MICROPY_FF_MKFS_FAT32 (0) // Only support simpler HID descriptors on SAMD21. #define CIRCUITPY_USB_HID_MAX_REPORT_IDS_PER_DESCRIPTOR (1) diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 5e8f32f17e..9e82654bc9 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -268,7 +268,13 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { //| //| @staticmethod //| def mkfs(self) -> None: -//| """Format the block device, deleting any data that may have been there""" +//| """Format the block device, deleting any data that may have been there. +//| +//| **Limitations**: On SAMD21 builds, `mkfs()` will raise ``OSError(22)`` when +//| attempting to format filesystems larger than 4GB. The extra code to format larger +//| filesystems will not fit on these builds. You can still access +//| larger filesystems, but you will need to format the filesystem on another device. +//| """ //| ... //| def open(self, path: str, mode: str) -> None: //| """Like builtin ``open()``"""