title: Linker script for an nrf52 S132 Bootloader
body: <p>I'm currently building a bootloader suitable for Dual Channel DFU and SD132. It is on nrf52832, currently on PCA10040. Although the linker script works, and creates a hex file, I am left with an <code>app_error_code 1</code> after <code>nrf_sdh_enable_request()</code>, from <code>sd_softdevice_enable()</code>.</p>
  
  <p>Is it the LS's fault? Have I completely missed the mark? Or is it something completely different. Feel free to ask for more details, I've included the LS, as I'm unsure of what else to add.</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p><em>Below is what I have so far, cobbled together from the various examples in the SDK.</em></p>
  
  <pre><code>SEARCH_DIR(.)
  GROUP(-lgcc -lc -lnosys)
  
  GROUP(S132_softdevice.o)
  MEMORY
  {
    FLASH_SOFTDEVICE (rx) : ORIGIN = 0x00001000, LENGTH = 0x00023000
    FLASH (rx) : ORIGIN = 0x24000, LENGTH = 0x6CA00
    SRAM_SOFTDEVICE (rwx) : ORIGIN = 0x20000000, LENGTH = 0x0005C10
    RAM (rwx) :  ORIGIN = 0x20005C11, LENGTH = 0x9D6F
  
    /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
     *  from application to bootloader when using buttonluss DFU OTA.
     */
    NOINIT (rw) :  ORIGIN = 0x2000F97F, LENGTH = 0x80
  
    /** Location of bootloader setting in flash. */
    BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000
  
    /** Location in UICR where bootloader start address is stored. */
    UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
  
    /** Location of mbr params page in flash. */
    MBR_PARAMS_PAGE (rw) : ORIGIN = 0x0007E000, LENGTH = 0x1000
  
    /** Location in UICR where mbr params page address is stored. */
    UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04
  }
  
  SECTIONS
  {
    /* Place the bootloader settings page in flash. */
    .bootloaderSettings(NOLOAD) :
    {
  
    } &gt; BOOTLOADER_SETTINGS
  
    /* Write the bootloader address in UICR. */
    .uicrBootStartAddress :
    {
      KEEP(*(.uicrBootStartAddress))
    } &gt; UICR_BOOTLOADER
  
    /* Place the mbr params page in flash. */
      .mbrParamsPage(NOLOAD) :
    {
  
    } &gt; MBR_PARAMS_PAGE
  
    /* Write the bootloader address in UICR. */
    .uicrMbrParamsPageAddress :
    {
      KEEP(*(.uicrMbrParamsPageAddress))
    } &gt; UICR_MBR_PARAM_PAGE
  
    /* No init RAM section in bootloader. Used for bond information exchange. */
    .noinit(NOLOAD) :
    {
  
    } &gt; NOINIT
    /* other placements follow here... */
  }
  
  SECTIONS
  {
    . = ALIGN(4);
    .softdevice :
    {
      KEEP(*(.softdevice))
      FILL(0xFFFFFFFF);
      . = 0x00023000;
    } &gt; FLASH_SOFTDEVICE
  
    . = ALIGN(4);
    .softdevice_sram :
    {
      FILL(0xFFFFFFFF);
      . = 0x00005C10;
    } &gt; SRAM_SOFTDEVICE
  
    .svc_data :
    {
      PROVIDE(__start_svc_data = .);
      KEEP(*(.svc_data))
      PROVIDE(__stop_svc_data = .);
    } &gt; RAM
  
    .fs_data :
    {
      PROVIDE(__start_fs_data = .);
      KEEP(*(.fs_data))
      PROVIDE(__stop_fs_data = .);
    } &gt; RAM
  
    .log_dynamic_data :
    {
      PROVIDE(__start_log_dynamic_data = .);
      KEEP(*(.log_dynamic_data))
      PROVIDE(__stop_log_dynamic_data = .);
    } &gt; RAM
  
    .cli_sorted_cmd_ptrs :
    {
      PROVIDE(__start_cli_sorted_cmd_ptrs = .);
      KEEP(*(.cli_sorted_cmd_ptrs))
      PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
    } &gt; RAM
  } INSERT AFTER .data;
  
  SECTIONS
  {
    .dfu_trans :
    {
      PROVIDE(__start_dfu_trans = .);
      KEEP(*(SORT(.dfu_trans*)))
      PROVIDE(__stop_dfu_trans = .);
    } &gt; FLASH
  
    .pwr_mgmt_data :
    {
      PROVIDE(__start_pwr_mgmt_data = .);
      KEEP(*(SORT(.pwr_mgmt_data*)))
      PROVIDE(__stop_pwr_mgmt_data = .);
    } &gt; FLASH
  
    .log_const_data :
    {
      PROVIDE(__start_log_const_data = .);
      KEEP(*(.log_const_data))
      PROVIDE(__stop_log_const_data = .);
    } &gt; FLASH
  
    .cli_command :
    {
      PROVIDE(__start_cli_command = .);
      KEEP(*(.cli_command))
      PROVIDE(__stop_cli_command = .);
    } &gt; FLASH
  
    . = ALIGN(4);
    .sdh_stack_observers :
    {
      PROVIDE(__start_sdh_stack_observers = .);
      KEEP(*(SORT(.sdh_stack_observers*)))
      PROVIDE(__stop_sdh_stack_observers = .);
    } &gt; FLASH
  
    . = ALIGN(4);
    .sdh_req_observers :
    {
      PROVIDE(__start_sdh_req_observers = .);
      KEEP(*(SORT(.sdh_req_observers*)))
      PROVIDE(__stop_sdh_req_observers = .);
    } &gt; FLASH
  
    . = ALIGN(4);
    .sdh_state_observers :
    {
      PROVIDE(__start_sdh_state_observers = .);
      KEEP(*(SORT(.sdh_state_observers*)))
      PROVIDE(__stop_sdh_state_observers = .);
    } &gt; FLASH
  
    /*.sdh_ant_observers :
    *{
    *  PROVIDE(__start_sdh_ant_observers = .);
    *  KEEP(*(SORT(.sdh_ant_observers*)))
    *  PROVIDE(__stop_sdh_ant_observers = .);
    *} &gt; FLASH
    */
    . = ALIGN(4);
    .sdh_ble_observers :
    {
      PROVIDE(__start_sdh_ble_observers = .);
      KEEP(*(SORT(.sdh_ble_observers*)))
      PROVIDE(__stop_sdh_ble_observers = .);
    } &gt; FLASH
  
    . = ALIGN(4);
    .sdh_soc_observers :
    {
      PROVIDE(__start_sdh_soc_observers = .);
      KEEP(*(SORT(.sdh_soc_observers*)))
      PROVIDE(__stop_sdh_soc_observers = .);
    } &gt; FLASH
  
  } INSERT AFTER .text
  
  INCLUDE "nrf5x_common.ld"
  PROVIDE(_sbss = __bss_start__);
  PROVIDE(_ebss = __bss_end__);
  PROVIDE(_sdata = __data_start__);
  PROVIDE(_sidata = __etext);
  PROVIDE(_estack = __StackTop);
  PROVIDE(_edata =__data_end__);
  PROVIDE(__isr_vector = __StackTop);
  </code></pre>