<?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>Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100618/zephyr-nvs-on-an-nrf5340_dk</link><description>Hi 
 I am trying to get the Zephyr NVS working on an nRF5340_DK board. 
 I am using the notes here : 
 And my starting code is based on the example it references: 
 In nrf5340_cpuapp_common.dts, the flash partitions are defined as follows: 
 
 
 The nRF5340</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 13 Jul 2023 18:36:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100618/zephyr-nvs-on-an-nrf5340_dk" /><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/436340?ContentTypeID=1</link><pubDate>Thu, 13 Jul 2023 18:36:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86d0b528-a6fb-4225-a4f4-3c910fe6d59c</guid><dc:creator>garrettb</dc:creator><description>&lt;p&gt;Hi Vidar&lt;/p&gt;
&lt;p&gt;You inadvertently solved my problem.&lt;br /&gt;In my existing project, I modified the pm_static.yml from:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;storage:
  address: 0xfa000
  size: 0x4000
  end_address: 0xfe000
  placement:
  before:
  - storage
  region: flash_primary
user_storage:
  address: 0xfe000
  size: 0x2000
  end_address: 0x100000
  placement:
  before:
  - end
  region: flash_primary
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;user_storage:
  address: 0xfe000
  size: 0x2000
  end_address: 0x100000
  placement:
  before:
  - end
  region: flash_primary

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And everything worked :)&lt;/p&gt;
&lt;p&gt;So the issue was that I must have been messing up the existing &amp;lsquo;storage&amp;rsquo; allocation/definition, and once I removed it from the .yml file, it must be happy with what ever default settings it has from elsewhere.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/436289?ContentTypeID=1</link><pubDate>Thu, 13 Jul 2023 14:22:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5850276-5dcb-4f6b-a117-173993fcf2aa</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Garret,&lt;/p&gt;
&lt;p&gt;I will try to follow up here while Hieu is out of the office. I&amp;#39;m not sure why the program fails to return from your nvs_mount() call. But are you still on SDK v2.1.0? &amp;nbsp;prepared a new test example based on the peripheral_lbs sample and the code snippets you posted here, and it would be great if you could try running this on your end to see if it works for you as well.&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t make much changes to the project.&amp;nbsp;Here is a &amp;#39;diff&amp;#39; of the changes I made to main.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="diff"&gt;diff --git a/src/main.c b/src/main.c
index 7483c69..163a979 100644
--- a/src/main.c
+++ b/src/main.c
@@ -181,6 +181,77 @@ static int init_button(void)
 	return err;
 }
 
+#include &amp;lt;zephyr/drivers/flash.h&amp;gt;
+#include &amp;lt;zephyr/storage/flash_map.h&amp;gt;
+#include &amp;lt;zephyr/fs/nvs.h&amp;gt;
+
+
+static struct nvs_fs fs;
+
+#define RBT_CNT_ID 3
+
+#define STORAGE_NODE_LABEL	user_storage
+
+int my_file_init() 
+{
+	int rc;
+	struct flash_pages_info info;
+	uint32_t reboot_counter = 0U;
+
+	/* define the nvs file system by settings with:
+	 *	sector_size equal to the pagesize,
+	 *	2 sectors
+	 *	starting at FLASH_AREA_OFFSET(STORAGE_NODE_LABEL)
+	 */
+	fs.flash_device = FLASH_AREA_DEVICE(STORAGE_NODE_LABEL);
+
+	if (!device_is_ready(fs.flash_device)) {
+		return -1;
+	}
+
+	fs.offset = FLASH_AREA_OFFSET(STORAGE_NODE_LABEL);
+
+	rc = flash_get_page_info_by_offs(fs.flash_device, fs.offset, &amp;amp;info);
+
+	if (rc) {
+		return -2;
+	}
+	fs.sector_size = info.size;
+	/* Allocate the whole partition to nvs */
+	fs.sector_count = FLASH_AREA_SIZE(STORAGE_NODE_LABEL) / info.size ;
+
+	rc = nvs_mount(&amp;amp;fs);
+
+	if (rc) {
+		return -3;
+	}
+
+	printk(&amp;quot;*** %s partition mounted *** \n&amp;quot;, STRINGIFY(STORAGE_NODE_LABEL));
+	printk(&amp;quot;Start address: 0x%x\n&amp;quot;, (uint32_t) info.start_offset);
+	printk(&amp;quot;Sectors: %d\n&amp;quot;, fs.sector_count);
+
+	/* RBT_CNT_ID is used to store the reboot counter, lets see
+	 * if we can read it from flash
+	 */
+	rc = nvs_read(&amp;amp;fs, RBT_CNT_ID, &amp;amp;reboot_counter, sizeof(reboot_counter));
+	if (rc &amp;gt; 0) { /* item was found, show it */
+		reboot_counter++;
+		(void)nvs_write(&amp;amp;fs, RBT_CNT_ID, &amp;amp;reboot_counter,
+			  sizeof(reboot_counter));
+		printk(&amp;quot;Id: %d, Reboot_counter: %d\n&amp;quot;,
+			RBT_CNT_ID, reboot_counter);
+
+	} else   {/* item was not found, add it */
+		printk(&amp;quot;No Reboot counter found, adding it at id %d\n&amp;quot;,
+		       RBT_CNT_ID);
+		(void)nvs_write(&amp;amp;fs, RBT_CNT_ID, &amp;amp;reboot_counter,
+			  sizeof(reboot_counter));
+	}
+
+	return 0;
+}
+
+
 void main(void)
 {
 	int blink_status = 0;
@@ -241,6 +312,8 @@ void main(void)
 
 	printk(&amp;quot;Advertising successfully started\n&amp;quot;);
 
+	my_file_init();
+
 	for (;;) {
 		dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
 		k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I also added this &amp;#39;pm_static.yml&amp;#39; file to allocate the &amp;#39;user_storage&amp;#39; partition:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;user_storage:
  address: 0xfe000
  size: 0x2000
  end_address: 0x100000
  placement:
  before:
  - end
  region: flash_primary&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Generated Memory report&lt;/strong&gt;&lt;/p&gt;
&lt;p&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/pastedimage1689258051897v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Note: the DTS partitions are ignored when the partition manager is enabled, which is true for any &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/nrf/app_dev/multi_image/index.html#memory-placement"&gt;multi-image&lt;/a&gt; builds.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/peripheral_5F00_lbs_5F00_nvs_5F00_user_5F00_storage.zip"&gt;devzone.nordicsemi.com/.../peripheral_5F00_lbs_5F00_nvs_5F00_user_5F00_storage.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/436112?ContentTypeID=1</link><pubDate>Wed, 12 Jul 2023 23:57:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db61f0ca-d73a-4497-b5db-33da9703e685</guid><dc:creator>garrettb</dc:creator><description>&lt;p&gt;Hi Hieu&lt;/p&gt;
&lt;p&gt;Thanks for the quick response &amp;ndash; and have a great vacation&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f60a.svg" title="Blush"&gt;&amp;#x1f60a;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For anyone else who is going to pick up this thread, I made some more changes and feel I am getting a bit closer, but&amp;hellip;.&lt;br /&gt;So here&amp;rsquo;s my update for now:&lt;/p&gt;
&lt;p&gt;I removed the following two settings from the prj.conf, and confirmed that CONFIG_PARTITION_MANAGER_ENABLED is still set, via some other configuration flag as you suggested:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#CONFIG_PARTITION_MANAGER_ENABLED=y
#CONFIG_SETTINGS_NVS_SECTOR_COUNT=6&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I moved the pm_static.yml to the source directory, and modified the contents, which are now:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;storage:
  address: 0xfa000
  size: 0x4000
  end_address: 0xfe000
  placement:
  before:
  - user_storage
  region: flash_primary
user_storage:
  address: 0xfe000
  size: 0x2000
  end_address: 0x100000
  placement:
  before:
  - end
  region: flash_primary&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I reverted the makefile back to its original:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;set(PM_STATIC_YML_FILE
  ${CMAKE_CURRENT_SOURCE_DIR}/boards/pm_static_${BOARD}.yml
  )&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The build system detects the .yml file and uses it.&lt;/p&gt;
&lt;p&gt;So now, I go to use the partition(s) mentioned in the .yml fiule.&lt;/p&gt;
&lt;p&gt;In my NVS code, I have the following init function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int my_file_init() {
	int rc = 0, cnt = 0, cnt_his = 0;
	char buf[16];
	uint8_t key[8], longarray[128];
	struct flash_pages_info info;

	is_initialised = false;

	reboot_counter = 0U;

	/* define the nvs file system by settings with:
	 *	sector_size equal to the pagesize,
	 *	2 sectors
	 *	starting at FLASH_AREA_OFFSET(STORAGE_NODE_LABEL)
	 */
	fs.flash_device = FLASH_AREA_DEVICE(STORAGE_NODE_LABEL);

	if (!device_is_ready(fs.flash_device)) {
		return -1;
	}

	fs.offset = FLASH_AREA_OFFSET(STORAGE_NODE_LABEL);

	rc = flash_get_page_info_by_offs(fs.flash_device, fs.offset, &amp;amp;info);

	// info.size = 0x1000
	// fs.offset = 0xFE000
	// info.index = 254
	// info.offset = 0xFE000

	if (rc) {
		return -2;
	}
	fs.sector_size = info.size;
	fs.sector_count = 2U;

	rc = nvs_mount(&amp;amp;fs);

	if (rc) {
		return -3;
	}

	:
	:&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If I define STORAGE_NODE_LABEL as &amp;lsquo;storage&amp;rsquo;, the code runs / works.&lt;br /&gt;However, I assume I might be using storage space that might be required by Bluetooth, or another system,&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;define STORAGE_NODE_LABEL storage
//#define STORAGE_NODE_LABEL user_storage&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So, then I defineSTORAGE_NODE_LABEL as &amp;lsquo;user_storage&amp;rsquo;, the code runs&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;//define STORAGE_NODE_LABEL storage
#define STORAGE_NODE_LABEL user_storage&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But it crashes here (does not return from the call):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	rc = nvs_mount(&amp;amp;fs);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here are the verified values before the call to nvs_mount()&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	// fs.offset = 0xFE000
	// info.size = 0x1000
	// info.index = 254
	// info.offset = 0xFE000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So, even though the .yml file is &amp;ldquo;accepted&amp;rdquo; and used, as soon as I use the &amp;ldquo;user_storage&amp;rdquo; region, the code does not work.&lt;/p&gt;
&lt;p&gt;By the way, the reason I am using addresses: 0xFA000 (size 0x6000) and 0xFE000 (size 0x2000), is because of the addresses used in nrf5340_cpuapp_comon.dts&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;0x00000000 0x00010000&amp;gt;;
		};
		slot0_partition: partition@10000 {
			label = &amp;quot;image-0&amp;quot;;
		};
		slot0_ns_partition: partition@50000 {
			label = &amp;quot;image-0-nonsecure&amp;quot;;
		};
		slot1_partition: partition@80000 {
			label = &amp;quot;image-1&amp;quot;;
		};
		slot1_ns_partition: partition@c0000 {
			label = &amp;quot;image-1-nonsecure&amp;quot;;
		};
		scratch_partition: partition@f0000 {
			label = &amp;quot;image-scratch&amp;quot;;
			reg = &amp;lt;0x000f0000 0xa000&amp;gt;;
		};
		storage_partition: partition@fa000 {
			label = &amp;quot;storage&amp;quot;;
			reg = &amp;lt;0x000fa000 0x00006000&amp;gt;;
		};
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/436079?ContentTypeID=1</link><pubDate>Wed, 12 Jul 2023 18:38:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b9a3ef2-acc5-4430-b298-1f799b62ef70</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Garrett,&lt;/p&gt;
[quote user="garrettb"]I read through those posts, and tried to modify my code based on my understanding of what they were saying, but I obviously don’t know what I am doing&amp;nbsp;&lt;span title="Frowning2"&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/8304.svg" style="max-height:32px;max-width:32px;" alt="Frowning2" /&gt;&lt;/span&gt;[/quote]
&lt;p&gt;I know that feeling. It took me some&amp;nbsp;bits of time to fully understand all that information too.&lt;/p&gt;
&lt;p&gt;I can only answer some of your points quickly today, because I will only work for a bit more today and then go on vacation from tomorrow.&amp;nbsp;However, let&amp;#39;s go over what I can, and if that turns out insufficient, someone else will surely follow up with you in future replies.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;P.s: My apologies for the repeated edits. I&amp;nbsp;keep&amp;nbsp;realizing mistakes I made writing this answer too quickly. The time pressure got the better of me &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/p&gt;
[quote user="garrettb"]&lt;p&gt;&lt;strong&gt;Point 1&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I was NOT using the CONFIG_PARTITION_MANAGER_ENABLED setting in my prj.conf file, but now I am:&lt;/p&gt;[/quote]
&lt;p&gt;I did not mean that you&amp;nbsp;&lt;em&gt;should&lt;/em&gt; use Partition Manager, but that it could have been set behind the scene. Some Kconfig can set other Kconfig. Take for example,&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/kconfig/index.html#CONFIG_LOG"&gt;CONFIG_LOG&lt;/a&gt;&amp;nbsp;will set&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/kconfig/index.html#CONFIG_PRINTK"&gt;CONFIG_PRINTK&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To check if a configuration is set or not, you can look in the &lt;em&gt;&amp;lt;build folder&amp;gt;/zephyr/.config&lt;/em&gt; file.&lt;/p&gt;
&lt;p&gt;I am ~90% sure that the Partition Manager is already enabled before you set it in prj.conf, so I will move forward with that assumption.&lt;/p&gt;
[quote user="garrettb"]&lt;p&gt;&lt;strong&gt;Point 2&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I have removed my overlay file, since my understanding is that the .yaml file will be used instead&lt;/p&gt;[/quote]
&lt;p&gt;With the Partition Manager enabled, this is the correct approach.&lt;/p&gt;
[quote user="garrettb"]&lt;p&gt;&lt;strong&gt;Point 3&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I defined a new yaml file: pm_static.yaml&lt;br /&gt;I didn’t know how to get this file included in the project, so I placed this in the boards directory, and modified the makelist file to use this file instead:&lt;/p&gt;[/quote]
&lt;p&gt;Please don&amp;#39;t modify the CMake file like that.&amp;nbsp;You can refer to &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/nrf/scripts/partition_manager/partition_manager.html#partition-manager"&gt;the Partition Manager documentation&lt;/a&gt; to see how to use pm_static.yml file.&lt;/p&gt;
&lt;p&gt;I unfortunately don&amp;#39;t have time to review your pm_static.yml for now. Please retry&amp;nbsp;after understanding my answer today, and if you still have issues, you can reply here and&amp;nbsp;another engineer will answer you in my stead.&lt;/p&gt;
[quote user="garrettb"]&lt;p&gt;&lt;strong&gt;Point 4&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I don’t understand how/why they are using the CONFIG_SETTINGS_NVS_SECTOR_COUNT setting, in their prj.conf file, but I went ahead and included it:&lt;/p&gt;[/quote]
&lt;p&gt;The config is discussed in the DevZone question that I linked:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/77781/problem-to-read-back-flash-with-nvs-when-concurrent-use-with-bluetooth/331360"&gt;RE: Problem to read back flash with NVS when concurrent use with Bluetooth&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, I understand that it is quite long. In short, Zephyr RTOS stores some persistent data using &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/zephyr/services/settings/index.html"&gt;the Zephyr Settings subsystem&lt;/a&gt;. This subsystem by default use NVS as a backend,&amp;nbsp;and store data in the same partition named &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;storage&lt;/span&gt;. It stores data within the first &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;n&lt;/span&gt; sectors, where &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;n&lt;/span&gt; is &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/kconfig/index.html#CONFIG_SETTINGS_NVS_SECTOR_COUNT"&gt;CONFIG_SETTINGS_NVS_SECTOR_COUNT&lt;/a&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Therefore, &lt;strong&gt;if you want to share the same &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;storage&lt;/span&gt; partition&lt;/strong&gt;, you don&amp;#39;t need to change CONFIG_SETTINGS_NVS_SECTOR_COUNT, but you need to offset your data location by that many sectors.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It seems you don&amp;#39;t want that, from point 5, so you don&amp;#39;t have to worry about it.&lt;/span&gt;&lt;/p&gt;
[quote user="garrettb"]&lt;p&gt;&lt;strong&gt;Point 5&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;My code now tries to refer to this storage section:&lt;/p&gt;[/quote]
&lt;p&gt;&lt;span&gt;It is probably&amp;nbsp;the pm_static.yml file still not working properly. First, please try to&amp;nbsp;set it up&amp;nbsp;like I answered above. If the issue persists, please reply, and someone will help you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Finally, it is the summer vacation&amp;nbsp;season here, so we are understaffed. Please excuse some delays in responses in the coming weeks.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/436076?ContentTypeID=1</link><pubDate>Wed, 12 Jul 2023 18:12:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c24f445-cc7b-42eb-bae4-5759176f13a4</guid><dc:creator>garrettb</dc:creator><description>&lt;p&gt;Hi Hieu&lt;/p&gt;
&lt;p&gt;I read through those posts, and tried to modify my code based on my understanding of what they were saying, but I obviously don&amp;rsquo;t know what I am doing&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/2639.svg" title="Frowning2"&gt;&amp;#x2639;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Point 1&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I was NOT using the CONFIG_PARTITION_MANAGER_ENABLED setting in my prj.conf file, but now I am:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_PARTITION_MANAGER_ENABLED=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Point 2&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I have removed my overlay file, since my understanding is that the .yaml file will be used instead&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Point 3&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I defined a new yaml file: pm_static.yaml&lt;br /&gt;I didn&amp;rsquo;t know how to get this file included in the project, so I placed this in the boards directory, and modified the makelist file to use this file instead:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# set(PM_STATIC_YML_FILE
# ${CMAKE_CURRENT_SOURCE_DIR}/boards/pm_static_${BOARD}.yml
# )
set(PM_STATIC_YML_FILE
${CMAKE_CURRENT_SOURCE_DIR}/boards/pm_static.yml
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is the contents of the yaml file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;user_storage:
address: 0xfa000
size: 0x2000
end_address:0xfc000
placement:
before:
- settings_storage
region: flash_primary
settings_storage:
address: 0xfc000
size: 0x4000
end_address: 0x100000
placement:
before:
- end
region: flash_primary&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Point 4&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t understand how/why they are using the CONFIG_SETTINGS_NVS_SECTOR_COUNT setting, in their prj.conf file, but I went ahead and included it:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_SETTINGS_NVS_SECTOR_COUNT=6&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I used the value 6, because user_storage uses 2 sectors, and settings_storage uses 4 sectors&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Point 5&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;My code now tries to refer to this storage section:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// #define STORAGE_NODE_LABEL storage
#define STORAGE_NODE_LABEL user_storage

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I still get an error:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;#39;PM_PM_PM_user_storage_ID_LABEL_OFFSET&amp;#39; undeclared (first use in this function)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/434545?ContentTypeID=1</link><pubDate>Tue, 04 Jul 2023 18:58:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8615800-2396-4aeb-830d-2334d5ee83ff</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Garrett,&lt;/p&gt;
&lt;p&gt;Thank you for your patience.&lt;/p&gt;
&lt;p&gt;Regarding question Three:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;For the user storage method&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;Can you check&amp;nbsp;if &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.0/kconfig/index.html#CONFIG_PARTITION_MANAGER_ENABLED"&gt;CONFIG_PARTITION_MANAGER_ENABLED&lt;/a&gt; is enabled in your project? I think it most likely is,&amp;nbsp;because&amp;nbsp;you have a build error mentioned a symbol&amp;nbsp;that only appears when Partition Manager is in use: &amp;quot;PM_PM_PM_userstorage_ID_LABEL_OFFSET.&amp;quot; (PM stands for Partition Manager).&lt;/p&gt;
&lt;p&gt;As you still have the Partition Manager enabled, you have to use pm_static.yml to define additional partitions. Changes in .dts do not have any effects.&lt;/p&gt;
&lt;p&gt;I think that you already see how to use pm_static.yml to define partitions from your earlier reply.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;For the storage partition sharing method&lt;/strong&gt;:&lt;/p&gt;
[quote user="garrettb"]&lt;p&gt;My code initialises the Flash are successfully, and increments the reboot counter on each reboot.&lt;/p&gt;
&lt;p&gt;I don’t know what this &lt;strong&gt;storage_partition&lt;/strong&gt; is defined for (I think Nordic’s BLE Peripheral UART example was my application starting point).&lt;br /&gt;So, I am guessing I shouldn’t really use this partition, as it is.&lt;/p&gt;[/quote]
&lt;p&gt;Your guess is correct. The storage partition is used by the Zephyr RTOS by default to store its Zephyr Settings.&amp;nbsp;You can use this partition to store your data from at offset &lt;strong&gt;out of&lt;/strong&gt; the Settings range.&amp;nbsp;I still recommend your own storage partition over this. However, if you are interest, Vidar explained this in detail in this DevZone question. Please try to go over the entire discussion.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/77781/problem-to-read-back-flash-with-nvs-when-concurrent-use-with-bluetooth"&gt;Problem to read back flash with NVS when concurrent use with Bluetooth&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Vidar also provides a sample code that does this. His sample code is based on a project that uses the Partition Manager. However, you can refer to the code where he&amp;nbsp;initializes NVS with offset calculated from&amp;nbsp;CONFIG_SETTINGS_NVS_SECTOR_COUNT.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/93394/nvs-not-compatible-with-mcuboot"&gt;NVS not compatible with MCUBOOT&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I understand that it can be a lot to take in. Please let me know if something is still&amp;nbsp;confusing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/433329?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2023 18:47:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8401710b-30cb-41d3-a6be-8c66f778cd65</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Garrett,&lt;/p&gt;
&lt;p&gt;Please be informed that I am still around and will continue to&amp;nbsp;help you. However, I am on sick leave at the moment, and my response are therefore delayed. I hope you could wait.&lt;/p&gt;
&lt;p&gt;Meanwhile, I can give these quick answers to your questions:&lt;/p&gt;
[quote user="garrettb"]&lt;strong&gt;One&lt;/strong&gt; – why is the storage_partition already defined in the nrf5340_cpuapp_common.dts file[/quote]
&lt;p&gt;The&amp;nbsp;storage_partition is the default partition for several Zephyr features, such as LittleFS and NVS. They are predefined for most if not all Nordic boards. For example, it is also defined for the nrf52840dk board:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.3.99-ncs1/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts#L278-L285"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.3.99-ncs1/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts#L278-L285&lt;/a&gt;.&lt;/p&gt;
[quote user="garrettb"]&lt;strong&gt;Two&lt;/strong&gt; – should I define my own user storage partition, to store my own application variables[/quote]
&lt;p&gt;This is one approach to it.&lt;/p&gt;
&lt;p&gt;Another approach is to store your data in the same partition, but at other sectors.&lt;/p&gt;
[quote user="garrettb"]&lt;strong&gt;Three&lt;/strong&gt; – If so, what am I missing / doing wrong, when trying to define the new userstorage partition[/quote]
&lt;p&gt;I cannot look into&amp;nbsp;this yet. Let me do that when I return to office.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/432788?ContentTypeID=1</link><pubDate>Fri, 23 Jun 2023 23:19:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b47b511b-4225-49af-9556-2563cdce6519</guid><dc:creator>garrettb</dc:creator><description>&lt;p&gt;Hi Hieu&lt;/p&gt;
&lt;p&gt;Thanks again for your response.&lt;/p&gt;
&lt;p&gt;A lot of it is very difficult for me to understand, but I will worry about that at a later stage, when I am implementing DFU.&lt;/p&gt;
&lt;p&gt;For now, I just want to deal with the basic system.&lt;/p&gt;
&lt;p&gt;I have a solution which works, using the default DTS settings for flash0. It is based on Zephyr&amp;rsquo;s NVBS sample project (nRF Connect SDK v2.1.0).&lt;br /&gt;I will detail the code and settings below.&lt;/p&gt;
&lt;p&gt;I am using the &lt;strong&gt;storage_partition&lt;/strong&gt; area that was already defined in the nrf5340_cpuapp_common.dts file.&lt;/p&gt;
&lt;p&gt;I refer to this partition at the start of my code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define STORAGE_NODE_LABEL storage
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;My code initialises the Flash are successfully, and increments the reboot counter on each reboot.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t know what this &lt;strong&gt;storage_partition&lt;/strong&gt; is defined for (I think Nordic&amp;rsquo;s BLE Peripheral UART example was my application starting point).&lt;br /&gt;So, I am guessing I shouldn&amp;rsquo;t really use this partition, as it is.&lt;br /&gt;This is why I try to define a new flash partition using a small space from this storage_partition.&lt;/p&gt;
&lt;p&gt;I try to define this new &lt;strong&gt;userstorage&lt;/strong&gt; partition in my overlay file, and refer to it in my code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define STORAGE_NODE_LABEL userstorage
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But while I rebuild, I get the following error:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;C:\Users\me\ncs\v2.1.0\nrf\include\flash_map_pm.h:39:11: error: &amp;#39;PM_PM_PM_userstorage_ID_LABEL_OFFSET&amp;#39; undeclared (first use in this function)
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;So my three questions for now:&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;One&lt;/strong&gt; &amp;ndash; why is the storage_partition already defined in the nrf5340_cpuapp_common.dts file&lt;br /&gt;&lt;strong&gt;Two&lt;/strong&gt; &amp;ndash; should I define my own user storage partition, to store my own application variables&lt;br /&gt;&lt;strong&gt;Three&lt;/strong&gt; &amp;ndash; If so, what am I missing / doing wrong, when trying to define the new userstorage partition&lt;/p&gt;
&lt;p&gt;Here is my code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// ................................................................................

static struct nvs_fs fs;

#define STORAGE_NODE_LABEL storage
//#define STORAGE_NODE_LABEL userstorage	&amp;lt;-- can&amp;#39;t get this working

/* 1000 msec = 1 sec */
#define SLEEP_TIME      100
/* maximum reboot counts, make high enough to trigger sector change (buffer */
/* rotation). */
#define MAX_REBOOT 400

#define ADDRESS_ID 1
#define KEY_ID 2
#define RBT_CNT_ID 3
#define STRING_ID 4
#define LONG_ID 5

// ................................................................................

uint32_t reboot_counter;
uint32_t reboot_counter_his;

// ................................................................................

int nvs_file_init() {
	int rc = 0, cnt = 0, cnt_his = 0;
	char buf[16];
	uint8_t key[8], longarray[128];
	struct flash_pages_info info;

	printk(&amp;quot;nsv_init - start\n&amp;quot;);

	reboot_counter = 0U;

	/* define the nvs file system by settings with:
	 *	sector_size equal to the pagesize,
	 *	3 sectors
	 *	starting at FLASH_AREA_OFFSET(STORAGE_NODE_LABEL)
	 */
	fs.flash_device = FLASH_AREA_DEVICE(STORAGE_NODE_LABEL);
	if (!device_is_ready(fs.flash_device)) {
		printk(&amp;quot;nsv_init - Flash device %s is not ready\n&amp;quot;, fs.flash_device-&amp;gt;name);
		return -1;
	}
	fs.offset = FLASH_AREA_OFFSET(STORAGE_NODE_LABEL);
	rc = flash_get_page_info_by_offs(fs.flash_device, fs.offset, &amp;amp;info);
	if (rc) {
		printk(&amp;quot;nsv_init - Unable to get page info\n&amp;quot;);
		return -2;
	}
	fs.sector_size = info.size;
	fs.sector_count = 3U;

	rc = nvs_mount(&amp;amp;fs);
	if (rc) {
		printk(&amp;quot;nsv_init - Flash Init failed\n&amp;quot;);
		return -3;
	}

	printk(&amp;quot;nsv_init - ADDRESS_ID\n&amp;quot;);

	/* ADDRESS_ID is used to store an address, lets see if we can
	 * read it from flash, since we don&amp;#39;t know the size read the
	 * maximum possible
	 */
	rc = nvs_read(&amp;amp;fs, ADDRESS_ID, &amp;amp;buf, sizeof(buf));
	if (rc &amp;gt; 0) { /* item was found, show it */
		printk(&amp;quot;nsv_init - Id: %d, Address: %s\n&amp;quot;, ADDRESS_ID, buf);
	} else   {/* item was not found, add it */
		strcpy(buf, &amp;quot;192.168.1.1&amp;quot;);
		printk(&amp;quot;nsv_init - No address found, adding %s at id %d\n&amp;quot;, buf,
		       ADDRESS_ID);
		(void)nvs_write(&amp;amp;fs, ADDRESS_ID, &amp;amp;buf, strlen(buf)+1);
	}

	printk(&amp;quot;nsv_init - KEY_ID\n&amp;quot;);

	/* KEY_ID is used to store a key, lets see if we can read it from flash
	 */
	rc = nvs_read(&amp;amp;fs, KEY_ID, &amp;amp;key, sizeof(key));
	if (rc &amp;gt; 0) { /* item was found, show it */
		printk(&amp;quot;nsv_init - Id: %d, Key: &amp;quot;, KEY_ID);
		for (int n = 0; n &amp;lt; 8; n++) {
			printk(&amp;quot;%x &amp;quot;, key[n]);
		}
		printk(&amp;quot;\n&amp;quot;);
	} else   {/* item was not found, add it */
		printk(&amp;quot;nsv_init - No key found, adding it at id %d\n&amp;quot;, KEY_ID);
		key[0] = 0xFF;
		key[1] = 0xFE;
		key[2] = 0xFD;
		key[3] = 0xFC;
		key[4] = 0xFB;
		key[5] = 0xFA;
		key[6] = 0xF9;
		key[7] = 0xF8;
		(void)nvs_write(&amp;amp;fs, KEY_ID, &amp;amp;key, sizeof(key));
	}

	printk(&amp;quot;nsv_init - RBT_CNT_ID\n&amp;quot;);

	/* RBT_CNT_ID is used to store the reboot counter, lets see
	 * if we can read it from flash
	 */
	rc = nvs_read(&amp;amp;fs, RBT_CNT_ID, &amp;amp;reboot_counter, sizeof(reboot_counter));
	if (rc &amp;gt; 0) { /* item was found, show it */
		printk(&amp;quot;nsv_init - Id: %d, Reboot_counter: %d\n&amp;quot;,
			RBT_CNT_ID, reboot_counter);
	} else   {/* item was not found, add it */
		printk(&amp;quot;nsv_init - No Reboot counter found, adding it at id %d\n&amp;quot;,
		       RBT_CNT_ID);
		(void)nvs_write(&amp;amp;fs, RBT_CNT_ID, &amp;amp;reboot_counter,
			  sizeof(reboot_counter));
	}

	printk(&amp;quot;nsv_init - STRING_ID\n&amp;quot;);

	/* STRING_ID is used to store data that will be deleted,lets see
	 * if we can read it from flash, since we don&amp;#39;t know the size read the
	 * maximum possible
	 */
	rc = nvs_read(&amp;amp;fs, STRING_ID, &amp;amp;buf, sizeof(buf));
	if (rc &amp;gt; 0) {
		/* item was found, show it */
		printk(&amp;quot;nsv_init - Id: %d, Data: %s\n&amp;quot;,
			STRING_ID, buf);
		/* remove the item if reboot_counter = 10 */
		if (reboot_counter == 10U) {
			(void)nvs_delete(&amp;amp;fs, STRING_ID);
		}
	} else   {
		/* entry was not found, add it if reboot_counter = 0*/
		if (reboot_counter == 0U) {
			printk(&amp;quot;nsv_init - Id: %d not found, adding it\n&amp;quot;,
			STRING_ID);
			strcpy(buf, &amp;quot;DATA&amp;quot;);
			(void)nvs_write(&amp;amp;fs, STRING_ID, &amp;amp;buf, strlen(buf) + 1);
		}
	}

	printk(&amp;quot;nsv_init - LONG_ID\n&amp;quot;);

	/* LONG_ID is used to store a larger dataset ,lets see if we can read
	 * it from flash
	 */
	rc = nvs_read(&amp;amp;fs, LONG_ID, &amp;amp;longarray, sizeof(longarray));
	if (rc &amp;gt; 0) {
		/* item was found, show it */
		printk(&amp;quot;nsv_init - Id: %d, Longarray: &amp;quot;, LONG_ID);
		for (int n = 0; n &amp;lt; sizeof(longarray); n++) {
			printk(&amp;quot;%x &amp;quot;, longarray[n]);
		}
		printk(&amp;quot;\n&amp;quot;);
	} else   {
		/* entry was not found, add it if reboot_counter = 0*/
		if (reboot_counter == 0U) {
			printk(&amp;quot;nsv_init - Longarray not found, adding it as id %d\n&amp;quot;,
			       LONG_ID);
			for (int n = 0; n &amp;lt; sizeof(longarray); n++) {
				longarray[n] = n;
			}
			(void)nvs_write(
				&amp;amp;fs, LONG_ID, &amp;amp;longarray, sizeof(longarray));
		}
	}


	printk(&amp;quot;nsv_init - end\n&amp;quot;);

	return (0);

}


void nvs_file_test() {
	ssize_t num_bytes;
	int rc;
	int cnt_his;

	printk(&amp;quot;nvs_test - start: reboot_counter = %d\n&amp;quot;, reboot_counter);

	// Increment reboot counter, that was read after boot up
	reboot_counter++;
	// Save the updated counter to flash
	num_bytes = nvs_write(&amp;amp;fs, RBT_CNT_ID, &amp;amp;reboot_counter, sizeof(reboot_counter));
	printk(&amp;quot;nvs_test - nvs_write: reboot_counter = %d, num_bytes or err = %d\n&amp;quot;, reboot_counter, num_bytes);

	// Add a delay
	k_sleep(K_MSEC(100));
	printk(&amp;quot;nvs_test - wake up 3\n&amp;quot;);

	// Calculate space avaiable
	num_bytes = nvs_calc_free_space(&amp;amp;fs);
	printk(&amp;quot;nvs_test - nvs_calc_free_space- before: num_bytes or err = %d\n&amp;quot;, num_bytes);

	printk(&amp;quot;nvs_test - end\n&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;From the DTS file:&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;0x00000000 0x00010000&amp;gt;;
		};
		slot0_partition: partition@10000 {
			label = &amp;quot;image-0&amp;quot;;
		};
		slot0_ns_partition: partition@50000 {
			label = &amp;quot;image-0-nonsecure&amp;quot;;
		};
		slot1_partition: partition@80000 {
			label = &amp;quot;image-1&amp;quot;;
		};
		slot1_ns_partition: partition@c0000 {
			label = &amp;quot;image-1-nonsecure&amp;quot;;
		};
		scratch_partition: partition@f0000 {
			label = &amp;quot;image-scratch&amp;quot;;
			reg = &amp;lt;0x000f0000 0xa000&amp;gt;;
		};
		storage_partition: partition@fa000 {
			label = &amp;quot;storage&amp;quot;;
			reg = &amp;lt;0x000fa000 0x00006000&amp;gt;;
		};
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;From my overlay file:&lt;br /&gt;(If I use this, and refer to &lt;strong&gt;userstorage&lt;/strong&gt; at the top of my file, I get the build error mentioned at the start of this message)&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;;
		storage_partition: partition@fa000 {
			label = &amp;quot;storage&amp;quot;;
			reg = &amp;lt;0x000fa000 0x00004000&amp;gt;;
		};
		user_partition: partition@fe000 {
			label = &amp;quot;userstorage&amp;quot;;
			reg = &amp;lt;0x000fe000 0x00002000&amp;gt;;
		};
	};
};&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/430581?ContentTypeID=1</link><pubDate>Mon, 12 Jun 2023 19:12:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6bc74b2-d6b3-49a7-ab3d-034a8d6dd3ba</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Garett,&lt;/p&gt;
&lt;p&gt;Ah,&lt;/p&gt;
[quote user="garrettb"]Q1:&lt;br /&gt;I couldn&amp;#39;t find anything, but did they define this &amp;quot;custom_nvs_storage&amp;quot; partition in an overlay file - similar to the way I tried to define my &amp;quot;user_partition&amp;quot;?[/quote]
&lt;p&gt;They didn&amp;#39;t.&lt;/p&gt;
&lt;p&gt;My apologies. I missed the difference in your setup vs. theirs. Let me explain, and it will answer the rest the &amp;quot;why&amp;quot; for Q1 and all of Q2.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;In that DevZone question, they are using the MCUboot Bootloader in order to enable DFU. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;In NCS, using MCUboot (or any other kind of &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.0/nrf/getting_started/modifying.html#child-images"&gt;child image&lt;/a&gt;) automatically enable &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.0/nrf/scripts/partition_manager/partition_manager.html#partition-manager"&gt;the Partition Manager&lt;/a&gt;. The Partition Manager will supersede the partitioning done in DTS, including the overlay.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We can proceed without further details; but if you are interested, I wrote about the details of how&amp;nbsp;Partition Manager supersedes the DTS partitions in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/98868/ncs-mcuboot-and-nvs/421284"&gt;this DevZone answer.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;pm_static.yml provides a static (developer configured)&amp;nbsp;configuration of the Partition Manager.&lt;/p&gt;
&lt;p&gt;For the next steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you don&amp;#39;t plan to use the Partition Manager, you can just use your overlay partitioning like you are doing. You can still refer to the code part&amp;nbsp;from&amp;nbsp;that sample.&lt;/li&gt;
&lt;li&gt;If you foresee yourself&amp;nbsp;needing&amp;nbsp;DFU, you can go ahead and look into the Partition Manager solution.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/430311?ContentTypeID=1</link><pubDate>Sat, 10 Jun 2023 14:34:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74f71b32-572f-42ce-a35f-31dfa8571700</guid><dc:creator>garrettb</dc:creator><description>&lt;p&gt;Hi Hieu&lt;/p&gt;
&lt;p&gt;Thank you for your response.&lt;br /&gt;Perhaps I am missing something - I read through that post and downloaded the minimal sample that they were discussing.&lt;/p&gt;
&lt;p&gt;I can see the contents of the pm_static.yml file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;custom_nvs_storage:
  address: 0xfc000
  end_address: 0x100000
  region: flash_primary
  size: 0x4000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Which indicates that there is a custom partition (custom_nvs_storage) of size 0x4000.&lt;br /&gt;And the code in main.c uses this partition, e.g.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define NVS_PARTITION		custom_nvs_storage
#define NVS_PARTITION_DEVICE	FIXED_PARTITION_DEVICE(NVS_PARTITION)
#define NVS_PARTITION_OFFSET	FIXED_PARTITION_OFFSET(NVS_PARTITION)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have two questions:&lt;/p&gt;
&lt;p&gt;Q1:&lt;br /&gt;I couldn&amp;#39;t find anything, but did they define this &amp;quot;custom_nvs_storage&amp;quot; partition in an overlay file - similar to the way I tried to define my &amp;quot;user_partition&amp;quot;?&lt;br /&gt;Q2:&lt;br /&gt;Did they manually edit the pm_static.yml file (and so I should do the same)?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Garrett&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr NVS on an nRF5340_DK</title><link>https://devzone.nordicsemi.com/thread/430221?ContentTypeID=1</link><pubDate>Fri, 09 Jun 2023 12:01:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1592e14-93f6-4961-974a-2158118f87a8</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Garrett,&lt;/p&gt;
&lt;p&gt;There is a DevZone case on this topic in the past. It is about safely using NVS to store data safely without overwriting&amp;nbsp;other kernel storage in general.&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/97525/setting-and-using-nvs-and-bt-settings-with-static-partition-manager"&gt;Setting and using NVS and BT Settings with Static Partition Manager&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;They discuss the solutions, and an example doing exactly what you are trying to do is&amp;nbsp;discussed and provided at the end.&lt;/p&gt;
&lt;p&gt;Could you please take a look and&amp;nbsp;see if it helps?&lt;/p&gt;
&lt;p&gt;If you still have difficulties then, I will be happy to investigate with you.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>