<?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>Issue with flash partitions in NCS 1.7.0 on nRF9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80581/issue-with-flash-partitions-in-ncs-1-7-0-on-nrf9160</link><description>Hi, 
 I&amp;#39;ve been trying to modify the flash partitions in the nvs example provided in ncs 1.7.0, namely, I want to greatly increase the size of the storage partition so I can log data there. I had been working in ncs 1.499, and I used the method that most</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Jul 2022 06:48:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80581/issue-with-flash-partitions-in-ncs-1-7-0-on-nrf9160" /><item><title>RE: Issue with flash partitions in NCS 1.7.0 on nRF9160</title><link>https://devzone.nordicsemi.com/thread/376880?ContentTypeID=1</link><pubDate>Thu, 14 Jul 2022 06:48:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6df33ba-584e-464c-a9ce-a575114b881c</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Jacob,&lt;/p&gt;
&lt;p&gt;I managed to get this working on my nRF52832.&amp;nbsp; There were some minor changes to the example code that I needed to make to initialise my flash storage correctly, and be able to access the sections of flash I wanted to.&amp;nbsp; I&amp;#39;m using the v2.0.0 of the SDK though, so not sure if this will apply to your situation&lt;/p&gt;
&lt;p&gt;I put in a static partition that looks like this (this is basically my pm_static.yml file)&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;user_storage:
  address: 0x7a000
  size: 0x2000
  placement:
    before: 
    - file_storage
  region: flash_primary
file_storage:
  address: 0x7c000
  size: 0x2000
  placement:
    before: 
    - settings_storage
  region: flash_primary
settings_storage:
  address: 0x7e000
  size: 0x2000
  placement:
    before:
    - end
  region: flash_primary
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The user_storage is where I&amp;#39;m storing my data.&amp;nbsp; The file_storage is for some future work (trying to implement a littlefs structure in flash) and the settings_storage is where all the BLE, etc stuff gets stored.&amp;nbsp; This all fits into the area designated as &amp;quot;storage&amp;quot; in the .dts for my board (from 0x7a000 to 0x80000)&lt;/p&gt;
&lt;p&gt;This is how I then initialise everything:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define STORAGE_NODE_LABEL storage
#define NVS_SECTOR_COUNT 2

struct flash_pages_info info;
static struct nvs_fs fs;

int16_t flash_initialise(void)
{
    int16_t rc;

	fs.flash_device = FLASH_AREA_DEVICE(STORAGE_NODE_LABEL);
	if (!device_is_ready(fs.flash_device)) {
		#ifdef DEBUG_NVS
			printk(&amp;quot;Flash device %s is not ready\n&amp;quot;, fs.flash_device-&amp;gt;name);
		#endif
		return -EINVAL;
	}

	fs.offset = FLASH_AREA_OFFSET(user_storage);
	rc = flash_get_page_info_by_offs(fs.flash_device, fs.offset, &amp;amp;info);
	if (rc !=0) 
	{
		#ifdef DEBUG_NVS		
			printk(&amp;quot;Unable to get page info\n&amp;quot;);
		#endif
		return rc = -EINVAL;
	}

	fs.sector_size = info.size;
	fs.sector_count = NVS_SECTOR_COUNT;

	if(fs.sector_size*fs.sector_count &amp;gt; (FLASH_AREA_SIZE(user_storage)))
	{
		#ifdef DEBUG_NVS
		printk(&amp;quot;ERROR: Area used by NVS is larger than user storage\n&amp;quot;);
		#endif
	}

	rc = nvs_mount(&amp;amp;fs);
	if (rc !=0) 
	{
		#ifdef DEBUG_NVS
			printk(&amp;quot;Flash Init failed\n&amp;quot;);
		#endif
		return rc;
	}

	// Check if data is stored in flash
	rc = check_for_nvs_key();
	return rc;
	
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Not sure why, but I had to ditch the use of:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;const struct device *flash_dev;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;from what the original sample code had employed, and then utilise the .flash_device element of the fs directly.&lt;/p&gt;
&lt;p&gt;Where I&amp;#39;ve called:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;fs.offset = FLASH_AREA_OFFSET(user_storage);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;you may need to adjust this to point to the area in flash you actually want to use.&lt;/p&gt;
&lt;p&gt;This all works perfectly for me...to a point.&amp;nbsp; I&amp;#39;m having issues where if I try and write more than about 2000 bytes of data to my user_storage partition, I get errors indicating I&amp;#39;ve run out of room, even though I have 2 sectors, each of ~ 4000 bytes available.&amp;nbsp; Still trying to work that one out.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with flash partitions in NCS 1.7.0 on nRF9160</title><link>https://devzone.nordicsemi.com/thread/376489?ContentTypeID=1</link><pubDate>Mon, 11 Jul 2022 16:06:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47fb92dd-ebf5-4aa3-9f2e-488c46d1d895</guid><dc:creator>jwhite</dc:creator><description>&lt;p&gt;Hi Mike,&lt;/p&gt;
&lt;p&gt;I unfortunately left this question open because I was not able to fix this specific error, even using &lt;a title="H&amp;aring;kon Alseth" href="https://devzone.nordicsemi.com/members/hkn"&gt; H&amp;aring;kon&lt;/a&gt;&amp;#39;s answer.&lt;/p&gt;
&lt;p&gt;My goal with this was to upgrade my project&amp;#39;s firmware from NCS version 1.5.0 to 1.7.0, and I ended up staying with 1.5.0 for now. Perhaps we can check with some of the Nordic folks to see if there is another way to do this in newer versions of NCS.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jacob&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with flash partitions in NCS 1.7.0 on nRF9160</title><link>https://devzone.nordicsemi.com/thread/376308?ContentTypeID=1</link><pubDate>Mon, 11 Jul 2022 02:17:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34cd7980-9275-4755-a39d-14d4e8bc018d</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/jwhite"&gt;jwhite&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hi Jacob,&lt;/p&gt;
&lt;p&gt;Did you ever get this sorted?&amp;nbsp; I&amp;#39;m struggling with a similar issue, trying to increase the NVS available for logging data, and am not really making much progress.&lt;/p&gt;
&lt;p&gt;Would be interested to hear if you got it fixed, and what you did to get your solution&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with flash partitions in NCS 1.7.0 on nRF9160</title><link>https://devzone.nordicsemi.com/thread/334280?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 08:34:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c683ffe8-5dd1-4171-bb09-b14f195ab5a5</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for the detailed description. I managed to reproduce this locally and will follow up internally with this issue.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As a workaround for now, could you try to revert to this &amp;quot;old&amp;quot; way of defining the flash device?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/commit/673b4b4394f4cd0c946419ac139abc17c6ec3feb#diff-45eb4432327c37ce8848981cdcf353afa36f5c46c0e09669d1034b3b991a10beL78"&gt;https://github.com/nrfconnect/sdk-zephyr/commit/673b4b4394f4cd0c946419ac139abc17c6ec3feb#diff-45eb4432327c37ce8848981cdcf353afa36f5c46c0e09669d1034b3b991a10beL78&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;ie, like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;flash_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with flash partitions in NCS 1.7.0 on nRF9160</title><link>https://devzone.nordicsemi.com/thread/334004?ContentTypeID=1</link><pubDate>Wed, 13 Oct 2021 17:18:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d14901fd-f669-47e1-a92b-6750ad9b5151</guid><dc:creator>jwhite</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the response. I have built a few other standalone projects with NCS 1.7.0, and added a pm_static.yml, and their partitions.yml do generate as expected&lt;/p&gt;
&lt;p&gt;What I&amp;#39;ve done next is try to integrate the code from the nvs example into others, namely the cloud_client example. I&amp;#39;ve modified the prj.conf and cmakelists.txt files accordingly, and tried adding some flash initialization to main.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static struct nvs_fs fs;

#define STORAGE_NODE DT_NODE_BY_FIXED_PARTITION_LABEL(storage)
#define FLASH_NODE DT_MTD_FROM_FIXED_PARTITION(STORAGE_NODE)


void main(void)
{
	int err;
	int rc = 0;
	struct flash_pages_info info;
	const struct device *flash_dev;

	/* define the nvs file system by settings with:
	 *	sector_size equal to the pagesize,
	 *	3 sectors
	 *	starting at FLASH_AREA_OFFSET(storage)
	 */
	flash_dev = DEVICE_DT_GET(FLASH_NODE);
	if (!device_is_ready(flash_dev)) {
		printk(&amp;quot;Flash device %s is not ready\n&amp;quot;, flash_dev-&amp;gt;name);
		return;
	}

	
	fs.offset = FLASH_AREA_OFFSET(storage);
	rc = flash_get_page_info_by_offs(flash_dev, fs.offset, &amp;amp;info);
	if (rc) {
		printk(&amp;quot;Unable to get page info\n&amp;quot;);
		return;
	}
	fs.sector_size = info.size;
	fs.sector_count = 3U;

	rc = nvs_init(&amp;amp;fs, flash_dev-&amp;gt;name);
	if (rc) {
		printk(&amp;quot;Flash Init failed\n&amp;quot;);
		return;
	}
.......&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But now, I am getting the same error that was present in this post a few weeks ago:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/78897/non-volatile-storage-nvs-sample-compile-issue-on-nrf-sdk-v1-6"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/78897/non-volatile-storage-nvs-sample-compile-issue-on-nrf-sdk-v1-6&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have tried applying the change that is suggested by &amp;Oslash;ivind, but the error persists. It seems that buried in the DEVICE_DT_GET function, something is undefined.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;In file included from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\toolchain\gcc.h:66,
                 from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\toolchain.h:43,
                 from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\kernel_includes.h:19,
                 from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\kernel.h:17,
                 from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\zephyr.h:18,
                 from c:\Users\jwhite\Desktop\L20\FW\1.7.0\cloud_l20\src\main.c:11:
../src/main.c: In function &amp;#39;main&amp;#39;:
C:\Users\jwhite\ncs\v1.7.0\zephyr\include\device.h:80:39: error: &amp;#39;__device_dts_ord_DT_COMPAT_fixed_partitions_LABEL_settings_storage_PARENT_PARENT_ORD&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: Issue with flash partitions in NCS 1.7.0 on nRF9160</title><link>https://devzone.nordicsemi.com/thread/333958?ContentTypeID=1</link><pubDate>Wed, 13 Oct 2021 13:13:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6eb60880-4ae7-4fbf-86a1-79adb3982e2e</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The project is failing before any PM is able to run properly:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;warning: ENTROPY_CC3XX (defined at C:\Users\jwhite\ncs\v1.7.0\nrf\drivers\entropy\Kconfig:7) has direct dependencies (CRYPTOCELL_USABLE || SPM || BUILD_WITH_TFM) &amp;amp;&amp;amp; ENTROPY_GENERATOR with value n, but is currently being y-selected by the following symbols:
 - SPM (defined at C:\Users\jwhite\ncs\v1.7.0\nrf\subsys\spm\Kconfig:9), with value y, direct dependencies !BUILD_WITH_TFM (value: y), and select condition !BUILD_WITH_TFM (value: y)

warning: ARM_FIRMWARE_USES_SECURE_ENTRY_FUNCS (defined at C:\Users\jwhite\ncs\v1.7.0\zephyr\arch\arm\core\aarch32\cortex_m\tz\Kconfig:57) has direct dependencies ARM_NONSECURE_FIRMWARE &amp;amp;&amp;amp; (ARM_SECURE_FIRMWARE || ARM_NONSECURE_FIRMWARE) &amp;amp;&amp;amp; ARM_TRUSTZONE_M &amp;amp;&amp;amp; CPU_CORTEX_M &amp;amp;&amp;amp; ARM with value n, but is currently being y-selected by the following symbols:
 - SPM_SECURE_SERVICES (defined at C:\Users\jwhite\ncs\v1.7.0\nrf\subsys\spm\Kconfig:82), with value y, direct dependencies IS_SPM || SPM (value: y), and select condition SPM &amp;amp;&amp;amp; (IS_SPM || SPM) (value: y)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It seems there&amp;#39;s a conflict between BUILD_WITH_TFM and SPM here. Do you see this issue&amp;nbsp;when building&amp;nbsp;other samples as well?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>