<?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>FOTA SMP very slow</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82686/fota-smp-very-slow</link><description>I am trying to move our existing code based on the recommended NCS SDK. I was able to get MCU boot and SMP working, however, the update is extremely slow. I now seem to be getting like 1Kb/s. On our existing NRF5 based products, I am able to get ~9-10</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Dec 2021 17:44:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82686/fota-smp-very-slow" /><item><title>RE: FOTA SMP very slow</title><link>https://devzone.nordicsemi.com/thread/343492?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 17:44:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d9ade88-ab07-4508-930a-73e091e9005e</guid><dc:creator>LukeC</dc:creator><description>[quote userid="2115" url="~/f/nordic-q-a/82686/fota-smp-very-slow/343374#343374"]&lt;p&gt;smp_bt already uses this:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.0-ncs1/subsys/mgmt/mcumgr/smp_bt.c#L189-L190"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.0-ncs1/subsys/mgmt/mcumgr/smp_bt.c#L189-L190&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So, there&amp;#39;s still room-for-improvement&amp;nbsp;from our side here, by adjusting the link parameters and so forth and providing a clear method on how to configure and set this up for the purpose of higher throughput.&amp;nbsp;&lt;/p&gt;[/quote]
&lt;p&gt;From my experience, as long as the peripheral connection settings are optimized, the biggest factor is the mobile app.&lt;/p&gt;
&lt;p&gt;Looking at the Device Manager Library, it does look like it is using a writeNoResponse architecture.&amp;nbsp; When I wrote a custom MCU BLE bootloader, this was the most critical piece to get fast bulk write speeds.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt; // Check that data length does not exceed the mtu.
        let mtu = targetPeripheral.maximumWriteValueLength(for: .withoutResponse)
        if data.count &amp;gt; mtu {
            log(msg: &amp;quot;Length of data to send exceeds MTU&amp;quot;, atLevel: .error)
            // Fail with an insufficient MTU error.
            fail(error: McuMgrTransportError.insufficientMtu(mtu: mtu) as Error, callback: callback)
            return false
        }
        
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Connect-Device-Manager/"&gt;https://github.com/NordicSemiconductor/IOS-nRF-Connect-Device-Manager/&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="2115" url="~/f/nordic-q-a/82686/fota-smp-very-slow/343374#343374"]One thing is that the binary itself is larger, but the throughput (per second) should still be matched in both SDKs. As mentioned, I&amp;#39;ve reported this back to the developers, so that we can look at improving the throughput.[/quote]
&lt;p&gt;At least for my setup, I am seeing around 1.5 kb/s with FOTA with the DLE settings above versus the 9+ Kb/s I get with the NRF5 DFU, so I certainly think there must be some tweaks we can try to get closer to the same performance.&amp;nbsp; With the old DFU, we have some updates that are very large (including some graphics), and it maintains the speed very well over the whole update.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FOTA SMP very slow</title><link>https://devzone.nordicsemi.com/thread/343374?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 11:18:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b793322f-e7eb-4bb4-a9c5-2492341a59fa</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="lukecorb@gmail.com"]&lt;p&gt;One other thought on this.&amp;nbsp; Isn&amp;#39;t a big reason the FOTA is slower than the DFU due to the NCS no longer&amp;nbsp;separates&amp;nbsp;out the Softdevice from the application.&lt;/p&gt;
&lt;p&gt;Before, we could just update the app without updating the softdevice, but now the softdevice is merged into the app correct?&amp;nbsp; So we are increasing the update size significantly for BLE applications.&lt;/p&gt;[/quote]
&lt;p&gt;This is correct. the application + stack is now one application. The time it takes to upgrade will heavily depend on how large your image is, and historically it has been smaller for a nRF5 SDK based application due to this stack + application split.&lt;/p&gt;
[quote user="lukecorb@gmail.com"]I thought when I looked at the mobile apps for the NRF5 DFU one of the tricks being used to get better speeds was using WRITE_NORESPONSE to send out the data.&amp;nbsp; Basically, send packets using no response writes and have the Nordic peripheral ack the large file buffer writes.[/quote]
&lt;p&gt;smp_bt already uses this:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.0-ncs1/subsys/mgmt/mcumgr/smp_bt.c#L189-L190"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.0-ncs1/subsys/mgmt/mcumgr/smp_bt.c#L189-L190&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So, there&amp;#39;s still room-for-improvement&amp;nbsp;from our side here, by adjusting the link parameters and so forth and providing a clear method on how to configure and set this up for the purpose of higher throughput.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="lukecorb@gmail.com"]It is just going to be very hard to go to our product guys and tell them we updated to a newer Bluetooth stack and reduced performance (from their limited perspective).&amp;nbsp; Obviously, NCS has lots of benefits in leveraging Zephyr, OpenThread, etc...&amp;nbsp;&amp;nbsp;[/quote]
&lt;p&gt;One thing is that the binary itself is larger, but the throughput (per second) should still be matched in both SDKs. As mentioned, I&amp;#39;ve reported this back to the developers, so that we can look at improving the throughput.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FOTA SMP very slow</title><link>https://devzone.nordicsemi.com/thread/343268?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 18:49:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03b7672f-c788-4ae6-ab72-4c067aed90f3</guid><dc:creator>LukeC</dc:creator><description>&lt;p&gt;One other thought on this.&amp;nbsp; Isn&amp;#39;t a big reason the FOTA is slower than the DFU due to the NCS no longer&amp;nbsp;separates&amp;nbsp;out the Softdevice from the application.&lt;/p&gt;
&lt;p&gt;Before, we could just update the app without updating the softdevice, but now the softdevice is merged into the app correct?&amp;nbsp; So we are increasing the update size significantly for BLE applications.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FOTA SMP very slow</title><link>https://devzone.nordicsemi.com/thread/343266?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 18:24:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce52b644-f8e8-452a-a8e9-e23af5bc86f1</guid><dc:creator>LukeC</dc:creator><description>&lt;p&gt;Thanks for the SPI Flash example&amp;nbsp;&lt;span&gt;H&amp;aring;kon&lt;/span&gt;, I will definitely try it out.&lt;/p&gt;
&lt;p&gt;One additional thought on the speed of the FOTA vs the DFU.&lt;br /&gt;&lt;br /&gt;I thought when I looked at the mobile apps for the NRF5 DFU one of the tricks being used to get better speeds was using WRITE_NORESPONSE to send out the data.&amp;nbsp; Basically, send packets using no response writes and have the Nordic peripheral ack the large file buffer writes.&lt;/p&gt;
&lt;p&gt;Maybe it would be possible to write a custom FOTA&amp;nbsp;BLE protocol that sends the app *.bin file quickly with CRC checking.&amp;nbsp; If we came up with a custom BLE&amp;nbsp; comms protocol we might be able to have much better throughput.&amp;nbsp; Once the file data is verified on the receiving side, it would just be hooking this into MCU boot.&lt;/p&gt;
&lt;p&gt;It is just going to be very hard to go to our product guys and tell them we updated to a newer Bluetooth stack and reduced performance (from their limited perspective).&amp;nbsp; Obviously, NCS has lots of benefits in leveraging Zephyr, OpenThread, etc...&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FOTA SMP very slow</title><link>https://devzone.nordicsemi.com/thread/343080?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 09:12:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6ca585d-dfcc-4f0d-b03c-af29ef71e7df</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]I now seem to be getting like 1Kb/s.&amp;nbsp; On our existing NRF5 based products, I am able to get ~9-10 Kb/s on the old DFU.[/quote]
&lt;p&gt;You can get a bit of a better speed by adjusting the BT params (data length max etc). Here&amp;#39;s a small sequence of config&amp;#39;s that should help (note: these are not included in the below .zip file!)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Speed up BT transfer
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_TX_COUNT=7
CONFIG_BT_BUF_ACL_RX_SIZE=255
CONFIG_BT_BUF_EVT_RX_SIZE=255
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]&lt;p&gt;Also, does anyone have any examples using MCUboot to store a FOTA image to a an external SPI flash chip?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="overflow:auto;"&gt;&lt;div&gt;&lt;a href="#"&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;[/quote]
&lt;p&gt;I have used one of our tests as the basis for this alteration of the smp_svr example:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/main/tests/modules/mcuboot/external_flash"&gt;https://github.com/nrfconnect/sdk-nrf/tree/main/tests/modules/mcuboot/external_flash&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What I did to add external flash over qspi support:&lt;/p&gt;
&lt;p&gt;* add external flash to the board (nrf52840dk_nrf52840) by placing an overlay file in boards/ folder of the application&lt;/p&gt;
&lt;p&gt;* add mcuboot configurations under child_image/ folder&lt;/p&gt;
&lt;p&gt;* add &amp;quot;overlay-bt.conf&amp;quot; to prj.conf&lt;/p&gt;
&lt;p&gt;* add&amp;nbsp;CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=32 (required for writing mcuboot magic header) and&amp;nbsp;CONFIG_PM_PARTITION_SIZE_MCUBOOT_SECONDARY=0xee000 to prj.conf&lt;/p&gt;
&lt;p&gt;* add static partition layout (pm_static.yml).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the altered example:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ncs_5F00_1_5F00_7_5F00_smp_5F00_svr_5F00_nrf52840dk_5F00_nrf52840_5F00_qspi_5F00_ext_5F00_flash.zip"&gt;devzone.nordicsemi.com/.../ncs_5F00_1_5F00_7_5F00_smp_5F00_svr_5F00_nrf52840dk_5F00_nrf52840_5F00_qspi_5F00_ext_5F00_flash.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Upload image:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sudo /path/to/mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name=&amp;#39;Zephyr&amp;#39; image upload zephyr/app_update.bin&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;List image (to get hash):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sudo /path/to/mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name=&amp;#39;Zephyr&amp;#39; image list&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Mark image for test:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sudo /path/to/mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name=&amp;#39;Zephyr&amp;#39; image test &amp;lt;hash of image 0 slot 1&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Reset to test-boot your new image:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sudo /path/to/mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name=&amp;#39;Zephyr&amp;#39; image reset&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;mcuboot should now show this output to indicate that it&amp;#39;s test booting the new image:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;....

*** Booting Zephyr OS build v2.6.99-ncs1-1  ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: test
I: Bootloader chainload address offset: 0xc000

....&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;once the new image is booted, you can confirm it from the uart serial console by writing &amp;quot;mcuboot confirm&amp;quot;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>