<?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>External Flash using SPI on nRF5340 DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117926/external-flash-using-spi-on-nrf5340-dk</link><description>I want to use the external flash on the nRF5340 DK using SPI as the board I&amp;#39;m developing for will not have QSPI. I used the littlefs sample which has a lot of the settings I need, like those in the spi_flash sample: 
 
 
 
 Which gives me: 
 
 I see it</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 Feb 2025 15:37:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117926/external-flash-using-spi-on-nrf5340-dk" /><item><title>RE: External Flash using SPI on nRF5340 DK</title><link>https://devzone.nordicsemi.com/thread/523570?ContentTypeID=1</link><pubDate>Tue, 18 Feb 2025 15:37:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1eeb75f-9689-48b8-9216-c1faaed265d4</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;In addition to the application-wise setup, you need to setup sysbuild.conf with specific entries, in this case:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;SB_CONFIG_BOOTLOADER_MCUBOOT=y
SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n
SB_CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and specify the partition in a pm_static.yml:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;littlefs_storage:
  address: 0x0
  device: mx25r6435f
  end_address: 0x800000
  region: external_flash
  size: 0x800000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since the nrf5340dk has the flash on the qspi peripheral, you need to delete it first:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/delete-node/ &amp;amp;mx25r64;
/delete-node/ &amp;amp;storage_partition;

..rest of file&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an example for your convenience:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/littlefs_5F00_ext_5F00_flash_5F00_sysbuild_5F00_nrf5340dk.zip"&gt;devzone.nordicsemi.com/.../littlefs_5F00_ext_5F00_flash_5F00_sysbuild_5F00_nrf5340dk.zip&lt;/a&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: External Flash using SPI on nRF5340 DK</title><link>https://devzone.nordicsemi.com/thread/523136?ContentTypeID=1</link><pubDate>Sun, 16 Feb 2025 05:55:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed695c68-1b14-49af-8bf5-084f529c52ef</guid><dc:creator>lcj</dc:creator><description>&lt;p&gt;Is this the same in nrfConnect 2.9 using sysbuild? Starting from scratch I use the Zephyr Hello World example&amp;nbsp;and created a build configuration for the nrf5340 cpu app using&amp;nbsp;SDK 2.9 and toolchain 2.9 and selecting sysbuild.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I added:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_FLASH=y
CONFIG_SPI=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Which built and flashed fine. I added:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_SPI_NOR=y&lt;/pre&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;and created an overlay with this:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
	chosen {
		nordic,pm-ext-flash = &amp;amp;mx25r64;
	};
};&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;when building I got&amp;nbsp;this warning:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;br /&gt;warning: SPI_NOR (defined at soc/gaisler/gr716a/Kconfig.defconfig:18, drivers/flash/Kconfig.nor:6)&lt;br /&gt;was assigned the value &amp;#39;y&amp;#39; but got the value &amp;#39;n&amp;#39;. Check these unsatisfied dependencies: ((FLASH &amp;amp;&amp;amp;&lt;br /&gt;SOC_GR716A) || (DT_HAS_JEDEC_SPI_NOR_ENABLED &amp;amp;&amp;amp; FLASH)) (=n). See&lt;br /&gt;&lt;a href="http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_SPI_NOR"&gt;docs.zephyrproject.org/.../kconfig.html&lt;/a&gt; and/or look up SPI_NOR in the&lt;br /&gt;menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,&lt;br /&gt;and Kconfig - Tips and Best Practices sections of the manual might be helpful too.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I see in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/108385/dfu-not-working-for-nrf52840-dk-using-onboard-external-flash/470155"&gt;this post &lt;/a&gt;that:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;The external flash on the nRF52840 is by default configured to use QSPI and not SPI.&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;span&gt;Which&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/bf64a318c900f2cf9b97e0df5bb813d47b398654/boards/nordic/nrf5340dk/nrf5340_cpuapp_common.dtsi#L117"&gt;&amp;nbsp;is the same for the nRF5340 DK&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;qspi {
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;qspi_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;qspi_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	mx25r64: mx25r6435f@0 {
		compatible = &amp;quot;nordic,qspi-nor&amp;quot;;
		reg = &amp;lt;0&amp;gt;;
		/* MX25R64 supports only pp and pp4io */
		writeoc = &amp;quot;pp4io&amp;quot;;
		/* MX25R64 supports all readoc options */
		readoc = &amp;quot;read4io&amp;quot;;
		sck-frequency = &amp;lt;8000000&amp;gt;;
		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;;
	};
};&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I read &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/82430/ncs-external-flash-ota-change-qspi-to-spi/345238"&gt;this post&lt;/a&gt; on &amp;quot;ncs external flash ota change qspi to spi&amp;quot; using the&amp;nbsp;nRF52840dk which had sample code in the solution with this in the overlay:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
	chosen {
		nordic,pm-ext-flash = &amp;amp;mx25r64test;
	};
};
&amp;amp;qspi {
	status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;spi3 {
	status = &amp;quot;okay&amp;quot;;
	sck-pin = &amp;lt;19&amp;gt;;
	mosi-pin = &amp;lt;20&amp;gt;;
	miso-pin = &amp;lt;21&amp;gt;;
	cs-gpios = &amp;lt;&amp;amp;gpio0 17 GPIO_ACTIVE_LOW&amp;gt;;
	mx25r64test: mx25r6435ftest@0 {
		compatible = &amp;quot;jedec,spi-nor&amp;quot;;
		reg = &amp;lt;0&amp;gt;;
		spi-max-frequency = &amp;lt;8000000&amp;gt;;
		label = &amp;quot;MX25R64TEST&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;;
	};
};&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But it didn&amp;#39;t work for nRF5340dk.&amp;nbsp;&lt;/span&gt;&lt;span&gt;How do I make it SPI?&amp;nbsp;Is this done in the overlay? &lt;a href="https://docs.nordicsemi.com/bundle/ug_nrf5340_dk/page/UG/dk/hw_external_memory.html"&gt;I see that it supports SPI&lt;/a&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;The&amp;nbsp;&lt;span class="keyword"&gt;nRF5340 DK&lt;/span&gt;&amp;nbsp;has a 64 megabit external flash memory. The memory is a multi-I/O memory supporting both&amp;nbsp;&lt;a title="Synchronous serial communication interface specification used for short-distance communication." href="https://docs.nordicsemi.com/bundle/ug_nrf5340_dk/page/dita_common/glossary/glossary.html#spi" data-bundleid="ug_nrf5340_dk" data-navpath="dita_common/glossary/glossary.html"&gt;&lt;dfn class="term abbreviated-form"&gt;Serial Peripheral Interface (SPI)&lt;/dfn&gt;&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a title="A Serial Peripheral Interface (SPI) controller that allows the use of multiple data lines." href="https://docs.nordicsemi.com/bundle/ug_nrf5340_dk/page/dita_common/glossary/glossary.html#qspi" data-bundleid="ug_nrf5340_dk" data-navpath="dita_common/glossary/glossary.html"&gt;&lt;dfn class="term abbreviated-form"&gt;Quad Serial Peripheral Interface (QSPI)&lt;/dfn&gt;&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: External Flash using SPI on nRF5340 DK</title><link>https://devzone.nordicsemi.com/thread/518126?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2025 11:25:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cc2cf5d-92fd-4720-a730-758a0d111f20</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;Have you followed the guide explained here?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/scripts/partition_manager/partition_manager.html#external_flash_memory_partitions"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/scripts/partition_manager/partition_manager.html#external_flash_memory_partitions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You will need to add a pm_static.yml file with the following (change sizes etc. to your liking):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;littlefs_storage:
  address: 0x0
  device: mx25r6435f
  region: external_flash
  size: 0x400000
external_flash:
  address: 0x400000
  device: mx25r6435f
  region: external_flash
  size: 0x400000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then add your overlay:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/delete-node/ &amp;amp;storage_partition;

/ {
	chosen {
		nordic,pm-ext-flash = &amp;amp;mx25r64;
	};
};

&amp;amp;mx25r64 {
    status = &amp;quot;okay&amp;quot;;
	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@0 {
			label = &amp;quot;storage&amp;quot;;
			reg = &amp;lt;0x00000000 0x00010000&amp;gt;;
		};
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And the corresponding config:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_FLASH=y
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then it should run towards ext flash:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting nRF Connect SDK v2.8.0-a2386bfc8401 ***
*** Using Zephyr OS v3.7.99-0bc3393fb112 ***
Sample program to r/w files on littlefs
Area 0 at 0x0 on mx25r6435f@1 for 4194304 bytes
I: LittleFS version 2.9, disk version 2.1
I: FS at mx25r6435f@1:0x0 is 1024 0x1000-byte blocks with 512 cycle
I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
E: WEST_TOPDIR/modules/fs/littlefs/lfs.c:1374: Corrupted dir pair at {0x1, 0x0}
W: can&amp;#39;t mount (LFS -84); formatting
I: /lfs mounted
/lfs mount: 0
/lfs: bsize = 16 ; frsize = 4096 ; blocks = 1024 ; bfree = 1022

Listing dir /lfs ...
/lfs/boot_count read count:0 (bytes: 0)
/lfs/boot_count write new boot count 1: [wr:1]
I: Test file: /lfs/pattern.bin not found, create one!
...&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></channel></rss>