summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-10-20 23:50:12 -0400
committerDan Halbert <halbert@halwitz.org>2019-10-20 23:50:12 -0400
commit7b79ac37399927070e1931022f5759393202ed3d (patch)
tree3ae5f0200b13562c880ea10fe24a2e185d0e4bd2
parentbe8136dc6d09e2c3af5c20c881662ebf51a778d8 (diff)
Parameterize linker script
-rwxr-xr-xmain.c2
-rw-r--r--ports/atmel-samd/Makefile22
-rw-r--r--ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/arduino_zero/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.h3
-rw-r--r--ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.h9
-rw-r--r--ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/common.template.ld89
-rw-r--r--ports/atmel-samd/boards/cp32-m4/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/datum_distance/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/datum_distance/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/datum_imu/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/datum_imu/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/datum_light/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/datum_light/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/datum_weather/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/datum_weather/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h7
-rw-r--r--ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk1
-rwxr-xr-xports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h6
-rwxr-xr-xports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/gemma_m0/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h2
-rw-r--r--ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/meowmeow/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/meowmeow/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pewpew10/mpconfigboard.h5
-rw-r--r--ports/atmel-samd/boards/pewpew10/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h9
-rw-r--r--ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pybadge/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/pybadge/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pygamer/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/pygamer/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pyportal/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/pyportal/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pyruler/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/pyruler/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/sam32/mpconfigboard.h5
-rw-r--r--ports/atmel-samd/boards/sam32/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld73
-rw-r--r--ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld73
-rw-r--r--ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld73
-rw-r--r--ports/atmel-samd/boards/samd21x18-bootloader.ld73
-rw-r--r--ports/atmel-samd/boards/samd21x18-external-flash.ld72
-rw-r--r--ports/atmel-samd/boards/samd21x18.ld72
-rw-r--r--ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld73
-rw-r--r--ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld73
-rw-r--r--ports/atmel-samd/boards/samd51x19-bootloader.ld73
-rw-r--r--ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld73
-rw-r--r--ports/atmel-samd/boards/samd51x20-bootloader.ld74
-rw-r--r--ports/atmel-samd/boards/samd51x20-external-flash.ld72
-rw-r--r--ports/atmel-samd/boards/samd51x20.ld72
-rw-r--r--ports/atmel-samd/boards/serpente/mpconfigboard.h7
-rw-r--r--ports/atmel-samd/boards/serpente/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/snekboard/mpconfigboard.h7
-rw-r--r--ports/atmel-samd/boards/snekboard/mpconfigboard.mk1
-rwxr-xr-xports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.h4
-rwxr-xr-xports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk1
-rwxr-xr-xports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.h10
-rwxr-xr-xports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.h7
-rw-r--r--ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h8
-rw-r--r--ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/trinket_m0/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/uchip/mpconfigboard.h4
-rw-r--r--ports/atmel-samd/boards/uchip/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/ugame10/mpconfigboard.h6
-rw-r--r--ports/atmel-samd/boards/ugame10/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/common-hal/microcontroller/__init__.c1
-rw-r--r--ports/atmel-samd/ld_defines.c14
-rw-r--r--ports/atmel-samd/mpconfigport.h37
-rw-r--r--ports/atmel-samd/mpconfigport.mk4
-rw-r--r--ports/atmel-samd/tick.c2
-rw-r--r--ports/cxd56/tick.c2
-rw-r--r--ports/nrf/boards/adafruit_nrf52840_s140_v6.ld3
-rw-r--r--ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/common.ld4
-rw-r--r--ports/nrf/boards/electronut_labs_blip/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/particle_argon/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/particle_boron/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/particle_xenon/mpconfigboard.h6
-rw-r--r--ports/nrf/boards/pca10056/mpconfigboard.h2
-rw-r--r--ports/nrf/boards/pca10059/mpconfigboard.h2
-rw-r--r--ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h2
-rw-r--r--ports/nrf/common-hal/_bleio/Adapter.c9
-rw-r--r--ports/nrf/common-hal/microcontroller/__init__.c5
-rw-r--r--ports/nrf/common-hal/nvm/ByteArray.c15
-rw-r--r--ports/nrf/common-hal/nvm/ByteArray.h2
-rw-r--r--ports/nrf/mpconfigport.h4
-rw-r--r--ports/nrf/peripherals/nrf/nvm.h4
-rw-r--r--ports/nrf/supervisor/internal_flash.c3
-rw-r--r--ports/nrf/tick.c2
-rw-r--r--ports/stm32f4/boards/feather_f405/mpconfigboard.h3
-rw-r--r--ports/stm32f4/boards/pyboard_v11/mpconfigboard.h3
-rw-r--r--ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h6
-rw-r--r--ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h4
-rw-r--r--ports/stm32f4/tick.c2
-rw-r--r--py/circuitpy_defns.mk1
-rw-r--r--py/circuitpy_mpconfig.h13
-rwxr-xr-xtools/gen_ld_files.py47
179 files changed, 272 insertions, 1490 deletions
diff --git a/main.c b/main.c
index 6b56f5ff6..4683bcf00 100755
--- a/main.c
+++ b/main.c
@@ -199,7 +199,7 @@ void cleanup_after_vm(supervisor_allocation* heap) {
bool run_code_py(safe_mode_t safe_mode) {
bool serial_connected_at_start = serial_connected();
- #ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
+ #if CIRCUITPY_AUTORELOAD_DELAY_MS > 0
if (serial_connected_at_start) {
serial_write("\n");
if (autoreload_is_enabled()) {
diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile
index 11e6874ed..16aed1615 100644
--- a/ports/atmel-samd/Makefile
+++ b/ports/atmel-samd/Makefile
@@ -292,12 +292,17 @@ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE))
$(addprefix shared-module/, $(SRC_SHARED_MODULE)) \
$(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL))
+# There may be duplicates between SRC_COMMON_HAL_EXPANDED and SRC_SHARED_MODULE_EXPANDED,
+# because a few modules have files both in common-hal/ and shared-modules/.
+# Doing a $(sort ...) removes duplicates as part of sorting.
+SRC_COMMON_HAL_SHARED_MODULE_EXPANDED = $(sort $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED))
+
+
SRC_S = supervisor/$(CHIP_FAMILY)_cpu.s
OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_ASF:.c=.o))
-OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
-OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
+OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
ifeq ($(INTERNAL_LIBM),1)
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
endif
@@ -310,9 +315,18 @@ SRC_QSTR_PREPROCESSOR += peripherals/samd/$(CHIP_FAMILY)/clocks.c
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
-$(BUILD)/firmware.elf: $(OBJ)
+LD_FILE = $(BUILD)/$(notdir $(patsubst %.template.ld,%.ld,$(LD_TEMPLATE_FILE)))
+
+# ld_defines.pp is generated from ld_defines.c. See py/mkrules.mk.
+# Run gen_ld_files.py over ALL *.template.ld files, not just LD_TEMPLATE_FILE,
+# because it may include other template files.
+$(LD_FILE): $(BUILD)/ld_defines.pp boards/*.template.ld
+ $(STEPECHO) "GEN $@"
+ $(Q)$(PYTHON3) $(TOP)/tools/gen_ld_files.py --defines $< --out_dir $(BUILD) boards/*.template.ld
+
+$(BUILD)/firmware.elf: $(OBJ) $(LD_FILE)
$(STEPECHO) "LINK $@"
- $(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
+ $(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE)
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
diff --git a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h
index a508d9191..226717c83 100644
--- a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h
+++ b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h
@@ -7,10 +7,6 @@
#define MICROPY_HW_LED_STATUS (&pin_PB23)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA09)
#define DEFAULT_I2C_BUS_SDA (&pin_PA08)
diff --git a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk
index a543468e5..bd682ade0 100644
--- a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x2341
USB_PID = 0x8053
USB_PRODUCT = "Arduino MKR1300"
diff --git a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h
index 02750e646..4871b1798 100644
--- a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h
+++ b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h
@@ -5,10 +5,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA09)
#define DEFAULT_I2C_BUS_SDA (&pin_PA08)
diff --git a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk
index 5612eb88d..894b9b011 100644
--- a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x239A
USB_PID = 0x8050
USB_PRODUCT = "Arduino MKRZero"
diff --git a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h
index ec201e6ef..bf2a68c57 100644
--- a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h
+++ b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h
@@ -10,10 +10,6 @@
#define MICROPY_PORT_B (PORT_PB03)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk
index cbbf15a3e..f94ec13b7 100644
--- a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x2341
USB_PID = 0x824D
USB_PRODUCT = "Arduino Zero"
diff --git a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.h b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.h
index 561240c69..cbfb11d20 100644
--- a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.h
+++ b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.h
@@ -5,6 +5,7 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
+// No microcontroller.nvm
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
#define DEFAULT_I2C_BUS_SCL (&pin_PA08)
@@ -17,8 +18,6 @@
#define DEFAULT_UART_BUS_RX (&pin_PA01)
#define DEFAULT_UART_BUS_TX (&pin_PA00)
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
-
#define IGNORE_PIN_PA03 1
#define IGNORE_PIN_PA12 1
#define IGNORE_PIN_PA13 1
diff --git a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk
index 08e42aa4e..c3f0750a9 100644
--- a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x1209
USB_PID = 0xBAB3
USB_PRODUCT = "Bast Pro Mini M0"
diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.h b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.h
index f4e40739b..d359687e1 100644
--- a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.h
+++ b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.h
@@ -3,7 +3,6 @@
#define CIRCUITPY_MCU_FAMILY samd51
-
#define MICROPY_HW_LED_STATUS (&pin_PA22)
// These are pins not to reset.
@@ -14,14 +13,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk
index f390a8681..0ff6f58ea 100644
--- a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x04D8
USB_PID = 0xEDB3
USB_PRODUCT = "Programmable USB Hub"
diff --git a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.h b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.h
index 7a32bf023..b92c2a65e 100644
--- a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.h
+++ b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.h
@@ -7,14 +7,10 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
#define DEFAULT_SPI_BUS_SCK (&pin_PA19)
#define DEFAULT_SPI_BUS_MOSI (&pin_PA18)
#define DEFAULT_SPI_BUS_MISO (&pin_PA22)
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define IGNORE_PIN_PA00 1
#define IGNORE_PIN_PA01 1
#define IGNORE_PIN_PA02 1
diff --git a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk
index 2399aad5c..adae4beb2 100644
--- a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x1209
USB_PID = 0xBAB2
USB_PRODUCT = "CatWAN USBStick"
diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h
index e6a7e0676..0ed5262ab 100644
--- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h
@@ -22,12 +22,6 @@
#define SPEAKER_ENABLE_PIN (&pin_PA30)
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define CALIBRATE_CRYSTALLESS 1
// Explanation of how a user got into safe mode.
diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk
index 3c43776f5..cdbdf44f8 100644
--- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x8019
USB_PRODUCT = "CircuitPlayground Express"
diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h
index ca6f9b773..2db512929 100644
--- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h
+++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h
@@ -22,12 +22,6 @@
#define SPEAKER_ENABLE_PIN (&pin_PA30)
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define CALIBRATE_CRYSTALLESS 1
// Explanation of how a user got into safe mode.
diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk
index f456515f9..a6ed28aa7 100644
--- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x8019
USB_PRODUCT = "CircuitPlayground Express with Crickit libraries"
diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h
index 333fc79f9..a1d5b0a67 100644
--- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h
+++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h
@@ -22,12 +22,6 @@
#define SPEAKER_ENABLE_PIN (&pin_PA30)
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define CALIBRATE_CRYSTALLESS 1
// Explanation of how a user got into safe mode.
diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk
index f0c9c6b8c..b5a7c2424 100644
--- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x8019
USB_PRODUCT = "CircuitPlayground Express with displayio"
diff --git a/ports/atmel-samd/boards/common.template.ld b/ports/atmel-samd/boards/common.template.ld
new file mode 100644
index 000000000..e02bbfab0
--- /dev/null
+++ b/ports/atmel-samd/boards/common.template.ld
@@ -0,0 +1,89 @@
+/* Template for SAMD21/SAMD51 linking. dollar-sign-curly-bracket items are replaced with strings. */
+
+/* Specify the memory areas */
+MEMORY
+{
+ /* CIRCUITPY_BOOTLOADER_SIZE is size of bootloader, if any.
+ * SAMD21 Arduino and UF2 bootloaders are 8KiB. SAMD51 UF2 is 6KiB.
+ * FLASH_SIZE is defined in ASF4.
+ * RAM_SIZE is defined in mpconfigport.h, from constants from ASF4.
+ * CIRCUITPY_INTERNAL_CONFIG_SIZE is size of an optional hidden config area, used currently
+ * for crystalless USB timing calibration.
+ * CIRCUITPY_INTERNAL_NVM_SIZE is the size of microntroller.nvm.
+ */
+ FLASH (rx) : ORIGIN = 0x00000000 + ${BOOTLOADER_SIZE}, LENGTH = ${FLASH_SIZE} - ${BOOTLOADER_SIZE} - ${CIRCUITPY_INTERNAL_CONFIG_SIZE} - ${CIRCUITPY_INTERNAL_NVM_SIZE}
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = ${RAM_SIZE}
+}
+
+/* top end of the stack */
+/* stack must be double-word (8 byte) aligned */
+_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
+_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
+
+/* define output sections */
+SECTIONS
+{
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors)) /* isr vector table */
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.exidx :
+ {
+ *(.ARM.exidx*)
+ *(.gnu.linkonce.armexidx.*)
+ _etext = .; /* define a global symbol at end of code */
+ _sidata = .; /* start of .data section */
+ } > FLASH
+
+ /* This is the initialized data section
+ The program executes knowing that the data is in the RAM
+ but the loader puts the initial values in the FLASH (inidata).
+ It is one task of the startup to copy the initial values from FLASH to RAM. */
+ .data : AT ( _sidata )
+ {
+ . = ALIGN(4);
+ _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialize the .data section in RAM */
+ *(.ramfunc)
+ *(.ramfunc*)
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialize the .data section in RAM */
+ } >RAM
+
+ /* Uninitialized data section */
+ .bss :
+ {
+ . = ALIGN(4);
+ _sbss = .;
+ _szero = .; /* define a global symbol at bss start; used by startup code */
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ezero = .; /* define a global symbol at bss end; used by startup code */
+ _ebss = .;
+ } >RAM
+
+ /* this just checks there is enough RAM for the requested stack. */
+ .stack :
+ {
+ . = ALIGN(4);
+ . = . + ${CIRCUITPY_DEFAULT_STACK_SIZE};
+ . = ALIGN(4);
+ } >RAM
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.h b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.h
index 9e329b3ed..8664a6a0e 100644
--- a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.h
+++ b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.h
@@ -12,14 +12,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PB09)
#define DEFAULT_I2C_BUS_SDA (&pin_PB08)
diff --git a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk
index 86a7719b8..25ec50162 100644
--- a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x20-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8021
USB_PRODUCT = "CP32-M4"
diff --git a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h
index 99167d31b..f560cfa49 100644
--- a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h
+++ b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h
@@ -20,14 +20,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
diff --git a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk
index aa5f47d40..b2823e30c 100644
--- a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x4097
USB_PID = 0x0001
USB_PRODUCT = "Datalore IP M4"
diff --git a/ports/atmel-samd/boards/datum_distance/mpconfigboard.h b/ports/atmel-samd/boards/datum_distance/mpconfigboard.h
index e02e43780..74706ba04 100644
--- a/ports/atmel-samd/boards/datum_distance/mpconfigboard.h
+++ b/ports/atmel-samd/boards/datum_distance/mpconfigboard.h
@@ -10,10 +10,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk b/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk
index a7bb8293d..4f6c7ab82 100644
--- a/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x04D8
USB_PID = 0xEE8C
USB_PRODUCT = "datum-Distance"
diff --git a/ports/atmel-samd/boards/datum_imu/mpconfigboard.h b/ports/atmel-samd/boards/datum_imu/mpconfigboard.h
index b87739dd0..3cc218f9e 100644
--- a/ports/atmel-samd/boards/datum_imu/mpconfigboard.h
+++ b/ports/atmel-samd/boards/datum_imu/mpconfigboard.h
@@ -10,10 +10,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk
index 507c83b04..336a1b832 100644
--- a/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x04D8
USB_PID = 0xEE8D
USB_PRODUCT = "datum-IMU"
diff --git a/ports/atmel-samd/boards/datum_light/mpconfigboard.h b/ports/atmel-samd/boards/datum_light/mpconfigboard.h
index 2a91c112d..33e80d06d 100644
--- a/ports/atmel-samd/boards/datum_light/mpconfigboard.h
+++ b/ports/atmel-samd/boards/datum_light/mpconfigboard.h
@@ -10,10 +10,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/datum_light/mpconfigboard.mk b/ports/atmel-samd/boards/datum_light/mpconfigboard.mk
index 4bb227ba4..7ec2efcf9 100644
--- a/ports/atmel-samd/boards/datum_light/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/datum_light/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x04D8
USB_PID = 0xEE8E
USB_PRODUCT = "datum-Light"
diff --git a/ports/atmel-samd/boards/datum_weather/mpconfigboard.h b/ports/atmel-samd/boards/datum_weather/mpconfigboard.h
index 45619197b..328a6860c 100644
--- a/ports/atmel-samd/boards/datum_weather/mpconfigboard.h
+++ b/ports/atmel-samd/boards/datum_weather/mpconfigboard.h
@@ -10,10 +10,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk b/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk
index 411aee625..d3ec1b0fd 100644
--- a/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x04D8
USB_PID = 0xEE8F
USB_PRODUCT = "datum-Weather"
diff --git a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h
index f27cb533b..3a984188f 100644
--- a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h
+++ b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h
@@ -8,12 +8,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define CALIBRATE_CRYSTALLESS 1
// Explanation of how a user got into safe mode.
diff --git a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk
index a2c182e68..dedd49ff7 100644
--- a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x1209
USB_PID = 0xBAB6
USB_PRODUCT = "Escornabot Makech"
diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
index eb1b90585..a0fde67ef 100644
--- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
@@ -8,10 +8,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA22)
#define DEFAULT_I2C_BUS_SDA (&pin_PA23)
diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk
index a88dbd563..134abf723 100644
--- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x239A
USB_PID = 0x8015
USB_PRODUCT = "Feather M0 Adalogger"
diff --git a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h
index a16cee0b4..41a4bde21 100644
--- a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h
@@ -8,10 +8,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk
index 076f1f8ff..364374350 100644
--- a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x239A
USB_PID = 0x8015
USB_PRODUCT = "Feather M0"
diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
index e6cd1c729..5421dc889 100644
--- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h
@@ -15,13 +15,6 @@
#define MICROPY_PORT_B ( 0 )
#define MICROPY_PORT_C ( 0 )
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk
index 5b89f1be4..cdee7b794 100644
--- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8023
USB_PRODUCT = "Feather M0 Express"
diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h
index 77146889e..ee61e1d87 100644
--- a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h
@@ -15,12 +15,6 @@
#define MICROPY_PORT_B ( 0 )
#define MICROPY_PORT_C ( 0 )
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk
index 5793d82e5..d5e03b49d 100644
--- a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8023
USB_PRODUCT = "Feather M0 Express"
diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h
index 19a514758..2a319a412 100644
--- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h
@@ -8,10 +8,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk
index 83d794d04..40a461b27 100644
--- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x239A
USB_PID = 0x8015
USB_PRODUCT = "Feather M0 RFM69"
diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h
index d3db098e5..850033dbe 100644
--- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h
@@ -8,10 +8,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk
index a84e14f55..736161047 100644
--- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x239A
USB_PID = 0x8015
USB_PRODUCT = "Feather M0 RFM9x"
diff --git a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h
index 5ad265bf1..2d9f88e2e 100644
--- a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h
@@ -17,12 +17,6 @@
#define MICROPY_PORT_B ( 0 )
#define MICROPY_PORT_C ( 0 )
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk
index c5fef4373..cb13adb76 100644
--- a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8023
USB_PRODUCT = "Feather M0 Supersized"
diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h
index f65ea8db7..ba16d17ee 100644
--- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h
@@ -16,14 +16,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define EXTERNAL_FLASH_QSPI_DUAL
#define BOARD_HAS_CRYSTAL 1
diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk
index 176ebac82..d736941df 100644
--- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8026
USB_PRODUCT = "Feather M4 Express"
diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h
index 7df31f3a9..2afe35817 100755
--- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h
+++ b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h
@@ -14,12 +14,6 @@
#define MICROPY_PORT_B ( 0 )
#define MICROPY_PORT_C ( 0 )
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk
index c4a3a5a19..05c305b1a 100755
--- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8023
USB_PRODUCT = "Feather RadioFruit Zigbee"
diff --git a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h
index 5f09ab4d2..b6d8f946b 100644
--- a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h
+++ b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h
@@ -10,16 +10,12 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA05)
#define DEFAULT_I2C_BUS_SDA (&pin_PA04)
#define DEFAULT_UART_BUS_RX (&pin_PA05)
#define DEFAULT_UART_BUS_TX (&pin_PA04)
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define IGNORE_PIN_PA03 1
#define IGNORE_PIN_PA06 1
#define IGNORE_PIN_PA07 1
diff --git a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk
index 6f44a22f8..d64938632 100644
--- a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x239A
USB_PID = 0x801D
USB_PRODUCT = "Gemma M0"
diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h
index bc8f5a134..bab055014 100644
--- a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h
@@ -21,14 +21,6 @@
#define MICROPY_PORT_C ( PORT_PC24 | PORT_PC30 | PORT_PC31 )
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_PB21)
diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk
index 423761c3f..49331a705 100644
--- a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x20-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8032
USB_PRODUCT = "Grand Central M4 Express"
diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h
index d5c274500..e5ac346da 100644
--- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h
@@ -16,12 +16,6 @@
#define MICROPY_PORT_B ( PORT_PB22 | PORT_PB23 )
#define MICROPY_PORT_C ( 0 )
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA17)
#define DEFAULT_I2C_BUS_SDA (&pin_PA16)
diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk
index 988d10d1c..af4a5a293 100644
--- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0xD1ED
USB_PRODUCT = "HalloWing M0 Express"
diff --git a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h
index 654632db5..a0c726e72 100644
--- a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.h
@@ -16,14 +16,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)
diff --git a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk
index 0d891abc8..9379ed3fe 100644
--- a/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/hallowing_m4_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x804A
USB_PRODUCT = "Hallowing M4 Express"
diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h
index 6f9f661d9..db5e2a4df 100644
--- a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h
@@ -16,12 +16,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk
index 2b64e9027..4d516c75b 100644
--- a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x8012
USB_PRODUCT = "ItsyBitsy M0 Express"
@@ -21,4 +20,3 @@ CIRCUITPY_RTC = 0
CFLAGS_INLINE_LIMIT = 60
SUPEROPT_GC = 0
-
diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h
index 9e4d4a10c..98920b54f 100644
--- a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h
@@ -17,14 +17,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)
diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk
index 5cab5bf43..7ce45d0a1 100644
--- a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x802C
USB_PRODUCT = "ItsyBitsy M4 Express"
diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h
index 194542b05..6664524d2 100644
--- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h
+++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.h
@@ -14,8 +14,6 @@
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - 0x010000)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA17)
#define DEFAULT_I2C_BUS_SDA (&pin_PA16)
diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
index 706e551c5..6d6571a2a 100644
--- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader.ld
USB_VID = 0x04D8
USB_PID = 0xED94
USB_PRODUCT = "kicksat-sprite"
diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.h b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h
index 1304b6dfb..80d367863 100644
--- a/ports/atmel-samd/boards/meowmeow/mpconfigboard.h
+++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h
@@ -8,12 +8,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define CALIBRATE_CRYSTALLESS 1
// Explanation of how a user got into safe mode.
diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk
index 894e19a6b..4b452ecbf 100644
--- a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x1209
USB_PID = 0xBAB1
USB_PRODUCT = "Meow Meow"
diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h
index bfa254b95..04565feb4 100644
--- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h
@@ -21,12 +21,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk
index d3f35ba8b..b52b1343f 100644
--- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8014
USB_PRODUCT = "Metro M0 Express"
diff --git a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.h b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.h
index e89b0322a..9fa401804 100644
--- a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.h
+++ b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.h
@@ -18,14 +18,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
diff --git a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk
index 98d85ba82..78e27b422 100644
--- a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8038
USB_PRODUCT = "Metro M4 Airlift Lite"
diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h
index 2a8878874..7f8dbb1d2 100644
--- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h
@@ -20,14 +20,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk
index 68b6f6406..4f01f3edd 100644
--- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8021
USB_PRODUCT = "Metro M4 Express"
diff --git a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h
index c4563964f..08ab7e16b 100644
--- a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h
+++ b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h
@@ -17,14 +17,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)
diff --git a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk
index 4bd1d6e52..eedfd2ecc 100644
--- a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x1209
USB_PID = 0x2017
USB_PRODUCT = "Mini SAM M4"
diff --git a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h
index fc77520f5..42fb4548e 100644
--- a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h
+++ b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h
@@ -13,14 +13,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA01)
#define DEFAULT_I2C_BUS_SDA (&pin_PA00)
diff --git a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk
index a3db7dc89..e61f3d240 100644
--- a/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/monster_m4sk/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8048
USB_PRODUCT = "Monster M4SK"
diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h
index 445ccc435..6b3b4aa15 100644
--- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h
@@ -5,11 +5,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
-
#define IGNORE_PIN_PB00 1
#define IGNORE_PIN_PB01 1
#define IGNORE_PIN_PB02 1
diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk
index e24a29051..c9aa26e3c 100644
--- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x239A
USB_PID = 0x801D
USB_PRODUCT = "PewPew 10.2"
diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h
index 1b3035e12..60cd8d754 100644
--- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h
@@ -9,14 +9,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA01)
#define DEFAULT_I2C_BUS_SDA (&pin_PA00)
@@ -48,4 +40,3 @@
#define IGNORE_PIN_PB09 1
#define IGNORE_PIN_PB10 1
#define IGNORE_PIN_PB11 1
-
diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk
index 54ec3d1d0..af7e3fb16 100644
--- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader.ld
USB_VID = 0x1d50
USB_PID = 0x60e8
USB_PRODUCT = "PewPew M4"
diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h
index 5a8eb9d14..866e21991 100644
--- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h
@@ -8,10 +8,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define IGNORE_PIN_PA02 1
#define IGNORE_PIN_PA03 1
#define IGNORE_PIN_PA04 1
diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk
index 686c9099f..c5b2c9eb5 100644
--- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x239A
USB_PID = 0x8028
USB_PRODUCT = "pIRKey M0"
diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.h b/ports/atmel-samd/boards/pybadge/mpconfigboard.h
index 36115bc87..435185322 100644
--- a/ports/atmel-samd/boards/pybadge/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.h
@@ -14,14 +14,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)
diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk
index 7e2cb6439..05df09627 100644
--- a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8034
USB_PRODUCT = "PyBadge"
diff --git a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h
index ade74786d..229cfa335 100644
--- a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h
@@ -14,14 +14,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)
diff --git a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk
index 7e77b0fea..242722870 100644
--- a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8043
USB_PRODUCT = "PyBadge AirLift"
diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.h b/ports/atmel-samd/boards/pygamer/mpconfigboard.h
index 4720b22eb..102c25956 100644
--- a/ports/atmel-samd/boards/pygamer/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.h
@@ -13,14 +13,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)
diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk
index 0fce468d9..70109e332 100644
--- a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x803E
USB_PRODUCT = "PyGamer"
diff --git a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h
index c05aa4f06..fbe946b72 100644
--- a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h
@@ -13,14 +13,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA13)
#define DEFAULT_I2C_BUS_SDA (&pin_PA12)
diff --git a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk
index 8711738d4..7f3207ecd 100644
--- a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x803E
USB_PRODUCT = "PyGamer Advance"
diff --git a/ports/atmel-samd/boards/pyportal/mpconfigboard.h b/ports/atmel-samd/boards/pyportal/mpconfigboard.h
index 43346488b..2c4cf4f58 100644
--- a/ports/atmel-samd/boards/pyportal/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pyportal/mpconfigboard.h
@@ -17,14 +17,6 @@
#define MICROPY_PORT_C ( 0 )
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)
diff --git a/ports/atmel-samd/boards/pyportal/mpconfigboard.mk b/ports/atmel-samd/boards/pyportal/mpconfigboard.mk
index f763c74fa..149141a4e 100644
--- a/ports/atmel-samd/boards/pyportal/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pyportal/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x20-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8036
USB_PRODUCT = "PyPortal"
diff --git a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h
index 91c118810..c463b5661 100644
--- a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h
@@ -16,14 +16,6 @@
#define MICROPY_PORT_C ( 0 )
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)
diff --git a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk
index 58b363779..dbc2d5ae9 100644
--- a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x20-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8054
USB_PRODUCT = "PyPortal Titano"
diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.h b/ports/atmel-samd/boards/pyruler/mpconfigboard.h
index 171873b47..4d0586d91 100644
--- a/ports/atmel-samd/boards/pyruler/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.h
@@ -10,10 +10,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define IGNORE_PIN_PA12 1
#define IGNORE_PIN_PA13 1
#define IGNORE_PIN_PA16 1
diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk
index 9663944a3..220e48872 100644
--- a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x239A
USB_PID = 0x804C
USB_PRODUCT = "PyRuler"
diff --git a/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.h b/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.h
index c6856c68f..68991f997 100644
--- a/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.h
+++ b/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.h
@@ -17,13 +17,6 @@
#define MICROPY_PORT_B ( 0 )
#define MICROPY_PORT_C ( 0 )
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define CALIBRATE_CRYSTALLESS 1
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
@@ -39,4 +32,3 @@
// USB is always used internally so skip the pin objects for it.
#define IGNORE_PIN_PA24 1
#define IGNORE_PIN_PA25 1
-
diff --git a/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.mk b/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.mk
index e703fbfb9..29cca569e 100644
--- a/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/robohatmm1_m0/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x1209
USB_PID = 0x4D43
USB_PRODUCT = "Robo HAT MM1 M0"
diff --git a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.h b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.h
index 64040a658..c66873aeb 100644
--- a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.h
+++ b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.h
@@ -21,14 +21,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk
index 56f1617db..b2ea18e5f 100644
--- a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x1209
USB_PID = 0x4D43
USB_PRODUCT = "Robo HAT MM1 M4"
diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.h b/ports/atmel-samd/boards/sam32/mpconfigboard.h
index f6d3fb6b4..3c6f52ebc 100644
--- a/ports/atmel-samd/boards/sam32/mpconfigboard.h
+++ b/ports/atmel-samd/boards/sam32/mpconfigboard.h
@@ -11,12 +11,9 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
+// No microcontroller.nvm
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - 0x010000)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_PA04)
diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.mk b/ports/atmel-samd/boards/sam32/mpconfigboard.mk
index 12884a9cc..0d6be6437 100644
--- a/ports/atmel-samd/boards/sam32/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/sam32/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x20-bootloader.ld
USB_VID = 0x04D8
USB_PID = 0xEDBE
USB_PRODUCT = "SAM32"
diff --git a/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld b/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld
index 2adf4fa90..1ee745eb1 100644
--- a/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld
+++ b/ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld
@@ -10,75 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
-/* top end of the stack */
-/* stack must be double-word (8 byte) aligned */
-_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
-_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialize the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialize the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 2K; /* Reserve a minimum of 2K for the stack. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd21-common.ld"
diff --git a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld
index bddaae99d..d8f4cc236 100644
--- a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld
+++ b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash-crystalless.ld
@@ -10,75 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
-/* top end of the stack */
-/* stack must be double-word (8 byte) aligned */
-_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
-_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 2K; /* Reserve a minimum of 2K for the stack. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd21-common.ld"
diff --git a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld
index 4e677a079..f663326d6 100644
--- a/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld
+++ b/ports/atmel-samd/boards/samd21x18-bootloader-external-flash.ld
@@ -10,75 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K /* 32 KiB RAM */
}
-/* top end of the stack */
-/* stack must be double-word (8 byte) aligned */
-_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
-_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _etext )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 2K; /* Reserve a minimum of 2K for the stack. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd21-common.ld"
diff --git a/ports/atmel-samd/boards/samd21x18-bootloader.ld b/ports/atmel-samd/boards/samd21x18-bootloader.ld
index 2ef09ba9a..666ac79c4 100644
--- a/ports/atmel-samd/boards/samd21x18-bootloader.ld
+++ b/ports/atmel-samd/boards/samd21x18-bootloader.ld
@@ -11,75 +11,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
-/* top end of the stack */
-/* stack must be double-word (8 byte) aligned */
-_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
-_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialize the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialize the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 2K; /* Reserve a minimum of 2K for the stack. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd21-common.ld"
diff --git a/ports/atmel-samd/boards/samd21x18-external-flash.ld b/ports/atmel-samd/boards/samd21x18-external-flash.ld
index a540bfde2..6afdab734 100644
--- a/ports/atmel-samd/boards/samd21x18-external-flash.ld
+++ b/ports/atmel-samd/boards/samd21x18-external-flash.ld
@@ -10,74 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
-/* top end of the stack */
-_estack = ORIGIN(RAM) + LENGTH(RAM);
-_bootloader_dbl_tap = 0;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 2K; /* Reserve a minimum of 2K for the stack. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd21-common.ld"
diff --git a/ports/atmel-samd/boards/samd21x18.ld b/ports/atmel-samd/boards/samd21x18.ld
index 139be86bb..c035f5117 100644
--- a/ports/atmel-samd/boards/samd21x18.ld
+++ b/ports/atmel-samd/boards/samd21x18.ld
@@ -10,74 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
-/* top end of the stack */
-_estack = ORIGIN(RAM) + LENGTH(RAM);
-_bootloader_dbl_tap = 0;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
-/* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 2K; /* Reserve a minimum of 2K for the stack. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd21-common.ld"
diff --git a/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld
index c0e812ce1..b22bef3f3 100644
--- a/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld
+++ b/ports/atmel-samd/boards/samd51x18-bootloader-external-flash.ld
@@ -10,75 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
}
-/* top end of the stack */
-/* stack must be double-word (8 byte) aligned */
-_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
-_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd51-common.ld"
diff --git a/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld
index 253a764c9..f1493f251 100644
--- a/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld
+++ b/ports/atmel-samd/boards/samd51x19-bootloader-external-flash.ld
@@ -10,75 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
}
-/* top end of the stack */
-/* stack must be double-word (8 byte) aligned */
-_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
-_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd51-common.ld"
diff --git a/ports/atmel-samd/boards/samd51x19-bootloader.ld b/ports/atmel-samd/boards/samd51x19-bootloader.ld
index 56786a37a..c73db2ece 100644
--- a/ports/atmel-samd/boards/samd51x19-bootloader.ld
+++ b/ports/atmel-samd/boards/samd51x19-bootloader.ld
@@ -10,75 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
}
-/* top end of the stack */
-/* stack must be double-word (8 byte) aligned */
-_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
-_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd51-common.ld"
diff --git a/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld b/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld
index 598915b1b..ee28fdf1c 100644
--- a/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld
+++ b/ports/atmel-samd/boards/samd51x20-bootloader-external-flash.ld
@@ -10,75 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
}
-/* top end of the stack */
-/* stack must be double-word (8 byte) aligned */
-_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
-_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd51-common.ld"
diff --git a/ports/atmel-samd/boards/samd51x20-bootloader.ld b/ports/atmel-samd/boards/samd51x20-bootloader.ld
index 49d4d8791..ea0e0569f 100644
--- a/ports/atmel-samd/boards/samd51x20-bootloader.ld
+++ b/ports/atmel-samd/boards/samd51x20-bootloader.ld
@@ -9,76 +9,4 @@ MEMORY
FLASH (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 1M - 16K - 512K - 8K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
}
-
-/* top end of the stack */
-/* stack must be double-word (8 byte) aligned */
-_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
-_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd51-common.ld"
diff --git a/ports/atmel-samd/boards/samd51x20-external-flash.ld b/ports/atmel-samd/boards/samd51x20-external-flash.ld
index d3ed90476..5212363fe 100644
--- a/ports/atmel-samd/boards/samd51x20-external-flash.ld
+++ b/ports/atmel-samd/boards/samd51x20-external-flash.ld
@@ -9,74 +9,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
}
-/* top end of the stack */
-_estack = ORIGIN(RAM) + LENGTH(RAM);
-_bootloader_dbl_tap = 0;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd51-common.ld"
diff --git a/ports/atmel-samd/boards/samd51x20.ld b/ports/atmel-samd/boards/samd51x20.ld
index e203c5b7a..1f0b66172 100644
--- a/ports/atmel-samd/boards/samd51x20.ld
+++ b/ports/atmel-samd/boards/samd51x20.ld
@@ -10,74 +10,4 @@ MEMORY
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
}
-/* top end of the stack */
-_estack = ORIGIN(RAM) + LENGTH(RAM);
-_bootloader_dbl_tap = 0;
-
-/* define output sections */
-SECTIONS
-{
- /* The program code and other data goes into FLASH */
- .text :
- {
- . = ALIGN(4);
- _sfixed = .;
- KEEP(*(.vectors)) /* isr vector table */
- *(.text) /* .text sections (code) */
- *(.text*) /* .text* sections (code) */
- *(.rodata) /* .rodata sections (constants, strings, etc.) */
- *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
-
- . = ALIGN(4);
- } >FLASH
-
- .ARM.exidx :
- {
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidx.*)
- _etext = .; /* define a global symbol at end of code */
- _sidata = .; /* start of .data section */
- } > FLASH
-
- /* This is the initialized data section
- The program executes knowing that the data is in the RAM
- but the loader puts the initial values in the FLASH (inidata).
- It is one task of the startup to copy the initial values from FLASH to RAM. */
- .data : AT ( _sidata )
- {
- . = ALIGN(4);
- _srelocate = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
- *(.ramfunc)
- *(.ramfunc*)
- *(.data) /* .data sections */
- *(.data*) /* .data* sections */
-
- . = ALIGN(4);
- _erelocate = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
- } >RAM
-
- /* Uninitialized data section */
- .bss :
- {
- . = ALIGN(4);
- _sbss = .;
- _szero = .; /* define a global symbol at bss start; used by startup code */
- *(.bss)
- *(.bss*)
- *(COMMON)
-
- . = ALIGN(4);
- _ezero = .; /* define a global symbol at bss end; used by startup code */
- _ebss = .;
- } >RAM
-
- /* this just checks there is enough RAM for a minimal stack */
- .stack :
- {
- . = ALIGN(4);
- . = . + 10K; /* Reserve a minimum of 10K for the stack. nvm will temporarily store 8k on the stack when writing. */
- . = ALIGN(4);
- } >RAM
-
- .ARM.attributes 0 : { *(.ARM.attributes) }
-}
+INCLUDE "samd51-common.ld"
diff --git a/ports/atmel-samd/boards/serpente/mpconfigboard.h b/ports/atmel-samd/boards/serpente/mpconfigboard.h
index 034e1f6c3..515bc1441 100644
--- a/ports/atmel-samd/boards/serpente/mpconfigboard.h
+++ b/ports/atmel-samd/boards/serpente/mpconfigboard.h
@@ -13,12 +13,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA09)
#define DEFAULT_I2C_BUS_SDA (&pin_PA08)
@@ -36,4 +30,3 @@
// Not connected
#define IGNORE_PIN_PA13 1
#define IGNORE_PIN_PA28 1
-
diff --git a/ports/atmel-samd/boards/serpente/mpconfigboard.mk b/ports/atmel-samd/boards/serpente/mpconfigboard.mk
index 98e1e3729..a5adb17a1 100644
--- a/ports/atmel-samd/boards/serpente/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/serpente/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x8058
USB_PRODUCT = "Serpente"
diff --git a/ports/atmel-samd/boards/snekboard/mpconfigboard.h b/ports/atmel-samd/boards/snekboard/mpconfigboard.h
index a349143d9..1c0804fe7 100644
--- a/ports/atmel-samd/boards/snekboard/mpconfigboard.h
+++ b/ports/atmel-samd/boards/snekboard/mpconfigboard.h
@@ -15,13 +15,6 @@
#define MICROPY_PORT_B ( 0 )
#define MICROPY_PORT_C ( 0 )
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 0
#define DEFAULT_I2C_BUS_SCL (&pin_PA08) /* ANALOG 5 */
diff --git a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk
index db2e511ab..4faa041b1 100644
--- a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x804E
USB_PRODUCT = "snekboard"
diff --git a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.h
index 80cacfa9b..d184945f3 100755
--- a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.h
+++ b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.h
@@ -13,10 +13,6 @@
#define MICROPY_PORT_B ( 0 )
#define MICROPY_PORT_C ( 0 )
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
//I2C
diff --git a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk
index 9d0ef1c04..6a2afc306 100755
--- a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x1B4F
USB_PID = 0x0017
USB_PRODUCT = "LUMIDrive Board"
diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.h
index cf7c3998b..ae272d502 100755
--- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.h
+++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.h
@@ -15,20 +15,12 @@
#define SPI_FLASH_SCK_PIN &pin_PB23
#define SPI_FLASH_CS_PIN &pin_PA13
-#define MICROPY_PORT_A ( 0 )
+#define MICROPY_PORT_A ( 0 )
#define MICROPY_PORT_B ( 0 )
#define MICROPY_PORT_C ( 0 )
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
-
// I2C - also QWIIC
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk
index e80ef6277..f2d4eccad 100755
--- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x1B4F
USB_PID = 0x0015
USB_PRODUCT = "RedBoard Turbo Board"
diff --git a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.h
index a50c61cf2..13bb26380 100644
--- a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.h
+++ b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.h
@@ -5,10 +5,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk
index c9d0baf11..0c33ef960 100644
--- a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x1B4F
USB_PID = 0x8D23
USB_PRODUCT = "SparkFun SAMD21 Dev Breakout"
diff --git a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h
index 6af7fa191..2cfdd9e73 100644
--- a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h
+++ b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h
@@ -5,10 +5,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
diff --git a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk
index a6e216575..d09785fb8 100644
--- a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x1B4F
USB_PID = 0x8D22
USB_PRODUCT = "SparkFun SAMD21 Mini Breakout"
diff --git a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.h
index 34ab8fcfb..02a6e7f7c 100644
--- a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.h
@@ -16,12 +16,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA05)
#define DEFAULT_I2C_BUS_SDA (&pin_PA04)
@@ -47,4 +41,3 @@
#define IGNORE_PIN_PA28 1
#define IGNORE_PIN_PA30 1
#define IGNORE_PIN_PA31 1
-
diff --git a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk
index 17de6ac74..92129eb63 100644
--- a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x8060
USB_PRODUCT = "StringCar M0 Express"
@@ -21,4 +20,3 @@ CIRCUITPY_RTC = 0
CFLAGS_INLINE_LIMIT = 60
SUPEROPT_GC = 0
-
diff --git a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h
index 8ca1df162..96b38810c 100644
--- a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h
+++ b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h
@@ -16,14 +16,6 @@
#define MICROPY_PORT_C (0)
#define MICROPY_PORT_D (0)
-#define AUTORESET_DELAY_MS 500
-
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code
-#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PB08)
#define DEFAULT_I2C_BUS_SDA (&pin_PB09)
diff --git a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk
index ec37186c3..379520872 100644
--- a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd51x19-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8030
USB_PRODUCT = "Trellis M4 Express"
diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h
index dd8bc03cc..69517534e 100644
--- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h
+++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h
@@ -11,10 +11,6 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define IGNORE_PIN_PA03 1
#define IGNORE_PIN_PA04 1
#define IGNORE_PIN_PA11 1
diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk
index b4a00b654..0d41fa4bd 100644
--- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk
@@ -1,4 +1,4 @@
-LD_FILE = boards/samd21x18-bootloader.ld
+LD_TEMPLATE_FILE = boards/common.template.ld
USB_VID = 0x239A
USB_PID = 0x801F
USB_PRODUCT = "Trinket M0"
diff --git a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h
index 369d84b8b..af473b128 100644
--- a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h
+++ b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h
@@ -18,12 +18,6 @@
#define CALIBRATE_CRYSTALLESS 1
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_PA09)
#define DEFAULT_I2C_BUS_SDA (&pin_PA08)
diff --git a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk
index c20358e19..bd6c9c9ff 100644
--- a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x801F
USB_PRODUCT="Trinket M0 Haxpress"
diff --git a/ports/atmel-samd/boards/uchip/mpconfigboard.h b/ports/atmel-samd/boards/uchip/mpconfigboard.h
index 6dcaf2965..1877a41ef 100644
--- a/ports/atmel-samd/boards/uchip/mpconfigboard.h
+++ b/ports/atmel-samd/boards/uchip/mpconfigboard.h
@@ -7,11 +7,9 @@
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
+// No microcontroller.nvm
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
-
-
// USB is always used internally so skip the pin objects for it.
#define IGNORE_PIN_PA24 1
#define IGNORE_PIN_PA25 1
diff --git a/ports/atmel-samd/boards/uchip/mpconfigboard.mk b/ports/atmel-samd/boards/uchip/mpconfigboard.mk
index 109492b76..950910e48 100644
--- a/ports/atmel-samd/boards/uchip/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/uchip/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader.ld
USB_VID = 0x04D8
USB_PID = 0xED5F
USB_PRODUCT = "uChip CircuitPython"
diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.h b/ports/atmel-samd/boards/ugame10/mpconfigboard.h
index b5590d986..550172a51 100644
--- a/ports/atmel-samd/boards/ugame10/mpconfigboard.h
+++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.h
@@ -13,12 +13,6 @@
#define CALIBRATE_CRYSTALLESS 1
-// If you change this, then make sure to update the linker scripts as well to
-// make sure you don't overwrite code.
-#define CIRCUITPY_INTERNAL_NVM_SIZE 256
-
-#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_SPI_BUS_SCK (&pin_PA07)
#define DEFAULT_SPI_BUS_MISO (&pin_PA11)
#define DEFAULT_SPI_BUS_MOSI (&pin_PA06)
diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk
index f0310b4aa..1c4336907 100644
--- a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk
@@ -1,4 +1,3 @@
-LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x801F
USB_PRODUCT = "uGame10"
diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c
index cb0751ace..41dee2b49 100644
--- a/ports/atmel-samd/common-hal/microcontroller/__init__.c
+++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c
@@ -92,7 +92,6 @@ const mcu_processor_obj_t common_hal_mcu_processor_obj = {
},
};
-// NVM is only available on Express boards for now.
#if CIRCUITPY_INTERNAL_NVM_SIZE > 0
// The singleton nvm.ByteArray object.
const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
diff --git a/ports/atmel-samd/ld_defines.c b/ports/atmel-samd/ld_defines.c
new file mode 100644
index 000000000..62838ca4b
--- /dev/null
+++ b/ports/atmel-samd/ld_defines.c
@@ -0,0 +1,14 @@
+// Fake source file used only to capture #define values for use in ld template files.
+#include "mpconfigport.h"
+
+// For each value needed in the LD file, create a C-like line:
+// NAME_OF_VALUE; ///DEFINE_VALUE NAME_OF_VALUE <optional Python lambda expression to transform value>
+// The C preprocessor will replace NAME_OF_VALUE with the actual value.
+// This will be post-processed by tools/gen_ld_files.py to extract the name and vlaue.
+
+BOOTLOADER_SIZE; ///DEFINE_VALUE BOOTLOADER_SIZE
+RAM_SIZE; ///DEFINE_VALUE RAM_SIZE lambda f: f.rstrip("UL")
+FLASH_SIZE; ///DEFINE_VALUE FLASH_SIZE lambda f: f.rstrip("UL")
+CIRCUITPY_INTERNAL_CONFIG_SIZE; ///DEFINE_VALUE CIRCUITPY_INTERNAL_CONFIG_SIZE
+CIRCUITPY_INTERNAL_NVM_SIZE; ///DEFINE_VALUE CIRCUITPY_INTERNAL_NVM_SIZE
+CIRCUITPY_DEFAULT_STACK_SIZE; ///DEFINE_VALUE CIRCUITPY_DEFAULT_STACK_SIZE
diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h
index 4e15a6c30..21adb1002 100644
--- a/ports/atmel-samd/mpconfigport.h
+++ b/ports/atmel-samd/mpconfigport.h
@@ -31,6 +31,30 @@
#include "include/sam.h"
#ifdef SAMD21
+
+// Default is 0, set by py/circuitpy_mpconfig.h
+#if INTERNAL_FLASH_FILESYSTEM
+// 64kB
+#define INTERNAL_FLASH_FILESYSTEM_SIZE (64*1024)
+#endif
+
+#ifndef CIRCUITPY_INTERNAL_NVM_SIZE
+#define CIRCUITPY_INTERNAL_NVM_SIZE (256)
+#endif
+
+// if CALIBRATE_CRYSTALLESS is requested, make room for storing
+// calibration data generated from external USB.
+#ifndef CIRCUITPY_INTERNAL_CONFIG_SIZE
+ #ifdef CALIBRATE_CRYSTALLESS
+#define CIRCUITPY_INTERNAL_CONFIG_SIZE (256)
+ #else
+#define CIRCUITPY_INTERNAL_CONFIG_SIZE (0)
+ #endif
+#endif
+
+// HMCRAMC0_SIZE is defined in the ASF4 include files for each SAMD21 chip.
+#define RAM_SIZE HMCRAMC0_SIZE
+#define BOOTLOADER_SIZE (8*1024)
#define CIRCUITPY_MCU_FAMILY samd21
#define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21"
#define SPI_FLASH_MAX_BAUDRATE 8000000
@@ -54,9 +78,17 @@
X(EISDIR) \
X(EINVAL) \
-#endif
+#endif // SAMD21
#ifdef SAMD51
+
+#ifndef CIRCUITPY_INTERNAL_NVM_SIZE
+#define CIRCUITPY_INTERNAL_NVM_SIZE (8192)
+#endif
+
+// HSRAM_SIZE is defined in the ASF4 include files for each SAMD51 chip.
+#define RAM_SIZE HSRAM_SIZE
+#define BOOTLOADER_SIZE (16*1024)
#define CIRCUITPY_MCU_FAMILY samd51
#define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51"
#define SPI_FLASH_MAX_BAUDRATE 24000000
@@ -69,7 +101,8 @@
#define MICROPY_PY_UJSON (1)
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
// MICROPY_PY_UERRNO_LIST - Use the default
-#endif
+
+#endif // SAMD51
// Turning off audioio, audiobusio, and touchio as necessary
// due to limitations of chips is handled in mpconfigboard.mk
diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk
index 88ddb49e0..63ddb5f23 100644
--- a/ports/atmel-samd/mpconfigport.mk
+++ b/ports/atmel-samd/mpconfigport.mk
@@ -1,3 +1,7 @@
+# All linking can be done with this common templated linker script, which has
+# parameters that vary based on chip and/or board.
+LD_TEMPLATE_FILE = boards/common.template.ld
+
# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.
diff --git a/ports/atmel-samd/tick.c b/ports/atmel-samd/tick.c
index 4d7bb9dca..6163a64d8 100644
--- a/ports/atmel-samd/tick.c
+++ b/ports/atmel-samd/tick.c
@@ -56,7 +56,7 @@ void SysTick_Handler(void) {
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
filesystem_tick();
#endif
-#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
+#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0
autoreload_tick();
#endif
#ifdef CIRCUITPY_GAMEPAD_TICKS
diff --git a/ports/cxd56/tick.c b/ports/cxd56/tick.c
index 6529db790..6b93a3b65 100644
--- a/ports/cxd56/tick.c
+++ b/ports/cxd56/tick.c
@@ -39,7 +39,7 @@ void board_timerhook(void)
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
filesystem_tick();
#endif
-#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
+#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0
autoreload_tick();
#endif
}
diff --git a/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld b/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld
index 90b8862cf..74e66754d 100644
--- a/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld
+++ b/ports/nrf/boards/adafruit_nrf52840_s140_v6.ld
@@ -19,11 +19,12 @@
/* Specify the memory areas (S140 6.x.x) */
MEMORY
{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x100000
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1M
FLASH_ISR (rx) : ORIGIN = 0x00026000, LENGTH = 0x001000
FLASH_TEXT (rx) : ORIGIN = 0x00027000, LENGTH = 0x086000
FLASH_FATFS (r) : ORIGIN = 0x000AD000, LENGTH = 0x040000
+ FLASH_NVM (r) : ORIGIN = 0x000EC000, LENGTH = 0x001000
FLASH_CONFIG (r): ORIGIN = 0x000ED000, LENGTH = 0x007000
/* 0x2000000 - RAM:ORIGIN is reserved for Softdevice */
diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h
index 1e55cd026..cc441eb0b 100644
--- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h
+++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h
@@ -55,12 +55,6 @@
#define SPI_FLASH_CS_PIN &pin_P0_15
#endif
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define DEFAULT_I2C_BUS_SCL (&pin_P0_04)
#define DEFAULT_I2C_BUS_SDA (&pin_P0_05)
diff --git a/ports/nrf/boards/common.ld b/ports/nrf/boards/common.ld
index dfb355a76..fade4b9e1 100644
--- a/ports/nrf/boards/common.ld
+++ b/ports/nrf/boards/common.ld
@@ -6,6 +6,10 @@ __fatfs_flash_length = LENGTH(FLASH_FATFS);
__config_flash_start_addr = ORIGIN(FLASH_CONFIG);
__config_flash_length = LENGTH(FLASH_CONFIG);
+/* Flash region for microcontroller.nvm region */
+__nvm_flash_start_addr = ORIGIN(FLASH_NVM);
+__nvm_flash_length = LENGTH(FLASH_NVM);
+
/* define output sections */
SECTIONS
{
diff --git a/ports/nrf/boards/electronut_labs_blip/mpconfigboard.h b/ports/nrf/boards/electronut_labs_blip/mpconfigboard.h
index 21e8c3ef6..6b0813e7d 100644
--- a/ports/nrf/boards/electronut_labs_blip/mpconfigboard.h
+++ b/ports/nrf/boards/electronut_labs_blip/mpconfigboard.h
@@ -34,12 +34,6 @@
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "ElectronutLabsPapyr"
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_P0_11)
diff --git a/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h b/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h
index 7f5021fdc..594c3e54c 100644
--- a/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h
+++ b/ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h
@@ -33,12 +33,6 @@
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "ElectronutLabsPapyr"
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_P0_06)
diff --git a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h
index 70ccffc3f..130c5f3e8 100644
--- a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h
+++ b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h
@@ -54,12 +54,6 @@
#define SPI_FLASH_CS_PIN &pin_P0_20
#endif
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_P0_11)
diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h
index ed4836494..093a0df3b 100644
--- a/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h
+++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h
@@ -40,12 +40,6 @@
#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 3)
#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(1, 8)
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 0
#define DEFAULT_UART_BUS_RX (&pin_P0_19)
diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h
index d4096503d..2128428b8 100644
--- a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h
+++ b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h
@@ -33,10 +33,4 @@
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "MakerDiary52840MDKDongle"
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1 // according to the schematic we do
diff --git a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h
index 520eef90d..99ed5c785 100644
--- a/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h
+++ b/ports/nrf/boards/metro_nrf52840_express/mpconfigboard.h
@@ -54,12 +54,6 @@
#define SPI_FLASH_CS_PIN &pin_P0_20
#endif
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_P0_16)
diff --git a/ports/nrf/boards/particle_argon/mpconfigboard.h b/ports/nrf/boards/particle_argon/mpconfigboard.h
index a4ecb2bb4..0d74869b1 100644
--- a/ports/nrf/boards/particle_argon/mpconfigboard.h
+++ b/ports/nrf/boards/particle_argon/mpconfigboard.h
@@ -53,12 +53,6 @@
#define SPI_FLASH_CS_PIN &pin_P0_17
#endif
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_P0_27)
diff --git a/ports/nrf/boards/particle_boron/mpconfigboard.h b/ports/nrf/boards/particle_boron/mpconfigboard.h
index 5e817311f..61af22f58 100644
--- a/ports/nrf/boards/particle_boron/mpconfigboard.h
+++ b/ports/nrf/boards/particle_boron/mpconfigboard.h
@@ -53,12 +53,6 @@
#define SPI_FLASH_CS_PIN &pin_P0_17
#endif
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_P0_27)
diff --git a/ports/nrf/boards/particle_xenon/mpconfigboard.h b/ports/nrf/boards/particle_xenon/mpconfigboard.h
index 6c8cc7cef..c2dfffde8 100644
--- a/ports/nrf/boards/particle_xenon/mpconfigboard.h
+++ b/ports/nrf/boards/particle_xenon/mpconfigboard.h
@@ -53,12 +53,6 @@
#define SPI_FLASH_CS_PIN &pin_P0_17
#endif
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
-
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_P0_27)
diff --git a/ports/nrf/boards/pca10056/mpconfigboard.h b/ports/nrf/boards/pca10056/mpconfigboard.h
index 48ef7f1c3..eca339a7d 100644
--- a/ports/nrf/boards/pca10056/mpconfigboard.h
+++ b/ports/nrf/boards/pca10056/mpconfigboard.h
@@ -30,8 +30,6 @@
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "nRF52840-DK"
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
#define MICROPY_HW_LED_STATUS (&pin_P0_13)
#define DEFAULT_I2C_BUS_SCL (&pin_P0_27)
diff --git a/ports/nrf/boards/pca10059/mpconfigboard.h b/ports/nrf/boards/pca10059/mpconfigboard.h
index d5ce21229..eaca1bf21 100644
--- a/ports/nrf/boards/pca10059/mpconfigboard.h
+++ b/ports/nrf/boards/pca10059/mpconfigboard.h
@@ -29,5 +29,3 @@
#define MICROPY_PY_SYS_PLATFORM "nRF52840-DK"
#define MICROPY_HW_LED_STATUS (&pin_P0_06)
-
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h b/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h
index a5ed69b2b..20a99a695 100644
--- a/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h
+++ b/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h
@@ -30,8 +30,6 @@
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "SFE_NRF52840_Mini"
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
#define DEFAULT_I2C_BUS_SCL (&pin_P0_11)
#define DEFAULT_I2C_BUS_SDA (&pin_P0_08)
diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c
index a8e1f1905..76f08b5ed 100644
--- a/ports/nrf/common-hal/_bleio/Adapter.c
+++ b/ports/nrf/common-hal/_bleio/Adapter.c
@@ -39,12 +39,21 @@
#include "supervisor/usb.h"
#include "shared-bindings/_bleio/Adapter.h"
#include "shared-bindings/_bleio/Address.h"
+#include "shared-bindings/nvm/ByteArray.h"
#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS)
#define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS)
#define BLE_SLAVE_LATENCY 0
#define BLE_CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)
+const nvm_bytearray_obj_t common_hal_bleio_nvm_obj = {
+ .base = {
+ .type = &nvm_bytearray_type,
+ },
+ .len = CIRCUITPY_BLE_CONFIG_SIZE,
+ .start_address = CIRCUITPY_BLE_CONFIG_ADDRESS,
+};
+
STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) {
mp_raise_msg_varg(&mp_type_AssertionError,
translate("Soft device assert, id: 0x%08lX, pc: 0x%08lX"), id, pc);
diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c
index a6b1c4ba3..eea3d43ce 100644
--- a/ports/nrf/common-hal/microcontroller/__init__.c
+++ b/ports/nrf/common-hal/microcontroller/__init__.c
@@ -76,11 +76,14 @@ const mcu_processor_obj_t common_hal_mcu_processor_obj = {
};
#if CIRCUITPY_INTERNAL_NVM_SIZE > 0
+
// The singleton nvm.ByteArray object.
const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
.base = {
.type = &nvm_bytearray_type,
- },
+ }
+ .start_address = CIRCUITPY_INTERNAL_NVM_ADDRESS,
+ .len = CIRCUITPY_INTERNAL_NVM_SIZE,
};
#endif
diff --git a/ports/nrf/common-hal/nvm/ByteArray.c b/ports/nrf/common-hal/nvm/ByteArray.c
index ee270f79b..416768101 100644
--- a/ports/nrf/common-hal/nvm/ByteArray.c
+++ b/ports/nrf/common-hal/nvm/ByteArray.c
@@ -31,19 +31,12 @@
#include "peripherals/nrf/nvm.h"
-// defined in linker
-extern uint32_t __fatfs_flash_start_addr[];
-extern uint32_t __fatfs_flash_length[];
-
-#define NVM_START_ADDR ((uint32_t)__fatfs_flash_start_addr + \
- (uint32_t)__fatfs_flash_length - CIRCUITPY_INTERNAL_NVM_SIZE)
-
uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) {
- return CIRCUITPY_INTERNAL_NVM_SIZE;
+ return self->len;
}
static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_t *bytes) {
- // Write a whole page to flash, buffering it first and then erasing and rewriting
+ // Write a whole page to flash, buffering it first and then erasing and rewriting
// it since we can only clear a whole page at a time.
if (offset == 0 && len == FLASH_PAGE_SIZE) {
@@ -59,7 +52,7 @@ static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_
bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self,
uint32_t start_index, uint8_t* values, uint32_t len) {
- uint32_t address = NVM_START_ADDR + start_index;
+ uint32_t address = self->start_address + start_index;
uint32_t offset = address % FLASH_PAGE_SIZE;
uint32_t page_addr = address - offset;
@@ -76,5 +69,5 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self,
void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self,
uint32_t start_index, uint32_t len, uint8_t* values) {
- memcpy(values, (uint8_t *)(NVM_START_ADDR + start_index), len);
+ memcpy(values, self->start_address + start_index, len);
}
diff --git a/ports/nrf/common-hal/nvm/ByteArray.h b/ports/nrf/common-hal/nvm/ByteArray.h
index a8d09dd43..c048d5577 100644
--- a/ports/nrf/common-hal/nvm/ByteArray.h
+++ b/ports/nrf/common-hal/nvm/ByteArray.h
@@ -31,6 +31,8 @@
typedef struct {
mp_obj_base_t base;
+ uint8_t* start_address;
+ uint32_t len;
} nvm_bytearray_obj_t;
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_NVM_BYTEARRAY_H
diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h
index 9c3d02f44..3cb086f31 100644
--- a/ports/nrf/mpconfigport.h
+++ b/ports/nrf/mpconfigport.h
@@ -43,6 +43,10 @@
#include "py/circuitpy_mpconfig.h"
+#ifndef CIRCUITPY_INTERNAL_NVM_SIZE
+#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
+#endif
+
#ifndef BOARD_HAS_32KHZ_XTAL
// Assume crystal is present, which is the most common case.
#define BOARD_HAS_32KHZ_XTAL (1)
diff --git a/ports/nrf/peripherals/nrf/nvm.h b/ports/nrf/peripherals/nrf/nvm.h
index 4eac3d728..60a663e81 100644
--- a/ports/nrf/peripherals/nrf/nvm.h
+++ b/ports/nrf/peripherals/nrf/nvm.h
@@ -27,8 +27,4 @@
#define FLASH_PAGE_SIZE (4096)
-#ifndef CIRCUITPY_INTERNAL_NVM_SIZE
-#define CIRCUITPY_INTERNAL_NVM_SIZE (0)
-#endif
-
void nrf_nvm_safe_flash_page_write(uint32_t page_addr, uint8_t *data);
diff --git a/ports/nrf/supervisor/internal_flash.c b/ports/nrf/supervisor/internal_flash.c
index dcacd4d27..c43454eb3 100644
--- a/ports/nrf/supervisor/internal_flash.c
+++ b/ports/nrf/supervisor/internal_flash.c
@@ -67,7 +67,7 @@ uint32_t supervisor_flash_get_block_size(void) {
}
uint32_t supervisor_flash_get_block_count(void) {
- return ((uint32_t) __fatfs_flash_length - CIRCUITPY_INTERNAL_NVM_SIZE) / FILESYSTEM_BLOCK_SIZE ;
+ return ((uint32_t) __fatfs_flash_length) / FILESYSTEM_BLOCK_SIZE ;
}
void supervisor_flash_flush(void) {
@@ -120,4 +120,3 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
void supervisor_flash_release_cache(void) {
}
-
diff --git a/ports/nrf/tick.c b/ports/nrf/tick.c
index 6d8fd13e0..1a9e69a8c 100644
--- a/ports/nrf/tick.c
+++ b/ports/nrf/tick.c
@@ -43,7 +43,7 @@ void SysTick_Handler(void) {
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
filesystem_tick();
#endif
-#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
+#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0
autoreload_tick();
#endif
#ifdef CIRCUITPY_GAMEPAD_TICKS
diff --git a/ports/stm32f4/boards/feather_f405/mpconfigboard.h b/ports/stm32f4/boards/feather_f405/mpconfigboard.h
index 831a17573..908b35a71 100644
--- a/ports/stm32f4/boards/feather_f405/mpconfigboard.h
+++ b/ports/stm32f4/boards/feather_f405/mpconfigboard.h
@@ -33,9 +33,6 @@
#define FLASH_SIZE (0x100000)
#define FLASH_PAGE_SIZE (0x4000)
-#define AUTORESET_DELAY_MS 500
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
-
// On-board flash
#define SPI_FLASH_MOSI_PIN &pin_PB05
#define SPI_FLASH_MISO_PIN &pin_PB04
diff --git a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h
index e8441d665..d793a222f 100644
--- a/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h
+++ b/ports/stm32f4/boards/pyboard_v11/mpconfigboard.h
@@ -32,6 +32,3 @@
#define FLASH_SIZE (0x100000)
#define FLASH_PAGE_SIZE (0x4000)
-
-#define AUTORESET_DELAY_MS 500
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) \ No newline at end of file
diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h
index d5491fe36..5bea08975 100644
--- a/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h
+++ b/ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h
@@ -32,9 +32,3 @@
#define FLASH_SIZE (0x80000) //512K
#define FLASH_PAGE_SIZE (0x4000) //16K
-
-#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000)
-
-#define AUTORESET_DELAY_MS 500
diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h
index ebee98f89..9e23f1db5 100644
--- a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h
+++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h
@@ -32,7 +32,3 @@
#define FLASH_SIZE (0x100000)
#define FLASH_PAGE_SIZE (0x4000)
-
-#define AUTORESET_DELAY_MS 500
-#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
-
diff --git a/ports/stm32f4/tick.c b/ports/stm32f4/tick.c
index 43521fb51..b417df305 100644
--- a/ports/stm32f4/tick.c
+++ b/ports/stm32f4/tick.c
@@ -44,7 +44,7 @@ void SysTick_Handler(void) {
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
filesystem_tick();
#endif
-#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
+#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0
autoreload_tick();
#endif
#ifdef CIRCUITPY_GAMEPAD_TICKS
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index b72d75390..915310f83 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -296,7 +296,6 @@ $(filter $(SRC_PATTERNS), \
fontio/Glyph.c \
microcontroller/RunMode.c \
math/__init__.c \
- supervisor/__init__.c \
)
SRC_BINDINGS_ENUMS += \
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index 2cb617819..91e2e223c 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -212,7 +212,6 @@ typedef long mp_off_t;
#define MP_SSIZE_MAX (0x7fffffff)
#endif
-
// These CIRCUITPY_xxx values should all be defined in the *.mk files as being on or off.
// So if any are not defined in *.mk, they'll throw an error here.
@@ -661,8 +660,20 @@ void run_background_tasks(void);
#define MICROPY_VM_HOOK_LOOP run_background_tasks();
#define MICROPY_VM_HOOK_RETURN run_background_tasks();
+// CIRCUITPY_AUTORELOAD_DELAY_MS = 0 will completely disable autoreload.
+#ifndef CIRCUITPY_AUTORELOAD_DELAY_MS
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
+#endif
+
+#ifndef CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS
#define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000
+#endif
+
+// Default is no internal flash filesystem.
+#ifndef INTERNAL_FLASH_FILESYSTEM_SIZE
+#define INTERNAL_FLASH_FILESYSTEM_SIZE (0)
+#endif
+
#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"
#endif // __INCLUDED_MPCONFIG_CIRCUITPY_H
diff --git a/tools/gen_ld_files.py b/tools/gen_ld_files.py
new file mode 100755
index 000000000..fc80d46c9
--- /dev/null
+++ b/tools/gen_ld_files.py
@@ -0,0 +1,47 @@
+#! /usr/bin/env python3
+import argparse
+
+import os
+import os.path
+import sys
+import re
+from string import Template
+
+parser = argparse.ArgumentParser(description='Apply #define values to .template.ld file.')
+parser.add_argument('template_files', metavar='TEMPLATE_FILE', type=argparse.FileType('r'),
+ nargs='+', help="template filename: <something>.template.ld")
+parser.add_argument('--defines', type=argparse.FileType('r'), required=True)
+parser.add_argument('--out_dir', required=True)
+
+args = parser.parse_args()
+
+defines = {}
+
+# We're looking for lines like this:
+# <expression> ///DEFINE_VALUE NAME_OF_VALUE <optional Python lambda expression to transform value>
+VALUE_LINE_RE = re.compile(r'^([^/].*); ///DEFINE_VALUE (\w+)(.*)$')
+
+for line in args.defines:
+ match = VALUE_LINE_RE.match(line.strip())
+ if match:
+ value = match.group(1).strip()
+ name = match.group(2)
+ lambda_exp = match.group(3).strip()
+ # Apply the given lambda to the value if it is present, else just store the value.
+ defines[match.group(2)] = eval(lambda_exp)(value) if lambda_exp else value
+
+#print(defines)
+fail = False
+
+for template_file in args.template_files:
+ ld_template_basename = os.path.basename(template_file.name)
+ ld_pathname = os.path.join(args.out_dir, ld_template_basename.replace('.template.ld', '.ld'))
+ with open(ld_pathname, 'w') as output:
+ try:
+ output.write(Template(template_file.read()).substitute(defines))
+ except KeyError as e:
+ print("ERROR: {}: No #define for '{}'".format(ld_pathname, e.args[0]), file=sys.stderr)
+ fail = True
+
+if fail:
+ sys.exit(1)