This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

uicr_mbr_params_page and uicr_bootloader_start_address overwrite the beginning of the softdevice.

Hi,

      I am running SDK 15.3, nRF52840 on a custom board, Softdevice 6.1.1 and SES.

When running the secure dfu example I find that the two segments uicr_mbr_params_page and uicr_bootloader_start_address overwrite the beginning of  the softdevice. nrfConnect programmer stops identifying the softdevice - turns black - and shows it as one contiguous segment at a larger size.

nrf_dfu_mbr_init_sd returns 0x7  which is NRF_ERROR_INVALID_PARAM  which in turn is returned by sd_mbr_command which is documented as  "NRF_ERROR_INVALID_PARAM if an invalid command is given." This I am interpreting as an indication that the softdevice can't be run.

I have tried moving these two segments back to their former locations - as mentioned to solve the same issue with GCC 

<MemorySegment name="mbr_params_page" start="0x000FE000" size="0x1000">
    <ProgramSection alignment="4" keep="Yes" load="No" name=".mbr_params_page" address_symbol="__start_mbr_params_page" end_symbol="__stop_mbr_params_page" start = "0x000FE000" size="0x1000" />
  </MemorySegment>
  <MemorySegment name="bootloader_settings_page" start="0x000FF000" size="0x1000">
    <ProgramSection alignment="4" keep="Yes" load="No" name=".bootloader_settings_page" address_symbol="__start_bootloader_settings_page" end_symbol="__stop_bootloader_settings_page" start = "0x000FF000" size="0x1000" />
  </MemorySegment>
  <MemorySegment name="uicr_mbr_params_page" start="0x10001018" size="0x4">
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_mbr_params_page" address_symbol="__start_uicr_mbr_params_page" end_symbol="__stop_uicr_mbr_params_page" start = "0x10001018" size="0x4" />
  </MemorySegment>
  <MemorySegment name="uicr_bootloader_start_address" start="0x10001014" size="0x4">
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_bootloader_start_address" address_symbol="__start_uicr_bootloader_start_address" end_symbol="__stop_uicr_bootloader_start_address" start = "0x10001014" size="0x4" />
  </MemorySegment>

However that causes an unplaced sections overflow for .init in elf. Flash placement does include .init but doesn't specify a location.

<MemorySegment name="FLASH" start="$(FLASH_PH_START)" size="$(FLASH_PH_SIZE)">
    <ProgramSection load="no" name=".reserved_flash" start="$(FLASH_PH_START)" size="$(FLASH_START)-$(FLASH_PH_START)" />
    <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START)" />
    <ProgramSection alignment="4" load="Yes" name=".init" />
    <ProgramSection alignment="4" load="Yes" name=".init_rodata" />
    <ProgramSection alignment="4" load="Yes" name=".text" />
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".crypto_data" inputsections="*(SORT(.crypto_data*))" address_symbol="__start_crypto_data" end_symbol="__stop_crypto_data" />
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".nrf_queue" inputsections="*(.nrf_queue*)" address_symbol="__start_nrf_queue" end_symbol="__stop_nrf_queue" />
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".dfu_trans" inputsections="*(SORT(.dfu_trans*))" address_symbol="__start_dfu_trans" end_symbol="__stop_dfu_trans" />
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".svc_data" inputsections="*(.svc_data*)" address_symbol="__start_svc_data" end_symbol="__stop_svc_data" />

The primary problem I want to fix is that softdevice isn't working. I am happy to try and fix the unplaced sections overflow or to fix the soft device over write whichever the wise heads suggest.

Many thanks in advance

Paul

Parents
  • Hi Paul, 

    Yes, this is a known issue in SDK v15.3.0, i.e. that the bootloader and SoftDevice( specifically the MBR) have overlapping sections. Programming the generated bootloader hex file with nrfjprog using the --sectorerase command, which is happening under the hood in the nRF Connect Programmer app, will result in the MBR being erased. 

    THis can be solved by merging the SoftDevice hex file with the bootloader hex file and then programming the combined hex. However, this is a bit cumbersome so we will likely switch to an approach where we write the bootloader start address to UICR and then the bootloader will at run-time write the bootloader start address to the MBR page. I have implemented this in SDK v15.3.0 and it is done by modifyying the uicr_bootloader_start_address section in the flash_placement.xml to the following

    <MemorySegment name="uicr_bootloader_start_address" start="0x10001014" size="0x04">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_bootloader_start_address" address_symbol="__start_uicr_bootloader_start_address" end_symbol="__stop_uicr_bootloader_start_address" start = "0x10001014" size="0x4" />
    </MemorySegment>

    Then add the nrf_bootloader_write_bl_addr_to_mbr() function to main.c and call it in main() before nrf_bootloader_flash_protect() is used to protect the MBR and the bootloader. 

    ret_code_t nrf_bootloader_write_bl_addr_to_mbr(void){
        // Enable Write with the NVMC
        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
        
        // Write Bootloader start address to MBR 
        *(volatile uint32_t *)MBR_BOOTLOADER_ADDR = BOOTLOADER_START_ADDR;
    
        // Revert NVMC to read-only
        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    
        return NRF_SUCCESS;
    }
    
    /**@brief Function for application main entry. */
    int main(void)
    {
        uint32_t ret_val;
        
        // Write bootloader start address to the MBR
        ret_val = nrf_bootloader_write_bl_addr_to_mbr();
        APP_ERROR_CHECK(ret_val);
    
        // Protect MBR and bootloader code from being overwritten.
        ret_val = nrf_bootloader_flash_protect(0, MBR_SIZE, false);
        APP_ERROR_CHECK(ret_val);
        ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE, false);
        APP_ERROR_CHECK(ret_val);
    
        (void) NRF_LOG_INIT(nrf_bootloader_dfu_timer_counter_get);
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        NRF_LOG_INFO("Inside main");
    
        ret_val = nrf_bootloader_init(dfu_observer);
        APP_ERROR_CHECK(ret_val);
    
        // Either there was no DFU functionality enabled in this project or the DFU module detected
        // no ongoing DFU operation and found a valid main application.
        // Boot the main application.
        nrf_bootloader_app_start();
    
        // Should never be reached.
        NRF_LOG_INFO("After main");
    }

    Best regards

    Bjørn

  • Hi Bjorn,

                    this looks good. However having made the changes you suggest I now get lots of errors. Most are almost certainly caused by the first which says .init doesn't fit in "unplaced sections"

     Generating linker script 'secure_bootloader_ble_s140_pca10056_debug.ld'
    1> Linking secure_bootloader_ble_s140_pca10056_debug.elf
    1> /usr/share/segger_embedded_studio_for_arm_4.12/gcc/arm-none-eabi/bin/ld: Output/Release/Exe/secure_bootloader_ble_s140_pca10056_debug.elf section `.init' will not fit in region `UNPLACED_SECTIONS'
    1> /usr/share/segger_embedded_studio_for_arm_4.12/gcc/arm-none-eabi/bin/ld: region `UNPLACED_SECTIONS' overflowed by 64528 bytes
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/thumb_crt0.o: In function `memory_set':
    1> (.init+0xdc): undefined reference to `__stack_end__'
    1> (.init+0xe0): undefined reference to `__stack_start__'
    1> (.init+0xe4): undefined reference to `__stack_process_end__'
    1> (.init+0xe8): undefined reference to `__stack_process_start__'
    1> (.init+0xec): undefined reference to `__data_load_start__'
    1> (.init+0xf0): undefined reference to `__data_start__'
    1> (.init+0xf4): undefined reference to `__data_end__'
    1> (.init+0xf8): undefined reference to `__text_load_start__'
    1> (.init+0xfc): undefined reference to `__text_start__'
    1> (.init+0x100): undefined reference to `__text_end__'
    1> (.init+0x104): undefined reference to `__fast_load_start__'
    1> (.init+0x108): undefined reference to `__fast_start__'
    1> (.init+0x10c): undefined reference to `__fast_end__'
    1> (.init+0x110): undefined reference to `__ctors_load_start__'
    1> (.init+0x114): undefined reference to `__ctors_start__'
    1> (.init+0x118): undefined reference to `__ctors_end__'
    1> (.init+0x11c): undefined reference to `__dtors_load_start__'
    1> (.init+0x120): undefined reference to `__dtors_start__'
    1> (.init+0x124): undefined reference to `__dtors_end__'
    1> (.init+0x128): undefined reference to `__rodata_load_start__'
    1> (.init+0x12c): undefined reference to `__rodata_start__'
    1> (.init+0x130): undefined reference to `__rodata_end__'
    1> (.init+0x134): undefined reference to `__tdata_load_start__'
    1> (.init+0x138): undefined reference to `__tdata_start__'
    1> (.init+0x13c): undefined reference to `__tdata_end__'
    1> (.init+0x140): undefined reference to `__bss_start__'
    1> (.init+0x144): undefined reference to `__bss_end__'
    1> (.init+0x148): undefined reference to `__tbss_start__'
    1> (.init+0x14c): undefined reference to `__tbss_end__'
    1> (.init+0x150): undefined reference to `__heap_start__'
    1> (.init+0x154): undefined reference to `__heap_end__'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/ses_startup_nrf52840.o: In function `_vectors':
    1> (.vectors+0x0): undefined reference to `__stack_end__'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/ses_startup_nrf_common.o: In function `InitializeUserMemorySections':
    1> (.init+0x54): undefined reference to `__start_nrf_sections'
    1> (.init+0x58): undefined reference to `__start_nrf_sections_run'
    1> (.init+0x5c): undefined reference to `__end_nrf_sections_run'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_log_frontend.o: In function `nrf_log_module_name_get':
    1> nrf_log_frontend.c:(.text.nrf_log_module_name_get+0x2c): undefined reference to `__start_log_const_data'
    1> nrf_log_frontend.c:(.text.nrf_log_module_name_get+0x30): undefined reference to `__stop_log_const_data'
    1> nrf_log_frontend.c:(.text.nrf_log_module_name_get+0x34): undefined reference to `__start_log_dynamic_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_log_frontend.o: In function `nrf_log_color_id_get':
    1> nrf_log_frontend.c:(.text.nrf_log_color_id_get+0x28): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_log_frontend.o: In function `nrf_log_frontend_dequeue':
    1> nrf_log_frontend.c:(.text.nrf_log_frontend_dequeue+0x230): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_log_frontend.o: In function `std_n':
    1> nrf_log_frontend.c:(.text.std_n+0xcc): undefined reference to `__stop_log_const_data'
    1> nrf_log_frontend.c:(.text.std_n+0xd0): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_req_observers+0x0): undefined reference to `__start_sdh_req_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_req_observers+0x4): undefined reference to `__stop_sdh_req_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_stack_observers+0x0): undefined reference to `__start_sdh_stack_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_stack_observers+0x4): undefined reference to `__stop_sdh_stack_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_state_observers+0x0): undefined reference to `__start_sdh_state_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_state_observers+0x4): undefined reference to `__stop_sdh_state_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_crypto_init.o: In function `nrf_crypto_init':
    1> nrf_crypto_init.c:(.text.nrf_crypto_init+0x2c): undefined reference to `__start_crypto_data'
    1> nrf_crypto_init.c:(.text.nrf_crypto_init+0x30): undefined reference to `__stop_crypto_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/main.o: In function `app_error_fault_handler':
    1> main.c:(.text.app_error_fault_handler+0x20): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/main.o: In function `app_error_handler_bare':
    1> main.c:(.text.app_error_handler_bare+0x1c): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/main.o: In function `main':
    1> main.c:(.text.startup.main+0x78): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader.o: In function `bootloader_reset.constprop.0':
    1> nrf_bootloader.c:(.text.bootloader_reset.constprop.0+0x2c): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader.o: In function `inactivity_timeout':
    1> nrf_bootloader.c:(.text.inactivity_timeout+0x24): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader.o:nrf_bootloader.c:(.text.nrf_dfu_init_user+0x20): more undefined references to `__start_log_const_data' follow
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_svc_handler.o: In function `nrf_svc_handler_c':
    1> nrf_svc_handler.c:(.text.nrf_svc_handler_c+0x60): undefined reference to `__start_svc_data'
    1> nrf_svc_handler.c:(.text.nrf_svc_handler_c+0x64): undefined reference to `__stop_svc_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_fw_activation.o: In function `bl_activate':
    1> nrf_bootloader_fw_activation.c:(.text.bl_activate+0x90): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_fw_activation.o: In function `image_copy.constprop.0':
    1> nrf_bootloader_fw_activation.c:(.text.image_copy.constprop.0+0xf4): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_fw_activation.o: In function `sd_activate':
    1> nrf_bootloader_fw_activation.c:(.text.sd_activate+0xe0): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_fw_activation.o: In function `nrf_bootloader_fw_activate':
    1> nrf_bootloader_fw_activation.c:(.text.nrf_bootloader_fw_activate+0x178): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_app_start.o: In function `nrf_bootloader_app_start':
    1> nrf_bootloader_app_start.c:(.text.nrf_bootloader_app_start+0x64): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_app_start_final.o:nrf_bootloader_app_start_final.c:(.text.nrf_bootloader_app_start_final+0xbc): more undefined references to `__start_log_const_data' follow
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_transport.o: In function `nrf_dfu_transports_init':
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_init+0x60): undefined reference to `__stop_dfu_trans'
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_init+0x6c): undefined reference to `__start_dfu_trans'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_transport.o: In function `nrf_dfu_transports_close':
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_close+0x5c): undefined reference to `__start_log_const_data'
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_close+0x64): undefined reference to `__stop_dfu_trans'
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_close+0x70): undefined reference to `__start_dfu_trans'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_utils.o: In function `nrf_dfu_cache_prepare':
    1> nrf_dfu_utils.c:(.text.nrf_dfu_cache_prepare+0x1ac): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o: In function `stored_init_cmd_decode':
    1> nrf_dfu_validation.c:(.text.stored_init_cmd_decode+0x120): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o: In function `update_data_size_get':
    1> nrf_dfu_validation.c:(.text.update_data_size_get+0x7c): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o: In function `pb_decoding_callback':
    1> nrf_dfu_validation.c:(.text.pb_decoding_callback+0x68): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o: In function `nrf_dfu_validation_signature_check':
    1> nrf_dfu_validation.c:(.text.nrf_dfu_validation_signature_check+0x134): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o:nrf_dfu_validation.c:(.text.nrf_dfu_validation_hash_ok+0xc8): more undefined references to `__start_log_const_data' follow
    Build failed

    My current flash_placement.xml is:

    <!DOCTYPE Linker_Placement_File>
    <Root name="Flash Section Placement">
      <MemorySegment name="FLASH" start="$(FLASH_PH_START)" size="$(FLASH_PH_SIZE)">
        <ProgramSection load="no" name=".reserved_flash" start="$(FLASH_PH_START)" size="$(FLASH_START)-$(FLASH_PH_START)" />
        <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START)" />
        <ProgramSection alignment="4" load="Yes" name=".init" />
        <ProgramSection alignment="4" load="Yes" name=".init_rodata" />
        <ProgramSection alignment="4" load="Yes" name=".text" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".crypto_data" inputsections="*(SORT(.crypto_data*))" address_symbol="__start_crypto_data" end_symbol="__stop_crypto_data" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".nrf_queue" inputsections="*(.nrf_queue*)" address_symbol="__start_nrf_queue" end_symbol="__stop_nrf_queue" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".dfu_trans" inputsections="*(SORT(.dfu_trans*))" address_symbol="__start_dfu_trans" end_symbol="__stop_dfu_trans" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".svc_data" inputsections="*(.svc_data*)" address_symbol="__start_svc_data" end_symbol="__stop_svc_data" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_const_data" inputsections="*(SORT(.log_const_data*))" address_symbol="__start_log_const_data" end_symbol="__stop_log_const_data" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".nrf_balloc" inputsections="*(.nrf_balloc*)" address_symbol="__start_nrf_balloc" end_symbol="__stop_nrf_balloc" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_backends" inputsections="*(SORT(.log_backends*))" address_symbol="__start_log_backends" end_symbol="__stop_log_backends" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_ble_observers" inputsections="*(SORT(.sdh_ble_observers*))" address_symbol="__start_sdh_ble_observers" end_symbol="__stop_sdh_ble_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_req_observers" inputsections="*(SORT(.sdh_req_observers*))" address_symbol="__start_sdh_req_observers" end_symbol="__stop_sdh_req_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_state_observers" inputsections="*(SORT(.sdh_state_observers*))" address_symbol="__start_sdh_state_observers" end_symbol="__stop_sdh_state_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_stack_observers" inputsections="*(SORT(.sdh_stack_observers*))" address_symbol="__start_sdh_stack_observers" end_symbol="__stop_sdh_stack_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_soc_observers" inputsections="*(SORT(.sdh_soc_observers*))" address_symbol="__start_sdh_soc_observers" end_symbol="__stop_sdh_soc_observers" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".nrf_sections" address_symbol="__start_nrf_sections" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_dynamic_data"  inputsections="*(SORT(.log_dynamic_data*))" runin=".log_dynamic_data_run"/>
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_filter_data"  inputsections="*(SORT(.log_filter_data*))" runin=".log_filter_data_run"/>
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".fs_data"  inputsections="*(.fs_data*)" runin=".fs_data_run"/>
        <ProgramSection alignment="4" load="Yes" name=".dtors" />
        <ProgramSection alignment="4" load="Yes" name=".ctors" />
        <ProgramSection alignment="4" load="Yes" name=".rodata" />
        <ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
        <ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
        <ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
        <ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
      </MemorySegment>
      <MemorySegment name="RAM" start="$(RAM_PH_START)" size="$(RAM_PH_SIZE)">
        <ProgramSection load="no" name=".reserved_ram" start="$(RAM_PH_START)" size="$(RAM_START)-$(RAM_PH_START)" />
        <ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START)" address_symbol="__app_ram_start__"/>
        <ProgramSection alignment="4" keep="Yes" load="No" name=".nrf_sections_run" address_symbol="__start_nrf_sections_run" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".log_dynamic_data_run" address_symbol="__start_log_dynamic_data" end_symbol="__stop_log_dynamic_data" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".log_filter_data_run" address_symbol="__start_log_filter_data" end_symbol="__stop_log_filter_data" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".fs_data_run" address_symbol="__start_fs_data" end_symbol="__stop_fs_data" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".nrf_sections_run_end" address_symbol="__end_nrf_sections_run" />
        <ProgramSection alignment="4" load="No" name=".fast_run" />
        <ProgramSection alignment="4" load="No" name=".data_run" />
        <ProgramSection alignment="4" load="No" name=".tdata_run" />
        <ProgramSection alignment="4" load="No" name=".bss" />
        <ProgramSection alignment="4" load="No" name=".tbss" />
        <ProgramSection alignment="4" load="No" name=".non_init" />
        <ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
        <ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack"  address_symbol="__StackLimit" end_symbol="__StackTop"/>
        <ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
      </MemorySegment>
      <MemorySegment name="mbr_params_page" start="0x000FE000" size="0x1000">
        <ProgramSection alignment="4" keep="Yes" load="No" name=".mbr_params_page" address_symbol="__start_mbr_params_page" end_symbol="__stop_mbr_params_page" start = "0x000FE000" size="0x1000" />
      </MemorySegment>
      <MemorySegment name="bootloader_settings_page" start="0x000FF000" size="0x1000">
        <ProgramSection alignment="4" keep="Yes" load="No" name=".bootloader_settings_page" address_symbol="__start_bootloader_settings_page" end_symbol="__stop_bootloader_settings_page" start = "0x000FF000" size="0x1000" />
      </MemorySegment>
      <MemorySegment name="uicr_mbr_params_page" start="0x10001018" size="0x4">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_mbr_params_page" address_symbol="__start_uicr_mbr_params_page" end_symbol="__stop_uicr_mbr_params_page" start = "0x10001018" size="0x4" />
      </MemorySegment>
      <MemorySegment name="uicr_bootloader_start_address" start="0x10001014" size="0x4">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_bootloader_start_address" address_symbol="__start_uicr_bootloader_start_address" end_symbol="__stop_uicr_bootloader_start_address" start = "0x10001014" size="0x4" />
      </MemorySegment>
    </Root>
    

    Many thanks

    Cheers Paul

Reply
  • Hi Bjorn,

                    this looks good. However having made the changes you suggest I now get lots of errors. Most are almost certainly caused by the first which says .init doesn't fit in "unplaced sections"

     Generating linker script 'secure_bootloader_ble_s140_pca10056_debug.ld'
    1> Linking secure_bootloader_ble_s140_pca10056_debug.elf
    1> /usr/share/segger_embedded_studio_for_arm_4.12/gcc/arm-none-eabi/bin/ld: Output/Release/Exe/secure_bootloader_ble_s140_pca10056_debug.elf section `.init' will not fit in region `UNPLACED_SECTIONS'
    1> /usr/share/segger_embedded_studio_for_arm_4.12/gcc/arm-none-eabi/bin/ld: region `UNPLACED_SECTIONS' overflowed by 64528 bytes
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/thumb_crt0.o: In function `memory_set':
    1> (.init+0xdc): undefined reference to `__stack_end__'
    1> (.init+0xe0): undefined reference to `__stack_start__'
    1> (.init+0xe4): undefined reference to `__stack_process_end__'
    1> (.init+0xe8): undefined reference to `__stack_process_start__'
    1> (.init+0xec): undefined reference to `__data_load_start__'
    1> (.init+0xf0): undefined reference to `__data_start__'
    1> (.init+0xf4): undefined reference to `__data_end__'
    1> (.init+0xf8): undefined reference to `__text_load_start__'
    1> (.init+0xfc): undefined reference to `__text_start__'
    1> (.init+0x100): undefined reference to `__text_end__'
    1> (.init+0x104): undefined reference to `__fast_load_start__'
    1> (.init+0x108): undefined reference to `__fast_start__'
    1> (.init+0x10c): undefined reference to `__fast_end__'
    1> (.init+0x110): undefined reference to `__ctors_load_start__'
    1> (.init+0x114): undefined reference to `__ctors_start__'
    1> (.init+0x118): undefined reference to `__ctors_end__'
    1> (.init+0x11c): undefined reference to `__dtors_load_start__'
    1> (.init+0x120): undefined reference to `__dtors_start__'
    1> (.init+0x124): undefined reference to `__dtors_end__'
    1> (.init+0x128): undefined reference to `__rodata_load_start__'
    1> (.init+0x12c): undefined reference to `__rodata_start__'
    1> (.init+0x130): undefined reference to `__rodata_end__'
    1> (.init+0x134): undefined reference to `__tdata_load_start__'
    1> (.init+0x138): undefined reference to `__tdata_start__'
    1> (.init+0x13c): undefined reference to `__tdata_end__'
    1> (.init+0x140): undefined reference to `__bss_start__'
    1> (.init+0x144): undefined reference to `__bss_end__'
    1> (.init+0x148): undefined reference to `__tbss_start__'
    1> (.init+0x14c): undefined reference to `__tbss_end__'
    1> (.init+0x150): undefined reference to `__heap_start__'
    1> (.init+0x154): undefined reference to `__heap_end__'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/ses_startup_nrf52840.o: In function `_vectors':
    1> (.vectors+0x0): undefined reference to `__stack_end__'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/ses_startup_nrf_common.o: In function `InitializeUserMemorySections':
    1> (.init+0x54): undefined reference to `__start_nrf_sections'
    1> (.init+0x58): undefined reference to `__start_nrf_sections_run'
    1> (.init+0x5c): undefined reference to `__end_nrf_sections_run'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_log_frontend.o: In function `nrf_log_module_name_get':
    1> nrf_log_frontend.c:(.text.nrf_log_module_name_get+0x2c): undefined reference to `__start_log_const_data'
    1> nrf_log_frontend.c:(.text.nrf_log_module_name_get+0x30): undefined reference to `__stop_log_const_data'
    1> nrf_log_frontend.c:(.text.nrf_log_module_name_get+0x34): undefined reference to `__start_log_dynamic_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_log_frontend.o: In function `nrf_log_color_id_get':
    1> nrf_log_frontend.c:(.text.nrf_log_color_id_get+0x28): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_log_frontend.o: In function `nrf_log_frontend_dequeue':
    1> nrf_log_frontend.c:(.text.nrf_log_frontend_dequeue+0x230): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_log_frontend.o: In function `std_n':
    1> nrf_log_frontend.c:(.text.std_n+0xcc): undefined reference to `__stop_log_const_data'
    1> nrf_log_frontend.c:(.text.std_n+0xd0): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_req_observers+0x0): undefined reference to `__start_sdh_req_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_req_observers+0x4): undefined reference to `__stop_sdh_req_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_stack_observers+0x0): undefined reference to `__start_sdh_stack_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_stack_observers+0x4): undefined reference to `__stop_sdh_stack_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_state_observers+0x0): undefined reference to `__start_sdh_state_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_sdh.o:(.rodata.sdh_state_observers+0x4): undefined reference to `__stop_sdh_state_observers'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_crypto_init.o: In function `nrf_crypto_init':
    1> nrf_crypto_init.c:(.text.nrf_crypto_init+0x2c): undefined reference to `__start_crypto_data'
    1> nrf_crypto_init.c:(.text.nrf_crypto_init+0x30): undefined reference to `__stop_crypto_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/main.o: In function `app_error_fault_handler':
    1> main.c:(.text.app_error_fault_handler+0x20): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/main.o: In function `app_error_handler_bare':
    1> main.c:(.text.app_error_handler_bare+0x1c): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/main.o: In function `main':
    1> main.c:(.text.startup.main+0x78): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader.o: In function `bootloader_reset.constprop.0':
    1> nrf_bootloader.c:(.text.bootloader_reset.constprop.0+0x2c): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader.o: In function `inactivity_timeout':
    1> nrf_bootloader.c:(.text.inactivity_timeout+0x24): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader.o:nrf_bootloader.c:(.text.nrf_dfu_init_user+0x20): more undefined references to `__start_log_const_data' follow
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_svc_handler.o: In function `nrf_svc_handler_c':
    1> nrf_svc_handler.c:(.text.nrf_svc_handler_c+0x60): undefined reference to `__start_svc_data'
    1> nrf_svc_handler.c:(.text.nrf_svc_handler_c+0x64): undefined reference to `__stop_svc_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_fw_activation.o: In function `bl_activate':
    1> nrf_bootloader_fw_activation.c:(.text.bl_activate+0x90): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_fw_activation.o: In function `image_copy.constprop.0':
    1> nrf_bootloader_fw_activation.c:(.text.image_copy.constprop.0+0xf4): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_fw_activation.o: In function `sd_activate':
    1> nrf_bootloader_fw_activation.c:(.text.sd_activate+0xe0): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_fw_activation.o: In function `nrf_bootloader_fw_activate':
    1> nrf_bootloader_fw_activation.c:(.text.nrf_bootloader_fw_activate+0x178): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_app_start.o: In function `nrf_bootloader_app_start':
    1> nrf_bootloader_app_start.c:(.text.nrf_bootloader_app_start+0x64): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_bootloader_app_start_final.o:nrf_bootloader_app_start_final.c:(.text.nrf_bootloader_app_start_final+0xbc): more undefined references to `__start_log_const_data' follow
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_transport.o: In function `nrf_dfu_transports_init':
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_init+0x60): undefined reference to `__stop_dfu_trans'
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_init+0x6c): undefined reference to `__start_dfu_trans'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_transport.o: In function `nrf_dfu_transports_close':
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_close+0x5c): undefined reference to `__start_log_const_data'
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_close+0x64): undefined reference to `__stop_dfu_trans'
    1> nrf_dfu_transport.c:(.text.nrf_dfu_transports_close+0x70): undefined reference to `__start_dfu_trans'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_utils.o: In function `nrf_dfu_cache_prepare':
    1> nrf_dfu_utils.c:(.text.nrf_dfu_cache_prepare+0x1ac): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o: In function `stored_init_cmd_decode':
    1> nrf_dfu_validation.c:(.text.stored_init_cmd_decode+0x120): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o: In function `update_data_size_get':
    1> nrf_dfu_validation.c:(.text.update_data_size_get+0x7c): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o: In function `pb_decoding_callback':
    1> nrf_dfu_validation.c:(.text.pb_decoding_callback+0x68): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o: In function `nrf_dfu_validation_signature_check':
    1> nrf_dfu_validation.c:(.text.nrf_dfu_validation_signature_check+0x134): undefined reference to `__start_log_const_data'
    1> Output/secure_bootloader_ble_s140_pca10056_debug Release/Obj/nrf_dfu_validation.o:nrf_dfu_validation.c:(.text.nrf_dfu_validation_hash_ok+0xc8): more undefined references to `__start_log_const_data' follow
    Build failed

    My current flash_placement.xml is:

    <!DOCTYPE Linker_Placement_File>
    <Root name="Flash Section Placement">
      <MemorySegment name="FLASH" start="$(FLASH_PH_START)" size="$(FLASH_PH_SIZE)">
        <ProgramSection load="no" name=".reserved_flash" start="$(FLASH_PH_START)" size="$(FLASH_START)-$(FLASH_PH_START)" />
        <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START)" />
        <ProgramSection alignment="4" load="Yes" name=".init" />
        <ProgramSection alignment="4" load="Yes" name=".init_rodata" />
        <ProgramSection alignment="4" load="Yes" name=".text" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".crypto_data" inputsections="*(SORT(.crypto_data*))" address_symbol="__start_crypto_data" end_symbol="__stop_crypto_data" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".nrf_queue" inputsections="*(.nrf_queue*)" address_symbol="__start_nrf_queue" end_symbol="__stop_nrf_queue" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".dfu_trans" inputsections="*(SORT(.dfu_trans*))" address_symbol="__start_dfu_trans" end_symbol="__stop_dfu_trans" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".svc_data" inputsections="*(.svc_data*)" address_symbol="__start_svc_data" end_symbol="__stop_svc_data" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_const_data" inputsections="*(SORT(.log_const_data*))" address_symbol="__start_log_const_data" end_symbol="__stop_log_const_data" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".nrf_balloc" inputsections="*(.nrf_balloc*)" address_symbol="__start_nrf_balloc" end_symbol="__stop_nrf_balloc" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_backends" inputsections="*(SORT(.log_backends*))" address_symbol="__start_log_backends" end_symbol="__stop_log_backends" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_ble_observers" inputsections="*(SORT(.sdh_ble_observers*))" address_symbol="__start_sdh_ble_observers" end_symbol="__stop_sdh_ble_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_req_observers" inputsections="*(SORT(.sdh_req_observers*))" address_symbol="__start_sdh_req_observers" end_symbol="__stop_sdh_req_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_state_observers" inputsections="*(SORT(.sdh_state_observers*))" address_symbol="__start_sdh_state_observers" end_symbol="__stop_sdh_state_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_stack_observers" inputsections="*(SORT(.sdh_stack_observers*))" address_symbol="__start_sdh_stack_observers" end_symbol="__stop_sdh_stack_observers" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_soc_observers" inputsections="*(SORT(.sdh_soc_observers*))" address_symbol="__start_sdh_soc_observers" end_symbol="__stop_sdh_soc_observers" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".nrf_sections" address_symbol="__start_nrf_sections" />
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_dynamic_data"  inputsections="*(SORT(.log_dynamic_data*))" runin=".log_dynamic_data_run"/>
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".log_filter_data"  inputsections="*(SORT(.log_filter_data*))" runin=".log_filter_data_run"/>
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".fs_data"  inputsections="*(.fs_data*)" runin=".fs_data_run"/>
        <ProgramSection alignment="4" load="Yes" name=".dtors" />
        <ProgramSection alignment="4" load="Yes" name=".ctors" />
        <ProgramSection alignment="4" load="Yes" name=".rodata" />
        <ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
        <ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
        <ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
        <ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
      </MemorySegment>
      <MemorySegment name="RAM" start="$(RAM_PH_START)" size="$(RAM_PH_SIZE)">
        <ProgramSection load="no" name=".reserved_ram" start="$(RAM_PH_START)" size="$(RAM_START)-$(RAM_PH_START)" />
        <ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START)" address_symbol="__app_ram_start__"/>
        <ProgramSection alignment="4" keep="Yes" load="No" name=".nrf_sections_run" address_symbol="__start_nrf_sections_run" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".log_dynamic_data_run" address_symbol="__start_log_dynamic_data" end_symbol="__stop_log_dynamic_data" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".log_filter_data_run" address_symbol="__start_log_filter_data" end_symbol="__stop_log_filter_data" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".fs_data_run" address_symbol="__start_fs_data" end_symbol="__stop_fs_data" />
        <ProgramSection alignment="4" keep="Yes" load="No" name=".nrf_sections_run_end" address_symbol="__end_nrf_sections_run" />
        <ProgramSection alignment="4" load="No" name=".fast_run" />
        <ProgramSection alignment="4" load="No" name=".data_run" />
        <ProgramSection alignment="4" load="No" name=".tdata_run" />
        <ProgramSection alignment="4" load="No" name=".bss" />
        <ProgramSection alignment="4" load="No" name=".tbss" />
        <ProgramSection alignment="4" load="No" name=".non_init" />
        <ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
        <ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack"  address_symbol="__StackLimit" end_symbol="__StackTop"/>
        <ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
      </MemorySegment>
      <MemorySegment name="mbr_params_page" start="0x000FE000" size="0x1000">
        <ProgramSection alignment="4" keep="Yes" load="No" name=".mbr_params_page" address_symbol="__start_mbr_params_page" end_symbol="__stop_mbr_params_page" start = "0x000FE000" size="0x1000" />
      </MemorySegment>
      <MemorySegment name="bootloader_settings_page" start="0x000FF000" size="0x1000">
        <ProgramSection alignment="4" keep="Yes" load="No" name=".bootloader_settings_page" address_symbol="__start_bootloader_settings_page" end_symbol="__stop_bootloader_settings_page" start = "0x000FF000" size="0x1000" />
      </MemorySegment>
      <MemorySegment name="uicr_mbr_params_page" start="0x10001018" size="0x4">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_mbr_params_page" address_symbol="__start_uicr_mbr_params_page" end_symbol="__stop_uicr_mbr_params_page" start = "0x10001018" size="0x4" />
      </MemorySegment>
      <MemorySegment name="uicr_bootloader_start_address" start="0x10001014" size="0x4">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_bootloader_start_address" address_symbol="__start_uicr_bootloader_start_address" end_symbol="__stop_uicr_bootloader_start_address" start = "0x10001014" size="0x4" />
      </MemorySegment>
    </Root>
    

    Many thanks

    Cheers Paul

Children
Related