<?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 change bootloader to single-bank</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16590/dfu-change-bootloader-to-single-bank</link><description>I am using nRF51 and latest s310 softdevice (3.0.0) and latest SDK (v10), which is the latest compatible with the softdevice. 
 My device is programmed with the softdevice and the dual-bank DFU BLE bootloader. 
 I want to update to single-bank bootloader</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Sep 2016 11:45:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16590/dfu-change-bootloader-to-single-bank" /><item><title>RE: DFU change bootloader to single-bank</title><link>https://devzone.nordicsemi.com/thread/63470?ContentTypeID=1</link><pubDate>Thu, 22 Sep 2016 11:45:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d87418f-ee93-4eda-9d5c-269c97eaa697</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;The problem with updating the bootloader from a dual to single bank bootloader is that the new bootloader expects the firmware image to be at the start of BANK 0, while it&amp;#39;s actually loaded to BANK1 by the old bootloader. After the update the new single bank bootloader verifies that the image was correctly written to flash by comparing itself with the firmware image that it expects to be located in BANK0. Since the actual firmware image is in BANK 1 this check will fail and the new bootloader updates itself with whatever data located in BANK0 using the MBR.&lt;/p&gt;
&lt;p&gt;The fix is to modify the &lt;code&gt;dfu_bl_image_validate()&lt;/code&gt; function in &lt;code&gt;dfu_single_bank.c&lt;/code&gt; run verification on both addresses (BANK0 and BANK1), i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t dfu_bl_image_validate(void) {
    bootloader_settings_t bootloader_settings;
    sd_mbr_command_t      sd_mbr_cmd_1;
    sd_mbr_command_t      sd_mbr_cmd_2;

    bootloader_settings_get(&amp;amp;bootloader_settings);

    if (bootloader_settings.bl_image_size != 0)
    {
        uint32_t bl_image_start_1 = (bootloader_settings.sd_image_size == 0) ?
                                  DFU_BANK_0_REGION_START :
                                  bootloader_settings.sd_image_start +
                                  bootloader_settings.sd_image_size;

        sd_mbr_cmd_1.command             = SD_MBR_COMMAND_COMPARE;
        sd_mbr_cmd_1.params.compare.ptr1 = (uint32_t *)BOOTLOADER_REGION_START;
        sd_mbr_cmd_1.params.compare.ptr2 = (uint32_t *)(bl_image_start_1);
        sd_mbr_cmd_1.params.compare.len  = bootloader_settings.bl_image_size / sizeof(uint32_t);



    uint32_t bl_image_start_2 = (bootloader_settings.sd_image_size == 0) ?
                                  DFU_BANK_1_REGION_START :
                                  bootloader_settings.sd_image_start +
                                  bootloader_settings.sd_image_size;

        sd_mbr_cmd_2.command             = SD_MBR_COMMAND_COMPARE;
        sd_mbr_cmd_2.params.compare.ptr1 = (uint32_t *)BOOTLOADER_REGION_START;
        sd_mbr_cmd_2.params.compare.ptr2 = (uint32_t *)(bl_image_start_2);
        sd_mbr_cmd_2.params.compare.len  = bootloader_settings.bl_image_size / sizeof(uint32_t);

        return sd_mbr_command(&amp;amp;sd_mbr_cmd_1) &amp;amp;&amp;amp; sd_mbr_command(&amp;amp;sd_mbr_cmd_2);
    }
    return NRF_SUCCESS;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>