SDK: nRF5SDK
Toolchain: ARM GCC
Hello,
I have some devices out in the field using nRF52840s, using the non-SoftDevice bootloader, and a custom mechanism for reading updates that I've downloaded to the flash remotely.
In our application, I'd like to start using a NOLOAD section of RAM, by altering the linker script.
However, I'm unsure of what guarantees I can make about how the bootloader will alter the RAM? Given that I can't remotely flash on a new bootloader with a linker script that respects by NOLOAD section.
Given that I have the bootloader code, and linker script, is there anyway I can analyse the memory addresses and determine if there's a portion of RAM which the bootloader defintely won't be initing or messing with, and thus I'm safe to use as a "NOLOAD" section in my application code?
Attached are the bootloader linker script and common linker script in case you don't have the SDK available to you
Thanks,
Joshua
/* Linker script to configure memory regions. */ SEARCH_DIR(.) GROUP(-lgcc -lc -lnosys) MEMORY { FLASH (rx) : ORIGIN = 0xf4000, LENGTH = 0x0A000 RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3FFF8 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 : { } .fs_data : { PROVIDE(__start_fs_data = .); KEEP(*(.fs_data)) PROVIDE(__stop_fs_data = .); } > 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 } 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 .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 .log_backends : { PROVIDE(__start_log_backends = .); KEEP(*(SORT(.log_backends*))) PROVIDE(__stop_log_backends = .); } > FLASH } INSERT AFTER .text SECTIONS { .noinit (NOLOAD) : { . = ALIGN(4); __noinit_start__ = .; *(.noinit*) __noinit_end__ = .; } > PD } INCLUDE "nrf_common.ld"
/* Linker script for Nordic Semiconductor nRF5 devices * * Version: Sourcery G++ 4.5-1 * Support: https://support.codesourcery.com/GNUToolchain/ * * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") /* Linker script to place sections and symbol values. Should be used together * with other linker script that defines memory regions FLASH and RAM. * It references following symbols, which must be defined in code: * Reset_Handler : Entry of reset handler * * It defines following symbols, which code can use without definition: * __exidx_start * __exidx_end * __etext * __data_start__ * __preinit_array_start * __preinit_array_end * __init_array_start * __init_array_end * __fini_array_start * __fini_array_end * __data_end__ * __bss_start__ * __bss_end__ * __end__ * end * __HeapLimit * __StackLimit * __StackTop * __stack */ ENTRY(Reset_Handler) SECTIONS { .text : { KEEP(*(.Vectors)) *(.text*) KEEP(*(.init)) KEEP(*(.fini)) /* .ctors */ *crtbegin.o(.ctors) *crtbegin?.o(.ctors) *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) *(SORT(.ctors.*)) *(.ctors) /* .dtors */ *crtbegin.o(.dtors) *crtbegin?.o(.dtors) *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) *(SORT(.dtors.*)) *(.dtors) *(.rodata*) *(.eh_frame*) . = ALIGN(4); } > FLASH .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) . = ALIGN(4); } > FLASH __exidx_start = .; .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) . = ALIGN(4); } > FLASH __exidx_end = .; __etext = .; .data : AT (__etext) { __data_start__ = .; *(vtable) *(.data*) . = ALIGN(4); /* preinit data */ PROVIDE_HIDDEN (__preinit_array_start = .); *(.preinit_array) PROVIDE_HIDDEN (__preinit_array_end = .); . = ALIGN(4); /* init data */ PROVIDE_HIDDEN (__init_array_start = .); *(SORT(.init_array.*)) *(.init_array) PROVIDE_HIDDEN (__init_array_end = .); . = ALIGN(4); /* finit data */ PROVIDE_HIDDEN (__fini_array_start = .); *(SORT(.fini_array.*)) *(.fini_array) PROVIDE_HIDDEN (__fini_array_end = .); *(.jcr) . = ALIGN(4); /* All data end */ __data_end__ = .; } > RAM .bss : { . = ALIGN(4); __bss_start__ = .; *(.bss*) *(COMMON) . = ALIGN(4); __bss_end__ = .; } > RAM .heap (COPY): { __end__ = .; end = __end__; *(.heap*) __HeapLimit = .; } > RAM /* .stack_dummy section doesn't contains any symbols. It is only * used for linker to calculate size of stack sections, and assign * values to stack symbols later */ .stack_dummy (COPY): { *(.stack*) } > RAM /* Set stack top to end of RAM, and stack limit move down by * size of stack_dummy section */ __StackTop = ORIGIN(RAM) + LENGTH(RAM); __StackLimit = __StackTop - SIZEOF(.stack_dummy); PROVIDE(__stack = __StackTop); /* Check if data + heap + stack exceeds RAM limit */ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") }