<?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>Entering DFU mode via SPI and updating firmware</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69480/entering-dfu-mode-via-spi-and-updating-firmware</link><description>Hi, 
 My application needs to enter DFU mode based on a command from another device connected via SPI. 
 I see that I could use the following two statements once the application receives the SPI command. This resets the device but the device doesn&amp;#39;t enter</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Dec 2020 08:05:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69480/entering-dfu-mode-via-spi-and-updating-firmware" /><item><title>RE: Entering DFU mode via SPI and updating firmware</title><link>https://devzone.nordicsemi.com/thread/285759?ContentTypeID=1</link><pubDate>Fri, 18 Dec 2020 08:05:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c835e42e-6b7b-4d6c-8edb-2cc5e23c747f</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Ram,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes. eventually, you can replace only the 1st one and re-work&amp;nbsp;serial_adapter.c for spi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;boot_serial_start(&amp;amp;boot_funcs)&lt;/strong&gt; implements whole dfu protocol, compatible with the mcumgr. serial_adapter.c implements uart or Usb-serial communication backends. We have also embedded mcumgr client sample (&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/6fdb224718bce0590aaff1ff5e3a9767dcac8d9d/samples/bluetooth/central_dfu_smp"&gt;https://github.com/nrfconnect/sdk-nrf/tree/6fdb224718bce0590aaff1ff5e3a9767dcac8d9d/samples/bluetooth/central_dfu_smp&lt;/a&gt;) in NCS. which might be modified to be spi counterpart on the second device.&lt;/p&gt;
&lt;p&gt;If you need further support, please create a new support case. I will start the holiday next week.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Merry Christmas &amp;amp; Happy new year.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Amanda H.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Entering DFU mode via SPI and updating firmware</title><link>https://devzone.nordicsemi.com/thread/285439?ContentTypeID=1</link><pubDate>Wed, 16 Dec 2020 17:13:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54347f9d-1720-45e9-9ebd-f935da641802</guid><dc:creator>RAS_ID</dc:creator><description>&lt;p&gt;Hi Amanda&lt;/p&gt;
&lt;p&gt;Thanks for your reply! Appreciate it!&lt;/p&gt;
&lt;p&gt;Presently, we are looking for option 2. The main application will initiate the DFU mode (using GPREGRET and System reset) but it will be served (processed) by the bootloader to overwrite the application.&lt;/p&gt;
&lt;p&gt;I will look into SPI samples from the link provided by you. Thanks!&lt;/p&gt;
&lt;p&gt;Also, I have seen the bootloader&amp;#39;s main(), and there are these two functions, which I think, are responsible to do the upgrade. &lt;strong&gt;Is it correct?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;rc = &lt;strong&gt;boot_console_init()&lt;/strong&gt;;&lt;br /&gt; __ASSERT(rc == 0, &amp;quot;Error initializing boot console.\n&amp;quot;);&lt;br /&gt; &lt;strong&gt;boot_serial_start(&amp;amp;boot_funcs)&lt;/strong&gt;;&lt;/p&gt;
&lt;p&gt;Since we would be using only SPI interface to update the firmware, it it okay to replace the two functions with the SPI functions to initialize the interface and upload the firmware?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, I would use dfu_target_&amp;nbsp; &amp;nbsp;APIs to update the target. While these APIs are listed as dfu_target_&amp;nbsp; , but one API is listed as nrf_target_image_type() in the DFU library documentation, and I picked this one in my message earlier.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you very much!&lt;/p&gt;
&lt;p&gt;Ram&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Entering DFU mode via SPI and updating firmware</title><link>https://devzone.nordicsemi.com/thread/285348?ContentTypeID=1</link><pubDate>Wed, 16 Dec 2020 13:49:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ef2977f-3f12-43e0-a27b-72cffd3a2409</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Ram,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There are two possible places where you can drive DFU (in mcuboot or in the application).&lt;/p&gt;
&lt;p&gt;Do you want 1) DFU to be served by the application, or 2) DFU served by mcuboot serial recovery protocol?&lt;/p&gt;
&lt;p&gt;For 1) firmware download might be a background process and bootloader works as dual-bank, previous app recovery is possible if new couldn&amp;#39;t run.&lt;/p&gt;
&lt;p&gt;For 2) bootloader does the update directly to the executable bank (if it is only possible DFU channel, no sense to have collection bank at all), but if the download is corrupted - no recovery possible, the app has to be downloaded again.&lt;/p&gt;
[quote user=""]1. Do I need to enable the SPI in my application prj.conf file to use the SPI functions to read data from the SPI bus?[/quote]
&lt;p&gt;Yes,&amp;nbsp;One of my colleagues has an SPI sample on his personal Github account:&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/spi"&gt;https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/spi&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;While it was written for the nRF9160, it should work without any modifications for other nRF devices (though the device might use different pins). Note that it has not been updated in a while, so it might not work on newer versions of NCS without some modifications.&lt;/p&gt;
[quote user=""]2. Is it correct that I need to use nrf_target_&amp;nbsp; &amp;nbsp;functions to initialize and write new application/MCUboot to the flash area?[/quote]
&lt;p&gt;You might use dfu_target_&amp;nbsp; API in your SPI protocol implementation in the application.&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Entering DFU mode via SPI and updating firmware</title><link>https://devzone.nordicsemi.com/thread/285204?ContentTypeID=1</link><pubDate>Wed, 16 Dec 2020 02:26:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9c6e2a8-0c17-4f87-91d9-80e93df41ee6</guid><dc:creator>RAS_ID</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Few more details on entering the DFU mode.&lt;/p&gt;
&lt;p&gt;My west build is not entering the DFU mode, but the SES build enters the bootloader. I put the above code in the application main() to be called every 20 seconds, and the device prints the DFU messages every 20 seconds.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know why the difference between the two builds.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any suggestion is well appreciated!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Ram&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>