From 2bd50673b6467e8b48b5858ee68d3081d7e5698d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 5 Oct 2022 09:55:48 -0500 Subject: [PATCH] Finish adapting flash storage size Before this, CIRCUITPY would start at 1MB anyway. This appeared to work only because I hadn't checked the actual size of the CIRCUITPY drive, and because until now the flash hadn't actually crossed that 1MB boundary into CIRCUITPY storage. WARNING: on pico_w, upgrading/downgrading CircuitPython across this commit boundary will erase the CIRCUITPY filesystem. After this commit, switching between pico and pico_w firmware will erase the CIRCUITPY filesystem --- .../boards/raspberry_pi_pico_w/mpconfigboard.mk | 2 ++ ports/raspberrypi/supervisor/internal_flash.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ports/raspberrypi/boards/raspberry_pi_pico_w/mpconfigboard.mk b/ports/raspberrypi/boards/raspberry_pi_pico_w/mpconfigboard.mk index 2b114b3954..a8938b2623 100644 --- a/ports/raspberrypi/boards/raspberry_pi_pico_w/mpconfigboard.mk +++ b/ports/raspberrypi/boards/raspberry_pi_pico_w/mpconfigboard.mk @@ -19,3 +19,5 @@ CIRCUITPY_SOCKETPOOL = 1 CIRCUITPY_WIFI = 1 CFLAGS += -DCYW43_PIN_WL_HOST_WAKE=24 -DCYW43_PIN_WL_REG_ON=23 -DCYW43_WL_GPIO_COUNT=3 -DCYW43_WL_GPIO_LED_PIN=0 +# Must be accompanied by a linker script change +CFLAGS += -DRESERVED_FLASH='(1792 * 1024)' diff --git a/ports/raspberrypi/supervisor/internal_flash.c b/ports/raspberrypi/supervisor/internal_flash.c index c128cb74b2..d2d80b40ad 100644 --- a/ports/raspberrypi/supervisor/internal_flash.c +++ b/ports/raspberrypi/supervisor/internal_flash.c @@ -46,7 +46,13 @@ #include "src/rp2_common/hardware_flash/include/hardware/flash.h" #include "src/common/pico_binary_info/include/pico/binary_info.h" +#if !defined(RESERVED_FLASH) #define RESERVED_FLASH (1 * 1024 * 1024) +#endif + +#if !defined(TOTAL_FLASH_MINIMUM) +#define TOTAL_FLASH_MINIMUM (2 * 1024 * 1024) +#endif // TODO: Split the caching out of supervisor/shared/external_flash so we can use it. #define SECTOR_SIZE 4096 @@ -60,7 +66,7 @@ void supervisor_flash_init(void) { BINARY_INFO_MAKE_TAG('C', 'P'), "CircuitPython", RESERVED_FLASH, - (1 * 1024 * 1024), // This is a minimum. We can't set it dynamically. + TOTAL_FLASH_MINIMUM - RESERVED_FLASH, // This is a minimum. We can't set it dynamically. NULL, BINARY_INFO_BLOCK_DEV_FLAG_READ | BINARY_INFO_BLOCK_DEV_FLAG_WRITE |