<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>NRF51822 DFU Problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6558/nrf51822-dfu-problem</link><description>I built the GCC bootloader from source based on the suggestion of another user in this forum instead of using a precompiled hex file. The Softdevice is 7.1. 
 It shows DfuTarg. And using nRF Toolbox, I can send a zip package of a new application. It</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 04 Dec 2015 11:52:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6558/nrf51822-dfu-problem" /><item><title>RE: NRF51822 DFU Problem</title><link>https://devzone.nordicsemi.com/thread/22889?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2015 11:52:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68fa425e-1a86-41e2-966c-e6a4cc86b62c</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;@Simon I&amp;#39;m facing the same problem now, I tryn to solve &amp;amp; I need your help, how to set that member in the dfu_app_handler.c ? ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51822 DFU Problem</title><link>https://devzone.nordicsemi.com/thread/22888?ContentTypeID=1</link><pubDate>Fri, 17 Apr 2015 17:56:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08f74d8b-d8ad-496d-a2ae-ccfb107dbd29</guid><dc:creator>Simon Ampleman</dc:creator><description>&lt;p&gt;I found the problem.&lt;/p&gt;
&lt;p&gt;The device manager is used in dfu_app_handler.c and it requires the member m_dm_handle_valid to be set in order to call dfu_app_set_peer_data.&lt;/p&gt;
&lt;p&gt;I had a problem in the initialization of the device manager, so the dfu_app_set_dm_handle never gets called so the peer data is not set.&lt;/p&gt;
&lt;p&gt;Thank you again.&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51822 DFU Problem</title><link>https://devzone.nordicsemi.com/thread/22887?ContentTypeID=1</link><pubDate>Fri, 17 Apr 2015 15:59:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c5d33fc-cec3-44d4-8aaf-783ec9f733c6</guid><dc:creator>Simon Ampleman</dc:creator><description>&lt;p&gt;Thank you for your detailed explanation.&lt;/p&gt;
&lt;p&gt;I updated the linker file and verified the dfu_ble_svc.c file according to your answer. I also ajusted the memory layout for 16 kB RAM version.&lt;/p&gt;
&lt;p&gt;However, I still have the same result.&lt;/p&gt;
&lt;p&gt;Here are the new files :&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bootloader Linker file :&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x00035000, LENGTH = 0xB000
  RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x1F80
  NOINIT (rwx) :  ORIGIN = 0x20003F80, LENGTH = 0x80
  BOOTLOADER_SETTINGS (rwx) : ORIGIN = 0x0003FC00, LENGTH = 0x400
  UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
}
SECTIONS
{
  .bootloaderSettings :
  {

  } &amp;gt; BOOTLOADER_SETTINGS

  /* Ensures the Bootloader start address in flash is written to UICR when flashing the image. */
  .uicrBootStartAddress : 
  {
    KEEP(*(.uicrBootStartAddress))
  } &amp;gt; UICR_BOOTLOADER

  /* No init RAM section in bootloader. Used for bond information exchange. */
  .NoInit :
  {

  } &amp;gt; NOINIT
}	

INCLUDE &amp;quot;gcc_nrf51_common.ld&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Application linker file&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x00016000, LENGTH = 0x2A000 
  RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x2000
}

INCLUDE &amp;quot;gcc_nrf51_common.ld&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;dfu_ble_svc.c&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#if defined   ( __GNUC__ )
static dfu_ble_peer_data_t m_peer_data __attribute__((section(&amp;quot;.NoInit&amp;quot;)))__attribute__((used));     /**&amp;lt; This variable should be placed in a non initialized RAM section in order to be valid upon soft reset from application into bootloader. */
static uint16_t            m_peer_data_crc __attribute__((section(&amp;quot;.NoInit&amp;quot;)))__attribute__((used)); /**&amp;lt; CRC variable to ensure the integrity of the peer data provided. */

#else
static dfu_ble_peer_data_t m_peer_data __attribute__((section(&amp;quot;NoInit&amp;quot;), zero_init));     /**&amp;lt; This variable should be placed in a non initialized RAM section in order to be valid upon soft reset from application into bootloader. */
static uint16_t            m_peer_data_crc __attribute__((section(&amp;quot;NoInit&amp;quot;), zero_init)); /**&amp;lt; CRC variable to ensure the integrity of the peer data provided. */
#endif
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Bootloader map file&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.bootloaderSettings
                0x0003fc00      0x400
 .bootloaderSettings
                0x0003fc00      0x400 _build/bootloader_util_gcc.o
                0x0003fc00                m_boot_settings

.uicrBootStartAddress
                0x10001014        0x4
 *(.uicrBootStartAddress)
 .uicrBootStartAddress
                0x10001014        0x4 _build/bootloader_util_gcc.o
                0x10001014                m_uicr_bootloader_start_address

.NoInit         0x20003f80       0x30
 .NoInit        0x20003f80       0x30 _build/dfu_ble_svc.o
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Last part of Application Map file in the ending region of the ram allocation&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                0x20002700                m_ble_evt_handler.lto_priv.86
                0x20002704                m_ble_evt_buffer_size.lto_priv.88
                0x20002708                m_evt_buffer.lto_priv.87
 *(COMMON)
                0x2000270c                . = ALIGN (0x4)
                0x2000270c                __bss_end__ = .

.heap           0x20002710      0x800
                0x20002710                __end__ = .
                0x20002710                end = __end__
 *(.heap*)
 .heap          0x20002710      0x800 _build/gcc_startup_nrf51.o
                0x20002710                __HeapBase
                0x20002f10                __HeapLimit = .

.stack_dummy    0x20002710      0x800
 *(.stack*)
 .stack         0x20002710      0x800 _build/gcc_startup_nrf51.o
                0x20004000                __StackTop = (ORIGIN (RAM) + 0x2000)
                0x20003800                __StackLimit = (__StackTop - SIZEOF (.stack_dummy))
                0x20004000                PROVIDE (__stack, __StackTop)
                0x00000001                ASSERT ((__StackLimit &amp;gt;= __HeapLimit), region RAM overflowed with stack)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Anybody see something wrong in these files ?&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51822 DFU Problem</title><link>https://devzone.nordicsemi.com/thread/22886?ContentTypeID=1</link><pubDate>Fri, 17 Apr 2015 09:38:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0687c49c-0d8d-467e-8531-e3550fc6c1ff</guid><dc:creator>Torsten Rasmussen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Based on your reporting I assume you are trying out the buttonless update procedure, where you jump from application into the bootloader.
For this to work, the bootloader needs to know the LTK, IRK and Address of the device which triggered the DFU mode.
Those are distributed from the app to bootloader through an SVC as described in:
&lt;a href="http://developer.nordicsemi.com/nRF51_SDK/nRF51_SDK_v8.x.x/doc/8.0.0/s110/html/a00079.html"&gt;developer.nordicsemi.com/.../a00079.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This means that the SVC must be implemented in the bootloader, which I assume that you already do. However, the data will be located in RAM and it is therefore critical that this data is not zero initialized upon reset into bootloader.&lt;/p&gt;
&lt;p&gt;Look in the file: dfu_ble_svc.c and find the definition of m_peer_data and m_peer_data_crc.
Ensure those are placed in no init section, for gcc:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;__attribute__((section(&amp;quot;.noinit&amp;quot;))) static dfu_ble_peer_data_t m_peer_data; 
__attribute__((section(&amp;quot;.noinit&amp;quot;))) static uint16_t            m_peer_data_crc;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then ensure to define this section in the linker script:&lt;/p&gt;
&lt;p&gt;As example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;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 = 0x3C000, LENGTH = 0x3C00

  /** RAM Region for bootloader. This setting is suitable when used with s110, s120, s130, s310. */
  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 at the last flash page. */
  BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0003FC00, LENGTH = 0x0400

  /** Location in UICR where bootloader start address is stored. */
  UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
}

SECTIONS
{
  /* Ensures the bootloader settings are placed at the last flash page. */
  .bootloaderSettings :
  {
	
  } &amp;gt; BOOTLOADER_SETTINGS

  /* Ensures the Bootloader start address in flash is written to UICR when flashing the image. */
  .uicrBootStartAddress : 
  {
    KEEP(*(.uicrBootStartAddress))
  } &amp;gt; UICR_BOOTLOADER

  /* No init RAM section in bootloader. Used for bond information exchange. */
  .noinit :
  {

  } &amp;gt; NOINIT
  /* other placements follow here... */
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the memory layout here is for 32 kB RAM version.
Adjust accordingly for the 16kB version.&lt;/p&gt;
&lt;p&gt;Try also to see if your device is advertising with another address (normal address + 1), as this will also indicate that the peer data has not been succesfully exchanged.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>