Skip to content

Commit c07b178

Browse files
robert-hhdpgeorge
authored andcommitted
samd: Add support for VfsRom filesystem for SAMD21 and SAMD51.
The flash driver is update to support the new `mp_vfs_rom_ioctl()` function, and the buffer protocol is added to `samd_flash_type` (it is needed for VfsRom on devices without external flash). For SAMD21, only boards with external SPI flash have VfsRom enabled, due to size constraints. For such boards, the VfsRom filesystem has a size of 12k and is placed at the upper end of the flash. The `onewire`, `ds18x20` and `dht` drivers have been removed from frozen bytecode as they can be placed into the VfsRom files when needed. For SAMD51, the VfsRom filesystem has a default size of 64k for SAMD51x19 and 256K for SAMD51x20. It is placed at the upper end of the flash. For boards with external SPI flash, the code size is reduced from 496K to 432K. If that is not sufficient for some boards or configurations, it can be changed for each board or board variant. Tested with ADAFRUIT_ITSYBITSY_M0_EXPRESS, ADAFRUIT_ITSYBITSY_M4_EXPRESS, SPARKFUN_SAMD51_THING_PLUS, SEEED_XIAO_SAMD21, SAMD_GENERIC_D51X19, and SAMD_GENERIC_D51X20. Signed-off-by: Damien George <damien@micropython.org> Signed-off-by: robert-hh <robert@hammelrath.com>
1 parent b857a91 commit c07b178

26 files changed

Lines changed: 197 additions & 62 deletions

File tree

ports/samd/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ CFLAGS += $(CFLAGS_EXTRA)
9090
CFLAGS += -DMICROPY_HW_CODESIZE=$(strip $(subst K,' ', $(MICROPY_HW_CODESIZE)))
9191

9292
LDFLAGS += -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
93-
LDFLAGS += --defsym=_codesize=$(MICROPY_HW_CODESIZE)
93+
LDFLAGS += --defsym=_codesize=$(MICROPY_HW_CODESIZE) --defsym=_micropy_hw_romfs_part0_size=$(MICROPY_HW_ROMFS_BYTES)
9494

9595
LIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
9696

@@ -103,6 +103,10 @@ CFLAGS += -Os -DNDEBUG
103103
LDFLAGS += --gc-sections --print-memory-usage
104104
CFLAGS += -fdata-sections -ffunction-sections
105105
endif
106+
# Disable VFSROM support if the size was set to 0
107+
ifeq ($(MICROPY_HW_ROMFS_BYTES),0)
108+
CFLAGS += -DMICROPY_VFS_ROM=0
109+
endif
106110

107111
# Flags for optional C++ source code
108112
CXXFLAGS += $(filter-out -std=c99,$(CFLAGS))

ports/samd/boards/ADAFRUIT_FEATHER_M0_EXPRESS/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ TEXT0 = 0x2000
55

66
# The ?='s allow overriding in mpconfigboard.mk.
77
# MicroPython settings
8-
MICROPY_HW_CODESIZE ?= 248K
8+
MICROPY_HW_CODESIZE ?= 236K

ports/samd/boards/ADAFRUIT_FEATHER_M4_EXPRESS/mpconfigboard.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ TEXT0 = 0x4000
55

66
# The ?='s allow overriding in mpconfigboard.mk.
77
# MicroPython settings
8-
MICROPY_HW_CODESIZE ?= 496K
8+
# The size of a MCU flash filesystem will be
9+
# 1008k - MICROPY_HW_CODESIZE - MICROPY_HW_ROMFS_BYTES
10+
# The default for MICROPY_HW_ROMFS_BYTES is 64K
11+
MICROPY_HW_CODESIZE ?= 432K

ports/samd/boards/ADAFRUIT_ITSYBITSY_M0_EXPRESS/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ TEXT0 = 0x2000
55

66
# The ?='s allow overriding in mpconfigboard.mk.
77
# MicroPython settings
8-
MICROPY_HW_CODESIZE ?= 248K
8+
MICROPY_HW_CODESIZE ?= 236K

ports/samd/boards/ADAFRUIT_ITSYBITSY_M4_EXPRESS/mpconfigboard.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ TEXT0 = 0x4000
55

66
# The ?='s allow overriding in mpconfigboard.mk.
77
# MicroPython settings
8-
MICROPY_HW_CODESIZE ?= 496K
8+
# The size of a MCU flash filesystem will be
9+
# 1008k - MICROPY_HW_CODESIZE - MICROPY_HW_ROMFS_BYTES
10+
# The default for MICROPY_HW_ROMFS_BYTES is 64K
11+
MICROPY_HW_CODESIZE ?= 432K

ports/samd/boards/ADAFRUIT_METRO_M4_EXPRESS/mpconfigboard.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ TEXT0 = 0x4000
77
MICROPY_PY_NETWORK ?= 1
88
MICROPY_PY_NETWORK_NINAW10 ?= 1
99

10-
MICROPY_HW_CODESIZE ?= 496K
10+
# The size of a MCU flash filesystem will be
11+
# 1008k - MICROPY_HW_CODESIZE - MICROPY_HW_ROMFS_BYTES
12+
# The default for MICROPY_HW_ROMFS_BYTES is 64K
13+
MICROPY_HW_CODESIZE ?= 432K
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
CFLAGS += -DMICROPY_HW_SPIFLASH=1
2-
MICROPY_HW_CODESIZE ?= 232K
2+
MICROPY_HW_CODESIZE ?= 236K

ports/samd/boards/MINISAM_M4/mpconfigboard.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ TEXT0 = 0x4000
66

77
# The ?='s allow overriding in mpconfigboard.mk.
88
# MicroPython settings
9-
MICROPY_HW_CODESIZE ?= 496K
9+
# The size of a MCU flash filesystem will be
10+
# 1008k - MICROPY_HW_CODESIZE - MICROPY_HW_ROMFS_BYTES
11+
# The default for MICROPY_HW_ROMFS_BYTES is 64K
12+
MICROPY_HW_CODESIZE ?= 432K

ports/samd/boards/SAMD21_XPLAINED_PRO/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ CMSIS_MCU = SAMD21J18A
33
LD_FILES = boards/samd21x18a.ld sections.ld
44
TEXT0 = 0x2000
55

6-
MICROPY_HW_CODESIZE ?= 248K
6+
MICROPY_HW_CODESIZE ?= 236K

ports/samd/boards/SAMD_GENERIC_D51X19/mpconfigboard.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ TEXT0 = 0x4000
66
# The ?='s allow overriding in mpconfigboard.mk.
77
# MicroPython settings
88
# The size of a MCU flash filesystem will be
9-
# 496k - MICROPY_HW_CODESIZE - MICROPY_HW_VFSROMSIZE
10-
# The default for MICROPY_HW_VFSROMSIZE is 64K
9+
# 496k - MICROPY_HW_CODESIZE - MICROPY_HW_ROMFS_BYTES
10+
# The default for MICROPY_HW_ROMFS_BYTES is 64K
1111
MICROPY_HW_CODESIZE ?= 368K

0 commit comments

Comments
 (0)