<?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>DFU failure when updating bootloader</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114324/dfu-failure-when-updating-bootloader</link><description>Hello, 
 I am using the nRF51822 with SDK v9.0.0, SoftDevice S110, and the DFU bootloader v8.1.0. 
 For certain reasons, I want to reserve one page of the &amp;#39;app data&amp;#39; for shared information between the application and the bootloader. To achieve this, I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 30 Aug 2024 08:19:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114324/dfu-failure-when-updating-bootloader" /><item><title>RE: DFU failure when updating bootloader</title><link>https://devzone.nordicsemi.com/thread/500532?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2024 08:19:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5ca1302-a211-4e8b-941b-af60ace5a404</guid><dc:creator>AmineKh</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Thank you for your reply.&lt;/p&gt;
&lt;p&gt;I have fixed the problem based on your answer.&lt;/p&gt;
&lt;p&gt;I updated the function dfu_bl_image_validate() as follows:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint32_t dfu_bl_image_validate(void)
{
    bootloader_settings_t bootloader_settings;
    sd_mbr_command_t      sd_mbr_cmd;

    bootloader_settings_get(&amp;amp;bootloader_settings);

    if (bootloader_settings.bl_image_size != 0)
    {
        // Determine the new and old (when DFU_APP_DATA_RESERVED was OLD_DFU_APP_DATA_RESERVED = 0x0) bank_1 addresses
        uint32_t bl_image_start_new = (bootloader_settings.sd_image_size == 0) ?
                                      DFU_BANK_1_REGION_START :
                                      bootloader_settings.sd_image_start +
                                      bootloader_settings.sd_image_size;

        uint32_t bl_image_start_old = (bootloader_settings.sd_image_size == 0) ?
                                      OLD_DFU_BANK_1_REGION_START :
                                      bootloader_settings.sd_image_start +
                                      bootloader_settings.sd_image_size;

        // Check at the new bank address first
        sd_mbr_cmd.command             = SD_MBR_COMMAND_COMPARE;
        sd_mbr_cmd.params.compare.ptr1 = (uint32_t *)BOOTLOADER_REGION_START;
        sd_mbr_cmd.params.compare.ptr2 = (uint32_t *)(bl_image_start_new);
        sd_mbr_cmd.params.compare.len  = bootloader_settings.bl_image_size / sizeof(uint32_t);

        uint32_t result = sd_mbr_command(&amp;amp;sd_mbr_cmd);

        // If the new bank address doesn&amp;#39;t match, check the old one
        if (result != NRF_SUCCESS)
        {
            sd_mbr_cmd.params.compare.ptr2 = (uint32_t *)(bl_image_start_old);
            result = sd_mbr_command(&amp;amp;sd_mbr_cmd);
        }

        return result;
    }
    return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In which:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define OLD_DFU_APP_DATA_RESERVED       0x0                                               /**&amp;lt; Old size of app data. */
#define DFU_APP_DATA_RESERVED           0x0400                                            /**&amp;lt; Size of Application Data that must be preserved between application updates. This value must be a multiple of page size. Page size is 0x400 (1024d) bytes, thus this value must be 0x0000, 0x0400, 0x0800, 0x0C00, 0x1000, etc. */
#define OLD_DFU_BANK_1_REGION_START     (DFU_BANK_1_REGION_START + DFU_APP_DATA_RESERVED) /**&amp;lt; Old Bank 1 region start when DFU_APP_DATA_RESERVED was OLD_DFU_APP_DATA_RESERVED = 0x0. */&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU failure when updating bootloader</title><link>https://devzone.nordicsemi.com/thread/500501?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2024 05:05:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91b29b50-e526-40c5-aac5-c6cedcbdebcd</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Please see my answer in this thread:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/14100/can-t-update-bootlader-over-the-air-when-changing-dfu_app_data_reserved"&gt;can&amp;#39;t update bootlader over the air when changing DFU_APP_DATA_RESERVED&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>