Merge pull request #6289 from stonehippo/samd51_mm_flash

Samd51 mm flash
This commit is contained in:
Dan Halbert 2022-04-18 18:59:58 -04:00 committed by GitHub
commit 6425e937b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 2 deletions

7
main.c
View File

@ -62,6 +62,7 @@
#include "supervisor/shared/workflow.h"
#include "supervisor/usb.h"
#include "supervisor/workflow.h"
#include "supervisor/shared/external_flash/external_flash.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Processor.h"
@ -836,6 +837,12 @@ int __attribute__((used)) main(void) {
// Start the debug serial
serial_early_init();
#if !INTERNAL_FLASH_FILESYSTEM
// 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.
// A power brownout here could make it appear as if there's
// no SPI flash filesystem, and we might erase the existing one.

View File

@ -26,6 +26,9 @@
#include "supervisor/board.h"
#include "mpconfigboard.h"
#include "common-hal/microcontroller/Pin.h"
#include "hal/include/hal_gpio.h"
#include "supervisor/shared/external_flash/external_flash.h"
void board_init(void) {
}
@ -39,3 +42,20 @@ void reset_board(void) {
void board_deinit(void) {
}
void external_flash_setup(void) {
// Do not reset the external flash write-protect and hold pins high
never_reset_pin_number(PIN_PB22);
never_reset_pin_number(PIN_PB23);
// note: using output instead of input+pullups because the pullups are a little weak
// Set the WP pin high
gpio_set_pin_function(PIN_PB22, GPIO_PIN_FUNCTION_OFF);
gpio_set_pin_direction(PIN_PB22, GPIO_DIRECTION_OUT);
gpio_set_pin_level(PIN_PB22, true);
// Set the HOLD pin high
gpio_set_pin_function(PIN_PB23, GPIO_PIN_FUNCTION_OFF);
gpio_set_pin_direction(PIN_PB23, GPIO_DIRECTION_OUT);
gpio_set_pin_level(PIN_PB23, true);
}

View File

@ -27,3 +27,7 @@
// USB is always used internally so skip the pin objects for it.
#define IGNORE_PIN_PA24 1
#define IGNORE_PIN_PA25 1
// The external flash chip has WP (write-protect) and hold pins we should ignore
#define IGNORE_PIN_PB22
#define IGNORE_PIN_PB23

View File

@ -49,7 +49,6 @@ CFLAGS += -DMICROPY_PY_USELECT=$(MICROPY_PY_USELECT)
MICROPY_PY_USELECT_SELECT ?= $(MICROPY_PY_USELECT)
CFLAGS += -DMICROPY_PY_USELECT_SELECT=$(MICROPY_PY_USELECT_SELECT)
CIRCUITPY_AESIO ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO)

View File

@ -47,5 +47,4 @@ void reset_board(void);
// disabling USB, BLE or flash) because CircuitPython may continue to run.
void board_deinit(void);
#endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H

View File

@ -588,3 +588,6 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t block_num,
}
return 0; // success
}
void MP_WEAK external_flash_setup(void) {
}

View File

@ -47,4 +47,9 @@
void supervisor_external_flash_flush(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_SHARED_EXTERNAL_FLASH_EXTERNAL_FLASH_H