From 156ee4833ab170d598991fd8d4d6f6d04c759744 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 7 Mar 2021 09:20:50 -0600 Subject: circuitpy_mpconfig: Disable flash multi-partition This adds some additional code in mkfs which doesn't seem necessary, and Disabling it saves 172 bytes flash. Testing performed: Using a Feather M0 Adalogger, checked that * an sdcard could still be mounted (using adafruit_sdcard) * os.listdir() of "/" and "/sd" worked * CIRCUITPY still mounted --- supervisor/shared/flash.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'supervisor/shared') diff --git a/supervisor/shared/flash.c b/supervisor/shared/flash.c index 1e09fe14b..66f2f0704 100644 --- a/supervisor/shared/flash.c +++ b/supervisor/shared/flash.c @@ -213,7 +213,9 @@ void supervisor_flash_init_vfs(fs_user_mount_t *vfs) { vfs->base.type = &mp_fat_vfs_type; vfs->flags |= FSUSER_NATIVE | FSUSER_HAVE_IOCTL; vfs->fatfs.drv = vfs; +#if MICROPY_FATFS_MULTI_PARTITION vfs->fatfs.part = 1; // flash filesystem lives on first partition +#endif vfs->readblocks[0] = (mp_obj_t)&supervisor_flash_obj_readblocks_obj; vfs->readblocks[1] = (mp_obj_t)&supervisor_flash_obj; vfs->readblocks[2] = (mp_obj_t)flash_read_blocks; // native version -- cgit v1.2.3 From 32475ce98c2eaa13240fa24e713ce3d5df60afd9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 7 Mar 2021 12:51:47 -0600 Subject: Automatically count EXTERNAL_FLASH_DEVICES (mk2) Instead of counting words in make, which is slightly awful, notice that possible_devices is local to external_flash.c, so we can declare the array with an automatic bound, and then get the count as the element-count (MP_ARRAY_SIZE) of the array. Since EXTERNAL_FLASH_DEVICE_COUNT is no longer a global macro, switch a few sites to using EXTERNAL_FLASH_DEVICES in `#if` checks instead. --- supervisor/flash.h | 2 +- supervisor/flash_root_pointers.h | 2 +- supervisor/shared/external_flash/external_flash.c | 3 ++- supervisor/supervisor.mk | 3 --- 4 files changed, 4 insertions(+), 6 deletions(-) (limited to 'supervisor/shared') diff --git a/supervisor/flash.h b/supervisor/flash.h index cd69cbfa9..289c76c2d 100644 --- a/supervisor/flash.h +++ b/supervisor/flash.h @@ -31,7 +31,7 @@ #include "py/mpconfig.h" -#ifdef EXTERNAL_FLASH_DEVICE_COUNT +#ifdef EXTERNAL_FLASH_DEVICES #include "supervisor/shared/external_flash/external_flash.h" #else #include "supervisor/shared/internal_flash.h" diff --git a/supervisor/flash_root_pointers.h b/supervisor/flash_root_pointers.h index 634ae58d3..a426b9c4e 100644 --- a/supervisor/flash_root_pointers.h +++ b/supervisor/flash_root_pointers.h @@ -26,7 +26,7 @@ #ifndef MICROPY_INCLUDED_SUPERVISOR_FLASH_ROOT_POINTERS_H #define MICROPY_INCLUDED_SUPERVISOR_FLASH_ROOT_POINTERS_H -#ifdef EXTERNAL_FLASH_DEVICE_COUNT +#ifdef EXTERNAL_FLASH_DEVICES #include "supervisor/shared/external_flash/external_flash_root_pointers.h" #else #include "supervisor/internal_flash_root_pointers.h" diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index e2d767235..23727e7e7 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -45,7 +45,8 @@ // The currently cached sector in the cache, ram or flash based. static uint32_t current_sector; -const external_flash_device possible_devices[EXTERNAL_FLASH_DEVICE_COUNT] = {EXTERNAL_FLASH_DEVICES}; +STATIC const external_flash_device possible_devices[] = {EXTERNAL_FLASH_DEVICES}; +#define EXTERNAL_FLASH_DEVICE_COUNT MP_ARRAY_SIZE(possible_devices) static const external_flash_device* flash_device = NULL; diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index f94bccd9a..083e7fb35 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -33,10 +33,7 @@ endif # (Right now INTERNAL_FLASH_FILESYSTEM and (Q)SPI_FLASH_FILESYSTEM are mutually exclusive. # But that might not be true in the future.) ifdef EXTERNAL_FLASH_DEVICES - COMMA := , - EXTERNAL_FLASH_DEVICE_COUNT := $(words $(subst $(COMMA), ,$(EXTERNAL_FLASH_DEVICES))) CFLAGS += -DEXTERNAL_FLASH_DEVICES=$(EXTERNAL_FLASH_DEVICES) \ - -DEXTERNAL_FLASH_DEVICE_COUNT=$(EXTERNAL_FLASH_DEVICE_COUNT) SRC_SUPERVISOR += supervisor/shared/external_flash/external_flash.c ifeq ($(SPI_FLASH_FILESYSTEM),1) -- cgit v1.2.3 From 1e5ffe1a53cce31e8335e2f0878963de87dae57f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 9 Mar 2021 11:08:36 -0600 Subject: Revert "circuitpy_mpconfig: Disable flash multi-partition" This reverts commit 156ee4833ab170d598991fd8d4d6f6d04c759744. --- py/circuitpy_mpconfig.h | 2 +- supervisor/shared/flash.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'supervisor/shared') diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 0cddcb83e..f61c3959f 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -133,7 +133,7 @@ #define MICROPY_FATFS_LFN_CODE_PAGE (437) #define MICROPY_FATFS_USE_LABEL (1) #define MICROPY_FATFS_RPATH (2) -#define MICROPY_FATFS_MULTI_PARTITION (0) +#define MICROPY_FATFS_MULTI_PARTITION (1) // Only enable this if you really need it. It allocates a byte cache of this size. // #define MICROPY_FATFS_MAX_SS (4096) diff --git a/supervisor/shared/flash.c b/supervisor/shared/flash.c index 66f2f0704..1e09fe14b 100644 --- a/supervisor/shared/flash.c +++ b/supervisor/shared/flash.c @@ -213,9 +213,7 @@ void supervisor_flash_init_vfs(fs_user_mount_t *vfs) { vfs->base.type = &mp_fat_vfs_type; vfs->flags |= FSUSER_NATIVE | FSUSER_HAVE_IOCTL; vfs->fatfs.drv = vfs; -#if MICROPY_FATFS_MULTI_PARTITION vfs->fatfs.part = 1; // flash filesystem lives on first partition -#endif vfs->readblocks[0] = (mp_obj_t)&supervisor_flash_obj_readblocks_obj; vfs->readblocks[1] = (mp_obj_t)&supervisor_flash_obj; vfs->readblocks[2] = (mp_obj_t)flash_read_blocks; // native version -- cgit v1.2.3