<?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>Programming nrf52840 via SPI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70691/programming-nrf52840-via-spi</link><description>Hi, 
 I have to program the application on an nrf52840 chip that is connected to another MCU via the SPI interface. Since I have to send the image from the MCU to program the Nordic chip, I have the following questions. 
 1. I should send a .hex file</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Jan 2021 14:36:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70691/programming-nrf52840-via-spi" /><item><title>RE: Programming nrf52840 via SPI</title><link>https://devzone.nordicsemi.com/thread/291316?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2021 14:36:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76123306-6110-4392-9dd3-6aa782cc74e6</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi Ram,&lt;/p&gt;
&lt;p&gt;Sorry for the slow response. I consulted with our developers and received some feedback on your questions.&lt;/p&gt;
[quote user="RAS_ID"]1. I believe that CBOR encoding in mcumgr is done just to speed up the data transfer process. I will use the frames as per SMP for the data transfer.[/quote]
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;It is not necessary to implement/use mcumgr protocol with SPI, if you are using MCUboot in serial recovery mode. Implement your own protocol for DFU via SPI would simplify things a lot. Both base64 and CBOR encoding is not necessary for SPI transfer for instance.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
[quote user="RAS_ID"]2. The master, another MCU, will read a &lt;strong&gt;signed binary file&lt;/strong&gt; (app_update.bin) and send the binary data packet&amp;nbsp; formatted as per SMP with or without encoding.[/quote]
&lt;p&gt;As described above, it is not required to follow the SMP format, if you are using serial recovery mode.&amp;nbsp;&lt;/p&gt;
[quote user="RAS_ID"]&lt;p&gt;3. The slave (nRF52840 with MCUboot and a sample application) will wait for the SPI packet in the function (identical to) boot_serial_start().&lt;/p&gt;
&lt;p&gt;Once a packet is received, slave&amp;nbsp;processor will continue from line#609.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (in_buf[0] == SHELL_NLIP_PKT_START1 &amp;amp;&amp;amp; …….&lt;/p&gt;[/quote]
&lt;p&gt;In mcuboot the path that serves the serial recovery is:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;boot_serial_start -&amp;gt; boot_serial_input -&amp;gt; bs_upload.&amp;nbsp;bs_upload calls CBOR decoder and performs flash writes.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
[quote user="RAS_ID"]&lt;p&gt;&amp;nbsp;4. If encoding was necessary (I would follow your reply in 1), and it was done in the master before sending the packet, I don&amp;#39;t need any further changes other than commenting out the code related to serial output.&lt;/p&gt;
&lt;p&gt;5. If encoding was not done in the master, I need to comment out the function calls related to decoding as well.&lt;/p&gt;[/quote]
&lt;p&gt;Encoding is not required.&lt;/p&gt;
[quote user="RAS_ID"]Any other comment?[/quote]
&lt;p&gt;Note that the serial recovery implementation in MCUboot currently does not support updating MCUboot itself. The application can overwrite the MCUboot slot, but this would be risky, as a reset/crash may leave the device bricked. Updating MCUboot would require B0 (&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bootloader/README.html#flash-memory-layout"&gt;Immutable bootloader&lt;/a&gt;) with S0 and S1 slot, and you need to add support for writing either S0 or S1 in MCUboot.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nrf52840 via SPI</title><link>https://devzone.nordicsemi.com/thread/290651?ContentTypeID=1</link><pubDate>Fri, 22 Jan 2021 07:24:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06b27ab8-2beb-40ef-b40c-fe1335966c1a</guid><dc:creator>RAS_ID</dc:creator><description>&lt;p&gt;Hi Jorgen,&lt;/p&gt;
&lt;p&gt;Thanks for your reply! Really appreciate!&lt;/p&gt;
&lt;p&gt;Before I start code&amp;nbsp;modifications for the upgrade,&amp;nbsp;I would like you to verify if my understanding is correct&amp;nbsp;about the upgrade process.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Please verify all the steps below and write your comment as appropriate&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;1. I believe that CBOR encoding in mcumgr is done just to speed up the data transfer process. I will use the frames as per SMP for the data transfer.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;Is it okay to send the binary from the master without encoding?&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;In that case, I will exclude packet decoding in slave before writing the data from the packet to flash-memory.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. The master, another MCU, will read a &lt;strong&gt;signed binary file&lt;/strong&gt; (app_update.bin) and send the binary data packet&amp;nbsp; formatted as per SMP with or without encoding.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;3. The slave (nRF52840 with MCUboot and a sample application) will wait for the SPI packet in the function (identical to) boot_serial_start().&lt;/p&gt;
&lt;p&gt;Once a packet is received, slave&amp;nbsp;processor will continue from line#609.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (in_buf[0] == SHELL_NLIP_PKT_START1 &amp;amp;&amp;amp; &amp;hellip;&amp;hellip;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;4. If encoding was necessary (I would follow your reply in 1), and it was done in the master before sending the packet, I don&amp;#39;t need any further changes other than commenting out the code related to serial output.&lt;/p&gt;
&lt;p&gt;5. If encoding was not done in the master, I need to comment out the function calls related to decoding as well.&lt;/p&gt;
&lt;p&gt;Any other comment?&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><item><title>RE: Programming nrf52840 via SPI</title><link>https://devzone.nordicsemi.com/thread/290469?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2021 11:28:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9533e827-2c99-4a49-8ef9-be5ddf0cc170</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The code in the link I posted is intended to use with nRF5 SDK and the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_bootloader_modules.html"&gt;Secure DFU Bootloader&lt;/a&gt;, not with nRF Connect SDK. This is why I asked which SDK your are using. I&amp;#39;m not sure how easily transferable these examples are to nRF Connect SDK and MCUboot.&lt;/p&gt;
[quote user="RAS_ID"]a. Shall&amp;nbsp;DFU master&amp;nbsp;use the hex file or the binary file (Awneil has suggested to use&amp;nbsp;the binary file)?[/quote]
&lt;p&gt;The nRF5 Secure DFU solution uses a ZIP-package generated by nrfutil, which includes the bin-file along with a manifest (json-file) and init-packet (dat-file).&lt;/p&gt;
[quote user="RAS_ID"]&lt;p&gt;b. Since the device&amp;nbsp;will be in DFU&amp;nbsp;mode&amp;nbsp;to update the firmware,&amp;nbsp;I need to make the code changes in the bootloader, not in the application. Is it correct?&lt;/p&gt;
&lt;p&gt;\ncs\bootloader\mcuboot\boot\zephyr\serial_adaptor.c and other files.&lt;/p&gt;[/quote]
&lt;p&gt;Yes, that sounds reasonable. However, if you are using multiple &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.2/mcuboot/design.html#image-slots"&gt;Image Slots&lt;/a&gt;, you may also be able to fill a new slot from the application (background update), and only use the Bootloader for the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.2/mcuboot/design.html#image-swapping"&gt;Image Swapping&lt;/a&gt;&amp;nbsp;part.&lt;/p&gt;
&lt;p&gt;I believe that you should use the same packet format as the console example if using MCUboot. The following links should provide some useful information:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.2/mcuboot/design.html"&gt;MCUboot Boot Loader&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.2/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/README.html?highlight=smp"&gt;SMP Server Sample&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-mcumgr/blob/master/transport/smp-console.md"&gt;SMP over Console&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nrf52840 via SPI</title><link>https://devzone.nordicsemi.com/thread/290400?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2021 07:38:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d569a38-5d05-43e3-aa26-f351b1aea529</guid><dc:creator>RAS_ID</dc:creator><description>&lt;p&gt;Hi Jorgen,&lt;/p&gt;
&lt;p&gt;Please see my setup and other details in my previous reply.&lt;/p&gt;
&lt;p&gt;I looked at the SPI DFU Master code in the link provided by you. It looks straight forward and simple.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;-Will it work for a hex file, if we needed to send the hex file to update the firmware?&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;-Will it work to send a binary signed application if we needed to send the binary file?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;On slave:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The example code in link has functions to receive SPI packets and send reply. There is nothing beyond that. Please correct me is I am missing anything.&lt;/p&gt;
&lt;p&gt;Presently, MCUboot in ncs supports upgrades through serial interface (see main.c),&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;BOOT_LOG_INFO(&amp;quot;Enter the serial recovery mode&amp;quot;);
rc = boot_console_init();
_ASSERT(rc == 0, &amp;quot;Error initializing boot console.\n&amp;quot;);
boot_serial_start(&amp;amp;boot_funcs);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;My plan&amp;nbsp;was to replace the two functions above with spi_init() and boot_spi_start() to initialize and read data over SPI and write to flash location identified by the type in the first SPI packet.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is&amp;nbsp;this the right way to do, especially with the signed binary file? Please suggest.&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><item><title>RE: Programming nrf52840 via SPI</title><link>https://devzone.nordicsemi.com/thread/290358?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2021 19:53:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ced4975a-0fd6-4c82-b20c-ef5692c8dd90</guid><dc:creator>RAS_ID</dc:creator><description>&lt;p&gt;Hi Jorgen,&lt;/p&gt;
&lt;p&gt;Thank you very much for your reply!&lt;/p&gt;
&lt;p&gt;In your link, C example project for the SPI DFU master is really useful. However, I&amp;nbsp;am not clear on the slave side so far. I am tying to understand it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Let me clarify a few things first before I ask questions.&lt;/p&gt;
&lt;p&gt;1. I am using &lt;strong&gt;nRF Connect SDK&amp;nbsp;v1.4.0&lt;/strong&gt;, which creates hex and binary files.&lt;/p&gt;
&lt;p&gt;2. I have&amp;nbsp;B0, MCUboot, and application code on a nRF52840-DK.&lt;/p&gt;
&lt;p&gt;3.&amp;nbsp;My application would&amp;nbsp;use&amp;nbsp;buttonless DFU mode.&lt;/p&gt;
&lt;p&gt;4. Another MCU (nRF52840-DK at this time) connected to nRF52840-DK via SPI will act as a DFU master to send the&amp;nbsp;application/MCUboot code. These&amp;nbsp;may be signed.&lt;/p&gt;
&lt;p&gt;5. The master will update either application or MCUboot at a time, not both together.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could you please clarify the&amp;nbsp;following?&lt;/p&gt;
&lt;p&gt;a. Shall&amp;nbsp;DFU master&amp;nbsp;use the hex file or the binary file (Awneil has suggested to use&amp;nbsp;the binary file)?&lt;/p&gt;
&lt;p&gt;b. Since the device&amp;nbsp;will be in DFU&amp;nbsp;mode&amp;nbsp;to update the firmware,&amp;nbsp;I need to make the code changes in the bootloader, not in the application. Is it correct?&lt;/p&gt;
&lt;p&gt;\ncs\bootloader\mcuboot\boot\zephyr\serial_adaptor.c and other files.&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><item><title>RE: Programming nrf52840 via SPI</title><link>https://devzone.nordicsemi.com/thread/290248?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2021 12:54:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5eabaa1-2429-4568-b86e-4902de40afc3</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Which SDK are you using?&lt;/p&gt;
&lt;p&gt;You can reference the examples found in the blog post&amp;nbsp;&lt;em&gt;Getting started with Nordic&amp;#39;s Secure DFU bootloader, a step by step guide.&lt;/em&gt; The section&amp;nbsp;&lt;strong&gt;&lt;a href="https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader?CommentId=bafdd6f3-ba2d-4fe6-9912-4c810091495e#h108sjziaxo3m81rkgr1has5r1d72qtu"&gt;6. DFU Master code&lt;/a&gt;&lt;/strong&gt;&amp;nbsp;contains C example projects for both SPI DFU master and SPIS bootloader.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nrf52840 via SPI</title><link>https://devzone.nordicsemi.com/thread/290145?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2021 08:49:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e36b318c-95c7-402e-9f1d-671b4af9d4a9</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Implementing a complete &amp;amp; reliable Hex file interpreter is non-trivial - in particular, there is no guarantee that the data will be in order.&lt;/p&gt;
&lt;p&gt;Therefore I&amp;#39;d suggest &lt;em&gt;&lt;strong&gt;not&lt;/strong&gt;&lt;/em&gt; sending a Hex file!&lt;/p&gt;
&lt;p&gt;With a Bin file, you just need to know the start address.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>