<?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>Fixing the &amp;quot;known issue&amp;quot; Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116900/fixing-the-known-issue-partitioning-limitation-with-mcuboot-swap-move</link><description>The subject issue is documented here as &amp;quot; NCSDK-20567: Partitioning limitation with MCUboot swap move&amp;quot;: This issue has been open for while. These two DevZone tickets refer to this issue and mention the impact is that you can use only around 95% of the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Feb 2026 17:54:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116900/fixing-the-known-issue-partitioning-limitation-with-mcuboot-swap-move" /><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/560374?ContentTypeID=1</link><pubDate>Wed, 04 Feb 2026 17:54:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99722c30-a776-4a00-aeb2-de22635ea063</guid><dc:creator>smith_tristan</dc:creator><description>&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/dominik_2d00_ns"&gt;Dominik-NS&lt;/a&gt;&amp;nbsp;, thank you so much for your help with all of this. Just wanted to share where we ended up, in case anyone else is on the same path:&lt;br /&gt; &lt;br /&gt; We ended up adding a script to our build pipeline that calculates our flash usage of the maximum firmware-upgradeable image given the trailer size, etc.&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;As discussed above, the west build reports flash usage of the primary partition, but staying below 100% alone doesn&amp;#39;t ensure firmware upgradeability - because of the necessary space for the trailer and image swap page.&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;So our new script takes that extra space into account, and analyzes files from the build/ directory in order to tell us the percentage used of the maximum firmware-upgradeable image size.&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;Here is our final &amp;quot;Build Artifacts&amp;quot; diagram for &amp;ldquo;Swap Using Move Without Scratch&amp;rdquo; based on NCS v2.6.x:&lt;br /&gt; &amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0in;"&gt;&lt;img style="max-height:595px;max-width:1027px;" src="https://devzone.nordicsemi.com/resized-image/__size/2054x1190/__key/communityserver-discussions-components-files/4/pastedimage1770227645039v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;And here are the key calculations we use in our script for the app image:&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:10.0pt;margin:0in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Maximum Image Size Calculations&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Block Size: &lt;/span&gt;&lt;span style="background:white;"&gt;4 Bytes (nRF5340 write block size)&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Page Size:&amp;nbsp;&lt;/span&gt;&lt;span style="background:white;"&gt;4096 Bytes (nRF5340 page erase/write size)&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;BOOT_MAX_IMG_SECTORS:&amp;nbsp;&lt;/span&gt;&lt;span style="background:white;"&gt;This is the max number of &amp;quot;sectors&amp;quot; necessary for mcuboot to manage our image slots. Recommended to include some padding. If unnecessarily large, will use unnecessary RAM and slow the bootloader down (more time to zero out the RAM).&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;"&gt;BOOT_MAX_IMG_SECTORS &amp;gt;= ceil [ ( largest image slot size ) / ( page size ) ]&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;color:#292a2e;font-weight:bold;"&gt;Swap Status Region Size: &lt;/span&gt;&lt;span style="background:white;color:#292a2e;"&gt;Part of the trailer. Depends on BOOT_MAX_IMG_SECTORS and which swap method you are using. For swap with move, we need 3 states - each in a discrete write block. &lt;/span&gt;&lt;a href="https://github.com/mcu-tools/mcuboot/blob/268968f8e4a834ea3825d98439e4c321de0c6a78/docs/design.md#swap-status"&gt;&lt;span style="background:white;"&gt;mcuboot/docs/design.md at 268968f8e4a834ea3825d98439e4c321de0c6a78 &amp;middot; mcu-tools/mcuboot&lt;/span&gt;&lt;/a&gt;&lt;span style="background:white;color:#292a2e;font-weight:bold;"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Swap Status Region Size&lt;/span&gt;&lt;span style="background:white;"&gt; = BOOT_MAX_IMG_SECTORS * &lt;/span&gt;&lt;span style="background:white;font-weight:bold;"&gt;Block Size&lt;/span&gt;&lt;span style="background:white;"&gt; * s&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;s&lt;/span&gt;&lt;span style="background:white;"&gt; (number of states for swap move without scratch) = 3&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Trailer Size:&lt;/span&gt;&lt;span style="background:white;"&gt; Part of the slot, this is the part of the slot that MCUBoot uses to keep track of the upgrade swap. Rounded&amp;nbsp;up to the nearest page, where Page Size is 4096 bytes (determined by nRF5340 hardware).&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Raw Trailer Size&lt;/span&gt;&lt;span style="background:white;"&gt; = ( Swap Status Region ) + 80 bytes&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Raw Trailer Size&lt;/span&gt;&lt;span style="background:white;"&gt; = ( BOOT_MAX_IMG_SECTORS * &lt;/span&gt;&lt;span style="background:white;font-weight:bold;"&gt;Block Size &lt;/span&gt;&lt;span style="background:white;"&gt;) * 3 + 80&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Trailer Size&lt;/span&gt;&lt;span style="background:white;"&gt; = round up to &lt;/span&gt;&lt;span style="background:white;font-weight:bold;"&gt;Page Size&lt;/span&gt;&lt;span style="background:white;"&gt; ( &lt;/span&gt;&lt;span style="background:white;font-weight:bold;"&gt;Raw Trailer Size&lt;/span&gt;&lt;span style="background:white;"&gt; )&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;color:#292a2e;font-weight:bold;"&gt;Maximum Upgradeable Image Size:&lt;/span&gt;&lt;span style="background:white;color:#292a2e;"&gt; Primary slot size (internal flash) for a firmware upgradeable image. Per below, +1 Page because we need a page as temporary scratch for the swap. See here: &lt;/span&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/mcuboot/design.html#swap_using_move_without_using_scratch"&gt;&lt;span style="background:white;"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/mcuboot/design.html#swap_using_move_without_using_scratch&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;"&gt;Maximum Image Size = ( N - 1 ) * Sector Size - Trailer Size&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;"&gt;Sector Size = Page Size = 4096&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;"&gt;Trailer Size = nearest page[ BOOT_MAX_IMG_SECTORS * Block Size * s + 80 ]&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;N &lt;/span&gt;&lt;span style="background:white;"&gt;= floor( Primary Slot Size / Page Size ) = number of full pages in primary slot&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Maximum Image Size&lt;/span&gt;&lt;span style="background:white;"&gt; = ( N - 1 ) * Page Size - Trailer Size&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Primary Slot Flash Usage &lt;/span&gt;&lt;span style="background:white;"&gt;= 100 * Image Size / Maximum Image Size&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;"&gt;This can also be rearranged/described as:&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;"&gt;&lt;span style="background:white;font-weight:bold;"&gt;Necessary Primary Slot Size for a Given App Image:&lt;/span&gt;&lt;/p&gt;
&lt;p style="color:#292a2e;font-family:&amp;#39;Atlassian Sans&amp;#39;;font-size:12.0pt;margin:0in;margin-left:.375in;"&gt;&lt;span style="background:white;"&gt;Primary Slot Size &amp;gt;= App Image Size + Trailer Size + 1 Move Page (Swap Sector Page)&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;And if you&amp;#39;re curious, here&amp;#39;s an example of our script&amp;#39;s output at the end of a build:&lt;/p&gt;
&lt;p style="margin:0in;"&gt;&lt;img style="max-height:912px;max-width:394px;" src="https://devzone.nordicsemi.com/resized-image/__size/788x1824/__key/communityserver-discussions-components-files/4/pastedimage1770227645043v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/544328?ContentTypeID=1</link><pubDate>Fri, 01 Aug 2025 12:39:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16375afe-6b41-49c6-a8dc-a82c9f2dedec</guid><dc:creator>Dominik-NS</dc:creator><description>&lt;p&gt;First, lets add here reference to MCUboot design doc, explaining the trailer:&lt;br /&gt;&lt;a href="https://github.com/mcu-tools/mcuboot/blame/268968f8e4a834ea3825d98439e4c321de0c6a78/docs/design.md#L493"&gt;https://github.com/mcu-tools/mcuboot/blame/268968f8e4a834ea3825d98439e4c321de0c6a78/docs/design.md#L493&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Q1) Swap means that image in slot1 will some time in the future end up in slot0; and may be reverted if only uploaded for test. So any image has to fit into both slots.&lt;/p&gt;
&lt;p&gt;If you have slot1 bigger than slot0, you may be able to upload thing that will never fit into image1, or will fit, but mcuboot will never be able to revert it, because it will not be able to write the trailer part.&lt;/p&gt;
&lt;p&gt;Think of this like this: it something is too big to fit into either slot, due to trailer and swap info that would appear in that slot, that is the same for the other slot; because in the end that thing will end up in the slot it is too big for.&lt;/p&gt;
&lt;p&gt;Q2) Trailer is added from the end of slot (or partition has been dedicated for it).&lt;/p&gt;
[quote userid="81660" url="~/f/nordic-q-a/116900/fixing-the-known-issue-partitioning-limitation-with-mcuboot-swap-move/542938"]Can you tell me if it is accurate?[/quote]
&lt;p&gt;No it is not. The trailer is written &amp;quot;backwards&amp;quot; from the end of partition.&lt;/p&gt;
&lt;p&gt;You have positioned the trailer in your images, it is placed at the end of partition/slot not app image.&lt;/p&gt;
&lt;p&gt;If you try to sign your image, using imgtool, to be already confirmed or set for test, the size of binary will be extended to full image slot, because it adds the trailer then.&lt;/p&gt;
&lt;p&gt;Lets say you have slot size of 256k; if you generate hello world, that takes ~34k, it will take ~34-35k signed, but if you sign if to be already confirmed, the signed image will take exactly 256k, because it fills all the space between image and the trailer that has to be placed at the end of image. The trailer comes from the end of partition, it is written &amp;quot;backwards&amp;#39;.&lt;/p&gt;
&lt;p&gt;If you have swap move, what happens is that MCUboot shifts up slot0 first, by one page, to release slot0 page for swap from slot1. So you need this extra one page in primary slot. Then it starts to write log from the back of the slot, after the trailer (again, backwards). The trailer does not have to take entire page and can cut into last page taken by application image (after the shift), because the image will not probably take entire page. If trailer is bigger then the space left in that last page, then trailer will need separate page and the space in last page, used by application image, will not be used.&lt;/p&gt;
&lt;p&gt;Swap-move does not use scratch page. What it does is moves image by one page, in slot0, which gives it ability to immediately place first page from slot1 into first page of slot0, as the first page has already been moved, basically it looks like this:&lt;br /&gt;1) in slot0 move page i to page i + 1, where i is N, N -1, ... 1, 0; this lives you with image in pages 1, to N + 1 of slot0&lt;br /&gt;2) page i from slot1 is taken and placed in page i of slot0&lt;br /&gt;3) page i + 1 is taken and placed in page i of slot1&lt;br /&gt;4) ++i; goto 2) till the larger image is completely moved.&lt;br /&gt;Of course there is erase of page between each copy and entry to trailer log is added to indicate how far operation went, to be able to recover in case device resets.&lt;br /&gt;Note that you will have at least one and at most two copies of move page at any point.&lt;/p&gt;
&lt;p&gt;If you have secondary slot bigger than primary, you may and up uploading something you will not be able to swap. Or once you have it swapped, you will not be able to revert it.&lt;/p&gt;
&lt;p&gt;Q3) &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote userid="81660" url="~/f/nordic-q-a/116900/fixing-the-known-issue-partitioning-limitation-with-mcuboot-swap-move/542938"]&lt;span style="font-weight:bold;"&gt;What do you mean by &amp;quot;256 logs take up to 3072&amp;quot;?&amp;nbsp;&lt;/span&gt;&lt;span style="font-weight:bold;"&gt;What logs are you referring to?&lt;/span&gt;[/quote]
&lt;p&gt;By log I mean, what is correct name, &amp;quot;Swap status&amp;quot;&amp;nbsp;&lt;a href="https://github.com/mcu-tools/mcuboot/blame/268968f8e4a834ea3825d98439e4c321de0c6a78/docs/design.md#L1057"&gt;https://github.com/mcu-tools/mcuboot/blame/268968f8e4a834ea3825d98439e4c321de0c6a78/docs/design.md#L1057&lt;/a&gt;&amp;nbsp;. MCUboot writes here each step it has completed to know where to start in case device reboots or something happens that interrupts the swap.&lt;br /&gt;256 is 3 states * 4 write block, which is 3072 size of max swap status, trailer would take additional 80 bytes. But you if you define 256 pages of 4095 and have slot of 256k, then 3/4 of your swap status will never be written, so the additional 80 byte just merge into it.&lt;/p&gt;
&lt;p&gt;Q4)&lt;/p&gt;
[quote userid="81660" url="~/f/nordic-q-a/116900/fixing-the-known-issue-partitioning-limitation-with-mcuboot-swap-move/542938"]Does CONFIG_BOOT_MAX_IMG_SECTORS affect the &amp;quot;Trailer Move Page / Swap Status Area&amp;quot; Size?[/quote]
&lt;p&gt;Yes.&lt;br /&gt;&lt;br /&gt; The&amp;nbsp;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;CONFIG_BOOT_MAX_IMG_SECTORS&lt;/span&gt;&amp;nbsp;determines size of allocated structures for storing information on layout of a device (aka pages) and how much will the &amp;quot;Swap status&amp;quot; cut into the image from the end of slot. You can basically see this as &amp;quot;biggest size of slot(partition) divided by size of device page&amp;quot;.&lt;/p&gt;
[quote userid="81660" url="~/f/nordic-q-a/116900/fixing-the-known-issue-partitioning-limitation-with-mcuboot-swap-move/542938"]If the actual used sectors is smaller than the max image sectors, will the Trailer and Trailer Move Page / Swap Status Area be smaller as well?[/quote]
&lt;p&gt;MCUboot will use all&amp;nbsp;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;CONFIG_BOOT_MAX_IMG_SECTORS&lt;/span&gt;&amp;nbsp;in RAM, when discovering device layout, but when writing swap status it may only take several, for example if you swap two images of ~40k (between slot0 and slot1), the swap status will only write ~10 * 4 * 3 bytes of status , because only 10 pages are moved. But you have to have enough space to cover entire slot.&lt;/p&gt;
[quote userid="81660" url="~/f/nordic-q-a/116900/fixing-the-known-issue-partitioning-limitation-with-mcuboot-swap-move/542938"]Basically, how do we determine the size of the &amp;quot;Trailer Move Page / Swap Status Area&amp;quot; ?[/quote]
&lt;p&gt;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;CONFIG_BOOT_MAX_IMG_SECTORS&lt;/span&gt;&amp;nbsp;is how many sectors MCUboot will be able to move in a biggest slot (still should be the same). It has to be able to cover the biggest slot/partition that is involved in image update.&lt;br /&gt;&lt;br /&gt;Here is how the swap status looks like:&amp;nbsp;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&lt;a href="https://github.com/mcu-tools/mcuboot/blame/268968f8e4a834ea3825d98439e4c321de0c6a78/docs/design.md#L493"&gt;https://github.com/mcu-tools/mcuboot/blame/268968f8e4a834ea3825d98439e4c321de0c6a78/docs/design.md#L493&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you set&amp;nbsp;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;CONFIG_BOOT_MAX_IMG_SECTORS=2048&lt;/span&gt;, you will have swap status of at most 24k, if you have page of 4k, that is able to handle 8MiB of slot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/542938?ContentTypeID=1</link><pubDate>Sun, 20 Jul 2025 17:03:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c27f08c-4070-4613-8b13-474cf36ffbe6</guid><dc:creator>smith_tristan</dc:creator><description>&lt;p&gt;It seems like my last response was visually clipped, so I&amp;#39;m copying it here at the top level as well...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/dominik_2d00_ns"&gt;Dominik-NS&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Hi Dominik, thanks again for all your responses. I think I understand a little bit better, but I still have a couple questions.&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Q1)&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Previously you said: &amp;quot;Please check your PM_MCUBOOT_SECONDARY_SIZE, because it seems that this is significantly shorter. The trailer equation will only work with the secondary slot, because here the trailer can touch the last page of binary, something it can not do in primary slot.&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;I am still trying to interpret this suggestion. My thought is:&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Primary Image Slot can take a maximum signed image of 966656 &amp;larr; 974848 - 2 * 4096&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Secondary Image Slot Size however is 974848. Which is much larger than the Primary Image Slot max image size.&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;So is your concern that we could have a secondary image too large to be swapped into the primary slot safely?&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;ie, the Secondary Slot is totally full and does not account for the 2 extra pages needed in the Primary Slot?&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Q2)&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;I&amp;#39;ve come up with this diagram to help me understand how this all goes together, and each piece that has to go into each slot.&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;Can you tell me if it is accurate?&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&lt;img style="max-height:491px;max-width:885px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1770x982/__key/communityserver-discussions-components-files/4/pastedimage1752877304735v1.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Q3)&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Previously you said: &amp;quot;Generally 256 is ok if size of slot is &amp;lt; 1MiB. As you can see this has to round up to a page anyway, and 256 logs take up to 3072 so plenty more space to fit the rest of trailer.&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&lt;span style="font-weight:bold;"&gt;What do you mean by &amp;quot;256 logs take up to 3072&amp;quot;?&amp;nbsp;&lt;/span&gt;&lt;span style="font-weight:bold;"&gt;What logs are you referring to?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Q4)&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;Looking at the diagram I shared,&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;Does CONFIG_BOOT_MAX_IMG_SECTORS affect the &amp;quot;Trailer Move Page / Swap Status Area&amp;quot; Size?&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;For example, if our CONFIG_BOOT_MAX_IMG_SECTORS=2048, will the extra space required in the Primary Slot be (2048 * 4 * 3 + 80) + the page for the Image Move?&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;Basically, how do we determine the size of the &amp;quot;Trailer Move Page / Swap Status Area&amp;quot; ?&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-family:Calibri;font-size:11.0pt;margin:0in;"&gt;&lt;span style="font-family:inherit;font-size:inherit;font-weight:bold;"&gt;If the actual used sectors is smaller than the max image sectors, will the Trailer and Trailer Move Page / Swap Status Area be smaller as well?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/539287?ContentTypeID=1</link><pubDate>Sun, 15 Jun 2025 18:16:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3ade0f3-a6f2-43dd-b414-bcaf389a80e5</guid><dc:creator>variant</dc:creator><description>&lt;p&gt;It&amp;#39;s been a while since Dominik&amp;#39;s reply. We appreciate the reply. One of our local experts has been away for a month. We still intend to reply if we have further questions once he returns.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/530317?ContentTypeID=1</link><pubDate>Wed, 02 Apr 2025 18:10:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26a4f907-ea23-415c-8f01-823dc0118249</guid><dc:creator>Dominik-NS</dc:creator><description>&lt;p&gt;1) Primary Slot Size: has to contain the image + trailer + 1 page for move page&lt;br /&gt;Yes, trailer is rounded to N pages, where page is 4096 bytes (min for hardware)&lt;/p&gt;
&lt;p&gt;2) BOOT_MAX_IMG_SECTORS must be larger than: ( Largest Image Slot Size ) / Erase Page Size&lt;br /&gt;Yes. Because&amp;nbsp;BOOT_MAX_IMG_SECTORS determines size of swap log size. You are swapping BOOT_MAX_IMG_SECTORS&amp;nbsp; at most, which is slot size/page size&lt;br /&gt;&lt;br /&gt;3) Erase Page Size = 4kBytes for the NRF5340&lt;br /&gt;Yes,; when external mem is used, the bigger size is used, but it can not be less than physical limitation of any of memories (4k is min for nrf53/nrf52)&lt;/p&gt;
&lt;p&gt;4) Trailer Size (bytes)&amp;nbsp;= ( BOOT_MAX_IMG_SECTORS * Block Size ) * 3 + 80&lt;/p&gt;
&lt;p&gt;Block size == Write block size (4 bytes); yes, but rounded up to pages. MCUboot has to copy/erase by pages.&lt;/p&gt;
&lt;p&gt;5) We start with a primary image slot size = 974848 bytes (0xEE000)&lt;/p&gt;
&lt;p&gt;OK&lt;/p&gt;
&lt;p&gt;6) BOOT_MAX_IMG_SECTORS &amp;gt;= 238 = 974848 / 4096&lt;/p&gt;
&lt;p&gt;ok&lt;/p&gt;
&lt;p&gt;7) Given that the trailer is 4096 bytes, this gives us a useable space of 966656 bytes.&lt;/p&gt;
&lt;p&gt;should&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q2) However, because of the MCUBOOT pad,&amp;nbsp;should we actually start with 974336 bytes as the primary image slot size?&lt;/strong&gt; That is address space of 0x10200 to 0xFE000.&lt;/p&gt;
&lt;p&gt;No.The pad is just shifting application image by the size required for image header, but header is part of the image that is being moved around. This thing is for compiler/linker to figure out where code actually should start. After you build application the 0x200 bytes are added in front of by imgtool when image is signed. There is another chunk of data added at the end in form of TLV that store info like signature. The real size that is swapped between slots is what you see as app_update.bin (or zephyr.signed.bin), not the thing that build reports in the end.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q3) Also, why is there not a general recommended BOOT_MAX_IMG_SECTORS configuration for any nRF5340 project? Would 256 always be the recommended number of sectors?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Generally 256 is ok if size of slot is &amp;lt; 1MiB. As you can see this has to round up to a page anyway, and 256 logs take up to 3072 so plenty more space to fit the rest of trailer. The space gets shorter when using encryption (because keys are also dropped there), in which case you may wan to cut the the BOOT_MAX_IMG_SECTORS to actual size, to not take another page.&lt;br /&gt;&lt;br /&gt;The best way to test your setup is build your app, check size difference between signed and unsigned. Then add, to the end of binary, enough bytes to fill the slot, save the header (0x200), the difference checked above and - 2* 4096 in pages. Now when you sign what you have you should have signed binary of size of slot - 2* 4096 bytes; that thing should correctly upload to device and swap into primary slot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/530083?ContentTypeID=1</link><pubDate>Tue, 01 Apr 2025 22:22:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f1ee3af-a570-4ec3-9153-8dc0fd2941c9</guid><dc:creator>smith_tristan</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/dominik_2d00_ns"&gt;Dominik-NS&lt;/a&gt;&amp;nbsp; - I work with&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/variant"&gt;variant&lt;/a&gt;&amp;nbsp;, trying to catch up on this thread...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q1) What do you mean when you say: &amp;quot;Please check your PM_MCUBOOT_SECONDARY_SIZE, because it seems that this is significantly shorter.&amp;quot;? Shorter than what?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In partitions.yml, I see mcuboot_secondary: size: 0xee000 (974848 bytes).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Just to make sure I&amp;#39;m understanding correctly:&lt;/p&gt;
&lt;p&gt;1) Primary Slot Size: has to contain the image + trailer + 1 page for move page&lt;/p&gt;
&lt;p&gt;2) BOOT_MAX_IMG_SECTORS must be larger than: ( Largest Image Slot Size ) / Erase Page Size&lt;/p&gt;
&lt;p&gt;3) Erase Page Size = 4kBytes for the NRF5340&lt;br /&gt;&lt;br /&gt;4) Trailer Size (bytes)&amp;nbsp;= ( BOOT_MAX_IMG_SECTORS * Block Size ) * 3 + 80&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So for the nRF5340:&lt;/p&gt;
&lt;p&gt;5) We start with a primary image slot size = 974848 bytes (0xEE000)&lt;/p&gt;
&lt;p&gt;6) BOOT_MAX_IMG_SECTORS &amp;gt;= 238 = 974848 / 4096&lt;/p&gt;
&lt;p&gt;7) Given that the trailer is 4096 bytes, this gives us a useable space of 966656 bytes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q2) However, because of the MCUBOOT pad,&amp;nbsp;should we actually start with 974336 bytes as the primary image slot size?&lt;/strong&gt; That is address space of 0x10200 to 0xFE000.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q3) Also, why is there not a general recommended BOOT_MAX_IMG_SECTORS configuration for any nRF5340 project? Would 256 always be the recommended number of sectors?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Tristan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/528448?ContentTypeID=1</link><pubDate>Fri, 21 Mar 2025 16:11:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1575976-3817-4fda-906e-f6c05e4928a9</guid><dc:creator>Dominik-NS</dc:creator><description>&lt;p&gt;I think we are mistaking binary with mcuboot image, these are different things:&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1742572272755v1.png" alt=" " /&gt;&lt;br /&gt;the top one is binary, that is the thing build logs size form; the bottom one is image, that is uploaded to the device.&lt;br /&gt;Once your image is signed there is additional information added to it, and build log does not show that info.&lt;br /&gt;For experiment I have appended my binary with enough data to fill, after signing, entire slot - 2 * 4096 bytes, and that worked fine. But I have been using equal slot sizes, that is why I have to subtract on slot for move area and one for trailer rounded up to one slot.&lt;br /&gt;In primary slot trailer may not be written in the same page as the swapped in image is.&lt;/p&gt;
&lt;p&gt;In secondary slot trailer may be written to the same page as uploaded, because there is no &amp;quot;move&amp;quot; page between trailer and image. &lt;br /&gt;The move page needs to be erased independently, so it can not be either part of image nor trailer.&lt;br /&gt;But that image will be swapped to the primary slot, and at that point that slot has to be able to &lt;br /&gt;&lt;br /&gt;It seems that you have CONFIG_BOOT_MAX_IMG_SECTORS=256, the nrf5340 has a 4096B page and 4B write block, &lt;span&gt;974848&lt;/span&gt; primary slot.&lt;br /&gt;&lt;br /&gt;The &lt;span&gt;974848&lt;/span&gt; takes 238 slots, so 238 * 3 * 4 + 80 = 2936 ~= 4096&lt;br /&gt;So primary slot can take max &lt;span&gt;974848&lt;/span&gt;&amp;nbsp; - 2 * 4096 = 966656&lt;/p&gt;
&lt;p&gt;Please check your &lt;span&gt;PM_MCUBOOT_SECONDARY_SIZE&lt;/span&gt;, because it seems that this is significantly shorter. The trailer equation will only work with the secondary slot, because here the trailer can touch the last page of binary, something it can not do in primary slot.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/528085?ContentTypeID=1</link><pubDate>Wed, 19 Mar 2025 20:39:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b784c24-12e1-4aa1-8a14-07802bc099a4</guid><dc:creator>variant</dc:creator><description>&lt;p&gt;Thanks for the reply&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&amp;nbsp;. And I apologize&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/dominik_2d00_ns"&gt;Dominik-NS&lt;/a&gt;&amp;nbsp;that I didn&amp;#39;t realize you were replying as a Nordic rep. Your reply was very detailed, but I wasn&amp;#39;t sure it was sanctioned by Nordic.&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;br /&gt;Attached is the build/mcuboot/zephyr/.config file that Vidar suggested I post.&lt;br /&gt;&lt;br /&gt;Thanks again.&lt;br /&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/.config_5F00_for_5F00_mcuboot.txt"&gt;devzone.nordicsemi.com/.../.config_5F00_for_5F00_mcuboot.txt&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/527580?ContentTypeID=1</link><pubDate>Mon, 17 Mar 2025 11:03:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b155783-6761-4487-a113-2b9e5d95aa23</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Sorry, I&amp;nbsp;assumed the questions&amp;nbsp;got answered by&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/dominik_2d00_ns"&gt;Dominik-NS&lt;/a&gt;&amp;nbsp; comments above. He&amp;nbsp;is a Nordicer who is&amp;nbsp;working on MCUBoot.&amp;nbsp;Could you upload the configuration file (build/mcuboot/zephyr/.config) for your bootloader so I can have a look at the configuration?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/527437?ContentTypeID=1</link><pubDate>Fri, 14 Mar 2025 19:41:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8392150-5b68-4848-b964-1833612521a1</guid><dc:creator>variant</dc:creator><description>&lt;p&gt;Is there going to be any reply from Nordic?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/517659?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2025 10:58:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:457f3a15-42b9-4324-a3fa-fc8924e99fda</guid><dc:creator>Dominik-NS</dc:creator><description>&lt;p&gt;One more update.&lt;br /&gt;&lt;br /&gt;As it may be tempting to set the BOOT_MAX_IMG_SECTORS to (image_slot_size_in_bytes - erase_page_size_in_bytes) / erase_page_size_in_bytes, it would not be correct.&lt;br /&gt;The BOOT_MAX_IMG_SECTORS needs to be set to highest of image_slot_size_in_bytes / erase_page_size_in_bytes of two values, assuming two slots may have different sizes, as it has to hold information on layout for both slots, as we will erase any page in the slot range.&lt;br /&gt;&lt;br /&gt;So in reality, after the BOOT_MAX_IMG_SECTORS&amp;nbsp; has been established, the trailer itself, can be calculated as&lt;br /&gt;(((BOOT_MAX_IMG_SECTORS * write_block_size) * 3 + 80.&lt;/p&gt;
&lt;p&gt;But aside from the above value, the image will also loose one additional page for the &amp;quot;move&amp;quot; page.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/517653?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2025 10:39:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a1969c2-6e3e-4f50-a5c3-00f75b832b2a</guid><dc:creator>Dominik-NS</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The BOOT_MAX_IMG_SECTORS is actually mentioned in &lt;span&gt;NCSDK-20567&lt;/span&gt;, as CONFIG_BOOT_MAX_IMG_SECTORS, and how it weights against (image_slot_size_in_bytes - erase_page_size_in_bytes) / erase_page_size_in_bytes. Unfortunately I did calculations from the point of hardware to software impact and so there was no clear indication how the BOOT_MAX_IMG_SECTORS&amp;nbsp; impacts calculations, as a software configuration item.&lt;/p&gt;
&lt;p&gt;The BOOT_MAX_IMG_SECTORS&amp;nbsp; does indeed impact size of footer. It is mainly used, in MCUboot, to calculate log size and to allocate array of sectors (erase units on device) (as explained in &lt;span&gt;NCSDK-20567&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;Internal details are below, if interested.&lt;br /&gt;&lt;br /&gt;The first usage is done here boot_status_internal_off (note that this is unfortunate name for a partial offset, not full offset from the end of slot):&lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/b82206c15fff357c151c24bf97c99c4348d14a46/boot/bootutil/src/swap_move.c#L221"&gt;https://github.com/nrfconnect/sdk-mcuboot/blob/b82206c15fff357c151c24bf97c99c4348d14a46/boot/bootutil/src/swap_move.c#L221&lt;/a&gt; (for MOVE algorithm, SCRATCH has own function for that) - basically the function is called given write-block-size of a device (elem_sz) and calculates log for 3 states (BOOT_STATUS_MOVE_STATE_COUNT) per page/sector moved (BOOT_MAX_IMG_SECTORS).&lt;br /&gt;Above can also be seen in swap_read_status_bytes &lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/b82206c15fff357c151c24bf97c99c4348d14a46/boot/bootutil/src/swap_move.c#L204"&gt;https://github.com/nrfconnect/sdk-mcuboot/blob/b82206c15fff357c151c24bf97c99c4348d14a46/boot/bootutil/src/swap_move.c#L204&lt;/a&gt; when calculating maximum expected log entries, without footer &amp;quot;header&amp;quot; (that is why it is &amp;quot;partial&amp;quot;).&lt;br /&gt;&lt;br /&gt;The other usage is in allocating table for sector information; the array is used to store information on offset and size of each sector that covers slot - this happens, because MCUboot has been designed with devices with non-uniform sector layout, like stm32, where each sector can have different size, &lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/b82206c15fff357c151c24bf97c99c4348d14a46/boot/bootutil/src/loader.c#L96"&gt;https://github.com/nrfconnect/sdk-mcuboot/blob/b82206c15fff357c151c24bf97c99c4348d14a46/boot/bootutil/src/loader.c#L96&lt;/a&gt;.&lt;br /&gt;The BOOT_MAX_IMG_SECTORS needs to be provided by user, because it is not always possible to get that info from DTS, for example spi devices do not have such info and so far non-uniform devices have no such definition.&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Dominik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/517467?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2025 12:57:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9bd62ba-4d60-45ae-a331-5a11b995b059</guid><dc:creator>variant</dc:creator><description>&lt;p&gt;Hi Vidar, is there any update on your last reply?&amp;nbsp; Can you at least confirm for sure that the value for&amp;nbsp;&lt;span&gt;BOOT_MAX_IMG_SECTORS&amp;nbsp;does indeed affect the max size of the updateable image.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/514769?ContentTypeID=1</link><pubDate>Thu, 12 Dec 2024 14:20:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e030e65-4118-4033-a8af-eb4c56a262ca</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, this does not appear to be correct, unfortunately. I&amp;#39;m awaiting feedback from the developers on this. The value of BOOT_MAX_IMG_SECTORS * 4096 must be&amp;nbsp;bigger than or equal to the size of the mcuboot&amp;nbsp;slot, and since&amp;nbsp;the&amp;nbsp;&lt;span&gt;BOOT_MAX_IMG_SECTORS&lt;/span&gt; value affects the image trailer size, it seems like it should have been included in the calculation as you said.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/514571?ContentTypeID=1</link><pubDate>Wed, 11 Dec 2024 15:23:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6fc86bb-90d8-423e-bc3e-f1d5e822946f</guid><dc:creator>variant</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;br /&gt;&lt;br /&gt;Ok, so for the equation in&amp;nbsp;&lt;span&gt;NCSDK-20567&lt;/span&gt; to calculate max app size:&lt;br /&gt;&lt;span class="pre"&gt;mcuboot_primary_size&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="pre"&gt;-&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="pre"&gt;80&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="pre"&gt;-&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="pre"&gt;(mcuboot_primary_size/&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="pre"&gt;4096)&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="pre"&gt;*&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="pre"&gt;12&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="pre"&gt;-4096&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;you said the mcuboot_primary_size is&amp;nbsp;&lt;span&gt;PM_MCUBOOT_PRIMARY_SIZE.&lt;br /&gt;&lt;br /&gt;1. For my case,&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;PM_MCUBOOT_PRIMARY_SIZE is&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0xee000, or&amp;nbsp;974848.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The max app size equation in NCSDK-20567 results in&amp;nbsp;967816&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Our build log &amp;quot;Memory region&amp;quot; for FLASH lists &amp;quot;Region Size&amp;quot; as&amp;nbsp;974336.&lt;br /&gt;&lt;br /&gt;If hypothetically my actual app size were 967816 as being the &amp;quot;Used Size&amp;quot; in the build log, the build log would report &amp;quot;%age Used&amp;quot; as 967816 / 974336 = 99.33%.&amp;nbsp; &amp;nbsp;I know that 99.33% can&amp;#39;t be correct because we hit the max size issue at 96% as reported by the build log.&amp;nbsp; What am I doing wrong in this example?&lt;br /&gt;&lt;br /&gt;I don&amp;#39;t think the NCSDK-20567&amp;#39;s &amp;quot;Some additional margin is suggested&amp;quot; would account for the discrepancy.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;2. According to&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/main/docs/design.md#image-trailer"&gt;image trailer&lt;/a&gt;,&amp;nbsp;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1733928968756v1.png" /&gt;&lt;br /&gt;&lt;br /&gt;If the image trailer size depends on&amp;nbsp;&lt;/span&gt;&lt;code&gt;BOOT_MAX_IMG_SECTORS,&lt;/code&gt;&lt;span&gt;&amp;nbsp;then why doesn&amp;#39;t the equation in NCSDK-20567 include that value in the equation?&amp;nbsp; More specifically, does&amp;nbsp;BOOT_MAX_IMG_SECTORS have any impact on the&amp;nbsp;max app size that can be FW updated?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks in advance!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/513942?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2024 02:27:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c9b926b-f3bc-4f11-ab20-34acce6baa10</guid><dc:creator>variant</dc:creator><description>&lt;p&gt;Thanks Vidar for the very detailed and clear reply.&lt;br /&gt;I will have a follow-up question on your answer shortly.&amp;nbsp; I haven&amp;#39;t had a chance to research something yet, but I wanted to get the thank you sent now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Fixing the "known issue" Partitioning limitation with MCUboot swap move</title><link>https://devzone.nordicsemi.com/thread/513467?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2024 14:44:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f25d446e-a8c0-4332-bed3-37f812e53f64</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The size of the primary slot is defined by the&amp;nbsp;PM_MCUBOOT_PRIMARY_SIZE symbol in pm_config.h which is generated by the partition manager during the build.&lt;/p&gt;
&lt;p&gt;Fixing this issue is still in our backlog. I’ve requested that we prioritize addressing it so you can receive a build time error if the image will exceed the maximum size for the secondary slot. As you may know, the reason the FW image can&amp;#39;t fill the whole partition is that&amp;nbsp;we need to leave room for the&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/main/docs/design.md#image-trailer"&gt;image trailer&lt;/a&gt;&amp;nbsp;at the end.&amp;nbsp;&lt;/p&gt;
[quote user=""]1. In the Workaround description, there is a formula to calculate the approximate size limitation. What CONFIG item is referred to for&amp;nbsp;mcuboot_primary_size?&amp;nbsp; I am not able to figure out how to use that equation to result in a value of approximately 95% of the &amp;quot;Region Size&amp;quot; for the application image indicated in the build log.[/quote]
&lt;p&gt;The percentage will vary depending on the size of the partition. Larger partitions can have utilization above 95%&lt;/p&gt;
[quote user=""]2. Why is &amp;quot;additional&amp;quot; margin suggested?&amp;nbsp; Can that margin be quantified?[/quote]
&lt;p&gt;This was to account for any changes in the image trailer size. For example, the image trailer becomes larger if encryption is enabled. The best way to verify that there is enough room for the image trailer with your configuration is to test the DFU of the image locally before distributing the update. If the image is too large, the bootloader will fail to copy the update to the primary slot. It is also important that you are using the same static partition layout across FW versions (&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/scripts/partition_manager/partition_manager.html#configuring_static_partitions"&gt;Configuring static partitions&lt;/a&gt;)&lt;/p&gt;
[quote user=""]4. When the fix is available, do you think the fix can be patched by us to an earlier NCS version, such as NCS 2.6?[/quote]
&lt;p&gt;The&amp;nbsp;planned fix is to&amp;nbsp;calculate the actual space available for the firmware image at build time and provide the user with an error if the image is too large for DFU.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>