From 16e7af43a3a9edcefe015af2c885be15af712d46 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 29 Nov 2019 11:44:51 +0700 Subject: [PATCH] fix linker for 833 compile and able to flash but 52833 is not compatible with S140 v6, need to upgrade it to S140 v7 --- Makefile | 2 +- src/linker/nrf52833_s140_v6.ld | 91 +++++++++++++++++++ .../{s140_v6.ld => nrf52840_s140_v6.ld} | 22 +++-- src/linker/{s132_v6.ld => nrf52_s132_v6.ld} | 21 +++-- 4 files changed, 116 insertions(+), 20 deletions(-) create mode 100644 src/linker/nrf52833_s140_v6.ld rename src/linker/{s140_v6.ld => nrf52840_s140_v6.ld} (88%) rename src/linker/{s132_v6.ld => nrf52_s132_v6.ld} (85%) diff --git a/Makefile b/Makefile index da92efe..372828b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ SD_FILENAME = $(SD_NAME)_nrf52_$(SD_VERSION) SD_API_PATH = $(SD_PATH)/$(SD_FILENAME)_API SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex -LD_FILE = $(SRC_PATH)/linker/$(SD_NAME)_v$(word 1, $(subst ., ,$(SD_VERSION))).ld +LD_FILE = $(SRC_PATH)/linker/$(MCU_SUB_VARIANT)_$(SD_NAME)_v$(word 1, $(subst ., ,$(SD_VERSION))).ld MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION) diff --git a/src/linker/nrf52833_s140_v6.ld b/src/linker/nrf52833_s140_v6.ld new file mode 100644 index 0000000..d665d8a --- /dev/null +++ b/src/linker/nrf52833_s140_v6.ld @@ -0,0 +1,91 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + /** Flash start address for the bootloader. This setting will also be stored in UICR to allow the + * MBR to init the bootloader when starting the system. This value must correspond to + * BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if + * those values do not match. The check is performed in main.c, see + * APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START); + */ + FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000 /* 40 KB */ + + /** Location of mbr params page in flash. */ + MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000 + + /** Location of bootloader setting in flash. */ + BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000 + + + + /** RAM Region for bootloader. */ + /* Avoid conflict with NOINIT for OTA bond sharing */ + RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20020000-0x20008000 + + /* Location for double reset detection, no init */ + DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04 + + /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information + * from application to bootloader when using buttonluss DFU OTA. */ + NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80 + + + + /** Location in UICR where bootloader start address is stored. */ + UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04 + + /** Location in UICR where mbr params page address is stored. */ + UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 +} + +SECTIONS +{ + .fs_data_out ALIGN(4): + { + PROVIDE( __start_fs_data = .); + KEEP(*(fs_data)) + PROVIDE( __stop_fs_data = .); + } = 0 + + /* Place the bootloader settings page in flash. */ + .bootloaderSettings(NOLOAD) : + { + + } > BOOTLOADER_SETTINGS + + /* Write the bootloader address in UICR. */ + .uicrBootStartAddress : + { + KEEP(*(.uicrBootStartAddress)) + } > UICR_BOOTLOADER + + /* Place the mbr params page in flash. */ + .mbrParamsPage(NOLOAD) : + { + + } > MBR_PARAMS_PAGE + + /* Write the bootloader address in UICR. */ + .uicrMbrParamsPageAddress : + { + KEEP(*(.uicrMbrParamsPageAddress)) + } > UICR_MBR_PARAM_PAGE + + .dbl_reset(NOLOAD) : + { + + } > DBL_RESET + + /* No init RAM section in bootloader. Used for bond information exchange. */ + .noinit(NOLOAD) : + { + + } > NOINIT + + /* other placements follow here... */ +} + +INCLUDE "nrf_common.ld" diff --git a/src/linker/s140_v6.ld b/src/linker/nrf52840_s140_v6.ld similarity index 88% rename from src/linker/s140_v6.ld rename to src/linker/nrf52840_s140_v6.ld index 67ff58a..bddaa26 100644 --- a/src/linker/s140_v6.ld +++ b/src/linker/nrf52840_s140_v6.ld @@ -11,7 +11,15 @@ MEMORY * those values do not match. The check is performed in main.c, see * APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START); */ - FLASH (rx) : ORIGIN = 0xF4000, LENGTH = 0xA000 /* 40 KB */ + FLASH (rx) : ORIGIN = 0xF4000, LENGTH = 0xFE000-0xF4000 /* 40 KB */ + + /** Location of mbr params page in flash. */ + MBR_PARAMS_PAGE (rw) : ORIGIN = 0xFE000, LENGTH = 0x1000 + + /** Location of bootloader setting in flash. */ + BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000 + + /** RAM Region for bootloader. */ /* Avoid conflict with NOINIT for OTA bond sharing */ @@ -21,20 +29,14 @@ MEMORY DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04 /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information - * from application to bootloader when using buttonluss DFU OTA. - */ + * from application to bootloader when using buttonluss DFU OTA. */ NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80 - - /** Location of bootloader setting in flash. */ - BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x000FF000, LENGTH = 0x1000 - + + /** Location in UICR where bootloader start address is stored. */ UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04 - /** Location of mbr params page in flash. */ - MBR_PARAMS_PAGE (rw) : ORIGIN = 0x000FE000, LENGTH = 0x1000 - /** Location in UICR where mbr params page address is stored. */ UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 } diff --git a/src/linker/s132_v6.ld b/src/linker/nrf52_s132_v6.ld similarity index 85% rename from src/linker/s132_v6.ld rename to src/linker/nrf52_s132_v6.ld index 206effa..db8d06b 100644 --- a/src/linker/s132_v6.ld +++ b/src/linker/nrf52_s132_v6.ld @@ -11,28 +11,31 @@ MEMORY * those values do not match. The check is performed in main.c, see * APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START); */ - FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0xA000 /* 40 KB */ + FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0x7E000-0x74000 /* 40 KB */ + + /** Location of mbr params page in flash. */ + MBR_PARAMS_PAGE (rw) : ORIGIN = 0x7E000, LENGTH = 0x1000 + + /** Location of bootloader setting in flash. */ + BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x7F000, LENGTH = 0x1000 + + /** RAM Region for bootloader. */ - RAM (rwx) : ORIGIN = 0x20003000, LENGTH = 0x20007F7C-0x20003000 + RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x20010000-0x20008000 /* Location for double reset detection, no init */ DBL_RESET (rwx) : ORIGIN = 0x20007F7C, LENGTH = 0x04 /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information - * from application to bootloader when using buttonluss DFU OTA. - */ + * from application to bootloader when using buttonluss DFU OTA. */ NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80 - /** Location of bootloader setting in flash. */ - BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000 + /** Location in UICR where bootloader start address is stored. */ UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04 - /** Location of mbr params page in flash. */ - MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000 - /** Location in UICR where mbr params page address is stored. */ UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04 }