<?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>nrf52 dfu crc check</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/27910/nrf52-dfu-crc-check</link><description>I use buttonless_dfu_app as template. SDK 14.2 
 Q1. Could someone help me.. After I updated my app I have changed crc (if more than just few changes), so bootloader installed into board from first dfu doesn&amp;#39;t allow me to update app (can&amp;#39;t accept crc</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 Dec 2017 10:08:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/27910/nrf52-dfu-crc-check" /><item><title>RE: nrf52 dfu crc check</title><link>https://devzone.nordicsemi.com/thread/110126?ContentTypeID=1</link><pubDate>Wed, 06 Dec 2017 10:08:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c6b631e-ec16-4888-8fbe-1f7e4c1e0f13</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Are you just flashing you application with a programmer, or are you sending the new application with OTA-DFU ?&lt;/p&gt;
&lt;p&gt;When you are flashing your new application to the nRF5x with a debugger/programmer, the current bootloader settings page is not updated automatically. So the CRC will not match, and the bootloader will not start the new application. In that case, you need to generate new bootloader settings page based on the new application every time you build a new application. Then merge this new settings page with your new application, and then flash over the new merged hex to the nRF5x. See &lt;a href="https://devzone.nordicsemi.com/question/114262/flashing-sdappbl-sdk122/?answer=114473#post-id-114473"&gt;this page&lt;/a&gt; and &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.tools/dita/tools/nrfutil/nrfutil_settings_generate_display.html?cp=5_5_6"&gt;this page&lt;/a&gt;. If you don’t want to create a new bootloader settings page +merge it every time you flash a new application, you can bypass this(skip crc check), with the workaround I suggested in Q1.&lt;/p&gt;
&lt;p&gt;If you are not flashing the new application with a programmer(SWD), but doing OTA-DFU, then the  bootloader settings page CRC field should be updated automatically with the CRC of the new application that is received.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dfu crc check</title><link>https://devzone.nordicsemi.com/thread/110125?ContentTypeID=1</link><pubDate>Tue, 05 Dec 2017 14:01:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f66b600-188b-4cb1-87bb-1ccf2b86b7d4</guid><dc:creator>Stas</dc:creator><description>&lt;p&gt;But I did all steps from infocenter
There&amp;#39;re not any problem besides crc checking after I changed app a lot.
and there are not example how to update bootloader OTA&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dfu crc check</title><link>https://devzone.nordicsemi.com/thread/110124?ContentTypeID=1</link><pubDate>Tue, 05 Dec 2017 13:46:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2130735e-a867-4eba-8add-a0834e1b831f</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;We have the guide I linked to &lt;a href="https://devzone.nordicsemi.com/blogs/1085/getting-started-with-nordics-secure-dfu-bootloader/"&gt;here&lt;/a&gt;. Please try to get that working, before we skip the crc checking.&lt;/p&gt;
&lt;p&gt;Also take a look at the nrfutil user guide &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.tools/dita/tools/nrfutil/nrfutil_intro.html?cp=5_5"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dfu crc check</title><link>https://devzone.nordicsemi.com/thread/110123?ContentTypeID=1</link><pubDate>Tue, 05 Dec 2017 13:41:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e30abd8-f6a0-4a07-9ca7-2fee3d06edc1</guid><dc:creator>Stas</dc:creator><description>&lt;p&gt;I&amp;#39;m a little confused about how to do it.
What I&amp;#39;m have:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;nrf52832 chip.&lt;/li&gt;
&lt;li&gt;smartphone with installed nrftoolbox app (but later develop own app used dfu library)&lt;/li&gt;
&lt;li&gt;sdk14.2, sd5.1, initially app.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Could you explain me step by step what I must to do for update changed app skipping crc checking by bootloader that in the chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dfu crc check</title><link>https://devzone.nordicsemi.com/thread/110122?ContentTypeID=1</link><pubDate>Tue, 05 Dec 2017 13:20:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2bc93d7-7f7c-4f56-9f6d-de49e5f990e5</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;You can update the application alone, without updating the bootloader.&lt;/p&gt;
&lt;p&gt;At the start of the DFU process, the CRC inside the initpacket is stored in the bootloader settings page. The CRC check is done at the end of the DFU process,  where we calculate the CRC of the received FW image, and compare it to the CRC stored in the bootloader settings page at the beginning of the DFU process. This is to ensure the integrity of the image.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dfu crc check</title><link>https://devzone.nordicsemi.com/thread/110121?ContentTypeID=1</link><pubDate>Tue, 05 Dec 2017 02:04:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:363ffdd1-6baa-4754-81b8-da936af8fa74</guid><dc:creator>Stas</dc:creator><description>&lt;p&gt;Thanks for so detail answer. I don&amp;#39;t have an experience of production products on nrf52832. But I have a fitness watch based on nrf52832 and it&amp;#39;s updates app OTA often enough,. As I understand they can do it only with BL update at the same time. If it&amp;#39;s true, could you give an example of raw for Bootloader update.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dfu crc check</title><link>https://devzone.nordicsemi.com/thread/110120?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2017 13:32:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:292cfb18-80c4-41aa-bb8e-baf83df0e6e7</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q1 )&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can make &lt;code&gt;nrf_dfu_app_is_valid()&lt;/code&gt; always return true for some testing, but this is dangerous and should not be used in an end product. I recommend you to go back and debug this issue so that there is no chance of accidentally forgetting to fix this before going into production. The reason is that in case there is no valid application, and the &lt;code&gt;nrf_dfu_app_is_valid()&lt;/code&gt; still returns true, the bootloader will branch to the start address of the faulty or non-existing application. This would effectively brick the device in a buttonless configuration, where there is no way to force a DFU upgrade by pushing a button during reset. In this case, the only way to recover is by means of a debugger.&lt;/p&gt;
&lt;p&gt;The bootloader uses the &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.2.0%2Flib_bootloader_dfu_process.html&amp;amp;anchor=lib_bootloader_dfu_process_settings"&gt;bootloader settings page&lt;/a&gt; for checking if the application is present and to check if the application is the correct one. You can &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.tools%2Fdita%2Ftools%2Fnrfutil%2Fnrfutil_settings_generate_display.html"&gt;generate a bootloader settings page using nrfutil&lt;/a&gt;, but the bootloader settings page will also be written if you perform DFU.
For &lt;strong&gt;debugging purposes only&lt;/strong&gt;, you can (in addition to the bootloader settings page) use a bootloader that does not  check the CRC of the application. The CRC changes every time you change the application, which is happening a lot while debugging. The bootloader CRC check is in &lt;code&gt;nrf_dfu_utils.c&lt;/code&gt;, in the function &lt;code&gt;nrf_dfu_app_is_valid()&lt;/code&gt;, and looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (s_dfu_settings.bank_0.image_crc != 0)
{
    uint32_t crc = crc32_compute((uint8_t*) CODE_REGION_1_START,
                                 s_dfu_settings.bank_0.image_size,
                                 NULL);

    if (crc != s_dfu_settings.bank_0.image_crc)
    {
        // CRC does not match with what is stored.
        NRF_LOG_DEBUG(&amp;quot;Return false in CRC&amp;quot;);
        return  false;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I suggest adding the lines &amp;quot;&lt;code&gt;#ifndef DISABLE_CRC_CHECK&lt;/code&gt;&amp;quot; before and &amp;quot;&lt;code&gt;#endif&lt;/code&gt;&amp;quot; after the above section of code, and set a &lt;code&gt;DISABLE_CRC_CHECK&lt;/code&gt; preprocessor define in order to disable CRC checking. Then use the bootloader with disabled CRC checking when &lt;strong&gt;debugging&lt;/strong&gt; the application. (You can of course choose another name for the define, in order to make it perfectly clear that the define &lt;strong&gt;is intended for development builds only&lt;/strong&gt;. For instance you can combine it with DEBUG so that it only can be omitted for debug builds.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q2)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Take a look at &lt;a href="https://devzone.nordicsemi.com/blogs/1085/getting-started-with-nordics-secure-dfu-bootloader/"&gt;this DFU guide&lt;/a&gt;. At the end of the guide we have the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The following code will generate a softdevice + application combination:&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;nrfutil pkg generate --hw-version 52
--application-version 1 --application application.hex --sd-req 0x98
--softdevice softdevice.hex --key-file private.key
app_dfu_package_softdevice.zip&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Q3)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the nRF52832 we have something called readback protection that prevents a someone to use a debugger to read the flash and RAM. You can enable readback protection of the device by writing &amp;#39;00&amp;#39; to the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/uicr.html?cp=2_1_0_13_0_61#register.APPROTECT"&gt;APPROTECT register&lt;/a&gt;. You can also do this with our tool nrfjprog:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrfjprog -f nrf52 --rbp ALL &amp;amp;&amp;amp; nrfjprog --pinreset -f nrf52
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Setting &lt;code&gt;APPROTECT&lt;/code&gt; &amp;quot;disconnects&amp;quot; the ability to connect with a programmer/debugger, but it still allows the microcontroller to access its own flash and RAM area. See &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.whitepapers/dita/whitepapers/nwp_027/nWP_027_approtect.html?cp=11_0_3"&gt;this whitepaper&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The only way to &amp;#39;reopen/unlock&amp;#39; the device after APPROTECT is set, is to issue an ERASEALL command through the CTRL-AP access port, and then issue a reset through the CTRL-AP. (&lt;code&gt;nrfjprog --recover&lt;/code&gt;). This will erase the entire code flash and UICR area of the device, in addition to the entire RAM.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>