<?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>Secure DFU, OTA failed scenario is not as expected</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34839/secure-dfu-ota-failed-scenario-is-not-as-expected</link><description>Hi, 
 
 I run the Secure DFU, and I&amp;#39;m doing OTA update without any issue. 
 
 The problem is the case that I&amp;#39;m doing an OTA update with a application-version smaller than the one is currently in the board. The Prevalidate fails as expected and sends the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 30 May 2018 11:12:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34839/secure-dfu-ota-failed-scenario-is-not-as-expected" /><item><title>RE: Secure DFU, OTA failed scenario is not as expected</title><link>https://devzone.nordicsemi.com/thread/134007?ContentTypeID=1</link><pubDate>Wed, 30 May 2018 11:12:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69cf713f-990f-44f1-b1d5-58c5d6d24859</guid><dc:creator>PouyaSe</dc:creator><description>&lt;p&gt;Hi Einar&lt;/p&gt;
&lt;p&gt;Ok, great.&amp;nbsp;I wanted to make sure that I&amp;#39;m not doing anything wrong.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I will tell the Mobile Application developer guys to do the check before doing OTA in a first place.&amp;nbsp;until we migrate the production code to SDK v14 at some point.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks again.&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;
&lt;p&gt;Pouya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure DFU, OTA failed scenario is not as expected</title><link>https://devzone.nordicsemi.com/thread/134006?ContentTypeID=1</link><pubDate>Wed, 30 May 2018 11:05:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ca43c6e-8475-41fe-9c95-ee684bdcc4d8</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;You are absolutely right. The only way to continue from this state is to upgrade with a valid DFU image.&amp;nbsp;This behavior has been remedied by the introduction of a &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/lib_bootloader_dfu_inactivity.html?cp=4_0_1_3_5_1_3"&gt;inactivity timer&lt;/a&gt; in SDK 14, which triggers a reset if there has been no activity for some time. This is essentially a application timer that is restarted every time there is activity, and calls&amp;nbsp;&lt;code&gt;NVIC_SystemReset()&lt;/code&gt; if it times out, so it should not be much work to port it to SDK 12.3 if you want it. A simpler alternative if you want to reset if prevalidation failed is to just call&amp;nbsp;&lt;code&gt;NVIC_SystemReset()&lt;/code&gt; after logging &amp;quot;Prevalidate FAILED&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure DFU, OTA failed scenario is not as expected</title><link>https://devzone.nordicsemi.com/thread/133940?ContentTypeID=1</link><pubDate>Wed, 30 May 2018 07:10:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63c1ad7f-273b-4e03-8ddf-a12a2fa18176</guid><dc:creator>PouyaSe</dc:creator><description>&lt;p&gt;Hi Einar&lt;br /&gt;&lt;br /&gt;Thanks for you response and time.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That is exactly What I have&amp;nbsp;was expecting, but not seeing in action. I&amp;#39;m pretty much sure that I don&amp;#39;t have DEBUG defined.&lt;br /&gt;&lt;br /&gt;and if you take a look at the &lt;em&gt;on_ctrl_pt_write()&lt;/em&gt; function, you would see the following code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;case BLE_DFU_OP_CODE_EXECUTE_OBJECT:
            NRF_LOG_INFO(&amp;quot;Received execute object\r\n&amp;quot;);

            // Set req type
            dfu_req.req_type     =  NRF_DFU_OBJECT_OP_EXECUTE;

            res_code = nrf_dfu_req_handler_on_req(NULL, &amp;amp;dfu_req, &amp;amp;dfu_res);
            return response_send(p_dfu, BLE_DFU_OP_CODE_EXECUTE_OBJECT, res_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;nrf_dfu_handler_on_req&lt;/em&gt; will return a fail state as expected (the&amp;nbsp;prevalidate failed), then it send the response the the mobile phone. when sending the response to the phone is successful, it would return success, noting else.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And, if you take a look at the&amp;nbsp;&lt;em&gt;on_ble_evt&lt;/em&gt; (inside nrf_ble_dfu.c), you would see the following code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
            if (p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.type
                != BLE_GATTS_AUTHORIZE_TYPE_INVALID)
            {
                if (on_rw_authorize_req(&amp;amp;m_dfu, p_ble_evt))
                {
                    err_code = on_ctrl_pt_write(&amp;amp;m_dfu, 
                           &amp;amp;(p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request.request.write));
#ifdef NRF_DFU_DEBUG_VERSION  
                    if (err_code != NRF_SUCCESS)
                    {
                        NRF_LOG_ERROR(&amp;quot;Could not handle on_ctrl_pt_write. err_code: 0x%04x\r\n&amp;quot;, err_code);
                    }
#else
                    // Swallow result
                    (void) err_code;
#endif
                }
            }
            break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;the code I see, will swallow the return code of&amp;nbsp;&lt;em&gt;on_ctrl_pt_write().&lt;/em&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So, Am i tracking the issue in a wrong place?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure DFU, OTA failed scenario is not as expected</title><link>https://devzone.nordicsemi.com/thread/133810?ContentTypeID=1</link><pubDate>Tue, 29 May 2018 12:29:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db2f366e-a43f-4674-a179-fa5969adc312</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The most likely reason for this is that you have &lt;code&gt;DEBUG&lt;/code&gt; defined in your project.&lt;/p&gt;
&lt;p&gt;I expect that &lt;code&gt;NRF_ERROR_INVALID_STATE&lt;/code&gt; is returned from the call to&amp;nbsp;&lt;code&gt;on_ctrl_pt_write()&lt;/code&gt; in this case, which should be caught by the &lt;code&gt;APP_ERROR_CHECK()&lt;/code&gt;. The&amp;nbsp;&lt;code&gt;app_error_handler_bare()&lt;/code&gt; or&amp;nbsp;&lt;code&gt;app_error_handler()&lt;/code&gt; which calls &lt;code&gt;app_error_fault_handler()&lt;/code&gt; behaves differently if &lt;code&gt;DEBUG&lt;/code&gt; is defined or not. The state of the system will be preserved without a reset to ease debugging in case &lt;code&gt;DEBUG&lt;/code&gt; is defined. However,&amp;nbsp;&lt;code&gt;NVIC_SystemReset()&lt;/code&gt; is called if &lt;code&gt;DEBUG&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; defined.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>