summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyke van Laethem <aykevanlaethem@gmail.com>2018-04-02 17:43:11 +0200
committerDamien George <damien.p.george@gmail.com>2018-07-18 17:12:26 +1000
commit2de65dda2226b6ac08e978a93365b886424838f1 (patch)
treefbe9e0c684072a143e782b4a7e0e4c658e473225
parent375bc31f4b61d8214b42b4f07c349e8d59304d24 (diff)
nrf: Make linker scripts more modular.
With all the variation in chips and boards it's tedious to copy and redefine linker scripts for every option. Making linker scripts more modular also opens up more possibilities, like enabling/disabling the flash file system from the Makefile - or even defining it's size from a Makefile argument (FS_SIZE=12 for a 12kB filesystem if tight on space).
-rw-r--r--ports/nrf/Makefile13
-rw-r--r--ports/nrf/boards/arduino_primo/mpconfigboard.mk3
-rw-r--r--ports/nrf/boards/arduino_primo/mpconfigboard_s132.mk9
-rw-r--r--ports/nrf/boards/common.ld3
-rw-r--r--ports/nrf/boards/dvk_bl652/mpconfigboard.mk4
-rw-r--r--ports/nrf/boards/dvk_bl652/mpconfigboard_s132.mk10
-rw-r--r--ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld3
-rw-r--r--ports/nrf/boards/feather52/mpconfigboard_s132.mk25
-rw-r--r--ports/nrf/boards/memory.ld19
-rw-r--r--ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld20
-rw-r--r--ports/nrf/boards/microbit/mpconfigboard.mk8
-rw-r--r--ports/nrf/boards/microbit/mpconfigboard_s110.mk8
-rw-r--r--ports/nrf/boards/nrf51x22_256k_16k.ld21
-rw-r--r--ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld19
-rw-r--r--ports/nrf/boards/nrf51x22_256k_32k.ld21
-rw-r--r--ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld19
-rw-r--r--ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld19
-rw-r--r--ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld19
-rw-r--r--ports/nrf/boards/nrf52832_512k_64k.ld16
-rw-r--r--ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld18
-rw-r--r--ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld18
-rw-r--r--ports/nrf/boards/nrf52840_1M_256k.ld22
-rw-r--r--ports/nrf/boards/pca10000/mpconfigboard.mk3
-rw-r--r--ports/nrf/boards/pca10000/mpconfigboard_s110.mk5
-rw-r--r--ports/nrf/boards/pca10001/mpconfigboard.mk3
-rw-r--r--ports/nrf/boards/pca10001/mpconfigboard_s110.mk5
-rw-r--r--ports/nrf/boards/pca10028/mpconfigboard.mk3
-rw-r--r--ports/nrf/boards/pca10028/mpconfigboard_s110.mk5
-rw-r--r--ports/nrf/boards/pca10028/mpconfigboard_s120.mk5
-rw-r--r--ports/nrf/boards/pca10028/mpconfigboard_s130.mk5
-rw-r--r--ports/nrf/boards/pca10031/mpconfigboard.mk3
-rw-r--r--ports/nrf/boards/pca10031/mpconfigboard_s110.mk5
-rw-r--r--ports/nrf/boards/pca10031/mpconfigboard_s120.mk5
-rw-r--r--ports/nrf/boards/pca10031/mpconfigboard_s130.mk5
-rw-r--r--ports/nrf/boards/pca10040/mpconfigboard.mk3
-rw-r--r--ports/nrf/boards/pca10040/mpconfigboard_s132.mk8
-rw-r--r--ports/nrf/boards/pca10056/mpconfigboard.mk2
-rw-r--r--ports/nrf/boards/s110_8.0.0.ld9
-rw-r--r--ports/nrf/boards/s132_3.0.0.ld4
-rw-r--r--ports/nrf/boards/wt51822_s4at/mpconfigboard.mk5
-rw-r--r--ports/nrf/boards/wt51822_s4at/mpconfigboard_s110.mk7
-rw-r--r--ports/nrf/modules/uos/microbitfs.c16
42 files changed, 102 insertions, 321 deletions
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index bcd48198d..4aa4d4622 100644
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -11,21 +11,28 @@ SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
# TODO: Verify that it is a valid target.
+include boards/$(BOARD)/mpconfigboard.mk
ifeq ($(SD), )
# If the build directory is not given, make it reflect the board name.
BUILD ?= build-$(BOARD)
include ../../py/mkenv.mk
- include boards/$(BOARD)/mpconfigboard.mk
else
# If the build directory is not given, make it reflect the board name.
BUILD ?= build-$(BOARD)-$(SD_LOWER)
include ../../py/mkenv.mk
- include boards/$(BOARD)/mpconfigboard_$(SD_LOWER).mk
+ LD_FILES += boards/$(SD_LOWER)_$(SOFTDEV_VERSION).ld
include drivers/bluetooth/bluetooth_common.mk
endif
+LD_FILES += boards/memory.ld boards/common.ld
+
+ifneq ($(LD_FILE),)
+ # Use custom LD file
+ LD_FILES = $(LD_FILE)
+endif
+
-include boards/$(BOARD)/modules/boardmodules.mk
# qstr definitions (must come before including py.mk)
@@ -102,7 +109,7 @@ CFLAGS += $(CFLAGS_LTO)
LDFLAGS = $(CFLAGS)
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
-LDFLAGS += -mthumb -mabi=aapcs -T $(LD_FILE) -L boards/
+LDFLAGS += -mthumb -mabi=aapcs $(addprefix -T,$(LD_FILES)) -L boards/
#Debugging/Optimization
ifeq ($(DEBUG), 1)
diff --git a/ports/nrf/boards/arduino_primo/mpconfigboard.mk b/ports/nrf/boards/arduino_primo/mpconfigboard.mk
index 0be6b3f95..260903783 100644
--- a/ports/nrf/boards/arduino_primo/mpconfigboard.mk
+++ b/ports/nrf/boards/arduino_primo/mpconfigboard.mk
@@ -1,7 +1,8 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52832
-LD_FILE = boards/nrf52832_512k_64k.ld
+SOFTDEV_VERSION = 3.0.0
+LD_FILES += boards/nrf52832_512k_64k.ld
FLASHER = pyocd
NRF_DEFINES += -DNRF52832_XXAA
diff --git a/ports/nrf/boards/arduino_primo/mpconfigboard_s132.mk b/ports/nrf/boards/arduino_primo/mpconfigboard_s132.mk
deleted file mode 100644
index cbbafebfa..000000000
--- a/ports/nrf/boards/arduino_primo/mpconfigboard_s132.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-MCU_SERIES = m4
-MCU_VARIANT = nrf52
-MCU_SUB_VARIANT = nrf52832
-SOFTDEV_VERSION = 3.0.0
-FLASHER=pyocd
-
-LD_FILE = boards/nrf52832_512k_64k_s132_$(SOFTDEV_VERSION).ld
-
-NRF_DEFINES += -DNRF52832_XXAA
diff --git a/ports/nrf/boards/common.ld b/ports/nrf/boards/common.ld
index fa1fbde99..8820c485b 100644
--- a/ports/nrf/boards/common.ld
+++ b/ports/nrf/boards/common.ld
@@ -98,6 +98,3 @@ SECTIONS
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_estack = ORIGIN(RAM) + LENGTH(RAM);
_heap_end = _ram_end - _stack_size;
-
-_flash_user_start = ORIGIN(FLASH_USER);
-_flash_user_end = ORIGIN(FLASH_USER) + LENGTH(FLASH_USER);
diff --git a/ports/nrf/boards/dvk_bl652/mpconfigboard.mk b/ports/nrf/boards/dvk_bl652/mpconfigboard.mk
index 83dbb5ab4..e16ca91e8 100644
--- a/ports/nrf/boards/dvk_bl652/mpconfigboard.mk
+++ b/ports/nrf/boards/dvk_bl652/mpconfigboard.mk
@@ -1,6 +1,8 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52832
-LD_FILE = boards/nrf52832_512k_64k.ld
+SOFTDEV_VERSION = 3.0.0
+LD_FILES += boards/nrf52832_512k_64k.ld
NRF_DEFINES += -DNRF52832_XXAA
+CFLAGS += -DBLUETOOTH_LFCLK_RC
diff --git a/ports/nrf/boards/dvk_bl652/mpconfigboard_s132.mk b/ports/nrf/boards/dvk_bl652/mpconfigboard_s132.mk
deleted file mode 100644
index 62e3b0f33..000000000
--- a/ports/nrf/boards/dvk_bl652/mpconfigboard_s132.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-MCU_SERIES = m4
-MCU_VARIANT = nrf52
-MCU_SUB_VARIANT = nrf52832
-SOFTDEV_VERSION = 3.0.0
-
-LD_FILE = boards/nrf52832_512k_64k_s132_$(SOFTDEV_VERSION).ld
-
-NRF_DEFINES += -DNRF52832_XXAA
-CFLAGS += -DBLUETOOTH_LFCLK_RC
-
diff --git a/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld
index ac7786b5c..13a435f7f 100644
--- a/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld
+++ b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld
@@ -17,4 +17,7 @@ MEMORY
_stack_size = 8K;
_minimum_heap_size = 16K;
+_fs_start = ORIGIN(FLASH_USER);
+_fs_end = ORIGIN(FLASH_USER) + LENGTH(FLASH_USER);
+
INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/feather52/mpconfigboard_s132.mk b/ports/nrf/boards/feather52/mpconfigboard_s132.mk
deleted file mode 100644
index ce8dcde30..000000000
--- a/ports/nrf/boards/feather52/mpconfigboard_s132.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-MCU_SERIES = m4
-MCU_VARIANT = nrf52
-MCU_SUB_VARIANT = nrf52832
-SOFTDEV_VERSION = 2.0.1
-
-LD_FILE = boards/feather52/custom_nrf52832_dfu_app.ld
-
-NRF_DEFINES += -DNRF52832_XXAA
-
-
-check_defined = \
- $(strip $(foreach 1,$1, \
- $(call __check_defined,$1,$(strip $(value 2)))))
-__check_defined = \
- $(if $(value $1),, \
- $(error Undefined make flag: $1$(if $2, ($2))))
-
-.PHONY: dfu-gen dfu-flash
-
-dfu-gen:
- nrfutil dfu genpkg --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip
-
-dfu-flash:
- @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
- sudo nrfutil dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL)
diff --git a/ports/nrf/boards/memory.ld b/ports/nrf/boards/memory.ld
new file mode 100644
index 000000000..48a94a37a
--- /dev/null
+++ b/ports/nrf/boards/memory.ld
@@ -0,0 +1,19 @@
+
+/* Flash layout: softdevice | application | filesystem */
+/* RAM layout: softdevice RAM | application RAM */
+_sd_size = DEFINED(_sd_size) ? _sd_size : 0;
+_sd_ram = DEFINED(_sd_ram) ? _sd_ram : 0;
+_fs_size = DEFINED(_fs_size) ? _fs_size : 64K; /* TODO: set to 0 if not using the filesystem */
+_app_size = _flash_size - _sd_size - _fs_size;
+_app_start = _sd_size;
+_fs_start = _sd_size + _app_size;
+_fs_end = _fs_start + _fs_size;
+_app_ram_start = 0x20000000 + _sd_ram;
+_app_ram_size = _ram_size - _sd_ram;
+
+/* Specify the memory areas */
+MEMORY
+{
+ FLASH_TEXT (rx) : ORIGIN = _app_start, LENGTH = _app_size /* app */
+ RAM (xrw) : ORIGIN = _app_ram_start, LENGTH = _app_ram_size
+}
diff --git a/ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld b/ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld
index a3962074f..fc286ecba 100644
--- a/ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld
+++ b/ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld
@@ -1,19 +1 @@
-/*
- GNU linker script for NRF51822 AA w/ S110 8.0.0 SoftDevice
-*/
-/* Specify the memory areas */
-SEARCH_DIR(.)
-GROUP(-lgcc -lc -lnosys)
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x00018000, LENGTH = 148K /* app */
- FLASH_USER (rx) : ORIGIN = 0x0003D000, LENGTH = 12K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x20002000, LENGTH = 8K /* app RAM */
-}
-
-/* produce a link error if there is not this amount of RAM for these sections */
-_stack_size = 2K;
-_minimum_heap_size = 1K;
-
-INCLUDE "boards/common.ld"
+_fs_size = 12K;
diff --git a/ports/nrf/boards/microbit/mpconfigboard.mk b/ports/nrf/boards/microbit/mpconfigboard.mk
index dd63e22e5..96f430071 100644
--- a/ports/nrf/boards/microbit/mpconfigboard.mk
+++ b/ports/nrf/boards/microbit/mpconfigboard.mk
@@ -1,5 +1,11 @@
MCU_SERIES = m0
MCU_VARIANT = nrf51
MCU_SUB_VARIANT = nrf51822
-LD_FILE = boards/nrf51x22_256k_16k.ld
+SOFTDEV_VERSION = 8.0.0
+ifneq ($(SD),)
+LD_FILES += boards/microbit/custom_nrf51822_s110_microbit.ld
+endif
+LD_FILES += boards/nrf51x22_256k_16k.ld
FLASHER = pyocd
+
+CFLAGS += -DBLUETOOTH_LFCLK_RC
diff --git a/ports/nrf/boards/microbit/mpconfigboard_s110.mk b/ports/nrf/boards/microbit/mpconfigboard_s110.mk
deleted file mode 100644
index efda6a0a2..000000000
--- a/ports/nrf/boards/microbit/mpconfigboard_s110.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 8.0.0
-LD_FILE = boards/microbit/custom_nrf51822_s110_microbit.ld
-FLASHER = pyocd
-
-CFLAGS += -DBLUETOOTH_LFCLK_RC
diff --git a/ports/nrf/boards/nrf51x22_256k_16k.ld b/ports/nrf/boards/nrf51x22_256k_16k.ld
index 9963a2535..8a40ae0f1 100644
--- a/ports/nrf/boards/nrf51x22_256k_16k.ld
+++ b/ports/nrf/boards/nrf51x22_256k_16k.ld
@@ -1,19 +1,12 @@
/*
- GNU linker script for NRF51 AA w/ no SoftDevice
+ GNU linker script for NRF51 AA
*/
-/* Specify the memory areas */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x00000000, LENGTH = 192K /* app */
- FLASH_USER (rx) : ORIGIN = 0x00030000, LENGTH = 64K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K /* use all RAM */
-}
-
-/* produce a link error if there is not this amount of RAM for these sections */
-_stack_size = 4K;
-_minimum_heap_size = 8K;
-INCLUDE "boards/common.ld"
+_flash_size = 256K;
+_ram_size = 16K;
+
+/* Default stack size when there is no SoftDevice */
+_stack_size = 4K;
+_minimum_heap_size = 8K;
diff --git a/ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld b/ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld
deleted file mode 100644
index ae301eb6f..000000000
--- a/ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- GNU linker script for NRF51822 AA w/ S110 8.0.0 SoftDevice
-*/
-/* Specify the memory areas */
-SEARCH_DIR(.)
-GROUP(-lgcc -lc -lnosys)
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x00018000, LENGTH = 140K /* app */
- FLASH_USER (rx) : ORIGIN = 0x0003B000, LENGTH = 20K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x20002000, LENGTH = 8K /* app RAM */
-}
-
-/* produce a link error if there is not this amount of RAM for these sections */
-_stack_size = 2K;
-_minimum_heap_size = 4K;
-
-INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/nrf51x22_256k_32k.ld b/ports/nrf/boards/nrf51x22_256k_32k.ld
index c9b70b6d0..06c091403 100644
--- a/ports/nrf/boards/nrf51x22_256k_32k.ld
+++ b/ports/nrf/boards/nrf51x22_256k_32k.ld
@@ -1,19 +1,12 @@
/*
- GNU linker script for NRF51 AC w/ no SoftDevice
+ GNU linker script for NRF51 AC
*/
-/* Specify the memory areas */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x00000000, LENGTH = 192K /* app */
- FLASH_USER (rx) : ORIGIN = 0x00030000, LENGTH = 64K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K /* use all RAM */
-}
-
-/* produce a link error if there is not this amount of RAM for these sections */
-_stack_size = 4K;
-_minimum_heap_size = 24K;
-INCLUDE "boards/common.ld"
+_flash_size = 256K;
+_ram_size = 32K;
+
+/* Default stack size when there is no SoftDevice */
+_stack_size = 4K;
+_minimum_heap_size = 24K;
diff --git a/ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld b/ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld
deleted file mode 100644
index 1979dfa95..000000000
--- a/ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- GNU linker script for NRF51822 AC w/ S110 8.0.0 SoftDevice
-*/
-/* Specify the memory areas */
-SEARCH_DIR(.)
-GROUP(-lgcc -lc -lnosys)
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x00018000, LENGTH = 140K /* app */
- FLASH_USER (rx) : ORIGIN = 0x0003B000, LENGTH = 20K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x20002000, LENGTH = 24K /* app RAM */
-}
-
-/* produce a link error if there is not this amount of RAM for these sections */
-_stack_size = 4K;
-_minimum_heap_size = 1K;
-
-INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld b/ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld
deleted file mode 100644
index 3b7240e3b..000000000
--- a/ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- GNU linker script for NRF51822 AC w/ S120 2.1.0 SoftDevice
-*/
-/* Specify the memory areas */
-SEARCH_DIR(.)
-GROUP(-lgcc -lc -lnosys)
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x0001D000, LENGTH = 130K /* app */
- FLASH_USER (rx) : ORIGIN = 0x0003D800, LENGTH = 10K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x20002800, LENGTH = 22K /* app RAM */
-}
-
-/* produce a link error if there is not this amount of RAM for these sections */
-_stack_size = 4K;
-_minimum_heap_size = 4K;
-
-INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld b/ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld
deleted file mode 100644
index 9309f17d7..000000000
--- a/ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- GNU linker script for NRF51822 AC w/ S130 2.0.1 SoftDevice
-*/
-/* Specify the memory areas */
-SEARCH_DIR(.)
-GROUP(-lgcc -lc -lnosys)
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x0001B000, LENGTH = 130K /* app */
- FLASH_USER (rx) : ORIGIN = 0x0003B000, LENGTH = 18K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x200013c8, LENGTH = 0x006c38 /* 27 KiB */
-}
-
-/* produce a link error if there is not this amount of RAM for these sections */
-_stack_size = 4K;
-_minimum_heap_size = 6K;
-
-INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/nrf52832_512k_64k.ld b/ports/nrf/boards/nrf52832_512k_64k.ld
index 05e3a6f8a..22804df5c 100644
--- a/ports/nrf/boards/nrf52832_512k_64k.ld
+++ b/ports/nrf/boards/nrf52832_512k_64k.ld
@@ -1,18 +1,10 @@
/*
- GNU linker script for NRF52832 blank w/ no SoftDevice
+ GNU linker script for NRF52832
*/
-/* Specify the memory areas */
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x00000000, LENGTH = 448K /* app */
- FLASH_USER (rx) : ORIGIN = 0x00070000, LENGTH = 64K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K /* use all RAM */
-}
-
+_flash_size = 512K;
+_ram_size = 64K;
+
/* produce a link error if there is not this amount of RAM for these sections */
_stack_size = 8K;
_minimum_heap_size = 32K;
-
-INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld b/ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld
deleted file mode 100644
index 324d710a3..000000000
--- a/ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- GNU linker script for NRF52 w/ s132 2.0.1 SoftDevice
-*/
-
-/* Specify the memory areas */
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x0001c000, LENGTH = 336K /* app */
- FLASH_USER (rx) : ORIGIN = 0x00070000, LENGTH = 64K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x200039c0, LENGTH = 0x0c640 /* 49.5 KiB, give 8KiB headroom for softdevice */
-}
-
-/* produce a link error if there is not this amount of RAM for these sections */
-_stack_size = 8K;
-_minimum_heap_size = 16K;
-
-INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld b/ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld
deleted file mode 100644
index d1153d69e..000000000
--- a/ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- GNU linker script for NRF52 w/ s132 3.0.0 SoftDevice
-*/
-
-/* Specify the memory areas */
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x0001F000, LENGTH = 324K /* app */
- FLASH_USER (rx) : ORIGIN = 0x00070000, LENGTH = 64K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x200039c0, LENGTH = 0x0c640 /* 49.5 KiB, give 8KiB headroom for softdevice */
-}
-
-/* produce a link error if there is not this amount of RAM for these sections */
-_stack_size = 8K;
-_minimum_heap_size = 16K;
-
-INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/nrf52840_1M_256k.ld b/ports/nrf/boards/nrf52840_1M_256k.ld
index 05984fd19..16d61af6a 100644
--- a/ports/nrf/boards/nrf52840_1M_256k.ld
+++ b/ports/nrf/boards/nrf52840_1M_256k.ld
@@ -1,26 +1,10 @@
/*
- GNU linker script for NRF52840 blank w/ no SoftDevice
+ GNU linker script for NRF52840
*/
-/* Specify the memory areas */
-MEMORY
-{
- FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1M /* entire flash */
- FLASH_TEXT (rx) : ORIGIN = 0x00000000, LENGTH = 960K /* app */
- FLASH_USER (rx) : ORIGIN = 0x000F0000, LENGTH = 64K /* app data, filesystem */
- RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K /* use all RAM */
-}
+_flash_size = 1M;
+_ram_size = 256K;
/* produce a link error if there is not this amount of RAM for these sections */
_stack_size = 8K;
_minimum_heap_size = 128K;
-
-/* top end of the stack */
-
-/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/
-_estack = ORIGIN(RAM) + LENGTH(RAM);
-
-/* RAM extents for the garbage collector */
-_ram_end = ORIGIN(RAM) + LENGTH(RAM);
-
-INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/pca10000/mpconfigboard.mk b/ports/nrf/boards/pca10000/mpconfigboard.mk
index 12087d682..c0cef5f3a 100644
--- a/ports/nrf/boards/pca10000/mpconfigboard.mk
+++ b/ports/nrf/boards/pca10000/mpconfigboard.mk
@@ -1,4 +1,5 @@
MCU_SERIES = m0
MCU_VARIANT = nrf51
MCU_SUB_VARIANT = nrf51822
-LD_FILE = boards/nrf51x22_256k_16k.ld
+SOFTDEV_VERSION = 8.0.0
+LD_FILES += boards/nrf51x22_256k_16k.ld
diff --git a/ports/nrf/boards/pca10000/mpconfigboard_s110.mk b/ports/nrf/boards/pca10000/mpconfigboard_s110.mk
deleted file mode 100644
index 5cd9966f9..000000000
--- a/ports/nrf/boards/pca10000/mpconfigboard_s110.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 8.0.0
-LD_FILE = boards/nrf51x22_256k_16k_s110_$(SOFTDEV_VERSION).ld
diff --git a/ports/nrf/boards/pca10001/mpconfigboard.mk b/ports/nrf/boards/pca10001/mpconfigboard.mk
index 12087d682..c0cef5f3a 100644
--- a/ports/nrf/boards/pca10001/mpconfigboard.mk
+++ b/ports/nrf/boards/pca10001/mpconfigboard.mk
@@ -1,4 +1,5 @@
MCU_SERIES = m0
MCU_VARIANT = nrf51
MCU_SUB_VARIANT = nrf51822
-LD_FILE = boards/nrf51x22_256k_16k.ld
+SOFTDEV_VERSION = 8.0.0
+LD_FILES += boards/nrf51x22_256k_16k.ld
diff --git a/ports/nrf/boards/pca10001/mpconfigboard_s110.mk b/ports/nrf/boards/pca10001/mpconfigboard_s110.mk
deleted file mode 100644
index 5cd9966f9..000000000
--- a/ports/nrf/boards/pca10001/mpconfigboard_s110.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 8.0.0
-LD_FILE = boards/nrf51x22_256k_16k_s110_$(SOFTDEV_VERSION).ld
diff --git a/ports/nrf/boards/pca10028/mpconfigboard.mk b/ports/nrf/boards/pca10028/mpconfigboard.mk
index 29e76d94a..b3c8f21ea 100644
--- a/ports/nrf/boards/pca10028/mpconfigboard.mk
+++ b/ports/nrf/boards/pca10028/mpconfigboard.mk
@@ -1,4 +1,5 @@
MCU_SERIES = m0
MCU_VARIANT = nrf51
MCU_SUB_VARIANT = nrf51822
-LD_FILE = boards/nrf51x22_256k_32k.ld
+SOFTDEV_VERSION = 8.0.0
+LD_FILES += boards/nrf51x22_256k_32k.ld
diff --git a/ports/nrf/boards/pca10028/mpconfigboard_s110.mk b/ports/nrf/boards/pca10028/mpconfigboard_s110.mk
deleted file mode 100644
index 6afc1466f..000000000
--- a/ports/nrf/boards/pca10028/mpconfigboard_s110.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 8.0.0
-LD_FILE = boards/nrf51x22_256k_32k_s110_$(SOFTDEV_VERSION).ld
diff --git a/ports/nrf/boards/pca10028/mpconfigboard_s120.mk b/ports/nrf/boards/pca10028/mpconfigboard_s120.mk
deleted file mode 100644
index 97843f8f7..000000000
--- a/ports/nrf/boards/pca10028/mpconfigboard_s120.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 2.1.0
-LD_FILE = boards/nrf51x22_256k_32k_s120_$(SOFTDEV_VERSION).ld
diff --git a/ports/nrf/boards/pca10028/mpconfigboard_s130.mk b/ports/nrf/boards/pca10028/mpconfigboard_s130.mk
deleted file mode 100644
index 908549afd..000000000
--- a/ports/nrf/boards/pca10028/mpconfigboard_s130.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 2.0.1
-LD_FILE = boards/nrf51x22_256k_32k_s130_$(SOFTDEV_VERSION).ld
diff --git a/ports/nrf/boards/pca10031/mpconfigboard.mk b/ports/nrf/boards/pca10031/mpconfigboard.mk
index 29e76d94a..b3c8f21ea 100644
--- a/ports/nrf/boards/pca10031/mpconfigboard.mk
+++ b/ports/nrf/boards/pca10031/mpconfigboard.mk
@@ -1,4 +1,5 @@
MCU_SERIES = m0
MCU_VARIANT = nrf51
MCU_SUB_VARIANT = nrf51822
-LD_FILE = boards/nrf51x22_256k_32k.ld
+SOFTDEV_VERSION = 8.0.0
+LD_FILES += boards/nrf51x22_256k_32k.ld
diff --git a/ports/nrf/boards/pca10031/mpconfigboard_s110.mk b/ports/nrf/boards/pca10031/mpconfigboard_s110.mk
deleted file mode 100644
index 6afc1466f..000000000
--- a/ports/nrf/boards/pca10031/mpconfigboard_s110.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 8.0.0
-LD_FILE = boards/nrf51x22_256k_32k_s110_$(SOFTDEV_VERSION).ld
diff --git a/ports/nrf/boards/pca10031/mpconfigboard_s120.mk b/ports/nrf/boards/pca10031/mpconfigboard_s120.mk
deleted file mode 100644
index 97843f8f7..000000000
--- a/ports/nrf/boards/pca10031/mpconfigboard_s120.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 2.1.0
-LD_FILE = boards/nrf51x22_256k_32k_s120_$(SOFTDEV_VERSION).ld
diff --git a/ports/nrf/boards/pca10031/mpconfigboard_s130.mk b/ports/nrf/boards/pca10031/mpconfigboard_s130.mk
deleted file mode 100644
index 908549afd..000000000
--- a/ports/nrf/boards/pca10031/mpconfigboard_s130.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 2.0.1
-LD_FILE = boards/nrf51x22_256k_32k_s130_$(SOFTDEV_VERSION).ld
diff --git a/ports/nrf/boards/pca10040/mpconfigboard.mk b/ports/nrf/boards/pca10040/mpconfigboard.mk
index 83dbb5ab4..f05373201 100644
--- a/ports/nrf/boards/pca10040/mpconfigboard.mk
+++ b/ports/nrf/boards/pca10040/mpconfigboard.mk
@@ -1,6 +1,7 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52832
-LD_FILE = boards/nrf52832_512k_64k.ld
+SOFTDEV_VERSION = 3.0.0
+LD_FILES += boards/nrf52832_512k_64k.ld
NRF_DEFINES += -DNRF52832_XXAA
diff --git a/ports/nrf/boards/pca10040/mpconfigboard_s132.mk b/ports/nrf/boards/pca10040/mpconfigboard_s132.mk
deleted file mode 100644
index 42d37d38d..000000000
--- a/ports/nrf/boards/pca10040/mpconfigboard_s132.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-MCU_SERIES = m4
-MCU_VARIANT = nrf52
-MCU_SUB_VARIANT = nrf52832
-SOFTDEV_VERSION = 3.0.0
-
-LD_FILE = boards/nrf52832_512k_64k_s132_$(SOFTDEV_VERSION).ld
-
-NRF_DEFINES += -DNRF52832_XXAA
diff --git a/ports/nrf/boards/pca10056/mpconfigboard.mk b/ports/nrf/boards/pca10056/mpconfigboard.mk
index 76661243a..a0af7e2a4 100644
--- a/ports/nrf/boards/pca10056/mpconfigboard.mk
+++ b/ports/nrf/boards/pca10056/mpconfigboard.mk
@@ -1,6 +1,6 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52840
-LD_FILE = boards/nrf52840_1M_256k.ld
+LD_FILES += boards/nrf52840_1M_256k.ld
NRF_DEFINES += -DNRF52840_XXAA
diff --git a/ports/nrf/boards/s110_8.0.0.ld b/ports/nrf/boards/s110_8.0.0.ld
new file mode 100644
index 000000000..b9cef1542
--- /dev/null
+++ b/ports/nrf/boards/s110_8.0.0.ld
@@ -0,0 +1,9 @@
+
+/* GNU linker script for s110 SoftDevice version 8.0.0 */
+
+_sd_size = 0x00018000;
+_sd_ram = 0x00002000;
+_fs_size = DEFINED(_fs_size) ? _fs_size : 20K;
+
+_stack_size = _ram_size > 16K ? 4K : 2K;
+_minimum_heap_size = 4K;
diff --git a/ports/nrf/boards/s132_3.0.0.ld b/ports/nrf/boards/s132_3.0.0.ld
new file mode 100644
index 000000000..38c483596
--- /dev/null
+++ b/ports/nrf/boards/s132_3.0.0.ld
@@ -0,0 +1,4 @@
+/* GNU linker script for s132 SoftDevice version 3.0.0 */
+
+_sd_size = 0x0001F000;
+_sd_ram = 0x000039c0;
diff --git a/ports/nrf/boards/wt51822_s4at/mpconfigboard.mk b/ports/nrf/boards/wt51822_s4at/mpconfigboard.mk
index 12087d682..515de07f5 100644
--- a/ports/nrf/boards/wt51822_s4at/mpconfigboard.mk
+++ b/ports/nrf/boards/wt51822_s4at/mpconfigboard.mk
@@ -1,4 +1,7 @@
MCU_SERIES = m0
MCU_VARIANT = nrf51
MCU_SUB_VARIANT = nrf51822
-LD_FILE = boards/nrf51x22_256k_16k.ld
+SOFTDEV_VERSION = 8.0.0
+LD_FILES += boards/nrf51x22_256k_16k.ld
+
+CFLAGS += -DBLUETOOTH_LFCLK_RC
diff --git a/ports/nrf/boards/wt51822_s4at/mpconfigboard_s110.mk b/ports/nrf/boards/wt51822_s4at/mpconfigboard_s110.mk
deleted file mode 100644
index 8f5433b47..000000000
--- a/ports/nrf/boards/wt51822_s4at/mpconfigboard_s110.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-MCU_SERIES = m0
-MCU_VARIANT = nrf51
-MCU_SUB_VARIANT = nrf51822
-SOFTDEV_VERSION = 8.0.0
-LD_FILE = boards/nrf51x22_256k_16k_s110_$(SOFTDEV_VERSION).ld
-
-CFLAGS += -DBLUETOOTH_LFCLK_RC
diff --git a/ports/nrf/modules/uos/microbitfs.c b/ports/nrf/modules/uos/microbitfs.c
index 49a9117e1..e231fd16f 100644
--- a/ports/nrf/modules/uos/microbitfs.c
+++ b/ports/nrf/modules/uos/microbitfs.c
@@ -137,8 +137,8 @@ STATIC uint8_t start_index;
STATIC file_chunk *file_system_chunks;
// Defined by the linker
-extern byte _flash_user_start[];
-extern byte _flash_user_end[];
+extern byte _fs_start[];
+extern byte _fs_end[];
STATIC_ASSERT((sizeof(file_chunk) == CHUNK_SIZE));
@@ -154,25 +154,25 @@ STATIC inline byte *roundup(byte *addr, uint32_t align) {
STATIC inline void *first_page(void) {
- return _flash_user_end - FLASH_PAGESIZE * first_page_index;
+ return _fs_end - FLASH_PAGESIZE * first_page_index;
}
STATIC inline void *last_page(void) {
- return _flash_user_end - FLASH_PAGESIZE * last_page_index;
+ return _fs_end - FLASH_PAGESIZE * last_page_index;
}
STATIC void init_limits(void) {
// First determine where to end
- byte *end = _flash_user_end;
+ byte *end = _fs_end;
end = rounddown(end, FLASH_PAGESIZE)-FLASH_PAGESIZE;
- last_page_index = (_flash_user_end - end)/FLASH_PAGESIZE;
+ last_page_index = (_fs_end - end)/FLASH_PAGESIZE;
// Now find the start
byte *start = roundup(end - CHUNK_SIZE*MAX_CHUNKS_IN_FILE_SYSTEM, FLASH_PAGESIZE);
- while (start < _flash_user_start) {
+ while (start < _fs_start) {
start += FLASH_PAGESIZE;
}
- first_page_index = (_flash_user_end - start)/FLASH_PAGESIZE;
+ first_page_index = (_fs_end - start)/FLASH_PAGESIZE;
chunks_in_file_system = (end-start)>>MBFS_LOG_CHUNK_SIZE;
}