Merged bootloader+settings+SD+app not working

Hello,

Issue: after successfully compiling, generating bootloader settings, merging and flashing bootloader+settings+sd+app, the device enters DFU mode while i was expecting to run the app.

I'm developing a solution based on a nRF52832 with a custom board, softdevice S112 version 7.0.2, with SDK 17.0.2.

I have successfully built the micro_eec library, and bootloader from $(SDK)/examples/dfu/secure_bootloader/pca10040e_s112_ble.

My app is tested working when flashing with no bootloader (erase device, flash the softdevice and app). My app also uses two flash pages to store data, as per this definition:

NRF_FSTORAGE_DEF(nrf_fstorage_t my_flash) =
{
.evt_handler = flash_callback,
.start_addr = 0x7E000,
.end_addr = 0x7FFFF,
};

Bootloader setting is generated successfully with the following line:

nrfutil settings generate --family NRF52 --application $(OUTPUT_DIRECTORY)/nrf52810_xxaa.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 $(OUTPUT_DIRECTORY)/bootloader_setting.hex

Here is the output:

Bootloader DFU Settings:
* File:                     _build/bootloader_setting.hex
* Family:                   nRF52
* Start Address:            0x0007F000
* CRC:                      0x3879A3DC
* Settings Version:         0x00000002 (2)
* App Version:              0x00000000 (0)
* Bootloader Version:       0x00000000 (0)
* Bank Layout:              0x00000000
* Current Bank:             0x00000000
* Application Size:         0x0000D8A4 (55460 bytes)
* Application CRC:          0x74ED94AE
* Bank0 Bank Code:          0x00000001
* Softdevice Size:          0x00000000 (0 bytes)
* Boot Validation CRC:      0xFEBF7781
* SD Boot Validation Type:  0x00000000 (0)
* App Boot Validation Type: 0x00000001 (1)

Bootloader project linker config file:

/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x28000, LENGTH = 0x6000
  RAM (rwx) :  ORIGIN = 0x200022c8, LENGTH = 0x3d38
  uicr_bootloader_start_address (r) : ORIGIN = 0x10001014, LENGTH = 0x4
  uicr_mbr_params_page (r) : ORIGIN = 0x10001018, LENGTH = 0x4
  mbr_params_page (r) : ORIGIN = 0x0002E000, LENGTH = 0x1000
  bootloader_settings_page (r) : ORIGIN = 0x0002F000, 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);
  .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
  . = ALIGN(4);
  .bootloader_settings_page(NOLOAD) :
  {
    PROVIDE(__start_bootloader_settings_page = .);
    KEEP(*(SORT(.bootloader_settings_page*)))
    PROVIDE(__stop_bootloader_settings_page = .);
  } > bootloader_settings_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
  .log_const_data :
  {
    PROVIDE(__start_log_const_data = .);
    KEEP(*(SORT(.log_const_data*)))
    PROVIDE(__stop_log_const_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
    .nrf_balloc :
  {
    PROVIDE(__start_nrf_balloc = .);
    KEEP(*(.nrf_balloc))
    PROVIDE(__stop_nrf_balloc = .);
  } > FLASH
    .svc_data :
  {
    PROVIDE(__start_svc_data = .);
    KEEP(*(.svc_data))
    PROVIDE(__stop_svc_data = .);
  } > FLASH
  .sdh_ble_observers :
  {
    PROVIDE(__start_sdh_ble_observers = .);
    KEEP(*(SORT(.sdh_ble_observers*)))
    PROVIDE(__stop_sdh_ble_observers = .);
  } > 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"

App project linker config file:

/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x19000, LENGTH = 0x17000
  RAM (rwx) :  ORIGIN = 0x200022c8, LENGTH = 0x3d38
}

SECTIONS
{
}

SECTIONS
{
  . = ALIGN(4);
  .mem_section_dummy_ram :
  {
  }
  .cli_sorted_cmd_ptrs :
  {
    PROVIDE(__start_cli_sorted_cmd_ptrs = .);
    KEEP(*(.cli_sorted_cmd_ptrs))
    PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
  } > 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 :
  {
  }
  .sdh_soc_observers :
  {
    PROVIDE(__start_sdh_soc_observers = .);
    KEEP(*(SORT(.sdh_soc_observers*)))
    PROVIDE(__stop_sdh_soc_observers = .);
  } > FLASH
  .sdh_ble_observers :
  {
    PROVIDE(__start_sdh_ble_observers = .);
    KEEP(*(SORT(.sdh_ble_observers*)))
    PROVIDE(__stop_sdh_ble_observers = .);
  } > FLASH
  .pwr_mgmt_data :
  {
    PROVIDE(__start_pwr_mgmt_data = .);
    KEEP(*(SORT(.pwr_mgmt_data*)))
    PROVIDE(__stop_pwr_mgmt_data = .);
  } > 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
    .nrf_queue :
  {
    PROVIDE(__start_nrf_queue = .);
    KEEP(*(.nrf_queue))
    PROVIDE(__stop_nrf_queue = .);
  } > FLASH
    .nrf_balloc :
  {
    PROVIDE(__start_nrf_balloc = .);
    KEEP(*(.nrf_balloc))
    PROVIDE(__stop_nrf_balloc = .);
  } > FLASH
    .cli_command :
  {
    PROVIDE(__start_cli_command = .);
    KEEP(*(.cli_command))
    PROVIDE(__stop_cli_command = .);
  } > FLASH
  .crypto_data :
  {
    PROVIDE(__start_crypto_data = .);
    KEEP(*(SORT(.crypto_data*)))
    PROVIDE(__stop_crypto_data = .);
  } > FLASH
  .log_const_data :
  {
    PROVIDE(__start_log_const_data = .);
    KEEP(*(SORT(.log_const_data*)))
    PROVIDE(__stop_log_const_data = .);
  } > FLASH
  .log_backends :
  {
    PROVIDE(__start_log_backends = .);
    KEEP(*(SORT(.log_backends*)))
    PROVIDE(__stop_log_backends = .);
  } > FLASH

} INSERT AFTER .text


INCLUDE "nrf_common.ld"

i have no warnings when merging (ie, no overlap)

Thanks,

Martin

Parents
  • Hi Martin,

    Your choice of fstorage pages sticks out. Referring to the memory layout from the bootloader documentation you see that the bootloader settings page and MBR params page (latter is optional but needed for SoftDevice and bootloader updates) are fixed to the two last pages. So using the example bootloader, when you write other data to these pages from your application they will be corrupted. With a corrupt bootloader settings page, the bootloader will enter DFU mode instead of starting the application.

    I see that you have relocated the bootloader settings page and MBR params page in your bootloader linker file though, so at first glance the above is not the issue in your bootloader. However, there are also other parts of the code where the bootloader settings page address is defined. Specifically, the definition of BOOTLOADER_SETTINGS_ADDRESS and NRF_MBR_PARAMS_PAGE_ADDRESS in <nRF5 SDK 17.0.2>\components\libraries\bootloader\dfu\nrf_dfu_types.h. Have you adjusted that?

    (Generally, I would recommend placing your user data below the bootloader (and even below the FDS pages if you use that, as that is also hard coded to always be immediately below the bootloader) just because that is what is supported out of the box. Generally where you locate data should not matter, but changing as little as possible in the SDK code probably makes sense unless there are good reasons to do so.)

  • Hello Einar,

    Thank you very much for your answer.

    First, i want to clarify that i did not make any changes in the bootloader linker script. All values shown in that file are the same as the ones stated in the bootloader documentation, under memory layout, but for the nRF52810 with S112.

    I'm on nRF52832 with S112, so it arises a couple of questions:

    1) is it possible to have the bootloader performing DFU over ble using nRF52832 with s112? all examples i see use S132 with nRF52832

    2) how do change a project (app and bootloader) to use nRF52832 with S112? i mean which defines and where do i need to update? do i have to change linker script by hand? When i change the CFLAGS/ASMFLAGS in the makefile of bootloader project from -DNRF52810_XXAA to -DNRF52832_XXAA, the compiler complains about nRF5_SDK_17.0.2_d674dde/modules/nrfx/mdk/system_nrf52810.c:133:16: error: 'NRF_CCM_Type' has no member named 'MAXPACKETSIZE'
    133 | NRF_CCM->MAXPACKETSIZE = 0xFBul;

    I made no changes about this in my current project (app and bootloader)

    But i did try this: from you answer i got that my settings page and MRB settings were placed incorrectly (according to bootloader linker script). So, as a quick fix i generate new bootloader settings with --family NRF82810. This outputs a setting hex with the information placed in 0x2E000 and 0x2F000. i merged all together (bl+settings+app+sd) and flashed, but i still enter DFU mode and no app shows up even waiting the DFU inactivity timeout.

    Thanks again,

    Martin

Reply
  • Hello Einar,

    Thank you very much for your answer.

    First, i want to clarify that i did not make any changes in the bootloader linker script. All values shown in that file are the same as the ones stated in the bootloader documentation, under memory layout, but for the nRF52810 with S112.

    I'm on nRF52832 with S112, so it arises a couple of questions:

    1) is it possible to have the bootloader performing DFU over ble using nRF52832 with s112? all examples i see use S132 with nRF52832

    2) how do change a project (app and bootloader) to use nRF52832 with S112? i mean which defines and where do i need to update? do i have to change linker script by hand? When i change the CFLAGS/ASMFLAGS in the makefile of bootloader project from -DNRF52810_XXAA to -DNRF52832_XXAA, the compiler complains about nRF5_SDK_17.0.2_d674dde/modules/nrfx/mdk/system_nrf52810.c:133:16: error: 'NRF_CCM_Type' has no member named 'MAXPACKETSIZE'
    133 | NRF_CCM->MAXPACKETSIZE = 0xFBul;

    I made no changes about this in my current project (app and bootloader)

    But i did try this: from you answer i got that my settings page and MRB settings were placed incorrectly (according to bootloader linker script). So, as a quick fix i generate new bootloader settings with --family NRF82810. This outputs a setting hex with the information placed in 0x2E000 and 0x2F000. i merged all together (bl+settings+app+sd) and flashed, but i still enter DFU mode and no app shows up even waiting the DFU inactivity timeout.

    Thanks again,

    Martin

Children
  • Hi Martin,

    Martin Buc said:

    First, i want to clarify that i did not make any changes in the bootloader linker script. All values shown in that file are the same as the ones stated in the bootloader documentation, under memory layout, but for the nRF52810 with S112.

    I'm on nRF52832 with S112, so it arises a couple of questions:

    I see. Then the problem is not that you modified the linker script, but that you are using one that does not match the IC you are using. The linker script you are using is for the nRF52810 (or other devices with 192 kB flash). As explained in my previous post the bootloader assumes that the special pages are located at the end of the flash, so with this linker script there will be a mismatch between where these are placed and where code expects to find it if you are using this with a nRF52832. So you need to pick the linker scripts form a nRF52832 project instead and most likely that will resolve the issue you are seeing.

    Martin Buc said:
    1) is it possible to have the bootloader performing DFU over ble using nRF52832 with s112? all examples i see use S132 with nRF52832

    Yes, the bootloader works the same way regardless of which SoftDevice you are using, as long as it is always the same.

    Martin Buc said:
    2) how do change a project (app and bootloader) to use nRF52832 with S112? i mean which defines and where do i need to update? do i have to change linker script by hand?

    For the application project, you need to adjust the start address (to the size of the SoftDevice you are using, refer to either a project that use this SoftDevice or the SoftDevice release notes). This is not needed for the bootloader. In both cases, you need to replace the header files for the SoftDevice with the one for your SoftDevice in your project (Makefile in your case). There is also a define defining the specific SoftDevice that needs to be changes. You can search through the Makefile for "S132" and "s132" and replace that with "S112" and "s112" respectively, and that should cover all. There is no need to change the linker script (just as long as you picked one from an example project for the same IC that you are using).

    Martin Buc said:
    When i change the CFLAGS/ASMFLAGS in the makefile of bootloader project from -DNRF52810_XXAA to -DNRF52832_XXAA, the compiler complains about nRF5_SDK_17.0.2_d674dde/modules/nrfx/mdk/system_nrf52810.c:133:16: error: 'NRF_CCM_Type' has no member named 'MAXPACKETSIZE'
    133 | NRF_CCM->MAXPACKETSIZE = 0xFBul;

    There are much more changes needed if you do it like this, start off with a nRF52832 project and modify it to use another SoftDevice in stead. This way only a few changes are needed (as explained above).

    Einar

  • Hello Einar,

    For the bootloader i started using the example "nRF5_SDK_17.0.2_d674dde/examples/dfu/secure_bootloader/pca10040_s132_ble, and changed header files and definitions in order to use s112 softdevice.

    For the app project i took makefile and linker script from "nRF5_SDK_17.0.2_d674dde/examples/ble_peripheral/ble_app_uart/pca10040/s112/", and adapted the makefile for my project (just added support for float printf, crc32 and sdflash access). Here are those files i'm using for the app project:

    linker script:

    /* Linker script to configure memory regions. */
    
    SEARCH_DIR(.)
    GROUP(-lgcc -lc -lnosys)
    
    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x19000, LENGTH = 0x67000
      RAM (rwx) :  ORIGIN = 0x200022c8, LENGTH = 0xdd38
    }
    
    SECTIONS
    {
    }
    
    SECTIONS
    {
      . = ALIGN(4);
      .mem_section_dummy_ram :
      {
      }
      .cli_sorted_cmd_ptrs :
      {
        PROVIDE(__start_cli_sorted_cmd_ptrs = .);
        KEEP(*(.cli_sorted_cmd_ptrs))
        PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
      } > 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 :
      {
      }
      .sdh_soc_observers :
      {
        PROVIDE(__start_sdh_soc_observers = .);
        KEEP(*(SORT(.sdh_soc_observers*)))
        PROVIDE(__stop_sdh_soc_observers = .);
      } > FLASH
      .sdh_ble_observers :
      {
        PROVIDE(__start_sdh_ble_observers = .);
        KEEP(*(SORT(.sdh_ble_observers*)))
        PROVIDE(__stop_sdh_ble_observers = .);
      } > FLASH
      .pwr_mgmt_data :
      {
        PROVIDE(__start_pwr_mgmt_data = .);
        KEEP(*(SORT(.pwr_mgmt_data*)))
        PROVIDE(__stop_pwr_mgmt_data = .);
      } > 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
        .nrf_queue :
      {
        PROVIDE(__start_nrf_queue = .);
        KEEP(*(.nrf_queue))
        PROVIDE(__stop_nrf_queue = .);
      } > FLASH
        .nrf_balloc :
      {
        PROVIDE(__start_nrf_balloc = .);
        KEEP(*(.nrf_balloc))
        PROVIDE(__stop_nrf_balloc = .);
      } > FLASH
        .cli_command :
      {
        PROVIDE(__start_cli_command = .);
        KEEP(*(.cli_command))
        PROVIDE(__stop_cli_command = .);
      } > FLASH
      .crypto_data :
      {
        PROVIDE(__start_crypto_data = .);
        KEEP(*(SORT(.crypto_data*)))
        PROVIDE(__stop_crypto_data = .);
      } > FLASH
      .log_const_data :
      {
        PROVIDE(__start_log_const_data = .);
        KEEP(*(SORT(.log_const_data*)))
        PROVIDE(__stop_log_const_data = .);
      } > FLASH
      .log_backends :
      {
        PROVIDE(__start_log_backends = .);
        KEEP(*(SORT(.log_backends*)))
        PROVIDE(__stop_log_backends = .);
      } > FLASH
    
    } INSERT AFTER .text
    
    
    INCLUDE "nrf_common.ld"
    

    makefile:

    PROJECT_NAME     := ble_app_uart_pca10040_s112
    TARGETS          := nrf52832_xxaa
    OUTPUT_DIRECTORY := _build
    
    SDK_ROOT := ${NRF_SDK}
    PROJ_DIR := ../../..
    
    $(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \
      LINKER_SCRIPT  := ble_app_uart_gcc_nrf52.ld
    
    # Source files common to all targets
    SRC_FILES += \
      $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52.S \
      $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_rtt.c \
      $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
      $(SDK_ROOT)/components/libraries/log/src/nrf_log_default_backends.c \
      $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
      $(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \
      $(SDK_ROOT)/components/libraries/button/app_button.c \
      $(SDK_ROOT)/components/libraries/util/app_error.c \
      $(SDK_ROOT)/components/libraries/util/app_error_handler_gcc.c \
      $(SDK_ROOT)/components/libraries/util/app_error_weak.c \
      $(SDK_ROOT)/components/libraries/fifo/app_fifo.c \
      $(SDK_ROOT)/components/libraries/scheduler/app_scheduler.c \
      $(SDK_ROOT)/components/libraries/timer/app_timer2.c \
      $(SDK_ROOT)/components/libraries/uart/app_uart_fifo.c \
      $(SDK_ROOT)/components/libraries/util/app_util_platform.c \
      $(SDK_ROOT)/components/libraries/timer/drv_rtc.c \
      $(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \
      $(SDK_ROOT)/components/libraries/util/nrf_assert.c \
      $(SDK_ROOT)/components/libraries/atomic_fifo/nrf_atfifo.c \
      $(SDK_ROOT)/components/libraries/atomic_flags/nrf_atflags.c \
      $(SDK_ROOT)/components/libraries/atomic/nrf_atomic.c \
      $(SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \
      $(SDK_ROOT)/external/fprintf/nrf_fprintf.c \
      $(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \
      $(SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \
      $(SDK_ROOT)/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c \
      $(SDK_ROOT)/components/libraries/ringbuf/nrf_ringbuf.c \
      $(SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \
      $(SDK_ROOT)/components/libraries/sortlist/nrf_sortlist.c \
      $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \
      $(SDK_ROOT)/components/libraries/uart/retarget.c \
      $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52.c \
      $(SDK_ROOT)/components/boards/boards.c \
      $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_clock.c \
      $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_uart.c \
      $(SDK_ROOT)/modules/nrfx/soc/nrfx_atomic.c \
      $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_clock.c \
      $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_gpiote.c \
      $(SDK_ROOT)/modules/nrfx/drivers/src/prs/nrfx_prs.c \
      $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uart.c \
      $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c \
      $(SDK_ROOT)/components/libraries/bsp/bsp.c \
      $(SDK_ROOT)/components/libraries/bsp/bsp_btn_ble.c \
      $(PROJ_DIR)/main.c \
      $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
      $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
      $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
      $(SDK_ROOT)/components/ble/common/ble_advdata.c \
      $(SDK_ROOT)/components/ble/ble_advertising/ble_advertising.c \
      $(SDK_ROOT)/components/ble/common/ble_conn_params.c \
      $(SDK_ROOT)/components/ble/common/ble_conn_state.c \
      $(SDK_ROOT)/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.c \
      $(SDK_ROOT)/components/ble/common/ble_srv_common.c \
      $(SDK_ROOT)/components/ble/nrf_ble_gatt/nrf_ble_gatt.c \
      $(SDK_ROOT)/components/ble/nrf_ble_qwr/nrf_ble_qwr.c \
      $(SDK_ROOT)/external/utf_converter/utf.c \
      $(SDK_ROOT)/components/ble/ble_services/ble_nus/ble_nus.c \
      $(SDK_ROOT)/components/softdevice/common/nrf_sdh.c \
      $(SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \
      $(SDK_ROOT)/components/softdevice/common/nrf_sdh_soc.c \
    	$(SDK_ROOT)/components/libraries/fstorage/nrf_fstorage.c \
    	$(SDK_ROOT)/components/libraries/fstorage/nrf_fstorage_sd.c \
    	$(SDK_ROOT)/components/libraries/crc32/crc32.c \
    
    # Include folders common to all targets
    INC_FOLDERS += \
      $(SDK_ROOT)/components/nfc/ndef/generic/message \
      $(SDK_ROOT)/components/nfc/t2t_lib \
      $(SDK_ROOT)/components/nfc/t4t_parser/hl_detection_procedure \
      $(SDK_ROOT)/components/ble/ble_services/ble_ancs_c \
      $(SDK_ROOT)/components/ble/ble_services/ble_ias_c \
      $(SDK_ROOT)/components/libraries/pwm \
      $(SDK_ROOT)/components/softdevice/s112/headers/nrf52 \
      $(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \
      $(SDK_ROOT)/components/libraries/usbd/class/hid/generic \
      $(SDK_ROOT)/components/libraries/usbd/class/msc \
      $(SDK_ROOT)/components/libraries/usbd/class/hid \
      $(SDK_ROOT)/modules/nrfx/hal \
      $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/le_oob_rec_parser \
      $(SDK_ROOT)/components/libraries/log \
      $(SDK_ROOT)/components/ble/ble_services/ble_gls \
      $(SDK_ROOT)/components/libraries/fstorage \
      $(SDK_ROOT)/components/nfc/ndef/text \
      $(SDK_ROOT)/components/libraries/mutex \
      $(SDK_ROOT)/components/libraries/gfx \
      $(SDK_ROOT)/components/libraries/bootloader/ble_dfu \
      $(SDK_ROOT)/components/nfc/ndef/connection_handover/common \
      $(SDK_ROOT)/components/libraries/fifo \
      $(SDK_ROOT)/components/boards \
      $(SDK_ROOT)/components/nfc/ndef/generic/record \
      $(SDK_ROOT)/components/nfc/t4t_parser/cc_file \
      $(SDK_ROOT)/components/ble/ble_advertising \
      $(SDK_ROOT)/external/utf_converter \
      $(SDK_ROOT)/components/ble/ble_services/ble_bas_c \
      $(SDK_ROOT)/modules/nrfx/drivers/include \
      $(SDK_ROOT)/components/libraries/experimental_task_manager \
      $(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \
      $(SDK_ROOT)/components/nfc/ndef/connection_handover/le_oob_rec \
      $(SDK_ROOT)/components/libraries/queue \
      $(SDK_ROOT)/components/libraries/pwr_mgmt \
      $(SDK_ROOT)/components/ble/ble_dtm \
      $(SDK_ROOT)/components/toolchain/cmsis/include \
      $(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \
      $(SDK_ROOT)/components/ble/common \
      $(SDK_ROOT)/components/ble/ble_services/ble_lls \
      $(SDK_ROOT)/components/nfc/platform \
      $(SDK_ROOT)/components/libraries/bsp \
      $(SDK_ROOT)/components/nfc/ndef/connection_handover/ac_rec \
      $(SDK_ROOT)/components/ble/ble_services/ble_bas \
      $(SDK_ROOT)/components/libraries/mpu \
      $(SDK_ROOT)/components/libraries/experimental_section_vars \
      $(SDK_ROOT)/components/ble/ble_services/ble_ans_c \
      $(SDK_ROOT)/components/libraries/slip \
      $(SDK_ROOT)/components/libraries/delay \
      $(SDK_ROOT)/components/libraries/csense_drv \
      $(SDK_ROOT)/components/libraries/memobj \
      $(SDK_ROOT)/components/ble/ble_services/ble_nus_c \
      $(SDK_ROOT)/components/softdevice/common \
      $(SDK_ROOT)/components/ble/ble_services/ble_ias \
      $(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \
      $(SDK_ROOT)/components/libraries/low_power_pwm \
      $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/ble_oob_advdata_parser \
      $(SDK_ROOT)/components/ble/ble_services/ble_dfu \
      $(SDK_ROOT)/external/fprintf \
      $(SDK_ROOT)/components/libraries/svc \
      $(SDK_ROOT)/components/libraries/atomic \
      $(SDK_ROOT)/components \
      $(SDK_ROOT)/components/libraries/scheduler \
      $(SDK_ROOT)/components/libraries/cli \
      $(SDK_ROOT)/components/ble/ble_services/ble_lbs \
      $(SDK_ROOT)/components/ble/ble_services/ble_hts \
      $(SDK_ROOT)/components/ble/ble_services/ble_cts_c \
      $(SDK_ROOT)/components/libraries/crc16 \
      $(SDK_ROOT)/components/nfc/t4t_parser/apdu \
      $(SDK_ROOT)/components/libraries/util \
      ../config \
      $(SDK_ROOT)/components/libraries/usbd/class/cdc \
      $(SDK_ROOT)/components/libraries/csense \
      $(SDK_ROOT)/components/libraries/balloc \
      $(SDK_ROOT)/components/libraries/ecc \
      $(SDK_ROOT)/components/libraries/hardfault \
      $(SDK_ROOT)/components/ble/ble_services/ble_cscs \
      $(SDK_ROOT)/components/libraries/uart \
      $(SDK_ROOT)/components/libraries/hci \
      $(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \
      $(SDK_ROOT)/components/libraries/timer \
      $(SDK_ROOT)/integration/nrfx \
      $(SDK_ROOT)/components/nfc/t4t_parser/tlv \
      $(SDK_ROOT)/components/libraries/sortlist \
      $(SDK_ROOT)/components/libraries/spi_mngr \
      $(SDK_ROOT)/components/softdevice/s112/headers \
      $(SDK_ROOT)/components/libraries/led_softblink \
      $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser \
      $(SDK_ROOT)/components/libraries/sdcard \
      $(SDK_ROOT)/components/nfc/ndef/parser/record \
      $(SDK_ROOT)/modules/nrfx/mdk \
      $(SDK_ROOT)/components/ble/ble_link_ctx_manager \
      $(SDK_ROOT)/components/ble/ble_services/ble_nus \
      $(SDK_ROOT)/components/libraries/twi_mngr \
      $(SDK_ROOT)/components/ble/ble_services/ble_hids \
      $(SDK_ROOT)/components/libraries/strerror \
      $(SDK_ROOT)/components/libraries/crc32 \
      $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_oob_advdata \
      $(SDK_ROOT)/components/nfc/t2t_parser \
      $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_pair_msg \
      $(SDK_ROOT)/components/libraries/usbd/class/audio \
      $(SDK_ROOT)/components/nfc/t4t_lib \
      $(SDK_ROOT)/components/ble/peer_manager \
      $(SDK_ROOT)/components/libraries/mem_manager \
      $(SDK_ROOT)/components/libraries/ringbuf \
      $(SDK_ROOT)/components/ble/ble_services/ble_tps \
      $(SDK_ROOT)/components/nfc/ndef/parser/message \
      $(SDK_ROOT)/components/ble/ble_services/ble_dis \
      $(SDK_ROOT)/components/nfc/ndef/uri \
      $(SDK_ROOT)/components/ble/nrf_ble_gatt \
      $(SDK_ROOT)/components/ble/nrf_ble_qwr \
      $(SDK_ROOT)/components/libraries/gpiote \
      $(SDK_ROOT)/components/libraries/button \
      $(SDK_ROOT)/modules/nrfx \
      $(SDK_ROOT)/components/libraries/twi_sensor \
      $(SDK_ROOT)/integration/nrfx/legacy \
      $(SDK_ROOT)/components/libraries/usbd \
      $(SDK_ROOT)/components/nfc/ndef/connection_handover/ep_oob_rec \
      $(SDK_ROOT)/external/segger_rtt \
      $(SDK_ROOT)/components/libraries/atomic_fifo \
      $(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \
      $(SDK_ROOT)/components/nfc/ndef/connection_handover/ble_pair_lib \
      $(SDK_ROOT)/components/libraries/crypto \
      $(SDK_ROOT)/components/ble/ble_racp \
      $(SDK_ROOT)/components/libraries/fds \
      $(SDK_ROOT)/components/nfc/ndef/launchapp \
      $(SDK_ROOT)/components/libraries/atomic_flags \
      $(SDK_ROOT)/components/ble/ble_services/ble_hrs \
      $(SDK_ROOT)/components/ble/ble_services/ble_rscs \
      $(SDK_ROOT)/components/nfc/ndef/connection_handover/hs_rec \
      $(SDK_ROOT)/components/nfc/ndef/conn_hand_parser/ac_rec_parser \
      $(SDK_ROOT)/components/libraries/stack_guard \
      $(SDK_ROOT)/components/libraries/log/src \
    	$(SDK_ROOT)/components/libraries/bootloader \
    
    # Libraries common to all targets
    LIB_FILES += \
    
    # Optimization flags
    OPT = -O3 -g3
    # Uncomment the line below to enable link time optimization
    #OPT += -flto
    
    # C flags common to all targets
    CFLAGS += $(OPT)
    CFLAGS += -DAPP_TIMER_V2
    CFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED
    CFLAGS += -DBOARD_PCA10040
    CFLAGS += -DCONFIG_GPIO_AS_PINRESET
    CFLAGS += -DFLOAT_ABI_HARD
    CFLAGS += -DNRF52
    CFLAGS += -DNRF52832_XXAA
    CFLAGS += -DNRF52_PAN_74
    CFLAGS += -DNRF_SD_BLE_API_VERSION=7
    CFLAGS += -DS112
    CFLAGS += -DSOFTDEVICE_PRESENT
    CFLAGS += -mcpu=cortex-m4
    CFLAGS += -mthumb -mabi=aapcs
    CFLAGS += -Wall -Werror
    CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    # keep every function in a separate section, this allows linker to discard unused ones
    CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
    CFLAGS += -fno-builtin -fshort-enums
    
    # C++ flags common to all targets
    CXXFLAGS += $(OPT)
    # Assembler flags common to all targets
    ASMFLAGS += -g3
    ASMFLAGS += -mcpu=cortex-m4
    ASMFLAGS += -mthumb -mabi=aapcs
    ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    ASMFLAGS += -DAPP_TIMER_V2
    ASMFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED
    ASMFLAGS += -DBOARD_PCA10040
    ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
    ASMFLAGS += -DFLOAT_ABI_HARD
    ASMFLAGS += -DNRF52
    ASMFLAGS += -DNRF52832_XXAA
    ASMFLAGS += -DNRF52_PAN_74
    ASMFLAGS += -DNRF_SD_BLE_API_VERSION=7
    ASMFLAGS += -DS112
    ASMFLAGS += -DSOFTDEVICE_PRESENT
    
    # Linker flags
    LDFLAGS += $(OPT)
    LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT)
    LDFLAGS += -mcpu=cortex-m4
    LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    # let linker dump unused sections
    LDFLAGS += -Wl,--gc-sections
    # use newlib in nano version
    LDFLAGS += --specs=nano.specs
    LDFLAGS += -u _printf_float			#MB
    
    nrf52832_xxaa: CFLAGS += -D__HEAP_SIZE=2048
    nrf52832_xxaa: CFLAGS += -D__STACK_SIZE=2048
    nrf52832_xxaa: ASMFLAGS += -D__HEAP_SIZE=2048
    nrf52832_xxaa: ASMFLAGS += -D__STACK_SIZE=2048
    
    # Add standard libraries at the very end of the linker input, after all objects
    # that may need symbols provided by these libraries.
    LIB_FILES += -lc -lnosys -lm
    
    
    .PHONY: default help
    
    # Default target - first one defined
    default: nrf52832_xxaa
    
    # Print all targets that can be built
    help:
    	@echo following targets are available:
    	@echo		nrf52832_xxaa
    	@echo		flash_softdevice
    	@echo		sdk_config - starting external tool for editing sdk_config.h
    	@echo		flash      - flashing binary
    
    TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
    
    
    include $(TEMPLATE_PATH)/Makefile.common
    
    $(foreach target, $(TARGETS), $(call define_target, $(target)))
    
    .PHONY: flash flash_softdevice erase flash_boot flash_all
    
    # Flash the program
    flash: default
    	@echo Flashing: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
    	nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex --sectorerase
    	nrfjprog -f nrf52 --reset
    
    SOFTDEVICE_LOCATION := $(SDK_ROOT)/components/softdevice/s112/hex/s112_nrf52_7.2.0_softdevice.hex
    # Flash softdevice
    flash_softdevice:
    	@echo Flashing: s112_nrf52_7.2.0_softdevice.hex
    	nrfjprog -f nrf52 --program $(SOFTDEVICE_LOCATION) --sectorerase
    	nrfjprog -f nrf52 --reset
    
    erase:
    	nrfjprog -f nrf52 --eraseall
    
    BOOTLOADER_LOCATION := /home/martin-dev/cattlerlink-bootloader/pca10040_s112_ble/armgcc/_build/nrf52832_xxaa_s112.hex
    flash_boot:
    	@echo Flashing: bootloader
    	nrfjprog -f nrf52 --program $(BOOTLOADER_LOCATION) --sectorerase
    	nrfjprog -f nrf52 --reset
    
    flash_all:
    	@echo Flashing: bootloader + app + softdevice
    	nrfutil settings generate --family NRF52 --application $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 $(OUTPUT_DIRECTORY)/bootloader_setting.hex
    	mergehex --merge  $(BOOTLOADER_LOCATION) $(OUTPUT_DIRECTORY)/bootloader_setting.hex $(SOFTDEVICE_LOCATION) $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex --output $(OUTPUT_DIRECTORY)/cattlerLink-bl-app-sd.hex
    	nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/cattlerLink-bl-app-sd.hex --sectorerase
    	nrfjprog -f nrf52 --reset
    
    
    SDK_CONFIG_FILE := ../config/sdk_config.h
    CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
    sdk_config:
    	java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)
    

    i am wondering what is the procedure to change de start address. But i really see no need to do so, since i got from s112 release notes that it needs 0x19000 flash bytes and at least 0xeb8 ram bytes.

    this is bootloader settings generation command (as you can see at the end of makefile), and output:

    nrfutil settings generate --family NRF52 --application $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 $(OUTPUT_DIRECTORY)/bootloader_setting.hex
    Bootloader DFU Settings:
    * File: _build/bootloader_setting.hex
    * Family: nRF52
    * Start Address: 0x0007F000
    * CRC: 0xB352EC49
    * Settings Version: 0x00000002 (2)
    * App Version: 0x00000000 (0)
    * Bootloader Version: 0x00000000 (0)
    * Bank Layout: 0x00000000
    * Current Bank: 0x00000000
    * Application Size: 0x0000D694 (54932 bytes)
    * Application CRC: 0x270738D4
    * Bank0 Bank Code: 0x00000001
    * Softdevice Size: 0x00000000 (0 bytes)
    * Boot Validation CRC: 0x9817AFAB
    * SD Boot Validation Type: 0x00000000 (0)
    * App Boot Validation Type: 0x00000001 (1)

    The behavior is still the same. When erasing, merging and flashing bl+settings+app+sd, the device enters DFU mode. I can perform an OTA DFU, but the app is still not running, and the device falls into DFU mode again.

    If i erase, then flash softdevice and app alone, then the apps runs ok. It's worth noticing that i moved de flash section i use for app's data as this:

    NRF_FSTORAGE_DEF(nrf_fstorage_t my_flash) =
    {
    .evt_handler = flash_callback,
    .start_addr = 0x76000,
    .end_addr = 0x77FFF,
    };
    Another thing i noticed is a change in address from hex file compared with what is actually written on the flash, as you can see from the image below:
    On the left you can see sd+app as loaded into the programmer software. On the right, you can find the actual read memory of the device, after writing the same exact files show on the left panel.
    To write i use nrfjprog, as you can tell from flash commands at the end of the makefile posted above.
    Thanks again, i really appreciate your help.
    Martin
  • Hi Martin,

    Can you upload the linker script for the bootloader (not the application) that you are using now, just so I can double check? The best would be to see the full bootloader project. 

    Martin Buc said:
    i am wondering what is the procedure to change de start address. But i really see no need to do so, since i got from s112 release notes that it needs 0x19000 flash bytes and at least 0xeb8 ram bytes.

    The start address you can get from the release notes. The RAM usage differs on use, and is typically higher than the minimal. For the RAM usage you can just set a higher start address and correspondingly lower size, or you can fine tune it if you like and the device is RAM constrained. See Adjustment of RAM and Flash memory for details.

    Martin Buc said:
    this is bootloader settings generation command (as you can see at the end of makefile), and output:

    This looks good.

    Martin Buc said:
    Another thing i noticed is a change in address from hex file compared with what is actually written on the flash, as you can see from the image below:

    The programmer app or nrfjprog should write exactly what what is in the hex file. One thing is to remember to do an erase all ("nrfjprog -e") before writing. But another highly likely explanation here is that the additional data on the IC (right side) is written runtime, for instance if the MBR params and bootloader settings page are still in the wrong (too low) location, it could be that. Or perhaps your application use FDS, either directly or via the peer manager? It does not look like it would overlap with your fstorage region, though.

    Martin Buc said:
    If i erase, then flash softdevice and app alone, then the apps runs ok. It's worth noticing that i moved de flash section i use for app's data as this:

    What is your memory layout now? Where is the bootloader and bootloader settings + MBR page (and even FDS pages if you use it). The release bootloader typically start at 0x00078000 on nRF52832 devices, so this would normally be OK, as long as you don't use FDS. If you do use FDS, this will overlap with FDS which is not OK. Also, if you use the debug bootloader then this would overlap with the bootloader. Regarding the debug bootloader - if this issue persists I would recommend to test with the debug bootloader with RTT logging (example bootloader project suffixed with "_debug"). That has very extensive logging, and you will typically see right away why the application is not started.

    Martin Buc said:
    To write i use nrfjprog, as you can tell from flash commands at the end of the makefile posted above.
    Thanks again, i really appreciate your help.

    That is OK and does not cause any problems. But note that if you do any changes to the bootloader start address for any reason, you must do a full chip erase before programming (this has to do with how the bootloader start address is stored in the UICR).

  • Hello Einar,

    Just a quick answer to try to keep up with this Slight smile

    This is current bootloader linker script:

    /* Linker script to configure memory regions. */
    
    SEARCH_DIR(.)
    GROUP(-lgcc -lc -lnosys)
    
    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x78000, LENGTH = 0x6000
      RAM (rwx) :  ORIGIN = 0x20005968, LENGTH = 0xa698
      uicr_bootloader_start_address (r) : ORIGIN = 0x10001014, LENGTH = 0x4
      uicr_mbr_params_page (r) : ORIGIN = 0x10001018, LENGTH = 0x4
      mbr_params_page (r) : ORIGIN = 0x0007E000, LENGTH = 0x1000
      bootloader_settings_page (r) : ORIGIN = 0x0007F000, 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);
      .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
      . = ALIGN(4);
      .bootloader_settings_page(NOLOAD) :
      {
        PROVIDE(__start_bootloader_settings_page = .);
        KEEP(*(SORT(.bootloader_settings_page*)))
        PROVIDE(__stop_bootloader_settings_page = .);
      } > bootloader_settings_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"

    I always perform a chip erase before any test in order to make sure a know starting point. This is the command i use:

    nrfjprog -f nrf52 --eraseall

    I don't use FDS (flashDataStorage). I use "nrf_fstorage_sd.c ".

    I though that you can check memory layout from linker scripts. What do you need to see?

    I will try the _debug bootloader to get more insight about this.

    I think the smoking gun here is that i don read from device what i just wrote. As in the example i posted, the application code portion is clearly on 0x19000 on hex file, but after flashing the device (no bootloader), i read with the programmer tool that application code is now in 0x26000.

    I will keep on trying. Thanks.

    Martin

  • Martin Buc said:
    but after flashing the device (no bootloader), i read with the programmer tool that application code is now in 0x26000.

    That matches the different size of the S112 and the S132 SoftDevices, but there is nothing in what I have seen that indicate that S132 is flashed.  Another thing - why is not the bootloader shown in the screenshot from the programmer app? So there are two things with this screenshot that does not match the rest of the information. 

    If you don't make progress, can you upload the complete bootloader and application projects (zip them up)? Perhaps that way it will be easier to spot what I am missing.

Related