<?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>Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/106791/static-partition-manager-and-xip-variant</link><description>Hi, I&amp;#39;m using VS Code and v2.5.0 with a custom board based on an nRF52820. I&amp;#39;m using a Segger J-Link Base to flash the board. 
 I&amp;#39;ve managed to set up the DFU example with mcuBoot and a static partition map, can flash that onto our board successfully</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 Dec 2023 08:29:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/106791/static-partition-manager-and-xip-variant" /><item><title>RE: Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/thread/461526?ContentTypeID=1</link><pubDate>Fri, 22 Dec 2023 08:29:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd6b943d-da34-48e9-a29a-ba2d7dd58b81</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Good catch! If you use serial DFU, you only need one slot, getting a lot more space to work with.&lt;/p&gt;
&lt;p&gt;Thanks a lot for the kind words, and especially for sharing the solution! I am sure that future users will find this helpful.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/thread/461503?ContentTypeID=1</link><pubDate>Thu, 21 Dec 2023 20:25:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1f96722-a279-425c-89fd-b62d70bd05a8</guid><dc:creator>alex-b</dc:creator><description>&lt;p&gt;Ok, so I&amp;#39;ve got it working, and here&amp;#39;s what I did in case others find it helpful!&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t quite end up following your suggestion above Sigurd, but I did get a lot of help from reading through all that, as well as &lt;a href="https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples/serial_recovery/mcuboot_serial_recovery_cdc_acm_wait"&gt;this&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve ended up making the mcuboot wait for 15 seconds when it starts for a DFU connection, and using that to update the application. This allows me to have a single image that&amp;#39;s big enough for my application to fit in, and will enable the devices to be updated in the field.&lt;/p&gt;
&lt;p&gt;I set the prj.conf for mcuboot as follows:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_MAIN_STACK_SIZE=10240
CONFIG_MBEDTLS_CFG_FILE=&amp;quot;mcuboot-mbedtls-cfg.h&amp;quot;

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y

CONFIG_PM_PARTITION_SIZE_MCUBOOT=0xc000

CONFIG_SIZE_OPTIMIZATIONS=y
CONFIG_SINGLE_APPLICATION_SLOT=y

# Enable wait for DFU functionality
CONFIG_BOOT_USB_DFU_WAIT=y
CONFIG_BOOT_USB_DFU_WAIT_DELAY_MS=15000

CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_FCB=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_FCB=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;(There&amp;#39;s other pointers on here how to do that in the child_image folder, but that&amp;#39;s for another day!)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In my board.dts file I had the following set up:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;flash0 {
	partitions {
		compatible = &amp;quot;fixed-partitions&amp;quot;;
		#address-cells = &amp;lt;1&amp;gt;;
		#size-cells = &amp;lt;1&amp;gt;;

		boot_partition: partition@0 {
			label = &amp;quot;mcuboot&amp;quot;;
			reg = &amp;lt;0x0 0x10000&amp;gt;;
		};
		slot0_partition: partition@10000 {
			label = &amp;quot;image-0&amp;quot;;
			reg = &amp;lt;0x10000 0x30000&amp;gt;;
		};
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In my application&amp;#39;s prj.conf file I added:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BOOTLOADER_MCUBOOT=y

# Build
CONFIG_SIZE_OPTIMIZATIONS=y

CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Once it was all up and working, I went back and added the pm_statc.yml file to my project (taken directly from the generated partitions.yml file in the build folder.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;app:
  address: 0xc200
  end_address: 0x3e000
  region: flash_primary
  size: 0x31e00
mcuboot:
  address: 0x0
  end_address: 0xc000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0xc000
mcuboot_pad:
  address: 0xc000
  end_address: 0xc200
  placement:
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0xc000
  end_address: 0x3e000
  orig_span: &amp;amp;id001
  - app
  - mcuboot_pad
  region: flash_primary
  size: 0x32000
  span: *id001
mcuboot_primary_app:
  address: 0xc200
  end_address: 0x3e000
  orig_span: &amp;amp;id002
  - app
  region: flash_primary
  size: 0x31e00
  span: *id002
settings_storage:
  address: 0x3e000
  end_address: 0x40000
  placement:
    align:
      start: 0x1000
    before:
    - end
  region: flash_primary
  size: 0x2000
sram_primary:
  address: 0x20000000
  end_address: 0x20008000
  region: sram_primary
  size: 0x8000
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;For completeness, when I boot the board up now, I can run the following line from where I downloaded &lt;a href="https://dfu-util.sourceforge.net"&gt;dfu-util&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;dfu-util --alt 0 --download ../nRFprojects/xxxx/build_Xxxx/zephyr/app_update.bin&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;My plan is to build a reset into my application, which can be triggered over the Bluetooth connection, so that in the field we can plug in the USB (which will also charge the device), trigger the reset from our app, then use df-util to update the app.&lt;/p&gt;
&lt;p&gt;What could go wrong!&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;/p&gt;
&lt;p&gt;Hopefully the above helps someone else out too, I&amp;#39;ve learnt a lot in doing it though, and thanks ever so much to Sigurd and the rest of the Nordic support team too!&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/thread/461144?ContentTypeID=1</link><pubDate>Tue, 19 Dec 2023 16:52:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bea40d80-d9c0-4a00-b3f9-cc30d364cb3e</guid><dc:creator>alex-b</dc:creator><description>&lt;p&gt;Thanks for the pointers Sigurd, sounds like a bit of a challenge but I&amp;#39;ll give it a go and report back how I get on!&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/thread/461125?ContentTypeID=1</link><pubDate>Tue, 19 Dec 2023 15:32:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93852a76-a18b-4781-ab3f-cf5e1e53f19d</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Here are some pointers:&lt;/p&gt;
&lt;p&gt;First, I would like to say that this approach is not officially supported by us, so best I can do is to give you help to do it yourself. And we can not guarantee anything related to this, as it is not properly tested.&lt;/p&gt;
&lt;p&gt;If you do not want to take all the effort to craft a new pm_static.yml for testing every time you change the partition size, you can temporarily make changes to pm.yml for mcuboot to set mcuboot_secondary. In that case, you can change &lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/adab597a0eb0eb9c030a7b797748a49ca89988c2/boot/zephyr/pm.yml#L47"&gt;this line&lt;/a&gt; to &amp;quot;size: 0x20000&amp;quot; (or any other size), and the partition manager will automatically size the rest to fit with that.&lt;/p&gt;
&lt;p&gt;Next up, if you build your project with &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_BOOT_BUILD_DIRECT_XIP_VARIANT"&gt;CONFIG_BOOT_BUILD_DIRECT_XIP_VARIANT&lt;/a&gt;, the build will create a secondary image file build/zephyr/mcuboot_secondary_app_update.bin which you should be able to use for the secondary slot.&lt;/p&gt;
&lt;p&gt;Further more, I think you need to do two different projects, and make sure that mcuboot signing keys match up (If you do not set the key manually it will be the same test key). &lt;br /&gt;Then as long as both projects have the same pm_static.yml, I think you should be able to switch between the two.&lt;/p&gt;
&lt;p&gt;Lastly, you need a way to go from the application to the DFU image when you want to do DFU.&lt;br /&gt;By default, direct_XIP boots the image with the newest version. So we need some trick to make it go back to the previous image. I think the easiest way here might be to set &lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/adab597a0eb0eb9c030a7b797748a49ca89988c2/boot/zephyr/Kconfig#L275C8-L275C30"&gt;CONFIG_BOOT_DIRECT_XIP_REVERT&lt;/a&gt; for the child image. Then find a way to revert the image when you need to go to the DFU image. &lt;br /&gt;Testing this, I see that MUCboot can no longer find the image if I enable this configuration. I asked our MCUboot developers about this. Maybe you can find another way to switch between the images?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/thread/461048?ContentTypeID=1</link><pubDate>Tue, 19 Dec 2023 12:34:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:321a40c4-aca4-4b25-a733-cb9183093f96</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Right, the DFU partition is smaller than the main application of course.&lt;/p&gt;
&lt;p&gt;One possible limitation here is that MCUboot assumes that both slots are the same size, which may make partitioning harder.&lt;/p&gt;
&lt;p&gt;In that case I agree that you need static partitioning to fix this yes.&lt;/p&gt;
&lt;p&gt;I will have a look and see if I can figure something out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/thread/461043?ContentTypeID=1</link><pubDate>Tue, 19 Dec 2023 12:27:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b7851b7-1de0-4f9a-b8af-ec84162f07b6</guid><dc:creator>alex-b</dc:creator><description>&lt;p&gt;Hi Sigurd, I can build them both separately without using the static PM, and they seem to work individually.&lt;/p&gt;
&lt;p&gt;However, following your excellent suggestion, I&amp;#39;ve removed the stain PM and tried using the DFU application to load a new version of the DFU application into the second slot, and that hasn&amp;#39;t worked.&lt;/p&gt;
&lt;p&gt;I made sure I updated the version, using:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION=&amp;quot;1.0.0+1&amp;quot;&lt;/pre&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;But when it resets after the DFU update, it still runs the initial version in slow 0.&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/thread/461038?ContentTypeID=1</link><pubDate>Tue, 19 Dec 2023 12:19:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:725b5322-ff8d-4894-802f-6fbac3610b79</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;I see, that makes sense.&lt;/p&gt;
&lt;p&gt;Does it work if you build without pm_static.yml?&lt;br /&gt;Generally I recommend building without pm_static.yml when developing. Then when having released the device (and when testing this last step), copy build/partitions.yml to pm_static.yml to make sure partitioning never changes, so that it repartitioning does not break future DFU.&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/config_and_build/bootloaders/bootloader.html#static-partition-requirement-for-dfu"&gt;Static partition requirement for DFU&lt;/a&gt; for more info on static partitioning.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/thread/461036?ContentTypeID=1</link><pubDate>Tue, 19 Dec 2023 12:14:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d031a0d-1ac0-4781-a6cb-1413647b0eb7</guid><dc:creator>alex-b</dc:creator><description>&lt;p&gt;Hi Sigurd, thanks for the quick response!&lt;/p&gt;
&lt;p&gt;Direct-XIP is what I need, to be able to run either the DFU or our application from internal flash.&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Static Partition Manager and XIP Variant</title><link>https://devzone.nordicsemi.com/thread/461032?ContentTypeID=1</link><pubDate>Tue, 19 Dec 2023 12:07:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dabf6234-c7cc-4808-b28c-a89293852910</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Direct-XIP is not the same as XIP.&lt;/p&gt;
&lt;p&gt;XIP is usually running part of the code from external flash.&lt;/p&gt;
&lt;p&gt;Direct-XIP still uses two slots in internal flash, but for DFU, MCUboot does not swap to run the new image. See &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/design.html#equal-slots-direct-xip"&gt;Equal slots (direct-xip&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Which of these do you want?&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></channel></rss>