From 3c00fba414a936560e97c93acf2e64a26ea336c5 Mon Sep 17 00:00:00 2001 From: solosky Date: Thu, 15 Feb 2024 16:32:08 +0800 Subject: [PATCH] add bootloader LD script --- fw/bootloader/Makefile | 2 +- fw/ld/bootloader_nrf52840.ld | 166 +++++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 fw/ld/bootloader_nrf52840.ld diff --git a/fw/bootloader/Makefile b/fw/bootloader/Makefile index bac8541e..160a7475 100644 --- a/fw/bootloader/Makefile +++ b/fw/bootloader/Makefile @@ -120,7 +120,7 @@ SRC_FILES += \ # Include folders common to all targets INC_FOLDERS += \ $(SDK_ROOT)/components/libraries/crypto/backend/micro_ecc \ - $(SDK_ROOT)/components/softdevice/s112/headers \ + $(SDK_ROOT)/components/softdevice/$(SD_VERSION_INC)/headers \ $(SDK_ROOT)/components/libraries/memobj \ $(SDK_ROOT)/components/libraries/sha256 \ $(SDK_ROOT)/components/libraries/crc32 \ diff --git a/fw/ld/bootloader_nrf52840.ld b/fw/ld/bootloader_nrf52840.ld new file mode 100644 index 00000000..246026bb --- /dev/null +++ b/fw/ld/bootloader_nrf52840.ld @@ -0,0 +1,166 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0xF3000, LENGTH = 0xB000 + RAM (rwx) : ORIGIN = 0x20005978, LENGTH = 0x32688 + uicr_bootloader_start_address (r) : ORIGIN = 0x10001014, LENGTH = 0x4 + bootloader_settings_page (r) : ORIGIN = 0x000FF000, LENGTH = 0x1000 + uicr_mbr_params_page (r) : ORIGIN = 0x10001018, LENGTH = 0x4 + mbr_params_page (r) : ORIGIN = 0x000FE000, LENGTH = 0x1000 +} + +SECTIONS +{ + . = ALIGN(4); + .uicr_bootloader_start_address : + { + PROVIDE(__start_uicr_bootloader_start_address = .); + KEEP(*(SORT(.uicr_bootloader_start_address*))) + PROVIDE(__stop_uicr_bootloader_start_address = .); + } > uicr_bootloader_start_address + . = ALIGN(4); + .bootloader_settings_page(NOLOAD) : + { + PROVIDE(__start_bootloader_settings_page = .); + KEEP(*(SORT(.bootloader_settings_page*))) + PROVIDE(__stop_bootloader_settings_page = .); + } > bootloader_settings_page + . = ALIGN(4); + .uicr_mbr_params_page : + { + PROVIDE(__start_uicr_mbr_params_page = .); + KEEP(*(SORT(.uicr_mbr_params_page*))) + PROVIDE(__stop_uicr_mbr_params_page = .); + } > uicr_mbr_params_page + . = ALIGN(4); + .mbr_params_page(NOLOAD) : + { + PROVIDE(__start_mbr_params_page = .); + KEEP(*(SORT(.mbr_params_page*))) + PROVIDE(__stop_mbr_params_page = .); + } > mbr_params_page +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + .log_dynamic_data : + { + PROVIDE(__start_log_dynamic_data = .); + KEEP(*(SORT(.log_dynamic_data*))) + PROVIDE(__stop_log_dynamic_data = .); + } > RAM + .log_filter_data : + { + PROVIDE(__start_log_filter_data = .); + KEEP(*(SORT(.log_filter_data*))) + PROVIDE(__stop_log_filter_data = .); + } > RAM + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + .crypto_data : + { + PROVIDE(__start_crypto_data = .); + KEEP(*(SORT(.crypto_data*))) + PROVIDE(__stop_crypto_data = .); + } > FLASH + .nrf_queue : + { + PROVIDE(__start_nrf_queue = .); + KEEP(*(.nrf_queue)) + PROVIDE(__stop_nrf_queue = .); + } > FLASH + .dfu_trans : + { + PROVIDE(__start_dfu_trans = .); + KEEP(*(SORT(.dfu_trans*))) + PROVIDE(__stop_dfu_trans = .); + } > FLASH + .svc_data : + { + PROVIDE(__start_svc_data = .); + KEEP(*(.svc_data)) + PROVIDE(__stop_svc_data = .); + } > FLASH + .log_const_data : + { + PROVIDE(__start_log_const_data = .); + KEEP(*(SORT(.log_const_data*))) + PROVIDE(__stop_log_const_data = .); + } > FLASH + .nrf_balloc : + { + PROVIDE(__start_nrf_balloc = .); + KEEP(*(.nrf_balloc)) + PROVIDE(__stop_nrf_balloc = .); + } > FLASH + .sdh_ble_observers : + { + PROVIDE(__start_sdh_ble_observers = .); + KEEP(*(SORT(.sdh_ble_observers*))) + PROVIDE(__stop_sdh_ble_observers = .); + } > FLASH + .log_backends : + { + PROVIDE(__start_log_backends = .); + KEEP(*(SORT(.log_backends*))) + PROVIDE(__stop_log_backends = .); + } > FLASH + .sdh_req_observers : + { + PROVIDE(__start_sdh_req_observers = .); + KEEP(*(SORT(.sdh_req_observers*))) + PROVIDE(__stop_sdh_req_observers = .); + } > FLASH + .sdh_state_observers : + { + PROVIDE(__start_sdh_state_observers = .); + KEEP(*(SORT(.sdh_state_observers*))) + PROVIDE(__stop_sdh_state_observers = .); + } > FLASH + .sdh_stack_observers : + { + PROVIDE(__start_sdh_stack_observers = .); + KEEP(*(SORT(.sdh_stack_observers*))) + PROVIDE(__stop_sdh_stack_observers = .); + } > FLASH + .sdh_soc_observers : + { + PROVIDE(__start_sdh_soc_observers = .); + KEEP(*(SORT(.sdh_soc_observers*))) + PROVIDE(__stop_sdh_soc_observers = .); + } > FLASH + +} INSERT AFTER .text + +INCLUDE "nrf_common.ld" + +SECTIONS +{ + .noinit (NOLOAD): + { + PROVIDE(__start_noinit = .); + /* place all symbols in input sections that start with .noinit */ + KEEP(*(*.noinit*)) + PROVIDE(__stop_noinit = .); + } > NOINIT +}