<?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>Mcuboot swap using move will brick device when power interrupted during move</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96156/mcuboot-swap-using-move-will-brick-device-when-power-interrupted-during-move</link><description>Dear all, 
 I&amp;#39;m working with the nrfconnect sdk on the nrf52840 and we are experiencing issues on the nrfconnect sdk 2.0.0 which uses sdk-mcuboot 1.9.99-ncs1. 
 We are using a swap using move algorithm with a swap_type test to update our firmware on the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Feb 2023 13:14:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96156/mcuboot-swap-using-move-will-brick-device-when-power-interrupted-during-move" /><item><title>RE: Mcuboot swap using move will brick device when power interrupted during move</title><link>https://devzone.nordicsemi.com/thread/409871?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2023 13:14:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60445975-f802-4bd4-8c34-b37588ecd1e5</guid><dc:creator>ImaraSpeek</dc:creator><description>&lt;p&gt;Hi Sigurd,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Mcuboot has been able to reproduce the issue and we have found a fix. Please see this issue link:&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://github.com/mcu-tools/mcuboot/issues/1588"&gt;https://github.com/mcu-tools/mcuboot/issues/1588&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Imara&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mcuboot swap using move will brick device when power interrupted during move</title><link>https://devzone.nordicsemi.com/thread/409825?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2023 11:37:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:146ba71c-501b-4028-937a-3fbaa6a4234c</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi Imara,&lt;/p&gt;
&lt;p&gt;Sorry for the wait.&lt;/p&gt;
&lt;p&gt;With the excellent information you have provided, I will try to reproduce your issue.&lt;/p&gt;
&lt;p&gt;A bootloader should be robust, and it should be tough to brick a device with a reset.&lt;br /&gt;If this turns out to be the case, I will let our developers know, and we will look into how we can fix this.&lt;/p&gt;
&lt;p&gt;I will return with more information on my progress on Thursday latest.&lt;br /&gt;Please let me know if you have found anything else since creating this post!&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mcuboot swap using move will brick device when power interrupted during move</title><link>https://devzone.nordicsemi.com/thread/407413?ContentTypeID=1</link><pubDate>Tue, 31 Jan 2023 16:37:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b2e3bb8-d986-4fea-ae1a-1489a93eb51c</guid><dc:creator>ImaraSpeek</dc:creator><description>&lt;p dir="auto"&gt;Another thought though: If the error occurs during the move, not the swap it would result in a state that isn&amp;#39;t described in&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/design.html#new-swaps-non-resumes" rel="nofollow"&gt;this section of the documentation&lt;/a&gt;, since&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;copy_done&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;isn&amp;#39;t set yet. Does that mean that when the move (instead of the swap) is interrupted, it will never set the outcome to&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;BOOT_SWAP_TYPE_REVERT&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;and thus not recover?&lt;/p&gt;
&lt;p dir="auto"&gt;The&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;bool_status_is_reset&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;will also think the status is reset when the swap is still busy moving the sectors us. Therefor it is required to read all headers, even though the header of the primary image has moved.&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;
&lt;pre class="notranslate"&gt;&lt;code class="notranslate"&gt;bool
boot_status_is_reset(const struct boot_status *bs)
{
    return (bs-&amp;gt;op == BOOT_STATUS_OP_MOVE &amp;amp;&amp;amp;
            bs-&amp;gt;idx == BOOT_STATUS_IDX_0 &amp;amp;&amp;amp;
            bs-&amp;gt;state == BOOT_STATUS_STATE_0);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;
&lt;pre class="notranslate"&gt;&lt;code class="notranslate"&gt;#ifdef MCUBOOT_SWAP_USING_MOVE
        /*
         * Must re-read image headers because the boot status might
         * have been updated in the previous function call.
         */
        rc = boot_read_image_headers(state, !boot_status_is_reset(bs), bs);
#ifdef MCUBOOT_BOOTSTRAP
        /* When bootstrapping it&amp;#39;s OK to not have image magic in the primary slot */
        if (rc != 0 &amp;amp;&amp;amp; (BOOT_CURR_IMG(state) != BOOT_PRIMARY_SLOT ||
                boot_check_header_erased(state, BOOT_PRIMARY_SLOT) != 0)) {
#else
        if (rc != 0) {
#endif

            /* Continue with next image if there is one. */
            BOOT_LOG_WRN(&amp;quot;Failed reading image headers; Image=%u&amp;quot;,
                    BOOT_CURR_IMG(state));
            BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_NONE;
            return;
        }
#endif
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p dir="auto"&gt;This then causes the code to return and never reach&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;boot_complete_partial_swap&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;as far as I can tell.&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Mcuboot swap using move will brick device when power interrupted during move</title><link>https://devzone.nordicsemi.com/thread/407319?ContentTypeID=1</link><pubDate>Tue, 31 Jan 2023 12:27:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:132f7ff6-fcd6-4169-bcf6-73c58ba545cf</guid><dc:creator>ImaraSpeek</dc:creator><description>&lt;p&gt;Some more info about this issue:&lt;/p&gt;
&lt;p&gt;Our reboot is issued whenever the entire device is updated. This causes the power to the nrf52840 to also briefly be cut, causing a reboot of the nrf52840.&lt;/p&gt;
&lt;p&gt;Both partitions are on internal flash and the images&amp;nbsp;are not encrypted&lt;/p&gt;
&lt;p&gt;The bin image is 0x5FB40 in size, the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;mcuboot_primary&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;is 0x6D000, the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;mcuboot_primary_app&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;starts 0x200 later and is 0x6CE00. The&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;mcuboot_secondary&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;starts right after and is 0x6D000. I&amp;#39;ve already tried increasing the primary partition to 0x6E000 so that it&amp;#39;d be a sector larger than the secondary, but that didn&amp;#39;t change anything yet. The hex I&amp;#39;ve added comes from the prior situation where both partitions are equal size (which should also be allowed according to the documentation).&lt;/p&gt;
&lt;p dir="auto"&gt;Please see the attached hexes of the last sectors (from when the partitions were still equally sized) after reproducing the issue.&lt;/p&gt;
&lt;p dir="auto"&gt;The image trailer is exactly the same except for the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;copy_done&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;and&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;image_ok&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;flags (I think these are the values in the memory, but I&amp;#39;m not sure). This means that the faulty image trailer indicates that a swap has been successfully done, but the image hasn&amp;#39;t been confirmed. Is is possible that this image trailer is left from a previous swap and isn&amp;#39;t correctly cleaned up after a swap? In my tests, I only ever reproduce this issue after &amp;gt; 25 updates, so that&amp;#39;d mean that many successful swaps happened prior to the faulty case.&lt;/p&gt;
&lt;p dir="auto"&gt;Another thought though: If the error occurs during the move, not the swap it would result in a state that isn&amp;#39;t described in&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/design.html#new-swaps-non-resumes" rel="nofollow"&gt;this section of the documentation&lt;/a&gt;, since&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;copy_done&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;isn&amp;#39;t set yet. Does that mean that when the move (instead of the swap) is interrupted, it will never set the outcome to&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code class="notranslate"&gt;BOOT_SWAP_TYPE_REVERT&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;and thus not recover?&lt;/p&gt;
&lt;p dir="auto"&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/failed_5F00_swap_5F00_hexes.zip"&gt;devzone.nordicsemi.com/.../failed_5F00_swap_5F00_hexes.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>