<?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 with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81729/dfu-with-zephyr-rtos-using-mcumgr</link><description>hello Nordic 
 
 i am working with nrf52840, zephyr rtos. 
 
 i can preform dfu via mcumgr cli (command line interface) or via nrfConnect application on my cell phone. 
 however, i need to be writing (in rust) a dfu over ble mechanism, like the mcumgr</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 26 Dec 2021 07:26:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81729/dfu-with-zephyr-rtos-using-mcumgr" /><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/345034?ContentTypeID=1</link><pubDate>Sun, 26 Dec 2021 07:26:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6295c206-4a3b-465a-80b0-56d1fba7b91c</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Aleksander&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;i found a hash implementation in rust which matchs this site test :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://emn178.github.io/online-tools/sha256_checksum.html"&gt;https://emn178.github.io/online-tools/sha256_checksum.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;also looked at the sha256.c file in the ncs/modules/crypto/mbedtls/library/&lt;/p&gt;
&lt;p&gt;however, both of them do&amp;#39;t give the same hash as i see in the smp dfu what is the protocol or what am i doing wrong ?&lt;/p&gt;
&lt;p&gt;hope to read from you soon&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/344228?ContentTypeID=1</link><pubDate>Sat, 18 Dec 2021 22:04:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:605753b9-4a67-4033-a5e8-3232ea9fa94c</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;As I wrote few comments above, the &amp;quot;sha&amp;quot; param can contain anything. It&amp;#39;s only session identifier. In the Android library we get it from taking 3 first bytes of hash, calculated from the whole bin file. Check ImageManager class. The proper hash is included in bin for header.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/344226?ContentTypeID=1</link><pubDate>Sat, 18 Dec 2021 19:29:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b3b0c0a-6085-49c7-ac4b-386ed65298a0</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Aleksander&lt;/p&gt;
[quote userid="3284" url="~/f/nordic-q-a/81729/dfu-with-zephyr-rtos-using-mcumgr/343413#343413"]1. The &amp;quot;validate&amp;quot; checks exactly what is to be done. E.g. the same image (with matching hash) could have been sent on a previous connection,[/quote]
&lt;p&gt;how do i know the &amp;quot;hash&amp;quot; before receiving it from the device ?&lt;/p&gt;
&lt;p&gt;is it calculated from the bun image ? if so, then what is the calculating algorithm&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;hope to read from you soon&lt;/p&gt;
&lt;p&gt;best regards&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/343413?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 13:17:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:510bad6c-5cc1-4281-8fdb-a78e56365656</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;1. The &amp;quot;validate&amp;quot; checks exactly what is to be done. E.g. the same image (with matching hash) could have been sent on a previous connection, so resume may be possible. Or, it received &amp;quot;off&amp;quot; is equal to &amp;quot;len&amp;quot;, the client can just send &amp;quot;confirm&amp;quot; or &amp;quot;test&amp;quot; command without the need of sending the image again. Have a look at Android implementation: &lt;a href="https://github.com/NordicSemiconductor/Android-nRF-Connect-Device-Manager/blob/3a1f9a5c35920530854f66e0009b2c5be5dd5b41/mcumgr-core/src/main/java/io/runtime/mcumgr/dfu/task/Validate.java#L62"&gt;https://github.com/NordicSemiconductor/Android-nRF-Connect-Device-Manager/blob/3a1f9a5c35920530854f66e0009b2c5be5dd5b41/mcumgr-core/src/main/java/io/runtime/mcumgr/dfu/task/Validate.java#L62&lt;/a&gt; for more details.&lt;/p&gt;
&lt;p&gt;2. &amp;quot;rc&amp;quot; and &amp;quot;off&amp;quot; always come in the response notification. Have a look at &lt;a href="https://github.com/nrfconnect/sdk-mcumgr/blob/d9adfe78efd71608b77ac88a5b088723a9fbe6ed/cmd/img_mgmt/src/img_mgmt.c#L333"&gt;https://github.com/nrfconnect/sdk-mcumgr/blob/d9adfe78efd71608b77ac88a5b088723a9fbe6ed/cmd/img_mgmt/src/img_mgmt.c#L333&lt;/a&gt;. On mobiles we send one packet and wait for the notification before sending another, but in theory it could be possible to send multiple, each with different SEQ number, and receive notifications later with matching SEQ. This seems not to work yet, at least I couldn&amp;#39;t make it work.&lt;/p&gt;
&lt;p&gt;Regarding number of bytes sent, seeing logs would be more helpful.&lt;/p&gt;
&lt;p&gt;3. Higher MTU are supported since Bluetooth 4.0. DLE (Data Length Extension) is not, but MTU are. Long MTU are required for mcumgr to work, as e.g. the first packet of an upload needs to have at least.. 30 (?) bytes. DLE is not required, without it the upload will just be slower.&lt;/p&gt;
&lt;p&gt;4. No, currently each packet sent needs to contain header (8 bytes) and complete CBOR content. Unfortunately. This issue was raised here: &lt;a href="https://github.com/apache/mynewt-mcumgr/issues/6"&gt;https://github.com/apache/mynewt-mcumgr/issues/6&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;5. You should receive a notification. Did you enable CCCD? In SMP protocol any message you sent shall be confirmed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/343354?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 10:16:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9c1399e-ab70-4ada-8b6f-2b212defb3f4</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Aleksander&lt;/p&gt;
&lt;p&gt;first, thanks a lot for the document and support&lt;/p&gt;
&lt;p&gt;i have&amp;nbsp;some more questions:&lt;/p&gt;
&lt;p&gt;1. what is the propose of the first command &amp;quot;validate&amp;quot;, since after uploading takes place i have to re read the device to get the hash of the new image ( also, will it always be in slot 1, or do i have to check and compare with previous read hash? ) ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2. when uploading in the document i saw there is a notification return with &amp;quot;rc&amp;quot; and &amp;quot;off&amp;quot; but when i looked in the messages transfer i could not find this return notifications ? so is the sending of data dependent on those notification return or does it stop when finishing the data transmission, another thing which was strange is that the packets size looked not constant, sometimes it was 219 bytes, sometimes 173 bytes etc. though on the device i see that every message is off course 248 bytes, any ideas on that ?&lt;/p&gt;
&lt;p&gt;3. my transmitter is BLE4.0 so my max MTU is 23/ 27, is that an issue that will cause problems ?&lt;/p&gt;
&lt;p&gt;4. can i preppier one packet with the data, len, image and all header, and let the ble manage the division to smaller packets, or do i need to divide my data to the size of my MTU&amp;nbsp;?&lt;/p&gt;
&lt;p&gt;5. if i am not receiving notifications after each transmit then how can i know when to send the next command ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;hope to red from you soon&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/343109?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 10:19:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20f30dad-871d-49b8-b093-a83cf88129c9</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Please, let me answer your questions.&lt;/p&gt;
&lt;p&gt;The &amp;quot;image&amp;quot; parameter was added in nRF Connect SDK in version 1.7. It allows multi-core update, e.g. for nRF5340 devices. Older versions didn&amp;#39;t support this parameter, and only one core could be updated in a single dfu operation. For other nRF5 devices it doesn&amp;#39;t matter. For nRF53 device the app core should be updated in the same operation as net core so that both cores have compatible fw.&lt;/p&gt;
&lt;p&gt;When you initiate dfu procedure, the first packet sent needs to have &amp;quot;off&amp;quot; set to 0, &amp;quot;len&amp;quot; set to image length, &amp;quot;sha&amp;quot; set to.. actually to anything (it&amp;#39;s session id and to allow resume on the same connection we set it to 3 bytes of the image hash, so when resuming, the string will be the same, but in can by any string), and &amp;quot;data&amp;quot; set to some number of image bytes. For multi-core updates the first packet should also contain &amp;quot;image&amp;quot; parameter, which is by default set to 0 for compatibility. The following data packets must only contain &amp;quot;data&amp;quot; and &amp;quot;off&amp;quot; (offset).&lt;/p&gt;
&lt;p&gt;We have &lt;a href="https://github.com/NordicSemiconductor/Android-nRF-Connect-Device-Manager"&gt;Android&lt;/a&gt; (in Java) and &lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Connect-Device-Manager"&gt;iOS&lt;/a&gt; (in Swift) implementations.&lt;/p&gt;
&lt;p&gt;Also, the documentation for SMP protocol is under construction here: &lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/40894"&gt;https://github.com/zephyrproject-rtos/zephyr/pull/40894&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;FYI: The current nRF Connect for Android (4.24.3) does not yet support mutli-core update using Mcu Manager.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/343034?ContentTypeID=1</link><pubDate>Sun, 12 Dec 2021 16:22:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e2a11a9-a98a-4b3a-8f26-5297aff1a6bc</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Einar&lt;/p&gt;
&lt;p&gt;regarding the document, first, a small correction:&lt;/p&gt;
&lt;p&gt;the payload received following the image state read request,&amp;nbsp; does not contain &amp;quot;image&amp;quot; element in the &amp;quot;Images&amp;quot; map)&lt;/p&gt;
&lt;p&gt;second, regarding the image upload command.. it is not clear if the components &amp;quot;data&amp;quot;, len, off, image and sha are part of every packet or is it just data in the beginning of payload, also since there is no component &amp;quot;image&amp;quot; what should replace the &amp;quot;image&amp;quot; in the payload&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;hope the you or the creator of the document can help&lt;/p&gt;
&lt;p&gt;hope to read from you soon&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/342128?ContentTypeID=1</link><pubDate>Mon, 06 Dec 2021 14:52:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2c2f6e7-8292-4cee-a062-f7782687475a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Ziv,&lt;/p&gt;
&lt;p&gt;You can see our fork in &lt;a href="https://github.com/nrfconnect/sdk-mcumgr"&gt;sdk-mcumgr&lt;/a&gt;. However this project is not written by Nordic and I cannot provide much insight into it, unfortunately. As you have been working with this I suspect you may be able to read something sensible out of the implementation. Also, as you are making the other end, it may be more relevant to look at some of the other implementations, like for instance the &lt;a href="https://github.com/NordicSemiconductor/Android-nRF-Connect-Device-Manager"&gt;nRF Connect Device Manager implementation&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/341984?ContentTypeID=1</link><pubDate>Mon, 06 Dec 2021 07:59:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f28e1643-c027-4f49-bfc2-0a09982cbbe2</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Einar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;it&amp;#39;s been a while, the document did help&lt;/p&gt;
&lt;p&gt;still i am trying to understand how to work with the CBOR, should i build structs for each notify etc.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i searched the ncs modules to see how the device uses the CBOR&amp;nbsp;to decode the data received from the nrfConnect and how it encodes the notification sent back to the nrfconnect. but i did not find the place where the byte array is converted to some struct and vice versa&amp;nbsp;&lt;/p&gt;
&lt;p&gt;maybe if i understand that, i will also understand&amp;nbsp;how the device know if it got all the data and how many packets are still left etc.&lt;/p&gt;
&lt;p&gt;any help and directions will be great&lt;/p&gt;
&lt;p&gt;hope to read from you soon&amp;nbsp;&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/339172?ContentTypeID=1</link><pubDate>Tue, 16 Nov 2021 09:46:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b5c3148-9a4e-4f82-9a5b-ad01e77e427d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Ziv,&lt;/p&gt;
[quote user="ziv123"]does the nrfConnect written in js ?[/quote]
&lt;p&gt;nRF Connect for&amp;nbsp;Desktop is written in js.&lt;/p&gt;
[quote user="ziv123"] is there no third side for support on that matter of mcumgr ?[/quote]
&lt;p&gt;Not that I am aware of.&lt;/p&gt;
[quote user="ziv123"]again any help will be appreciated[/quote]
&lt;p&gt;I discussed with our developer responsible for SMP DFU supper in our mobile apps, and as there is no proper documentation for the protocol he made some for his reference while developing. That describes the basics of the protocol in some more details, which hopefully can be relevant: &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/MCUmgr_5F00_Bluetooth_5F00_protocol.pdf"&gt;devzone.nordicsemi.com/.../MCUmgr_5F00_Bluetooth_5F00_protocol.pdf&lt;/a&gt;. Note that this is not official documentation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/339134?ContentTypeID=1</link><pubDate>Tue, 16 Nov 2021 07:47:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20ec20d0-c8e6-4685-ab5c-b9da0846acde</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Einar&amp;nbsp;&lt;/p&gt;
&lt;p&gt;does the nrfConnect written in js ?&amp;nbsp; is there no third side for support on that matter of mcumgr ?&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/81729/dfu-with-zephyr-rtos-using-mcumgr/339047#339047"]If you refer to &lt;a href="https://github.com/apache/mynewt-newtmgr/blob/c56797e09f8b1efe2e1ec9c44ac3a041320e0823/newtmgr/cli/image.go"&gt;image.go&lt;/a&gt; you can see that the data you see form image confirm is a hash.[/quote]
&lt;p&gt;the data i am talking about in the massege is not the hash,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;the hash is &amp;quot;hash: 471256019b441f8f026790ada969c0182c3a1d2963f5263b1962f190fa29bb83&amp;quot;&lt;/p&gt;
&lt;p&gt;the data i am asking about is the data in the command sent to the device, in at in the body&amp;nbsp; &amp;quot;&amp;nbsp;in npm, BodyByets, data = [162 103 99 111 110 102 105 114 109 245 100 104 97 115 104 246]&amp;quot;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;printed from&amp;nbsp;&amp;nbsp;&amp;#39;npm.go&amp;#39; , the struct sent looks like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;type NmpHdr struct {
	Op    uint8 /* 3 bits of opcode */
	Flags uint8
	Len   uint16
	Group uint16
	Seq   uint8
	Id    uint8
}

type NmpMsg struct {
	Hdr  NmpHdr
	Body interface{}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;image confirm is just an example, in image upload it seems that only data is transfered from the first byte without any header or instruction type which is strange to me but still, how is the &amp;#39;.bin&amp;#39; file send ?&lt;/p&gt;
&lt;p&gt;again any help will be appreciated&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: dfu with zephyr rtos using mcumgr</title><link>https://devzone.nordicsemi.com/thread/339047?ContentTypeID=1</link><pubDate>Mon, 15 Nov 2021 14:15:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a87bf89-fe70-476a-992a-81b0a3ff64be</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Ziv,&lt;/p&gt;
&lt;p&gt;Unfortunately,&amp;nbsp;the mcumgr protocol is not very well documented (in fact, the &lt;a href="https://github.com/zephyrproject-rtos/mcumgr/blob/master/protocol.md"&gt;documentation&lt;/a&gt; states that &amp;quot;&lt;em&gt;The protocol isn&amp;#39;t fully documented&lt;/em&gt;&amp;quot;). While this is used by the nRF Connect SDK and Zephyr it is not developed by Nordic and I do not hav any more information about it than what is available. I do not have any better suggestions than to refer to the implementation of the &lt;a href="https://github.com/apache/mynewt-mcumgr-clihttps://github.com/apache/mynewt-mcumgr-cli"&gt;mcumgr command line tool&lt;/a&gt;, which is in &lt;a href="https://github.com/apache/mynewt-newtmgr"&gt;newtmgr&lt;/a&gt;&amp;nbsp;(or other implementations like iOS-/Android- nRF-Connect-Device-Manager).&lt;/p&gt;
&lt;p&gt;If you refer to &lt;a href="https://github.com/apache/mynewt-newtmgr/blob/c56797e09f8b1efe2e1ec9c44ac3a041320e0823/newtmgr/cli/image.go"&gt;image.go&lt;/a&gt; you can see that the data you see form image confirm is a hash.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>