<?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>Understanding the S0 vs S1 MCUBoot images and slots</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112754/understanding-the-s0-vs-s1-mcuboot-images-and-slots</link><description>Hello, 
 
 We are currently helping one of our client develop a product using the nRF5340. 
 DK versions: 
 
 nRF5340-DK 
 PCA10095 
 2.0.1 
 
 Host OS: 
 
 Ubuntu 22.04.2 
 Linux 6.5.0-41-generic 
 
 nRF SDK and toolchains version: 
 
 nRF SDK 2.6.1</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Jul 2024 08:30:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112754/understanding-the-s0-vs-s1-mcuboot-images-and-slots" /><item><title>RE: Understanding the S0 vs S1 MCUBoot images and slots</title><link>https://devzone.nordicsemi.com/thread/492298?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2024 08:30:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af3b17a2-27d3-4c03-980d-6c3d0ffaa8be</guid><dc:creator>Dax-id</dc:creator><description>&lt;p&gt;I can convert it to public. I didn&amp;#39;t know how far I needed to go into details, but nothing confidential was shared.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding the S0 vs S1 MCUBoot images and slots</title><link>https://devzone.nordicsemi.com/thread/492297?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2024 08:28:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0dbac7a-ee10-4745-a95a-96d283e80d9e</guid><dc:creator>Dax-id</dc:creator><description>&lt;p&gt;Thanks for these additional details.&lt;/p&gt;
&lt;p&gt;In our setup, we really need the upgrade to come from the SD-Card, so I&amp;#39;m thinking placing the upgrade code in the application is the way to go, while keeping a safety-net by enabling Serial recovery in the SBL.&lt;/p&gt;
&lt;p&gt;We are still discussing with our client to know if an upgradable SBL is really needed or not in the project.&lt;/p&gt;
&lt;p&gt;Concerning the sending s0 image while SBL runs from s0, I still don&amp;#39;t fully understand why it won&amp;#39;t work if I changed the SBL that I&amp;#39;m sending. In my tests, I changed both a log print in MCUBoot as well as incrementing the FW_INFO_FIRMWARE_VERSION config. Is it because it then has nothing to compare to validate that the image has changed?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;David TRUAN&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding the S0 vs S1 MCUBoot images and slots</title><link>https://devzone.nordicsemi.com/thread/492296?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2024 08:18:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4b0473c-130b-43b3-8e9c-15397ac29f0d</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Oh and by the way, I just noticed this was a private case. FYI in the future this is a typical case that would&amp;#39;ve benefited from being a public case since it&amp;#39;s a question that many other developers are asking as well :)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Nothing wrong with creating a private case, specially as your first one, but private cases are typically meant for cases where you share sensitive information with us w.r.t debugging and development&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding the S0 vs S1 MCUBoot images and slots</title><link>https://devzone.nordicsemi.com/thread/492295?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2024 08:15:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5e853b3-04ed-490d-a8a2-d751972e6a87</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Glad to hear that it was helpful!&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;&lt;em&gt;believe&lt;/em&gt; that the answer to your follow up question is answered by the DFU/FOTA lesson on our academy pages&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/"&gt;https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/&lt;/a&gt;, but I don&amp;#39;t remember the contents from cover to cover, so I&amp;#39;ll chime in with some additional comments as well:&lt;/p&gt;
[quote user="Dax-id"]&lt;ul&gt;&lt;li&gt;Have the upgrade code residing in the Application code, which would run only once per boot when the app is booted.&lt;/li&gt;
&lt;li&gt;Have the upgrade code residing in the second stage bootloader (MCUBoot), also ran only once per boot. Is it even possible to &amp;quot;add&amp;quot; some processing to MCUBoot without modifying the SDK to much? I read about the MCUBoot hooks and will have to dig a bit here, but is it planned to do such operations here?&lt;/li&gt;&lt;/ul&gt;[/quote]
&lt;p&gt;My assumption is that here you refer to the &amp;quot;upgrade code&amp;quot; as either the code to initiate DFU and perform it or &amp;quot;the new update image&amp;quot;. I&amp;#39;m going to assume it is the first one, so correct me if I&amp;#39;m wrong and I&amp;#39;ll explain for the other case as well&lt;/p&gt;
&lt;p&gt;This is explained in&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/topic/device-firmware-update-dfu-essentials/"&gt;https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/topic/device-firmware-update-dfu-essentials/&lt;/a&gt;&amp;nbsp;where it is stated that you can choose either to have the upgrade code initiating the update in the bootloader or in the application. In either case you will have to have some sort of way to enter the bootloader mode, for instance with a button press, power cycle where you hold a button for certain seconds when you power on or through a BLE SMP server initiating the DFU mode.&lt;/p&gt;
&lt;p&gt;I think for now the course I linked is the best entry point since it has explanations, graphics crosslinks to our official documentation as well as hands on exercises for you to have a look at that are more minimal than the samples in the SDK which supports DFU&lt;/p&gt;
[quote user=""]Why nothing happens when sending &lt;strong&gt;s0&lt;/strong&gt; image when the device currently uses&amp;nbsp;&lt;strong&gt;s0&lt;/strong&gt; as the bootloader slot?[/quote]
&lt;p&gt;I also noticed this question in your description. This is implied in my previous description but I&amp;#39;ll state it explicetly as well: An new image will not be &amp;quot;accepted&amp;quot; as a new image by the bootloader to run from/swap into, both for the case of application image and second stage bootloader image, unless there has been made changes to the firmware (it can be as little as a log/print statement modification or simply changing the fw version number) due to a checksum comparison.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let me know if this answers your questions&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding the S0 vs S1 MCUBoot images and slots</title><link>https://devzone.nordicsemi.com/thread/492294?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2024 05:46:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5abf3cbe-0b23-40d4-80e5-254d528b0640</guid><dc:creator>Dax-id</dc:creator><description>&lt;p&gt;Hi Andrea,&lt;/p&gt;
&lt;p&gt;Thanks a lot for these explanations!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It is now much clearer. I also had a better look at the source code and the FOTA example. I copied the&amp;nbsp;&lt;strong&gt;read_s0_active()&amp;nbsp;&lt;/strong&gt;function to check which one is currently in use and I&amp;#39;ll always store both s0 and s1 variants in the upgrade package, which will then be chosen depending on&lt;strong&gt; read_s0_active()&lt;/strong&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now I have another question related:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For the upgrade solution we&amp;#39;re building, what is the nRF/Zephyr planned way&amp;nbsp;to do so?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Have the upgrade code residing in the Application code, which would run only once per boot when the app is booted.&lt;/li&gt;
&lt;li&gt;Have the upgrade code residing in the second stage bootloader (MCUBoot), also ran only once per boot. Is it even possible to &amp;quot;add&amp;quot; some processing to MCUBoot without modifying the SDK to much? I read about the MCUBoot hooks and will have to dig a bit here, but is it planned to do such operations here?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Again thanks for your time and clear answer!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;David TRUAN&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding the S0 vs S1 MCUBoot images and slots</title><link>https://devzone.nordicsemi.com/thread/492293?ContentTypeID=1</link><pubDate>Wed, 03 Jul 2024 13:58:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27df365d-8f14-4ff7-93f8-5fdaf9213063</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The short, but hopefully good enough answer, to the questions is that it acts similarly to &lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_BOOT_BUILD_DIRECT_XIP_VARIANT"&gt;Direct XiP&lt;/a&gt;&amp;nbsp;DFU, i.e that there are no swapping of the image between the slot where the existing image resides and the new update image resides. The architecture with s0 and s1 slots, which you&amp;#39;ve probably seen already, is illustrated in&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/bootloader/README.html#flash_memory_layout"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/bootloader/README.html#flash_memory_layout&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;NSIB, the first stage bootloader, checks s0 and s1 for any second stage bootloader image present. If there is an image present in both of these slot, it will check the version number on these two images and then select the slot with the highest/newest revision number.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is somewhat elaborated on here&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/config_and_build/bootloaders/bootloader.html#immutable-bootloader"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/config_and_build/bootloaders/bootloader.html#immutable-bootloader&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For your first iteration of firmware you will typically have a second stage bootloader present in S0. When you then need to update your second stage bootloader you would upload the new mcuboot image that is built for S1 and upload it to S1. Since this image has a newer version than the old one, NSIB will then select to boot MCUboot from S1 instead of S0.&lt;/p&gt;
&lt;p&gt;The reason for this is because of how NSIB is implemented w.r.t revert and fallback protection AFAIK to better protect the device from downgrade attacks.&lt;/p&gt;
&lt;p&gt;This link should also give a pointer to what the various build output files are (including the s0/s1 variants)&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/config_and_build/configuring_app/output_build_files.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/config_and_build/configuring_app/output_build_files.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let me know if this short answer answers your question and/or if you have any additional followups/things I&amp;#39;ve explained poorly.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>