<?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>Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113254/use-of-zephyr-inbuilt-apis-to-use-external-flash-with-nrf9160</link><description>I am using MX25 external flash with nRF9160. I am unable to find the configuration to use the Zephyr APIs to access the flash. I am able to access it when I am using 
 
 spi_write_dt funtion but for this I have to do some SPI configuration using the following</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 08 Aug 2024 14:12:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113254/use-of-zephyr-inbuilt-apis-to-use-external-flash-with-nrf9160" /><item><title>RE: Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/thread/497500?ContentTypeID=1</link><pubDate>Thu, 08 Aug 2024 14:12:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd4abbd3-d018-41fe-a849-3ed3a43971eb</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi Amit,&lt;/p&gt;
&lt;p&gt;I have tested on nrf52840dk, and I do not get any problem&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/0363.pastedimage1723126116407v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I can see the correct functionality as well.&lt;/p&gt;
&lt;p&gt;Just for reference, I am putting the nrf52840DK overlay here which is based on your overlay, the sample output dts, and the information from the DK guide.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/delete-node/ &amp;amp;mx25r64;
&amp;amp;qspi{
    status = &amp;quot;disabled&amp;quot;;
    
};
&amp;amp;spi3{
    compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
    status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt; &amp;amp;spi3_default &amp;gt;;
    pinctrl-1 = &amp;lt; &amp;amp;spi3_sleep &amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
    cs-gpios = &amp;lt;&amp;amp;gpio0 17 GPIO_ACTIVE_LOW&amp;gt;; /* D10 */
    mx25r64: mx25r6435f@0 {
        compatible = &amp;quot;jedec,spi-nor&amp;quot;;
        reg = &amp;lt; 0x0 &amp;gt;;
        spi-max-frequency = &amp;lt; 8000000 &amp;gt;;
        status = &amp;quot;okay&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; 0x4000000 &amp;gt;;
        has-dpd;
        t-enter-dpd = &amp;lt; 0x2710 &amp;gt;;
        t-exit-dpd = &amp;lt; 0x88b8 &amp;gt;;
    };
};

&amp;amp;pinctrl{
    spi3_default: spi3_default {
		group1 {
			psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 19)&amp;gt;,
				&amp;lt;NRF_PSEL(SPIM_MISO, 0, 21)&amp;gt;,
				&amp;lt;NRF_PSEL(SPIM_MOSI, 0, 20)&amp;gt;;
		};
	};

	spi3_sleep: spi3_sleep {
		group1 {
			psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 19)&amp;gt;,
				&amp;lt;NRF_PSEL(SPIM_MISO, 0, 21)&amp;gt;,
				&amp;lt;NRF_PSEL(SPIM_MOSI, 0, 20)&amp;gt;;
			low-power-enable;
		};
	};
};

/{
    aliases{
        spi-flash0 = &amp;amp;mx25r64;
    };
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I am using the exact sample without modifying anything in the main except including a header file for the spi.&lt;/p&gt;
&lt;p&gt;In the project configurations, SPI is enabled and QSPI is disabled; similarly in the overlay.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/thread/497072?ContentTypeID=1</link><pubDate>Tue, 06 Aug 2024 05:22:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f43e821-339d-4723-bd97-da515d365a2f</guid><dc:creator>AKO</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722921710127v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;. You can see in the above image when I execute line 242, I am getting exceptions and that could be because of the erase is not pointing to any valid function (as seen in watch)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/thread/497022?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2024 15:28:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4c50124-32f6-4dca-b734-dcec7717f565</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;what error you are getting now?&lt;/p&gt;
&lt;p&gt;defining aliases for instances is fine.&lt;/p&gt;
&lt;p&gt;you can do the debugging to see what is causing the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/thread/495430?ContentTypeID=1</link><pubDate>Wed, 24 Jul 2024 13:22:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21c92d25-3bc9-46e8-bef5-4f0998924fa4</guid><dc:creator>AKO</dc:creator><description>&lt;p&gt;My Device Tree:&lt;br /&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/pastedimage1721827323813v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/thread/495428?ContentTypeID=1</link><pubDate>Wed, 24 Jul 2024 13:15:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d9030ad-b67d-4aad-92fd-215470334140</guid><dc:creator>AKO</dc:creator><description>&lt;p&gt;I am using the following to the flash device from DT:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;#define SPI_FLASH DEVICE_DT_GET(DT_ALIAS(ext_flash))&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The aliases where I have used ext_flash:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&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/pastedimage1721826886618v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/thread/495424?ContentTypeID=1</link><pubDate>Wed, 24 Jul 2024 13:07:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0cce122-eb97-4162-b378-a47ae3eb35f7</guid><dc:creator>AKO</dc:creator><description>&lt;p&gt;There are no compilation error, and I am able to flash it. The example that you have shared worked fine with QSPI (where the Flash_Erase/Flash_Read API are connecting with Zephyr APIs) but I am using SPI-NOR where I am facing issue.&lt;/p&gt;
&lt;p&gt;Also, I am able to get the flash device from the Device tree.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/thread/495391?ContentTypeID=1</link><pubDate>Wed, 24 Jul 2024 10:41:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:743d962f-377e-4374-9240-160420cf1e71</guid><dc:creator>Naeem Maroof</dc:creator><description>[quote user="AKO"]I have checked this example but it didn&amp;#39;t worked for me[/quote]
&lt;p&gt;What do you mean by &amp;quot;did not work&amp;quot;? Did it not compile well? Were you able to flash it? Did you get runtime error?&lt;/p&gt;
[quote user="AKO"]but here I see that no function is assigned to&lt;strong&gt; api-&amp;gt;erase&amp;nbsp;&lt;/strong&gt;[/quote]
&lt;p&gt;In the main, you will see that we are getting the flash device from the&amp;nbsp;devicetree by calling DEVICE_DT_GET().&lt;/p&gt;
&lt;p&gt;Therefore, the drivers configured for that device in the DTS would be used to connect to the flash api.&lt;/p&gt;
&lt;p&gt;I have compiled the example for NRF52840, and I can see (in the DTS) that spi-flash0 is using QSPI-NOR driver from NORDIC (see compatible), and in the NRF_QSPI_NOR.C file we see that:&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/pastedimage1721817526387v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Hence the flash erase would eventually connect with qspi_nor_erase from this driver.&lt;/p&gt;
&lt;p&gt;If you are unfamiliar with this then I would recommend you to go through the &lt;a href="https://academy.nordicsemi.com/"&gt;DevAcademy &lt;/a&gt;courses that would quickly ramp up expertise working with NCS/Zephyr.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Warm regards,&lt;/p&gt;
&lt;p&gt;Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/thread/495205?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2024 12:29:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c802ba4b-5cb7-464b-95ad-ec36499478f8</guid><dc:creator>AKO</dc:creator><description>&lt;p&gt;I have checked this example but it didn&amp;#39;t worked for me. When I was calling the &lt;strong&gt;flash_erase &lt;/strong&gt;I was getting some wierd observation.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This functions calls the following code:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;static inline int z_impl_flash_erase(const struct device *dev, off_t offset,&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;size_t size)&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; const struct flash_driver_api *api =&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (const struct flash_driver_api *)dev-&amp;gt;api;&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; int rc;&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; rc = api-&amp;gt;erase(dev, offset, size);&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; return rc;&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;but here I see that no function is assigned to&lt;strong&gt; api-&amp;gt;erase&amp;nbsp;&lt;/strong&gt;&lt;/em&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of Zephyr inbuilt APIs to Use External Flash with nRF9160</title><link>https://devzone.nordicsemi.com/thread/495162?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2024 09:03:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab5b6817-d3db-422d-96dc-5ea62c7f10c9</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;You might want to look at Zephyr Flash sample that demonstrates the use of flash API:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/samples/drivers/spi_flash/README.html"&gt;Zephyr Flash Sample&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>