<?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>Not enough free space to run swap upgrade</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116293/not-enough-free-space-to-run-swap-upgrade</link><description>Hello, 
 I need to make the OTA DFU work and I followed the instructions here: https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/README.html#smp-svr 
 In some situations I&amp;#39;m getting this error: &amp;quot; W: Not enough</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 19 Oct 2025 14:09:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116293/not-enough-free-space-to-run-swap-upgrade" /><item><title>RE: Not enough free space to run swap upgrade</title><link>https://devzone.nordicsemi.com/thread/551874?ContentTypeID=1</link><pubDate>Sun, 19 Oct 2025 14:09:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4e03bb3-b933-4ca2-84f3-93345493b0f4</guid><dc:creator>Achim Kraus</dc:creator><description>[quote userid="9456" url="~/f/nordic-q-a/116293/not-enough-free-space-to-run-swap-upgrade/511281"]It can happen during development, but it should never happen with your end users, in the sense that the new image should be tested extensively before deployment.[/quote]
&lt;p&gt;Just to add about the &amp;quot;tested extensively&amp;quot;:&lt;/p&gt;
&lt;p&gt;I currently saw some device reporting:&lt;/p&gt;
&lt;p&gt;I: Starting bootloader &lt;br /&gt;I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1 &lt;br /&gt;I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3 &lt;br /&gt;I: Boot source: none &lt;br /&gt;I: Image index: 0, Swap type: test &lt;br /&gt;I: Starting swap using move algorithm. &lt;br /&gt;W: Not enough free space to run swap upgrade &lt;br /&gt;W: required 425984 bytes but only 421888 are available &lt;br /&gt;I: Bootloader chainload address offset: 0xc000 &lt;br /&gt;I: Jumping to the first image slot &lt;/p&gt;
&lt;p&gt;while other applied that update without issues.&lt;/p&gt;
&lt;p&gt;In both cases I used the same application version before and the same application version to update to. The only difference was, that some devices have been for longer in the field. My analysis showed then, it occurs with the McuBoot of NCS 2.6.4 (this devices will not be able to update the application without updating the McuBoot), but using the McuBoot of NCS 2.9.2 the bigger image works.&lt;/p&gt;
&lt;p&gt;Conclusion:&lt;/p&gt;
&lt;p&gt;It&amp;#39;s not enough to only test, if the image could be applied to the previous version ... you will need to test it with all McuBoot version in field ;-(.&lt;/p&gt;
&lt;p&gt;And if you have McuBoot of 2.6.4 (or earlier) in the field, you will need to check you maximum image size with that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough free space to run swap upgrade</title><link>https://devzone.nordicsemi.com/thread/511281?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2024 12:32:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ecf3995-aca2-4eb9-8723-42e973293529</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I will continue to support you on this case.&lt;/p&gt;
[quote user="JH7"]&lt;p&gt;I&amp;#39;m thinking in the scenario where my product is released and the only way to update it is over BLE.&lt;/p&gt;
&lt;p&gt;[...]&lt;/p&gt;
&lt;p&gt;Can this be executed over BLE?&lt;/p&gt;[/quote]
&lt;p&gt;Yes, it can. Please try to do so with our Device Manager app.&lt;/p&gt;
[quote user="JH7"]If I understand your suggestions, there will always be the possibility of having a bigger image that would lead to this problem, no matter how I adjust the application and partitions, right?[/quote]
&lt;p&gt;It can happen during development, but it should never happen with your end users, in the sense that the new image should be tested extensively before deployment.&lt;/p&gt;
[quote user="JH7"]It looks like the options are: change the MCUBoot code to check the size[/quote]
&lt;p&gt;I believe what Susheel recommended was to change the &lt;em&gt;application&lt;/em&gt; code to check the size, rather than MCUboot.&lt;/p&gt;
[quote user="JH7"]make it erase the secondary partition[/quote]
&lt;p&gt;This is a reasonable approach.&lt;/p&gt;
[quote user="JH7"]try to control the access to the BLE OTA (let only authorised apps to update firmware).[/quote]
&lt;p&gt;For most applications, this is recommended regardless. The only exception I can think of is a hacking/development platform.&lt;/p&gt;
[quote user="JH7"]Do you have any other idea?[/quote]
&lt;p&gt;Your mobile app can also pre-emptively erase the flash area after a failed attempt, depends on the failure reason.&lt;/p&gt;
&lt;p&gt;Obviously, this doesn&amp;#39;t help the end-user having to sit through the entire download time. However,&amp;nbsp;this issue should be circumvented altogether by testing the new application before deployment to end-users, like I mentioned above.&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough free space to run swap upgrade</title><link>https://devzone.nordicsemi.com/thread/510199?ContentTypeID=1</link><pubDate>Tue, 12 Nov 2024 21:36:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b0c6157-b32f-4e8c-a000-fc40f6eb6ed2</guid><dc:creator>JH7</dc:creator><description>&lt;p&gt;Hi Susheel, thanks for your reply.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m thinking in the scenario where my product is released and the only way to update it is over BLE.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;mcumgr -t 5 -c &amp;lt;connection_type&amp;gt; flash erase &amp;lt;secondary_slot_offset&amp;gt; &amp;lt;size&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Can this be executed over BLE?&lt;/p&gt;
&lt;p&gt;If I understand your suggestions, there will always be the possibility of having a bigger image that would lead to this problem, no matter how I adjust the application and partitions, right?&lt;br /&gt;I could make sure to test a new image everytime before releasing it, but I&amp;#39;m thinking this can also be a vector of attack as a malicious user could prevent updates only by uploading an invalid image that is too big. Does it make sense?&lt;/p&gt;
&lt;p&gt;It looks like the options are: change the MCUBoot code to check the size, make it erase the secondary partition, and/or try to control the access to the BLE OTA (let only authorised apps to update firmware).&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Do you have any other idea?&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough free space to run swap upgrade</title><link>https://devzone.nordicsemi.com/thread/510033?ContentTypeID=1</link><pubDate>Tue, 12 Nov 2024 08:17:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10beddb6-00ba-407a-aa82-3d212f6409d5</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I am not expert in this, but searching for some info here are my few thoughts&lt;/p&gt;
&lt;p&gt;Considering the constraints of flash memory and the issues with OTA updates when larger apps (like app3 with CONFIG_SHELL=y) push memory usage to its limit, here are some ways to address each question:&lt;/p&gt;
[quote user=""]1 - If there&amp;#39;s no space to swap, why the bootloader lets the upload to start? How to prevent that?[/quote]
&lt;p&gt;The bootloader, MCUboot in this case, doesn&amp;#39;t automatically verify available swap space before beginning an upload. To mitigate this, you might look into two possible approaches:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Configure a Pre-Upload Check in the Application: Adding a check within the application using mcumgr commands or a custom routine to assess available swap space before initiating a DFU update could help. Keep in mind that this requires custom logic, as MCUboot doesn’t currently halt uploads based on space limitations.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Expand the Swap Partition (if feasible): Adjusting your partition setup to enlarge the swap area might make larger uploads possible, depending on the available flash space. You can modify pm_static.yml to reallocate memory for secondary images if needed.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
[quote user=""]2 - If an image fails to upload completely for any reason, how to erase it from flash so it does not block future updates?[/quote]
&lt;p&gt;To clear a failed image from flash:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Erase the Secondary Slot Using mcumgr: The mcumgr tool has commands that can erase sectors or flash regions. You could run the following command to erase the secondary slot:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div dir="ltr"&gt;&lt;pre class="ui-code" data-mode="text"&gt;mcumgr -t 5 -c &amp;lt;connection_type&amp;gt; flash erase &amp;lt;secondary_slot_offset&amp;gt; &amp;lt;size&amp;gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Replace &amp;lt;secondary_slot_offset&amp;gt; and &amp;lt;size&amp;gt; with values from your partition layout; for instance, mcuboot_secondary begins at 0x51000 and spans 0x2F000 (188kB) in your case.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Reboot and Retry the Upload: After erasing, reboot the device to let MCUboot clear any flags related to the prior upload, then try uploading a smaller image like app2.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
[quote user=""]3 - If this is something related to a specific NCS/Zephyr/MCUboot version, could you point an older version that doesn&amp;#39;t show this issue?[/quote]
&lt;p&gt;This is likely due to partition size rather than a specific bug in recent versions. Still, some potential options include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Testing a Smaller Application Version: Temporarily reducing the app size by disabling some features could make DFU uploads more manageable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Trying nRF Connect SDK v2.6.x: This version &lt;strong&gt;may&lt;/strong&gt; handle partitions and memory slightly differently. Running a test build with v2.6.x could highlight any improvements in memory management.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Implementing these strategies should help manage space limitations during DFU updates. Also, fine-tuning your partition layout and reducing the application’s footprint may prevent similar issues in future updates.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>