<?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>Unable to use LittleFS on External Flash on nrf9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/101242/unable-to-use-littlefs-on-external-flash-on-nrf9160</link><description>Hello, 
 I am currently using the nrf9160dk and would like to use the external flash available on the development kit. I want to use LittleFS on the external flash. 
 I found several articles all covering different aspects, but I was unable to arrive</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Jun 2023 15:58:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/101242/unable-to-use-littlefs-on-external-flash-on-nrf9160" /><item><title>RE: Unable to use LittleFS on External Flash on nrf9160</title><link>https://devzone.nordicsemi.com/thread/433513?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2023 15:58:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1257ff6b-0bd6-49ad-8c6e-0c75ef0eb615</guid><dc:creator>Ben_R831</dc:creator><description>&lt;p&gt;Hello Vidar,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Awesome. That makes sense. Tried the static partition file, and it worked nicely. I also realized I read the datasheet wrong and that the external flash chip has 64Mbit (8MB) verses 64MByte.&lt;/p&gt;
&lt;p&gt;Thank you for your help,&lt;/p&gt;
&lt;p&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to use LittleFS on External Flash on nrf9160</title><link>https://devzone.nordicsemi.com/thread/433395?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2023 08:51:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cf5657a-891f-4c9b-9460-fb13419125e1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Ben,&lt;/p&gt;
&lt;p&gt;The external flash region gets added when you have set the &amp;#39;pm-ext-flash&amp;#39; property, as explained in the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.1/nrf/scripts/partition_manager/partition_manager.html#external-flash"&gt;External Flash&lt;/a&gt;&amp;nbsp;of the partition manager documentation.&amp;nbsp;However, it does not automatically place the littlefs partition within it.&amp;nbsp;We added the&amp;nbsp;&lt;span&gt;CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL symbol in v2.1.0 to allow the partition to be added automatically.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For v1.7.1, you need to define the partition yourself. You can do this by creating a file named &amp;#39;pm_static.yml&amp;#39; that contains the following:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;littlefs_storage:
  region: external_flash
  address: 0x0
  size: 0x10000
external_flash:
  address: 0x10000
  size: 0x7F0000
  device: MX25R64
  region: external_flash
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then place the file in your project directory so it gets picked up by the build system (&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.1/nrf/scripts/partition_manager/partition_manager.html#static-configuration"&gt;Static Configuration&lt;/a&gt;).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Tip: you can use the &amp;quot;Memory report&amp;quot; button in VS code&amp;nbsp;if you want to view the memory layout, or &amp;quot;$ west build -t partition_manager_report&amp;quot; if you are building from the command line.&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/pastedimage1687941586470v1.png" alt=" " /&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/pastedimage1687941616045v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to use LittleFS on External Flash on nrf9160</title><link>https://devzone.nordicsemi.com/thread/433337?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2023 23:43:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c109174-1236-462e-99ff-3d0b9b03970c</guid><dc:creator>Ben_R831</dc:creator><description>&lt;p&gt;One interesting observation is that automount or mounting in main does use the external flash. However, mounting via shell via the &amp;quot;fs mount&amp;quot; command uses the internal flash.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to use LittleFS on External Flash on nrf9160</title><link>https://devzone.nordicsemi.com/thread/433336?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2023 23:36:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b49051d-3368-426c-bd18-53dc030c590c</guid><dc:creator>Ben_R831</dc:creator><description>&lt;p&gt;Hello Vidar,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for the response. I tried your device overlay. At first it didn&amp;#39;t work as expected. However, I noticed that it did not define the pins and it marked the mx25r64 as disabled. I made slight modifications and I got it to work.&lt;/p&gt;
&lt;p&gt;Here is the overlay:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2019 Peter Bigot Consulting, LLC
 *
 * SPDX-License-Identifier: Apache-2.0
 */

 /delete-node/ &amp;amp;storage_partition;

 /* Configure partition manager to use mx25r64 as the external flash device */
 / {
	 chosen {
		 nordic,pm-ext-flash = &amp;amp;mx25r64;
	 };
 };

 &amp;amp;spi3 {
	status = &amp;quot;okay&amp;quot;;
	sck-pin = &amp;lt;13&amp;gt;;
	mosi-pin = &amp;lt;11&amp;gt;;
	miso-pin = &amp;lt;12&amp;gt;;
	 cs-gpios = &amp;lt;&amp;amp;arduino_header 16 GPIO_ACTIVE_LOW&amp;gt;, /* D10 */
			&amp;lt;&amp;amp;gpio0 25 GPIO_ACTIVE_LOW&amp;gt;;
	 mx25r64: mx25r6435f@1 {
		 compatible = &amp;quot;jedec,spi-nor&amp;quot;;
		 status = &amp;quot;okay&amp;quot;;
		 reg = &amp;lt;1&amp;gt;;
		 spi-max-frequency = &amp;lt;8000000&amp;gt;;
		 label = &amp;quot;MX25R64&amp;quot;;
		 jedec-id = [c2 28 17];
		 sfdp-bfp = [
			 e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
			 ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
			 10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
			 30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
		 ];
		 size = &amp;lt;67108864&amp;gt;;
		 has-dpd;
		 t-enter-dpd = &amp;lt;10000&amp;gt;;
		 t-exit-dpd = &amp;lt;35000&amp;gt;;
	 };
 };
 
 
 / {
	 fstab {
		 compatible = &amp;quot;zephyr,fstab&amp;quot;;
		 lfs1: lfs1 {
			 compatible = &amp;quot;zephyr,fstab,littlefs&amp;quot;;
			 mount-point = &amp;quot;/lfs1&amp;quot;;
			 partition = &amp;lt;&amp;amp;lfs1_part&amp;gt;;
			 automount;
			 read-size = &amp;lt;16&amp;gt;;
			 prog-size = &amp;lt;16&amp;gt;;
			 cache-size = &amp;lt;64&amp;gt;;
			 lookahead-size = &amp;lt;32&amp;gt;;
			 block-cycles = &amp;lt;512&amp;gt;;
		 };
	 };
 };
 
 &amp;amp;mx25r64 {
	 partitions {
		 compatible = &amp;quot;fixed-partitions&amp;quot;;
		 #address-cells = &amp;lt;1&amp;gt;;
		 #size-cells = &amp;lt;1&amp;gt;;
 
		 lfs1_part: partition@0 {
			 label = &amp;quot;storage&amp;quot;;
			 reg = &amp;lt;0x00000000 0x00010000&amp;gt;;
		 };
	 };
 };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;prj.conf&amp;nbsp; (changed slightly... added PM_EXTERNAL_FLASH)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Optionally force the file system to be recreated
#CONFIG_APP_WIPE_STORAGE=y

# fs_dirent structures are big.
CONFIG_MAIN_STACK_SIZE=2048

# Let __ASSERT do its job
CONFIG_DEBUG=y

CONFIG_LOG=y

CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y

CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y

# CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y


CONFIG_FLASH=y
CONFIG_LOG=y
#CONFIG_FS_LOG_LEVEL_DBG=y
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_SHELL=y
CONFIG_SHELL_LOG_LEVEL_INF=y
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_SHELL=y
CONFIG_FILE_SYSTEM_LITTLEFS=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

CONFIG_PM_EXTERNAL_FLASH=y
CONFIG_PM_EXTERNAL_FLASH_DEV_NAME=&amp;quot;MX25R64&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And this worked for the &amp;quot;_ns&amp;quot; build target which is perfect.&lt;/p&gt;
&lt;p&gt;For the logs, does this verify it is using the external flash? (I do notice the MX25R64 indicated, and the size is about 8MB, so it seems correct.) Is there a way to increase the size (as the chip has 64MB)?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.6.99-ncs1  ***
Area 0 at 0x0 on MX25R64 for 8388608 bytes
/lfs1 automounted
/lfs1: bsize = 16 ; frsize = 4096 ; blocks = 2048 ; bfree = 2046
/lfs1/boot_count stat: 0
        fn &amp;#39;boot_count&amp;#39; siz 4
/lfs1/boot_count read count 4: 4
/lfs1/boot_count seek start: 0
/lfs1/boot_count write new boot count 5: 4
/lfs1/boot_count close: 0
/lfs1 opendir: 0
  F 4 boot_count
End of files
/lfs1 unmount: 0
[00:00:00.203,002] &amp;lt;inf&amp;gt; littlefs: littlefs partition at /lfs1
[00:00:00.203,063] &amp;lt;inf&amp;gt; littlefs: LittleFS version 2.2, disk version 2.0
[00:00:00.204,986] &amp;lt;inf&amp;gt; littlefs: FS at MX25R64:0x0 is 2048 0x1000-byte blocks with 512 cycle
[00:00:00.204,986] &amp;lt;inf&amp;gt; littlefs: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
[00:00:00.208,312] &amp;lt;inf&amp;gt; littlefs: /lfs1 mounted
[00:00:00.208,312] &amp;lt;inf&amp;gt; littlefs: Automount /lfs1 succeeded
[00:00:00.256,896] &amp;lt;inf&amp;gt; littlefs: /lfs1 unmounted&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Ben&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to use LittleFS on External Flash on nrf9160</title><link>https://devzone.nordicsemi.com/thread/433239?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2023 12:32:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93ff0823-2dbc-4f72-91eb-a855d72b24c0</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Ben,&lt;/p&gt;
&lt;p&gt;I tried to do the same with the littlefs sample using the following device tree overlay:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2019 Peter Bigot Consulting, LLC
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/delete-node/ &amp;amp;storage_partition;

/* Configure partition manager to use mx25r64 as the external flash device */
/ {
    chosen {
        nordic,pm-ext-flash = &amp;amp;mx25r64;
    };
};

&amp;amp;spi3 {
	cs-gpios = &amp;lt;&amp;amp;arduino_header 16 GPIO_ACTIVE_LOW&amp;gt;, /* D10 */
		   &amp;lt;&amp;amp;gpio0 25 GPIO_ACTIVE_LOW&amp;gt;;
	mx25r64: mx25r6435f@1 {
		compatible = &amp;quot;jedec,spi-nor&amp;quot;;
		status = &amp;quot;disabled&amp;quot;;
		reg = &amp;lt;1&amp;gt;;
		spi-max-frequency = &amp;lt;8000000&amp;gt;;
		label = &amp;quot;MX25R64&amp;quot;;
		jedec-id = [c2 28 17];
		sfdp-bfp = [
			e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
			10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
			30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
		];
		size = &amp;lt;67108864&amp;gt;;
		has-dpd;
		t-enter-dpd = &amp;lt;10000&amp;gt;;
		t-exit-dpd = &amp;lt;35000&amp;gt;;
	};
};


/ {
	fstab {
		compatible = &amp;quot;zephyr,fstab&amp;quot;;
		lfs1: lfs1 {
			compatible = &amp;quot;zephyr,fstab,littlefs&amp;quot;;
			mount-point = &amp;quot;/lfs1&amp;quot;;
			partition = &amp;lt;&amp;amp;lfs1_part&amp;gt;;
			automount;
			read-size = &amp;lt;16&amp;gt;;
			prog-size = &amp;lt;16&amp;gt;;
			cache-size = &amp;lt;64&amp;gt;;
			lookahead-size = &amp;lt;32&amp;gt;;
			block-cycles = &amp;lt;512&amp;gt;;
		};
	};
};

&amp;amp;mx25r64 {
	partitions {
		compatible = &amp;quot;fixed-partitions&amp;quot;;
		#address-cells = &amp;lt;1&amp;gt;;
		#size-cells = &amp;lt;1&amp;gt;;

		lfs1_part: partition@0 {
			label = &amp;quot;storage&amp;quot;;
			reg = &amp;lt;0x00000000 0x00010000&amp;gt;;
		};
	};
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But I realized the&amp;nbsp;CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL symbol didn&amp;#39;t get introduced until SDK v2.1.0:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/releases/release-notes-2.1.0.html#scripts"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/releases/release-notes-2.1.0.html#scripts&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Would it be an option to upgrade to a more recent version? If not, I think the solution will be to create a static partition file with your partition in external flash (&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/scripts/partition_manager/partition_manager.html#configuring-static-partitions"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/scripts/partition_manager/partition_manager.html#configuring-static-partitions&lt;/a&gt;) or cherry-pick the changes from SDK 2.1.0.&lt;/p&gt;
&lt;p&gt;Another post with a similar question:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/96202/using-littlefs-with-mx25r64-and-nrf-connect-vs-code"&gt;Using LittleFS with mx25r64 and nRF Connect VS Code&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, for reference, here are instructions on how to add external flash from the latest SDK documentation:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/working_with_nrf/nrf91/nrf9160.html#adding-the-configuration-and-devicetree-option"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/working_with_nrf/nrf91/nrf9160.html#adding-the-configuration-and-devicetree-option&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: I see now that the overlay for the spi3 node should be redundant if you build for revision 0.14.0 of the board (default):&amp;nbsp;&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi#L40"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi#L40&lt;/a&gt;.&amp;nbsp;Prior versions did not include the flash IC so it was not defined in the device tree either.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>