<?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>Flash partitioning</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110879/flash-partitioning</link><description>The MCUboot, Slot0, and Slot1 flash partitions are defined in the board file. E.g., nrf52840dk_nrf52840.dts has boot_partition at 0 with length 0xC000, slot0_partition at 0xC000 with length 0x76000, slot1_partition at 0x82000 with length 0x76000, and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 31 May 2024 18:13:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110879/flash-partitioning" /><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/486956?ContentTypeID=1</link><pubDate>Fri, 31 May 2024 18:13:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7307ee17-31ab-4da3-a5ab-04410b94bd6a</guid><dc:creator>David Ormand</dc:creator><description>&lt;p&gt;Thank you for this excellent explanation and the background info.&amp;nbsp; Since I am approaching Zephyr from a Nordic point-of-view, I&amp;#39;m aware there are differences between Zephyr as part of NCS and &amp;quot;vanilla&amp;quot; Zephyr from&amp;nbsp;&lt;a href="https://www.zephyrproject.org/"&gt;https://www.zephyrproject.org/ &lt;/a&gt;- which states that a number of platforms are supported, including Nordic, but not any notion of how far a &amp;quot;fork&amp;quot; for that support may go.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/485423?ContentTypeID=1</link><pubDate>Wed, 22 May 2024 12:50:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:769cc903-6ed2-49f3-b102-65372eb8e354</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;We hade some national holidays here, so things became a bit delayed.&lt;/p&gt;
&lt;p&gt;I see that you found a solution, and if that works for you, no need to change it.&lt;br /&gt;But I will try to explain it all from the bottom up, in case you are interested.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:150%;"&gt;&lt;strong&gt;Zephyr vs nRF Connect SDK&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Some years ago, we only had the nRF5 SDK. But to keep up with the times, we needed an RTOS. For this, we chose the Zephyr RTOS. However, we needed some leeway, so we created the nRF Connect SDK, which is basically the Zephyr RTOS with our own stuff on top.&lt;br /&gt;Some info on this can be found in &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/nrf-connect-sdk-and-nrf5-sdk-statement"&gt;nRF Connect SDK and nRF5 SDK statement&lt;/a&gt; . &lt;/p&gt;
&lt;p&gt;I will refer to only Zephyr (without the nRF Connect SDK) as Vanilla Zephyr.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:150%;"&gt;&lt;strong&gt;Zephyr DTS and Partition Manager&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Zephyr use DeviceTree (DTS) to configure the hardware. Among this DTS config there are partition information. However, for the nRF Connect SDK we needed something more dynamic than DTS partitioning. So for the nRF Connect SDK we created the Partition Manager.&lt;br /&gt;This means that the Partition Manager is only in the nRF Connect SDK and not in Vanilla Zephyr.&lt;br /&gt;And the nRF Connect SDK uses Zephyr but not vice versa.&lt;br /&gt;So you can use DTS partitioning in the nRF Connect SDK but not the Partition Manager in Vanilla Zephyr.&lt;/p&gt;
&lt;p&gt;This means that in the nRF Connect SDK, you have two alternatives for partitioning: DTS partitioning or Partition Manager. &lt;br /&gt;To complicate things a bit: The build system still uses DTS partitioning, so the partition manager technically generates DTS partitioning I think. &lt;br /&gt;But from a user perspective, you have must use only one to configure your project.&lt;br /&gt;=&amp;gt; You can not configure partitions with DTS partitioning and the Partition Manager at the same time. If you do, DTS partitioning will be ignored and the Parititon Manager will &amp;quot;win&amp;quot;.&lt;/p&gt;
&lt;p&gt;How can you know if your project uses DTS partitioning or the Partition Manager?&lt;br /&gt;If the Parititon Manager is enabled, that is used. If not, DTS partitioning is used. You can check &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_PARTITION_MANAGER_ENABLED"&gt;CONFIG_PARTITION_MANAGER_ENABLED&lt;/a&gt; to see which one is used.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:150%;"&gt;&lt;strong&gt;How to work with static partitioning&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Okay, so the whole point of the Partition Manager is that it is dynamic.&lt;br /&gt;Then why even allow for static partitioning?&lt;br /&gt;The reason is twofold:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;MCUboot requires that partitioning remain the same between DFUs&lt;/li&gt;
&lt;li&gt;To create custom partitions&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;While you technically can use pm_static.yml in your project at any time, i would argue that you should only do it for one or both of the above reasons. The reason for this is mostly that working with pm_static.yml is hard, because we need to apply our feeble human brains to align hex values manually, instead of making the build system do this automatically for you.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:150%;"&gt;&lt;strong&gt;How to do static partitioning for MCUboot&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Backup your whole build folder from your release build. This is generally a good idea.&lt;/li&gt;
&lt;li&gt;Copy build/partitions.yml to pm_static.yml for your project. This will make sure that project partitioning never changes as long as pm_static.yml stays the same.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As you can see, this does not require you to edit pm_static.yml manually.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:150%;"&gt;&lt;strong&gt;How to create a custom partition&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a pm_static.yml file&lt;/li&gt;
&lt;li&gt;Add only your custom partition&lt;/li&gt;
&lt;li&gt;The partition manager should now dynamically add partitions around your custom partition&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here, you can see that you only need to add custom partitions in pm_static.yml, so you do need minimal editing of pm_static.yml&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:150%;"&gt;&lt;strong&gt;Where are Partition Manager partitions defined&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;These are defined in one of two places:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/main/subsys/partition_manager"&gt;ncs/nrf/subsys/partition_manager&lt;/a&gt;, see pm.yml files&lt;/li&gt;
&lt;li&gt;Child image samples with pm.yml files.
&lt;ol&gt;
&lt;li&gt;Examples:
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/main/boot/zephyr/pm.yml"&gt;mcuboot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/samples/nrf5340/netboot/pm.yml"&gt;netboot (b0n)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/samples/bootloader/pm.yml"&gt;NSIB (b0)&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You should not change these, but they are good to know about for debugging sometimes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NVS, Settings, and general file systems&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So NVS, Settings and file systems are kinda corner cases.&lt;/p&gt;
&lt;p&gt;Firstly, if you enable for example NVS in your project, the partition manager will automatically add a partition named &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/0ebb976e964800e48f91d11cb60e2087828f9803/subsys/partition_manager/pm.yml.nvs#L3"&gt;nvs_storage&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;This means that our internal uses of NVS will use nvs_storage automatically.&lt;br /&gt;You can still use nvs_storage from your application. However, if you use NVS in your application, you can also point your app&amp;#39;s instance of NVS to another partition, usually a custom NVS partition. The reason to use a custom partition is related to flash_map_pm.h, explained below.&lt;/p&gt;
&lt;p&gt;Then we also have &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/include/flash_map_pm.h"&gt;nrf/include/flash_map_pm.h&lt;/a&gt; you can see that we define a partition named &amp;quot;storage_partitions&amp;quot; for multiple different file sysstems. Because of this, if you add both NVS and littlefs to a project, these may end up using the same partition. I must admit that I am a bit unsure to how this will work in practice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/484586?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 23:08:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce16804b-5909-4990-8022-780c3bb0c771</guid><dc:creator>David Ormand</dc:creator><description>&lt;p&gt;The solution I&amp;#39;ve adopted is inspired by&amp;nbsp;&lt;a id="" href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/scripts/partition_manager/partition_manager.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/scripts/partition_manager/partition_manager.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;1. Copy build/partitions.yml to pm_static.yml,&lt;/p&gt;
&lt;p&gt;2. Edit to remove everything in each partition section except for address and size.&lt;/p&gt;
&lt;p&gt;3. Delete the partitions for mcuboot_primary, mcuboot_primary_app, and mcuboot_pad.&amp;nbsp; These partition definitions will be supplied by Partition Manager from MCUboot&amp;#39;s allocations.&amp;nbsp; An error in the build process informs me there must be exactly one gap in the allocation to be used for &amp;quot;app&amp;quot; (which seems to conflict with what the above page says about the default &amp;quot;flash_primary&amp;quot; region).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;4. Insert a new partition, in my case &amp;quot;nvs_storage&amp;quot;.&lt;/p&gt;
&lt;p&gt;5. By default, the Settings subsystem uses the &amp;quot;settings_storage&amp;quot; partition.&amp;nbsp; The default size of this partition is 2 sectors, 0x2000, or 8K.&amp;nbsp; The Zephyr authorities thought 2 would be enough.&amp;nbsp; I don&amp;#39;t think I&amp;#39;m going to be using NVS for program data storage much more than BLE would be, so I&amp;#39;ll set size for &amp;quot;nvs_storage&amp;quot; to 0x2000 also.&lt;/p&gt;
&lt;p&gt;6. The only place to steal 2 sectors is from the primary and secondary image slots.&amp;nbsp; They should be the same.&amp;nbsp; Therefore, steal 1 sector from the gap to eventually be filled in by &amp;quot;mcuboot_primary&amp;quot; and 1 sector from &amp;quot;mcuboot_secondary&amp;quot;.&amp;nbsp; Additionally, adjust the address for &amp;quot;mcuboot_secondary&amp;quot; up by one sector&amp;nbsp;to be adjacent to&amp;nbsp;&amp;quot;mcuboot_primary&amp;quot;.&lt;/p&gt;
&lt;p&gt;In this case, the resulting pm_static.yml looks like:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;mcuboot:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; address: 0x0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; size: 0xc000&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;# Gap from 0x000C000 to 0x00084000 reserved for &amp;quot;app&amp;quot;&lt;br /&gt;# This gap will be filled in with what MCUboot allocates,&lt;br /&gt;# in this case, mcuboot_primary, mcuboot_primary_app, and mcuboot_pad.&lt;br /&gt;mcuboot_secondary:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; address: 0x84000&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; size: 0x78000&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;nvs_storage:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; address: 0xfc000&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; size: 0x2000&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;settings_storage:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; address: 0xfe000&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; size: 0x2000&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;7. In the project source file that implements the NVS filesystem, change the flash device designation to:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;#define NVS_PARTITION&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nvs_storage&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and remember to load fs.sector_count with 2.&lt;/p&gt;
&lt;p&gt;Now, when I build and flash the project and issue my command to dump memory (altered to report the tops of both the NVS and Settings partitions), I get&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFF8001 AC2807FA E8DA3D07 968B0056&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : A6C9D78D 682F7462 FF687361 FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The two-sector Settings block at the end of memory starts at 0xFE000, and there is the same thing I saw earlier.&amp;nbsp; Whatever it is.&lt;/p&gt;
&lt;p&gt;Then I issue some commands to write entries into the NVS filesystem.&amp;nbsp; Dumping the memory, I get&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : 73646401 0000007B FFFFFF00 12FFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : 00000034 73646401 0000007C FFFFFF00&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : 12FFFFFF FFFFFF34 FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FC000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFF8001 AC2807FA E8DA3D07 968B0056&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : A6C9D78D 682F7462 FF687361 FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FE000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The written data is showing up in the hacked-in partition subsequently dedicated to the NVS filesystem.&amp;nbsp; NVS for data storage and NVS for BLE settings are no longer in conflict.&lt;/p&gt;
&lt;p&gt;There may be a more elegant way to accomplish this than essentially forcing Partition Manager to accept manually-assigned allocations, and I would like to know if there is.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/484582?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 20:31:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20edee35-da15-4e69-be1d-66575bec673a</guid><dc:creator>David Ormand</dc:creator><description>&lt;p&gt;My application&amp;nbsp;has a serial command interface (sort of &amp;quot;shell&amp;quot;) in which a command writes a 20-byte object to NVS.&amp;nbsp; I&amp;#39;ve rigged this command to print what it is about to write.&amp;nbsp; I&amp;#39;ve rigged another command to dump a portion at the top of the Settings partition.&amp;nbsp; Which is sized at 0x3000 in prj.conf (per above).&lt;/p&gt;
&lt;p&gt;Start: clear out all flash with nrfjprog --eraseall and then west flash the bootloader and application.&lt;/p&gt;
&lt;p&gt;Note that the NVS filesystem is initialized before bt_enable() and settings_load() are called.&lt;/p&gt;
&lt;p&gt;When I dump the partition portion before doing anything else, I get&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FD000 : FFFF8001 AC2807FA E8DA3D07 968B0056&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FD000 : A6C9D78D 682F7462 FF687361 FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FD000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FD000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m guessing this is something the BLE subsystem writes into the settings.&lt;/p&gt;
&lt;p&gt;Then I command writing the following object to ID 1 in NVS:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;73646401 0000007B FFFFFF00 12FFFFFF 00000034&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;and then dump the partition portion again.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FD000 : 73640001 0000007A E8DA3D00 128B0056&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FD000 : 00000004 682F7462 FF687361 FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FD000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;000FD000 : FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;nvs_write() is overwriting the previous info.&amp;nbsp; Therefore I conclude that NVS filesystem for program data storage and NVS for Settings are not compatible.&amp;nbsp; I&amp;#39;m going to have to set up separate partitions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/484572?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 17:37:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ae89a70-97d4-4af8-9301-4a4579d9f853</guid><dc:creator>David Ormand</dc:creator><description>&lt;p&gt;Interestingly, if&amp;nbsp;CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE is left at the default 2 sectors, and NVS is set up at runtime with 3 sectors, nvs_mount() won&amp;#39;t complain, but (at least) nvs_read() will fail with -EINVAL.&amp;nbsp; So the PARTITION_SIZE has to be set at least as large as what is requested for the NVS filesystem.&amp;nbsp; I do that, and nvs_read() doesn&amp;#39;t complain anymore.&lt;/p&gt;
&lt;p&gt;I have not yet got to the point of seeing how well NVS for data storage cooperates with NVS for BLE settings.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/483136?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 21:09:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:948da8cd-0681-4d5d-af64-137192cd9f17</guid><dc:creator>David Ormand</dc:creator><description>&lt;p&gt;Or perhaps I&amp;#39;m laboring under the misconception that Settings with the NVS backend is using a different flash area than NVS for program data storage.&amp;nbsp; Perhaps the bond info, and anything else stored as Settings, are mixed in with the entries that the program makes for other purposes.&amp;nbsp; But then it would seem that Settings would have an allocation of ID numbers separate from the set available for NVS filesystem.&lt;/p&gt;
&lt;p&gt;Even if this is true, seems odd that nvs_mount() would allow setting up the filesystem in three sectors when there are two available.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/483134?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 20:56:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c0646b5-8917-47e0-b72d-cd62aa45a59f</guid><dc:creator>David Ormand</dc:creator><description>&lt;p&gt;Thanks. That blog article is very helpful. I will have more questions about using flash when my project gets to that point.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been playing with UICR and it will do exactly what I want for semi-permanently storing the unit serial number, and access it from within the code as *(uint32_t *)(0x10001080). Super!&lt;/p&gt;
&lt;p&gt;Now: I hope you can explain this partition management business to me.&lt;/p&gt;
&lt;p&gt;Among other things, this project:&lt;br /&gt;1. Uses BLE and saves bonding info, so I&amp;#39;ve got Settings and BT Settings enabled&lt;br /&gt;2. Uses NVS for saving program data in flash, to survive power cycles&lt;br /&gt;3. Will accept DFU via &amp;quot;serial recovery&amp;quot; in the bootloader.&lt;/p&gt;
&lt;p&gt;The relevant config selections:&lt;br /&gt;CONFIG_FLASH=y&lt;br /&gt;CONFIG_FLASH_MAP=y&lt;br /&gt;CONFIG_FLASH_PAGE_LAYOUT=y&lt;br /&gt;CONFIG_NVS=y&lt;br /&gt;CONFIG_SETTINGS=y&lt;br /&gt;CONFIG_BT_SETTINGS=y&lt;br /&gt;CONFIG_BOOTLOADER_MCUBOOT=y&lt;/p&gt;
&lt;p&gt;For NVS, I&amp;#39;m following the NVS sample. I&amp;#39;m allocating three 4K sectors&lt;/p&gt;
&lt;p&gt;fs.sector_count = 3U;&lt;/p&gt;
&lt;p&gt;The DTS for the nRF52840DK has storage_partition starting at 0xf8000. The code has&lt;/p&gt;
&lt;p&gt;#define NVS_PARTITION storage_partition&lt;br /&gt;#define NVS_PARTITION_DEVICE FIXED_PARTITION_DEVICE(NVS_PARTITION)&lt;br /&gt;#define NVS_PARTITION_OFFSET FIXED_PARTITION_OFFSET(NVS_PARTITION)&lt;/p&gt;
&lt;p&gt;If I print&lt;/p&gt;
&lt;p&gt;fs.offset = NVS_PARTITION_OFFSET;&lt;/p&gt;
&lt;p&gt;I get 0xfe000.&lt;/p&gt;
&lt;p&gt;As previously explained, Partition Manager is overriding the Device Tree allocations. However, so happens this is 0x2000 before the end of memory. How is it allocating three sectors (without throwing any errors) when there&amp;#39;s only two available?&lt;/p&gt;
&lt;p&gt;And where would it be putting the settings?&lt;/p&gt;
&lt;p&gt;If I look through build/zephyr/.config, I find&lt;/p&gt;
&lt;p&gt;CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x2000&lt;/p&gt;
&lt;p&gt;and if I get a partition_manager_report, I get&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;flash_primary (0x100000 - 1024kB):&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;+-------------------------------------------------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;| 0x0: mcuboot (0xc000 - 48kB) |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;+---0xc000: mcuboot_primary (0x79000 - 484kB)-----+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;| 0xc000: mcuboot_pad (0x200 - 512B) |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;+---0xc200: mcuboot_primary_app (0x78e00 - 483kB)-+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;| 0xc200: app (0x78e00 - 483kB) |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;+-------------------------------------------------+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;| 0x85000: mcuboot_secondary (0x79000 - 484kB) |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;| 0xfe000: settings_storage (0x2000 - 8kB) |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;+-------------------------------------------------+&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;What I believe I&amp;#39;m seeing is that there is no NVS partition reported, just a block for the settings, and there&amp;#39;s two 4K sectors. And the space for the secondary image for DFU runs right up to the start of the settings block.&lt;/p&gt;
&lt;p&gt;Apparently, I can&amp;#39;t allocate space for an NVS partition separately from the NVS settings space. The symbol&lt;/p&gt;
&lt;p&gt;CONFIG_PM_PARTITION_SIZE_NVS_STORAGE&lt;/p&gt;
&lt;p&gt;depends on&lt;/p&gt;
&lt;p&gt;CONFIG_NVS &amp;amp;&amp;amp; !CONFIG_SETTINGS_NVS&lt;/p&gt;
&lt;p&gt;and&amp;nbsp;&lt;span&gt;CONFIG_SETTINGS_NVS is True if CONFIG_SETTINGS and CONFIG_NVS are True.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/483027?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 12:03:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dc71376-8127-436d-a470-0ed7d51fd24a</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Short answer: UICR looks like what you need. Specifically &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/uicr.html?cp=5_0_0_3_4_0_2#register.CUSTOMER-0-31"&gt;CUSTOMEr&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This cannot be changed, and you have limited space.&lt;/p&gt;
&lt;p&gt;NVS is more for changeable persistent data, or data that you will add regularly (aka large amounts in the end)&lt;/p&gt;
&lt;p&gt;I will return later and write answers to your context questions.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Maybe &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/persistent-storage-of-keys-and-data-using-the-nrf-connect-sdk"&gt;Persistent storage of keys and data using the nRF Connect SDK&lt;/a&gt; would be of interest in the meantime&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/482870?ContentTypeID=1</link><pubDate>Fri, 10 May 2024 20:50:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e0d3f2e-44ef-42b5-8238-eb82a6f613d5</guid><dc:creator>David Ormand</dc:creator><description>&lt;p&gt;You know what, it just dawned on me there is a much better solution.&amp;nbsp; This is what UICR is intended for.&amp;nbsp; I should change the approach I implemented in the previous product software version.&amp;nbsp; It&amp;#39;s still a fixed memory location suitable for coding into the nrfjprog script.&lt;/p&gt;
&lt;p&gt;Although I think the question is still useful:&amp;nbsp; How can users assert control over how Partition Manager assigns flash memory?&amp;nbsp; Can a new partition be introduced in a way that Partition Manager would respect and manage it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/482869?ContentTypeID=1</link><pubDate>Fri, 10 May 2024 20:44:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61163f2c-6a80-45c4-aa07-6064a28638c9</guid><dc:creator>David Ormand</dc:creator><description>&lt;p&gt;I&amp;#39;m trying to anticipate or counter a potential problem.&lt;/p&gt;
&lt;p&gt;This project I&amp;#39;ve got will use NVS as a data storing facility.&amp;nbsp; It&amp;#39;s also a Bluetooth Central, so the bonding info will be saved.&amp;nbsp; I&amp;#39;m guessing the storage_partition is used for both purposes.&amp;nbsp; Maybe the bonding info is just NVS records.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m also expecting that the flash management method is to mark deleted records rather than actually erasing them, and acquire another flash page as the one currently in use is exhausted.&amp;nbsp; At some point the management system would search the pages for one consisting entirely of deleted records and erase that page.&amp;nbsp; But probably not until the end of the memory region was reached.&amp;nbsp; That is, the end of flash memory.&lt;/p&gt;
&lt;p&gt;But if I have critical information written by an external tool like nrfjprog into a known memory location in flash at a point in product manufacture, and eventually NVS creeps up to and overwrites this information, then units are going to be failing in the field some (possibly lengthy) time after starting their service.&lt;/p&gt;
&lt;p&gt;I was hoping that I could split off a little partition at the end of flash memory (I guess it would have to at least be a page) for this purpose in the Device Tree, but this won&amp;#39;t work if Partition Manager doesn&amp;#39;t respect it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/482211?ContentTypeID=1</link><pubDate>Tue, 07 May 2024 08:41:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3599e979-cc7b-418a-9d51-726aba8866dd</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;You are talking like you are currently seeing an issue, but I can not see that you mention anything specific.&lt;/p&gt;
&lt;p&gt;Do you have an issue now?&lt;br /&gt;Or are you simply trying to think about what could go wrong in the future?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/482096?ContentTypeID=1</link><pubDate>Mon, 06 May 2024 15:22:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da187b5a-c10d-47c8-920a-00e6357c4f67</guid><dc:creator>David Ormand</dc:creator><description>&lt;p&gt;That&amp;#39;s correct and i knew that; I shouldn&amp;#39;t have mentioned DFU (even if that&amp;#39;s my current bugbear).&amp;nbsp; For a Bluetooth device, for storing bond information in a non-volatile way, NVS is set up, and Partition Manager allocates a chunk of flash all the way to the end.&amp;nbsp; Maybe I&amp;#39;ve been lucky, and the bond info is stored at the top of this chunk of flash working down, and it&amp;#39;s never gotten to the bit that I&amp;#39;ve reserved for the serial number.&amp;nbsp; But I suspect that with repeated bonding/unpairing, that region of flash used for bond info will creep down and eventually overwrite what I had naively thought I had reserved for the serial number.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash partitioning</title><link>https://devzone.nordicsemi.com/thread/481975?ContentTypeID=1</link><pubDate>Mon, 06 May 2024 10:53:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8b075ee-c427-4cdb-8ed9-e1fab3b6bec3</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""] Is the stuff in the DTS just a suggestion?[/quote]
&lt;p&gt;The Partition Manager will override DTS.&lt;/p&gt;
[quote user=""]CONFIG_USE_DT_CODE_PARTITION[/quote]
&lt;p&gt;I think we &amp;quot;technically&amp;quot; in the build system use this even with the Partition Manager, we just do it a bit differently.&lt;/p&gt;
[quote user=""]But if partition manager isn&amp;#39;t really paying attention to the partition allocations in DT, how would I tell partition manager to reserve the space and not potentially overwrite it with a DFU or some NVS operation?[/quote]
&lt;p&gt;See &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/topic/multi-image-builds-and-the-partition-manager/"&gt;this devacademy lesson&lt;/a&gt; for some background.&lt;/p&gt;
&lt;p&gt;But to answer what I think you ask for:&lt;/p&gt;
&lt;p&gt;DFU only updates mcuboot_primary and mcuboot_secondary, so the rest of your partitions should be unchanged.&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>