<?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 Service with readback protection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11305/dfu-service-with-readback-protection</link><description>Can DFU Service update the SoftDevice, Application, and/or Bootloader if readback protection is set to ALL?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Nov 2016 11:13:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11305/dfu-service-with-readback-protection" /><item><title>RE: DFU Service with readback protection</title><link>https://devzone.nordicsemi.com/thread/42528?ContentTypeID=1</link><pubDate>Fri, 18 Nov 2016 11:13:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:630b569a-c673-4d94-9aff-55376072b04c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Greg Lund: You are correct, if UICR.RBPCONF.PR0 is enabled, meaning readback protection for code region 0 only. The question was about UICR.RBPCONF.PALL, when code region 1 still have read access to region 0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU Service with readback protection</title><link>https://devzone.nordicsemi.com/thread/42527?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 16:46:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f4a04d7-2c70-4bc0-959a-c765ef9e5a37</guid><dc:creator>Greg Lund</dc:creator><description>&lt;p&gt;The DFU example included in SDK 10 is indeed affected by the status of the readback protection settings if you have softdevice readback protection enabled.  There are several instances where dfu code tries to directly read soft device memory areas.&lt;/p&gt;
&lt;h2&gt;Instance 1: (main.c lines ~230 - 250)&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;if (dfu_start || (!bootloader_app_is_valid(DFU_BANK_0_REGION_START)))
{
    //nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);

    // Initiate an update of the firmware.
    err_code = bootloader_dfu_start();
    APP_ERROR_CHECK(err_code);

    //nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);
}


if (bootloader_app_is_valid(DFU_BANK_0_REGION_START) &amp;amp;&amp;amp; !bootloader_dfu_sd_in_progress())
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;DFU_BANK_0_REGION_START is a series of defines and macros that lead to checking a memory location within the soft device.  This will cause the device to hard fault if readback protection is enabled.&lt;/p&gt;
&lt;p&gt;I changed this to read NRF_UICR-&amp;gt;CLENR0 to get the start address.&lt;/p&gt;
&lt;h2&gt;Instance 2: (dfu_init_template.c lines ~117 - 130)&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;// Third check: Check the array of supported SoftDevices by this application.
//              If the installed SoftDevice does not match any SoftDevice in the list then an
//              error is returned.
while (i &amp;lt; p_init_packet-&amp;gt;softdevice_len)
{
    if (p_init_packet-&amp;gt;softdevice[i]   == DFU_SOFTDEVICE_ANY ||
        p_init_packet-&amp;gt;softdevice[i++] == SD_FWID_GET(MBR_SIZE))
    {
        return NRF_SUCCESS;
    }
}

// No matching SoftDevice found - Return NRF_ERROR_INVALID_DATA.
return NRF_ERROR_INVALID_DATA;
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;The macro SD_FWID_GET(MBR_SIZE) attempts to read from data within the softdevice.  For lack of a better solution at this time, I have simply commented out this block of code and replaced it with&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;return NRF_SUCCESS;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU Service with readback protection</title><link>https://devzone.nordicsemi.com/thread/42526?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2016 08:48:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f6d0c46-0c9c-4b9f-8eff-d8b6daf4eecf</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brett,&lt;/p&gt;
&lt;p&gt;Read back protection has nothing to do with the DFU as the readback only protect the content of flash (code region 0 or all) from reading from the SWD interface. DFU on the other hand is the modification of the flash by the CPU (by the code in bootloader and the MBR).&lt;/p&gt;
&lt;p&gt;If CLENR0 = 0xFFFFFFFF, it&amp;#39;s interpreted as CLENR0 size = 0. Everything is Region 1.&lt;/p&gt;
&lt;p&gt;When you set CLENR0, (e.g enable protection when flashing softdevice), it&amp;#39;s still possible to update the softdevice (region 0) because the MBR is located inside region 0 and it&amp;#39;s possible to modify code region 0 (but not changing the size of it).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU Service with readback protection</title><link>https://devzone.nordicsemi.com/thread/42525?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2016 04:08:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bf54e1b-8d81-4481-91a7-7a8f77d2201d</guid><dc:creator>Brett</dc:creator><description>&lt;p&gt;The way I interpret the table is that everything (SD, App, BL) is in region 1 not region 0.  If CLENR0 is not written then Region 0 Size = 0, and then Region 1 would have to be whats left, which is the entire ROM code memory.&lt;/p&gt;
&lt;p&gt;Let  UICR.RBPCONF.PALL = 0x00
Let UICR.RBPCONF.PRO = 0xFF&lt;/p&gt;
&lt;p&gt;According to Table 40 in section 9.1.3:
If a SWD attempts to access region 1 then all regions are NA0 (Good).&lt;/p&gt;
&lt;p&gt;If code in region 1 (i.e. DFU bootloader) requests access then the code/ram region 0 = Limited Access.  Since all code is in region 1 then this doesn&amp;#39;t matter if my understanding above is correct.&lt;/p&gt;
&lt;p&gt;If code in region 1 (i.e. DFU bootloader) requests access then the code/ram region 1 = Full Access. This is good because the SoftDevice, Application, and Bootloader are all in Region 1 if my understanding is correct.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU Service with readback protection</title><link>https://devzone.nordicsemi.com/thread/42524?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2016 02:52:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0fa200c-dd6b-44f2-b12d-beacb25624a4</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Thats what my reading of that table says. PALL is on, Code0 protect is off and everything is Region 0 because you haven&amp;#39;t defined CLENR0. That prevents any SWD access of anything but allows all your code to read and write all your code and RAM space.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU Service with readback protection</title><link>https://devzone.nordicsemi.com/thread/42523?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2016 02:30:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7014b598-bdd1-4e7b-a745-161e8b91869d</guid><dc:creator>Brett</dc:creator><description>&lt;p&gt;I have some follow up question just to make sure that I am fully understanding this correctly.  I need to ensure our firmware is protected from security threats such as SWD flash downloads if we enable the BLE DFU Service.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;If I do not write CLENR0, and I write 0xFFFF00FF to RBPCONF, can a SWD read anything from the device?  (YES,NO)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If I do not write CLENR0, and I write 0xFFFF00FF to RBPCONF, can the DFU Service update the SoftDevice, Application, and/or Bootloader per the SDK documentation? (YES,NO)&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Thanks for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU Service with readback protection</title><link>https://devzone.nordicsemi.com/thread/42522?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2016 00:46:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9707d6ed-8c40-48e3-a2a2-7884cf816ca9</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;No the DFU service won&amp;#39;t be able to update anything in region 0 if region 0 is defined, ie CLENR0 is set to something other than the default. If you look at the table in the MPU chapter you&amp;#39;ll see that ALL has more to do with debugger access to data, code in region 1 can&amp;#39;t read or write to the code space in region 0 in any case where CLENR0 is defined.&lt;/p&gt;
&lt;p&gt;This is why, since the advent of the Master Boot Record and basic support for DFU, loading the softdevice no-longer sets CLENR0. I think the nRF52 does away with all the region0/region1 stuff and protection is limited to turning the debugger access off.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s not clear why a readback protection would prevent you from writing? If you could write to region 0 you could clear one page in region 0, write a tiny piece of code to it which dumps the rest of the pages you didn&amp;#39;t clear to wherever you like and hence subvert much of the read protection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU Service with readback protection</title><link>https://devzone.nordicsemi.com/thread/42521?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2016 20:19:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfb26d99-7672-4903-beb3-b8ed92edf63b</guid><dc:creator>Brett</dc:creator><description>&lt;p&gt;In the nRF51 Series Reference Manual Version 3.0, Section 8.1 it states...&lt;/p&gt;
&lt;p&gt;&amp;quot;Code running from code region 1 will not be able to write to code region 0.&amp;quot;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m assuming this means that only region 0 is protected.  Since the bootloader for the DFU service is located in region 1 then I would assume the DFU Service would not work.  I wanted to make sure, because it is not clear why a readback protection would prevent me from writing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>