<?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 question - I wonder whether there is a way that BLE knows the device is upgrade its software</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92130/dfu-question---i-wonder-whether-there-is-a-way-that-ble-knows-the-device-is-upgrade-its-software</link><description>Dear support 
 I tried DFU OTA example here recently and it works for me and have a question to ask. 
 My application is a central app and host by my main MCU via UART interface, I wonder when device firmware is being updated by OTA, is there a way the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 23 Sep 2022 15:01:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92130/dfu-question---i-wonder-whether-there-is-a-way-that-ble-knows-the-device-is-upgrade-its-software" /><item><title>RE: DFU question - I wonder whether there is a way that BLE knows the device is upgrade its software</title><link>https://devzone.nordicsemi.com/thread/387721?ContentTypeID=1</link><pubDate>Fri, 23 Sep 2022 15:01:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9748667-129f-47b1-8118-1b3ed289fe6d</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Ping,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Ah, so the change in overlay file is for upgrading the SDK, not for setting up the img_mgmt callbacks, right?&amp;nbsp;That would make sense.&lt;/p&gt;
&lt;p&gt;Your observation is the same as mine. If you wish to see the other callback in action, try playing with DFU using the Advanced option on the app &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nrf-connect-device-manager"&gt;nRF Connect Device Manager&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The Started callback works exactly as you understand it. Only for the initial trigger of an image upload. If the upload is paused and resumed, the callback is not called again.&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t investigated this thoroughly, but if I understand correctly, the Stopped callback is only called when firmware upload or erase encounters an error. You could check more by looking up where &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;img_mgmt_dfu_stopped()&lt;/span&gt; is called.&lt;/p&gt;
&lt;p&gt;The Confirmed callback is only called when&amp;nbsp;the new firmware is Confirmed during its Test boot.&lt;/p&gt;
&lt;p&gt;See also:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/services/device_mgmt/mcumgr.html#image-management"&gt;MCUmgr — Zephyr Project Documentation (nordicsemi.com)&lt;/a&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;By the way, just for completeness&amp;#39;s sake, there is one more callback API of interest. This one is called before any upload happen:&lt;/p&gt;
&lt;p&gt;In &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-branch/subsys/mgmt/mcumgr/lib/cmd/img_mgmt/include/img_mgmt/img_mgmt.h#L235"&gt;&amp;lt;NCS Root&amp;gt;\zephyr\subsys\mgmt\mcumgr\lib\cmd\img_mgmt&lt;/a&gt;&lt;br /&gt;void img_mgmt_register_callbacks(const struct img_mgmt_dfu_callbacks_t *cb_struct);&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I have suggested my previous reply as the answer. If you can verify it, that would be great, or I will do so in a few days.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU question - I wonder whether there is a way that BLE knows the device is upgrade its software</title><link>https://devzone.nordicsemi.com/thread/387666?ContentTypeID=1</link><pubDate>Fri, 23 Sep 2022 11:03:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67b56597-9324-4cd0-a03e-37bd609f22f0</guid><dc:creator>PingISTL</dc:creator><description>&lt;p&gt;Hi, Hieu&lt;/p&gt;
&lt;p&gt;Thanks for the link,&amp;nbsp;I will read it&amp;nbsp; although it is better read before. It seems like a big change.&lt;/p&gt;
&lt;p&gt;I had to change the uart1 pin like the new pinctrl feature format like below instead of pin number for the overlay file. Had to manually create new custom board file too.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;uart1 {
    status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;uart1_default&amp;gt;;
    pinctrl-1 = &amp;lt;&amp;amp;uart1_sleep&amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
}; &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also tested some DFU OTA this morning, and found that:&lt;/p&gt;
&lt;p&gt;1. &amp;quot;started call back&amp;quot; is only called when start&amp;nbsp; downloading a new version, if image is already there, it won&amp;#39;t downloading, right?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. Never &amp;quot; stopped call back &amp;quot; happen.&lt;/p&gt;
&lt;p&gt;3. Sometime, &amp;quot;confirmed call back &amp;quot; is not called.&lt;/p&gt;
&lt;p&gt;Anyway, it is good enough for me to use and thank you again for your hard work!&lt;/p&gt;
&lt;p&gt;Regards!&lt;/p&gt;
&lt;p&gt;Ping&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU question - I wonder whether there is a way that BLE knows the device is upgrade its software</title><link>https://devzone.nordicsemi.com/thread/387650?ContentTypeID=1</link><pubDate>Fri, 23 Sep 2022 10:19:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7031f9d-1b71-4a4b-98b8-7ba144ba0689</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Ping,&lt;/p&gt;
&lt;p&gt;Glad to hear things worked for you. I have not performed an SDK upgrade myself, so I don&amp;#39;t know the first-hand experience. I think you already know, but just in case, there is a guide available here:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/nrf/migration/migration_guide_1.x_to_2.x.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/nrf/migration/migration_guide_1.x_to_2.x.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It is weird that you have to update overlay file for this, since we didn&amp;#39;t really touch any hardware resources.&amp;nbsp;&lt;br /&gt;If you don&amp;#39;t mind, what did you have to change?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU question - I wonder whether there is a way that BLE knows the device is upgrade its software</title><link>https://devzone.nordicsemi.com/thread/387552?ContentTypeID=1</link><pubDate>Thu, 22 Sep 2022 16:06:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dc28fd6-c3db-4a9e-9984-c8ae07c27221</guid><dc:creator>PingISTL</dc:creator><description>&lt;p&gt;Hi, Hieu&lt;/p&gt;
&lt;p&gt;Thank you for your contribution!&lt;/p&gt;
&lt;p&gt;The solution works for me - exactly what I need.&lt;/p&gt;
&lt;p&gt;1. I had to upgrade my SDK to v2.1.0 to use first feature,&amp;nbsp;which took a while as code is not backwards compatible, don&amp;#39;t understand why it is so hard to migrant from 1 version to another.&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp;The&amp;nbsp;second call back works&amp;nbsp;straight away.&lt;/p&gt;
&lt;p&gt;3. BTW - my custom board overlay file had to modify too to work on it.&lt;/p&gt;
&lt;p&gt;Thank again.&lt;/p&gt;
&lt;p&gt;Ping&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU question - I wonder whether there is a way that BLE knows the device is upgrade its software</title><link>https://devzone.nordicsemi.com/thread/387355?ContentTypeID=1</link><pubDate>Wed, 21 Sep 2022 16:55:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca5edacc-a9fd-444c-83f0-b578b491a344</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Ping,&lt;/p&gt;
&lt;p&gt;I found a few API that can help you. You can click the link&amp;nbsp;to go to the header file with full documentation. Further&amp;nbsp;below are&amp;nbsp;an example usage from me and the&amp;nbsp;log from my test.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;In &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/subsys/mgmt/mcumgr/lib/cmd/os_mgmt/include/os_mgmt/os_mgmt.h"&gt;&amp;lt;NCS Root&amp;gt;\zephyr\subsys\mgmt\mcumgr\lib\cmd\os_mgmt&lt;/a&gt;&lt;br /&gt;void os_mgmt_register_reset_evt_cb(os_mgmt_on_reset_evt_cb cb);&lt;br /&gt;Unfortunately this API is only available from NCS v2.0.0. Are you working on the same NCS v1.9.1 from your previous ticket...?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;In &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-branch/subsys/mgmt/mcumgr/lib/cmd/img_mgmt/include/img_mgmt/img_mgmt.h#L235"&gt;&amp;lt;NCS Root&amp;gt;&lt;/a&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-branch/subsys/mgmt/mcumgr/lib/cmd/img_mgmt/include/img_mgmt/img_mgmt.h#L235"&gt;&lt;span&gt;\zephyr\subsys\mgmt\mcumgr\lib\cmd\img_mgmt&lt;br /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;void&lt;span&gt; &lt;/span&gt;&lt;span&gt;img_mgmt_register_callbacks&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;img_mgmt_dfu_callbacks_t&lt;/span&gt;&lt;span&gt; *cb_struct);&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void test_dfu_started_cb(void) { printk(&amp;quot;%s\n&amp;quot;, __func__); }
void test_dfu_stopped_cb(void) { printk(&amp;quot;%s\n&amp;quot;, __func__); }
void test_dfu_pending_cb(void) { printk(&amp;quot;%s\n&amp;quot;, __func__); }
void test_dfu_confirmed_cb(void) { printk(&amp;quot;%s\n&amp;quot;, __func__); }

const struct img_mgmt_dfu_callbacks_t test_img_mgmt_dfu_callbacks = {
    .dfu_started_cb = &amp;amp;test_dfu_started_cb,
    .dfu_stopped_cb = &amp;amp;test_dfu_stopped_cb,
    .dfu_pending_cb = &amp;amp;test_dfu_pending_cb,
    .dfu_confirmed_cb = &amp;amp;test_dfu_confirmed_cb
};

int test_os_mgmt_on_reset_evt_cb(void) {
    printk(&amp;quot;%s\n&amp;quot;, __func__);
    return 0;
}

void main(void)
{
    [...]
    
    printk(&amp;quot;build time: &amp;quot; __DATE__ &amp;quot; &amp;quot; __TIME__ &amp;quot;\n&amp;quot;);

    os_mgmt_register_group();
    os_mgmt_register_reset_evt_cb(&amp;amp;test_os_mgmt_on_reset_evt_cb);
    img_mgmt_register_group();
    img_mgmt_register_callbacks(&amp;amp;test_img_mgmt_dfu_callbacks);
    smp_bt_register();
    
    [...]
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v3.0.99-ncs1-1  ***
I: Starting bootloader
I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: none
I: Bootloader chainload address offset: 0xc000
I: Jumping to the first image slot
▒*** Booting Zephyr OS build v3.0.99-ncs1-1  ***
Starting Nordic UART service example
build time: Sep 21 2022 18:40:24
test_dfu_started_cb
test_dfu_pending_cb
test_os_mgmt_on_reset_evt_cb
*** Booting Zephyr OS build v3.0.99-ncs1-1  ***
I: Starting bootloader
I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1
I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: test
I: Starting swap using move algorithm.
I: Bootloader chainload address offset: 0xc000
I: Jumping to the first image slot
*** Booting Zephyr OS build v3.0.99-ncs1-1  ***
Starting Nordic UART service example
build timex: Sep 21 2022 17:18:35&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As of now I haven&amp;#39;t seen any API to interfere with the DFU process as suggested in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/84115/dfu-via-ota"&gt;this Q&amp;amp;A&lt;/a&gt; yet. However, is it enough for your current requirement yet?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Side note, I am out of office tomorrow, so unfortunately&amp;nbsp;the earliest I can follow up will be Friday.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU question - I wonder whether there is a way that BLE knows the device is upgrade its software</title><link>https://devzone.nordicsemi.com/thread/387342?ContentTypeID=1</link><pubDate>Wed, 21 Sep 2022 15:11:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20fce54a-6903-45e5-83e1-4228fcb83144</guid><dc:creator>PingISTL</dc:creator><description>&lt;p&gt;Hi, Hieu&lt;/p&gt;
&lt;p&gt;Thank you for reply and spend time on it, it is not an easy one, I understand.&lt;/p&gt;
&lt;p&gt;Initially I thought it can tell by connected as a peripheral role as the advertising function is only added for DFU purpose, but then it is possible that it can be connected for echo or something else but not upgrading firmware.&lt;/p&gt;
&lt;p&gt;If firmware had an unexpected reboot - not initiated by host MCU, then it is probably&amp;nbsp;a reboot following a DFU OTA, but that can only be told after the DFU happened.&lt;/p&gt;
&lt;p&gt;That is all I can think of, I am not familiar with more deep insight into the protocols.&lt;/p&gt;
&lt;p&gt;Regards!&lt;/p&gt;
&lt;p&gt;Ping&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU question - I wonder whether there is a way that BLE knows the device is upgrade its software</title><link>https://devzone.nordicsemi.com/thread/387341?ContentTypeID=1</link><pubDate>Wed, 21 Sep 2022 14:57:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:181ace37-4ef7-4682-a927-c9c54cad35a3</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Ping,&lt;/p&gt;
&lt;p&gt;Just want to let you know that I got on the case. I will have to spend some more time on this, sorry.&lt;/p&gt;
&lt;p&gt;I did spend quite some time looking into the APIs of SMP services and GATT, but&amp;nbsp;there don&amp;#39;t seem to be anything there that can&amp;nbsp;serve your purpose.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>