Add hook to do some flash setup before filesystem init

This commit is contained in:
George White 2022-04-17 17:14:39 +00:00
parent 4f04cee729
commit f502703e52
3 changed files with 13 additions and 0 deletions

6
main.c
View File

@ -836,6 +836,12 @@ int __attribute__((used)) main(void) {
// Start the debug serial // Start the debug serial
serial_early_init(); serial_early_init();
#if CIRCUITPY_EXTERNAL_FLASH_SETUP
// Set up anything that might need to get done before we try to use SPI flash
// This is needed for some boards where flash relies on GPIO setup to work
external_flash_setup();
#endif
// Create a new filesystem only if we're not in a safe mode. // Create a new filesystem only if we're not in a safe mode.
// A power brownout here could make it appear as if there's // A power brownout here could make it appear as if there's
// no SPI flash filesystem, and we might erase the existing one. // no SPI flash filesystem, and we might erase the existing one.

View File

@ -49,6 +49,9 @@ CFLAGS += -DMICROPY_PY_USELECT=$(MICROPY_PY_USELECT)
MICROPY_PY_USELECT_SELECT ?= $(MICROPY_PY_USELECT) MICROPY_PY_USELECT_SELECT ?= $(MICROPY_PY_USELECT)
CFLAGS += -DMICROPY_PY_USELECT_SELECT=$(MICROPY_PY_USELECT_SELECT) CFLAGS += -DMICROPY_PY_USELECT_SELECT=$(MICROPY_PY_USELECT_SELECT)
# enable pre-flash GPIO setup
CIRCUITPY_EXTERNAL_FLASH_SETUP ?= 0
CFLAGS += -DCIRCUITPY_EXTERNAL_FLASH_SETUP=$(CIRCUITPY_EXTERNAL_FLASH_SETUP)
CIRCUITPY_AESIO ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_AESIO ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO) CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO)

View File

@ -47,5 +47,9 @@ void reset_board(void);
// disabling USB, BLE or flash) because CircuitPython may continue to run. // disabling USB, BLE or flash) because CircuitPython may continue to run.
void board_deinit(void); void board_deinit(void);
// Configure anything that needs to get set up before the external flash
// is init'ed. For example, if GPIO needs to be configured to enable the
// flash chip, as is the case on some boards.
void external_flash_setup(void);
#endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H #endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H