From 1e1611c50a3547188549812f891d37e8c7c03a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 7 Mar 2019 16:47:38 +0100 Subject: [PATCH 1/3] makefiles/mcuboot.mk: prepare for using cortexm.ld Prepare mcuboot for changing `nrf52` to use `cortexm.ld`. It sets the offset for linking the image. --- makefiles/mcuboot.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/makefiles/mcuboot.mk b/makefiles/mcuboot.mk index 09987798c5..a20cc686b1 100644 --- a/makefiles/mcuboot.mk +++ b/makefiles/mcuboot.mk @@ -22,6 +22,7 @@ $(MCUBOOT_KEYFILE): $(Q)$(IMGTOOL) keygen -k $@ -t rsa-2048 endif +mcuboot: ROM_OFFSET=$$(($(MCUBOOT_SLOT0_SIZE) + $(IMAGE_HDR_SIZE))) mcuboot: mcuboot-create-key link @$(COLOR_ECHO) @$(COLOR_ECHO) '$(COLOR_PURPLE)Re-linking for MCUBoot at $(MCUBOOT_SLOT0_SIZE)...$(COLOR_RESET)' From 3163b8d6e2a8c025f796f2149ec91f8075a27bad Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Thu, 7 Mar 2019 14:27:45 +0100 Subject: [PATCH 2/3] nrf52: use cortexm.ld script when applicable The common linker script is not used when the nordic_softdevice_ble is included --- cpu/cortexm_common/ldscripts/multislot.ld | 22 ---------------- cpu/nrf52/Makefile.include | 15 +++++++++++ cpu/nrf52/ldscripts/nrf52832xxaa.ld | 31 ----------------------- cpu/nrf52/ldscripts/nrf52840xxaa.ld | 27 -------------------- 4 files changed, 15 insertions(+), 80 deletions(-) delete mode 100644 cpu/cortexm_common/ldscripts/multislot.ld delete mode 100644 cpu/nrf52/ldscripts/nrf52832xxaa.ld delete mode 100644 cpu/nrf52/ldscripts/nrf52840xxaa.ld diff --git a/cpu/cortexm_common/ldscripts/multislot.ld b/cpu/cortexm_common/ldscripts/multislot.ld deleted file mode 100644 index 22d89a7958..0000000000 --- a/cpu/cortexm_common/ldscripts/multislot.ld +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2017 Kaspar Schleiser - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @addtogroup cpu_cortex_common - * @{ - * - * @file - * @brief Offset definitions for cortex MCUs - * - * @author Kaspar Schleiser - * - * @} - */ - -boot_offset = DEFINED( offset ) ? offset : 0x0 ; -rom_length = DEFINED( length ) ? length : rom_length ; diff --git a/cpu/nrf52/Makefile.include b/cpu/nrf52/Makefile.include index 03647d823b..0bf5dfcb0e 100644 --- a/cpu/nrf52/Makefile.include +++ b/cpu/nrf52/Makefile.include @@ -7,6 +7,21 @@ export MCUBOOT_SLOT0_SIZE = 0x8000 export MCUBOOT_SLOT1_SIZE = 0x3C000 export MCUBOOT_SLOT2_SIZE = 0x3C000 +# Set ROM and RAM lengths according to CPU model +ifneq (,$(filter nrf52832xxaa,$(CPU_MODEL))) + ROM_LEN ?= 0x80000 + RAM_LEN ?= 0x10000 +endif +ifneq (,$(filter nrf52840xxaa,$(CPU_MODEL))) + ROM_LEN ?= 0x100000 + RAM_LEN ?= 0x40000 +endif + +ROM_START_ADDR ?= 0x00000000 +RAM_START_ADDR ?= 0x20000000 + +LINKER_SCRIPT ?= cortexm.ld + ifneq (,$(filter nrf802154,$(USEMODULE))) CFLAGS += -DGNRC_NETIF_MSG_QUEUE_SIZE=16 endif diff --git a/cpu/nrf52/ldscripts/nrf52832xxaa.ld b/cpu/nrf52/ldscripts/nrf52832xxaa.ld deleted file mode 100644 index aced7f46cd..0000000000 --- a/cpu/nrf52/ldscripts/nrf52832xxaa.ld +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2016 Freie Universität Berlin - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @addtogroup cpu_nrf52 - * @{ - * - * @file - * @brief Memory definitions for the NRF52832XXAA - * - * @author Hauke Petersen - * - * @} - */ - -rom_length = 512K; - -INCLUDE multislot.ld - -MEMORY -{ - rom (rx) : ORIGIN = 0x00000000 + boot_offset, LENGTH = rom_length - ram (w!rx) : ORIGIN = 0x20000000, LENGTH = 64K -} - -INCLUDE cortexm_base.ld diff --git a/cpu/nrf52/ldscripts/nrf52840xxaa.ld b/cpu/nrf52/ldscripts/nrf52840xxaa.ld deleted file mode 100644 index fe7499cb16..0000000000 --- a/cpu/nrf52/ldscripts/nrf52840xxaa.ld +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2017 Freie Universität Berlin - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @addtogroup cpu_nrf52 - * @{ - * - * @file - * @brief Memory definitions for the NRF52840XXAA - * - * @author Hauke Petersen - * - * @} - */ - -MEMORY -{ - rom (rx) : ORIGIN = 0x00000000, LENGTH = 1024K - ram (w!rx) : ORIGIN = 0x20000000, LENGTH = 256K -} - -INCLUDE cortexm_base.ld From a3df00ca174cbdf6bed91ce558c8f72e7defd597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 7 Mar 2019 16:49:44 +0100 Subject: [PATCH 3/3] makefiles/mcuboot.mk: remove compatibility with old ldscript Linkerscript for `nrf52dk` has been updated to use `cortexm.ld` so does not need the configuration anymore for the removed `cpu/nrf52/ldscripts/nrf52832xxaa.ld`. --- makefiles/mcuboot.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/makefiles/mcuboot.mk b/makefiles/mcuboot.mk index a20cc686b1..c5b0bccf71 100644 --- a/makefiles/mcuboot.mk +++ b/makefiles/mcuboot.mk @@ -27,9 +27,7 @@ mcuboot: mcuboot-create-key link @$(COLOR_ECHO) @$(COLOR_ECHO) '$(COLOR_PURPLE)Re-linking for MCUBoot at $(MCUBOOT_SLOT0_SIZE)...$(COLOR_RESET)' @$(COLOR_ECHO) - $(Q)$(_LINK) $(LINKFLAGPREFIX)--defsym=offset="$$(($(MCUBOOT_SLOT0_SIZE) + $(IMAGE_HDR_SIZE)))" \ - $(LINKFLAGPREFIX)--defsym=length="$$(($(MCUBOOT_SLOT1_SIZE) - $(IMAGE_HDR_SIZE)))" \ - $(LINKFLAGPREFIX)--defsym=image_header="$(IMAGE_HDR_SIZE)" -o $(ELFFILE) && \ + $(Q)$(_LINK) -o $(ELFFILE) && \ $(OBJCOPY) $(OFLAGS) -Obinary $(ELFFILE) $(BINFILE) && \ $(IMGTOOL) sign --key $(MCUBOOT_KEYFILE) --version $(IMAGE_VERSION) --align \ $(MCUBOOT_IMAGE_ALIGN) -H $(IMAGE_HDR_SIZE) $(BINFILE) $(SIGN_BINFILE)