Skip to content

Commit f502703

Browse files
committed
Add hook to do some flash setup before filesystem init
1 parent 4f04cee commit f502703

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,12 @@ int __attribute__((used)) main(void) {
836836
// Start the debug serial
837837
serial_early_init();
838838

839+
#if CIRCUITPY_EXTERNAL_FLASH_SETUP
840+
// Set up anything that might need to get done before we try to use SPI flash
841+
// This is needed for some boards where flash relies on GPIO setup to work
842+
external_flash_setup();
843+
#endif
844+
839845
// Create a new filesystem only if we're not in a safe mode.
840846
// A power brownout here could make it appear as if there's
841847
// no SPI flash filesystem, and we might erase the existing one.

py/circuitpy_mpconfig.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ CFLAGS += -DMICROPY_PY_USELECT=$(MICROPY_PY_USELECT)
4949
MICROPY_PY_USELECT_SELECT ?= $(MICROPY_PY_USELECT)
5050
CFLAGS += -DMICROPY_PY_USELECT_SELECT=$(MICROPY_PY_USELECT_SELECT)
5151

52+
# enable pre-flash GPIO setup
53+
CIRCUITPY_EXTERNAL_FLASH_SETUP ?= 0
54+
CFLAGS += -DCIRCUITPY_EXTERNAL_FLASH_SETUP=$(CIRCUITPY_EXTERNAL_FLASH_SETUP)
5255

5356
CIRCUITPY_AESIO ?= $(CIRCUITPY_FULL_BUILD)
5457
CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO)

supervisor/board.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,9 @@ void reset_board(void);
4747
// disabling USB, BLE or flash) because CircuitPython may continue to run.
4848
void board_deinit(void);
4949

50+
// Configure anything that needs to get set up before the external flash
51+
// is init'ed. For example, if GPIO needs to be configured to enable the
52+
// flash chip, as is the case on some boards.
53+
void external_flash_setup(void);
5054

5155
#endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H

0 commit comments

Comments
 (0)