Skip to content

Commit bb1822f

Browse files
committed
atmel-samd: Support external flash on the Metro M0 w/Flash.
This uses a scratch flash sector to save data before writing a full sector.
1 parent 46f6f9f commit bb1822f

7 files changed

Lines changed: 266 additions & 70 deletions

File tree

atmel-samd/boards/metro_m0_flash/conf_access.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@
6868
/*! \name LUN 0 Definitions
6969
*/
7070
//! @{
71-
#define LUN_0_INCLUDE "rom_fs.h"
72-
#define Lun_0_test_unit_ready rom_fs_test_unit_ready
73-
#define Lun_0_read_capacity rom_fs_read_capacity
74-
#define Lun_0_unload NULL /* Can not be unloaded */
75-
#define Lun_0_wr_protect rom_fs_wr_protect
76-
#define Lun_0_removal rom_fs_removal
77-
#define Lun_0_usb_read_10 rom_fs_usb_read_10
78-
#define Lun_0_usb_write_10 rom_fs_usb_write_10
79-
#define LUN_0_NAME "\"On-Chip ROM\""
71+
#define LUN_0_INCLUDE "access_vfs.h"
72+
#define Lun_0_test_unit_ready vfs_test_unit_ready
73+
#define Lun_0_read_capacity vfs_read_capacity
74+
#define Lun_0_unload NULL
75+
#define Lun_0_wr_protect vfs_wr_protect
76+
#define Lun_0_removal vfs_removal
77+
#define Lun_0_usb_read_10 vfs_usb_read_10
78+
#define Lun_0_usb_write_10 vfs_usb_write_10
79+
#define LUN_0_NAME "\"MicroPython VFS[0]\""
8080
//! @}
8181

8282
#define MEM_USB LUN_USB
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// LEDs
2-
#define MICROPY_HW_LED1 PIN_PA17 // red
31
// #define UART_REPL
42
#define USB_REPL
53

@@ -8,3 +6,25 @@
86

97
#define MICROPY_HW_LED_TX PIN_PA27
108
#define MICROPY_HW_LED_RX PIN_PB03
9+
10+
#define SPI_FLASH_BAUDRATE (1000000)
11+
12+
// Off-board flash
13+
// #define SPI_FLASH_MUX_SETTING SPI_SIGNAL_MUX_SETTING_E
14+
// #define SPI_FLASH_PAD0_PINMUX PINMUX_PA16C_SERCOM1_PAD0 // MISO D11
15+
// Use default pinmux for the chip select since we manage it ourselves.
16+
// #define SPI_FLASH_PAD1_PINMUX PINMUX_DEFAULT
17+
// #define SPI_FLASH_PAD2_PINMUX PINMUX_PA18C_SERCOM1_PAD2 // MOSI D10
18+
// #define SPI_FLASH_PAD3_PINMUX PINMUX_PA19C_SERCOM1_PAD3 // SCK D12
19+
// #define SPI_FLASH_CS PIN_PA17
20+
// #define SPI_FLASH_SERCOM SERCOM1
21+
22+
// On-board flash
23+
#define SPI_FLASH_MUX_SETTING SPI_SIGNAL_MUX_SETTING_E
24+
#define SPI_FLASH_PAD0_PINMUX PINMUX_PA12D_SERCOM4_PAD0 // MISO
25+
// Use default pinmux for the chip select since we manage it ourselves.
26+
#define SPI_FLASH_PAD1_PINMUX PINMUX_DEFAULT // CS
27+
#define SPI_FLASH_PAD2_PINMUX PINMUX_PB10D_SERCOM4_PAD2 // MOSI
28+
#define SPI_FLASH_PAD3_PINMUX PINMUX_PB11D_SERCOM4_PAD3 // SCK
29+
#define SPI_FLASH_CS PIN_PA13
30+
#define SPI_FLASH_SERCOM SERCOM4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
LD_FILE = boards/samd21x18-bootloader-external-flash.ld
22
USB_VID = 0x239A
33
USB_PID = 0x8015
4+
5+
FLASH_IMPL = spi_flash.c

atmel-samd/boards/metro_m0_flash/pins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ PIN(PA19, false, NO_ADC_INPUT,
9292
TIMER(TC3, 0, 1, 1, PIN_PA19E_TC3_WO1, MUX_PA19E_TC3_WO1),
9393
TIMER(0, TCC0, 3, 3, PIN_PA19F_TCC0_WO3, MUX_PA19F_TCC0_WO3),
9494
SERCOM(SERCOM1, 3, PINMUX_PA19C_SERCOM1_PAD3),
95-
SERCOM(SERCOM3, 3, PINMUX_PA19C_SERCOM1_PAD3));
95+
SERCOM(SERCOM3, 3, PINMUX_PA19D_SERCOM3_PAD3));
9696
PIN(PA17, false, NO_ADC_INPUT,
9797
TIMER(0, TCC2, 1, 1, PIN_PA17E_TCC2_WO1, MUX_PA17E_TCC2_WO1),
9898
TIMER(0, TCC0, 3, 7, PIN_PA17F_TCC0_WO7, MUX_PA17F_TCC0_WO7),

atmel-samd/boards/samd21x18-bootloader-external-flash.ld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,13 @@ SECTIONS
6464
_ebss = .;
6565
} >RAM
6666

67+
/* this just checks there is enough RAM for a minimal stack */
68+
.stack :
69+
{
70+
. = ALIGN(4);
71+
. = . + 0x800; /* Reserve a minimum of 2K for the stack. */
72+
. = ALIGN(4);
73+
} >RAM
74+
6775
.ARM.attributes 0 : { *(.ARM.attributes) }
6876
}

0 commit comments

Comments
 (0)