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

m_dfu_settings_buffer in ram with GCC 5.4.1?

Hello,

I'm trying to implement DFU support to our application on nRF52832. I got it working fine with SDK11 SD2.0, but now SDK12.2 SD3.0 is causing "gray hairs". I used the file "nrf_dfu_flash_buttonless.c" from examples to avoid peer_manager (which used huge amount or ram), but I can't get it to work.

If I understand correctly the m_dfu_settings_buffer should point to the FLASH page with DFU settings. However the target.map generated by the linker shows:

.bootloaderSettings
                0x200024c0     0x1000 load address 0x00059890
 .bootloaderSettings
                0x200024c0     0x1000 C:/Projects/nextgen/movesense-gcc/package/lib/GCCARM/libmovesense-coreD.a(nrf_dfu_settings.c.obj)
                0x200024c0                m_dfu_settings_buffer

.fs_data        0x200034c0       0x10 load address 0x0005a890

and the JLink debug output shows:

    0> :INFO:running nrf_dfu_settings_init
 0> :INFO:!!!!!!!!!!!!!!! Resetting bootloader settings !!!!!!!!!!!
 0> :INFO:Erasing old settings at: 0x200024c0
 0> :INFO:Erasing: 0x200024c0, num: 1
 0> :INFO:Erase failed: 1
 0> :ERROR:Erasing from flash memory failed.

The obvious problem is that the bootloaderSettings / m_dfu_settings_buffer is mapped to RAM instead of FLASH where it should be, even if it is set there in .ld -file:

/* Linker script to configure memory regions. */

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

MEMORY
{
  /** Flash start address for the bootloader. This setting will also be stored in UICR to allow the
   *  MBR to init the bootloader when starting the system. This value must correspond to
   *  BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if
   *  those values do not match. The check is performed in main.c, see
   *  APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
   */
  FLASH (rx) : ORIGIN = 0x75000, LENGTH = 0x9000

  /** RAM Region for bootloader. This setting is suitable when used with s132. */
  RAM (rwx) :  ORIGIN = 0x20002C00, LENGTH = 0x5380

  /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
   *  from application to bootloader when using buttonluss DFU OTA.
   */
  NOINIT (rwx) :  ORIGIN = 0x20007F80, 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) :
  {

  } > BOOTLOADER_SETTINGS

  /* Write the bootloader address in UICR. */
  .uicrBootStartAddress :
  {
    KEEP(*(.uicrBootStartAddress))
  } > UICR_BOOTLOADER

  /* Place the mbr params page in flash. */
    .mbrParamsPage(NOLOAD) :
  {

  } > MBR_PARAMS_PAGE

  /* Write the bootloader address in UICR. */
  .uicrMbrParamsPageAddress :
  {
    KEEP(*(.uicrMbrParamsPageAddress))
  } > UICR_MBR_PARAM_PAGE

  /* No init RAM section in bootloader. Used for bond information exchange. */
  .noinit(NOLOAD) :
  {

  } > NOINIT
  /* other placements follow here... */
}

SECTIONS
{
  . = ALIGN(4);
  .fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } > RAM

  . = ALIGN(4);
  .svc_data :
  {
    PROVIDE(__start_svc_data = .);
    KEEP(*(.svc_data))
    PROVIDE(__stop_svc_data = .);
  } > RAM

  . = ALIGN(4);
  .dfu_trans :
  {
    PROVIDE(__start_dfu_trans = .);
    KEEP(*(.dfu_trans))
    PROVIDE(__stop_dfu_trans = .);
  } > RAM

} INSERT AFTER .data

INCLUDE "nrf52_common.ld"

Any ideas?

Related