<?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>9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112912/9160dk-external-flash-operation-address-length-issue</link><description>The default setting for the external flash chip of 9160dk appears to be 64m, but when used, the log display only shows 8m, and only the part within 8m can be used, 
 
 Then I set the chip size to 8 times that of 64m in order to use all 64m of flash properly</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Jul 2024 08:27:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112912/9160dk-external-flash-operation-address-length-issue" /><item><title>RE: 9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/thread/494292?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2024 08:27:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cc40070-f2b7-49c0-854c-f08b47c0fdaf</guid><dc:creator>llly</dc:creator><description>&lt;p&gt;Hi Hieu&lt;/p&gt;
&lt;p&gt;Sorry, I asked Zephyr and found out that I made a mistake. The unit of this flash chip is bits, not bytes, so he only has 8M bytes, which is correct. This problem should not be a problem anymore.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/thread/493918?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2024 13:16:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30962702-2886-445e-b75c-ec5b6a133860</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi llly,&lt;/p&gt;
&lt;p&gt;Interesting findings.&amp;nbsp;Were you able to capture what the external flash device sent back to the nRF9160? In particular, is the SFDP data the same as the sfdp-bfp property in the Devicetree?&lt;/p&gt;
&lt;p&gt;It might be necessary to raise this issue on the &lt;a href="https://github.com/zephyrproject-rtos/zephyr"&gt;Zephyr RTOS&lt;/a&gt;&amp;nbsp;GitHub repository, because this part of the SDK is&amp;nbsp;inherited from Zephyr and not NCS specific.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/thread/493818?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2024 07:29:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64199623-af1a-4efe-bc21-03351be1641c</guid><dc:creator>llly</dc:creator><description>&lt;p&gt;Hi Hieu&lt;/p&gt;
&lt;p&gt;I am currently using Solution 3, and I have tested Solution 4. The information it reads from the flash shows that it is an 8m flash, so I cannot test the 4-byte address.&amp;nbsp;For Solution 2, I couldn&amp;#39;t find a way to set a 4-byte address. For Solution 1, I did not conduct any testing and I believe the result should be the same as Solution 4.&lt;/p&gt;
&lt;p&gt;I think Solution 4 is the most convenient solution because it directly reads information from the flash, and replacing the flash chip does not require much modification. But I don&amp;#39;t know why the code in spi_nor. c sets the flash size to one eighth of the read size. The flash on 9160dk has 64m, but can only use 8m. I connected a 32m flash externally, which shows that only 4m can be used&lt;/p&gt;
&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/7103.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/thread/493747?ContentTypeID=1</link><pubDate>Sat, 13 Jul 2024 12:18:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5f2e240-52ef-401f-91b6-44cb4442fb74</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;I have determined that&amp;nbsp;the issue comes from loading the&amp;nbsp;external flash device&amp;#39;s capability into the driver.&lt;/p&gt;
&lt;p&gt;I am honestly not an expert in it, and this is just my rough understanding. I will try to only write about what I am relatively sure of, but I hope you can help me test something to see if it works.&lt;/p&gt;
&lt;p&gt;The external flash capability is stored in Serial Flash Discoverable Parameters (SFDP).&amp;nbsp;There are two Kconfigs that are relevant to the way the flash driver loads the SFDP: &lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/kconfig/index.html#CONFIG_FLASH_JESD216_API"&gt;CONFIG_FLASH_JESD216_API&lt;/a&gt; and &lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/kconfig/index.html#CONFIG_SPI_NOR_SFDP"&gt;CONFIG_SPI_NOR_SFDP&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;CONFIG_FLASH_JESD216_API&lt;span&gt;&amp;nbsp;enable some&amp;nbsp;Flash APIs, one of which is&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/zephyr/hardware/peripherals/flash.html#c.flash_sfdp_read"&gt;flash_sfdp_read&lt;/a&gt;().&amp;nbsp;It loads the SFDP from the external flash device when called. By default, this is disabled.&lt;br /&gt;--&amp;gt; &lt;strong&gt;Solution 1&lt;/strong&gt;: enable&amp;nbsp;CONFIG_FLASH_JESD216_API&amp;nbsp;and call flash_sfdp_read() during initialization.&lt;/span&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;As for&amp;nbsp;CONFIG_SPI_NOR_SFDP, by default, it is set to&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/kconfig/index.html#CONFIG_SPI_NOR_SFDP_MINIMAL"&gt;CONFIG_SPI_NOR_SFDP_MINIMAL&lt;/a&gt;,&amp;nbsp;synthesize a SFDP based on just the jedec-id and size property of the external flash node on the Devicetree (DT). However, this also defaults the flash&amp;nbsp;address mode to 24-bit, and expects that if 32-bit is needed, then the&amp;nbsp;external flash node has to have the property &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.6.99-ncs2/dts/bindings/mtd/jedec%2Cjesd216.yaml#L56-L70"&gt;enter-4byte-addr&lt;/a&gt;&amp;nbsp;set properly. I haven&amp;#39;t looked into&amp;nbsp;how the value should be derived though...&lt;/p&gt;
&lt;p&gt;--&amp;gt; &lt;strong&gt;Solution 2&lt;/strong&gt;: set the&amp;nbsp;enter-4byte-addr property in the external flash node.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;CONFIG_SPI_NOR_SFDP can also be set to&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/kconfig/index.html#CONFIG_SPI_NOR_SFDP_DEVICETREE"&gt;CONFIG_SPI_NOR_SFDP_DEVICETREE&lt;/a&gt;, which loads the SFDP from the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.6.99-ncs2/dts/bindings/mtd/jedec%2Cjesd216.yaml#L29-L36"&gt;sfdp-bfp&lt;/a&gt; of the external flash&amp;nbsp;DT node. This property is already set for the external flash on the nRF9160 DK board file, so it should work.&lt;/p&gt;
&lt;p&gt;--&amp;gt; &lt;strong&gt;Solution 3&lt;/strong&gt;: Disable&amp;nbsp;CONFIG_SPI_NOR_SFDP_MINIMAL and enable&amp;nbsp;CONFIG_SPI_NOR_SFDP_DEVICETREE.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Finally,&amp;nbsp;CONFIG_SPI_NOR_SFDP can also be set to&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/kconfig/index.html#CONFIG_SPI_NOR_SFDP_RUNTIME"&gt;CONFIG_SPI_NOR_SFDP_RUNTIME&lt;/a&gt;, which loads SFDP from the external flash device itself during runtime.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;--&amp;gt; &lt;strong&gt;Solution 4&lt;/strong&gt;:&amp;nbsp;&lt;span&gt;Disable&amp;nbsp;CONFIG_SPI_NOR_SFDP_MINIMAL and enable&amp;nbsp;CONFIG_SPI_NOR_SFDP_RUNTIME.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I realize that I am violating the Occam&amp;#39;s Razor principle a lot here, but I figure&amp;nbsp;the information might come in handy eventually for readers with different&amp;nbsp;external flash device, and another reason is that I&amp;nbsp;couldn&amp;#39;t test any of them at the moment.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please consider which solution best suit you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hieu&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/thread/493562?ContentTypeID=1</link><pubDate>Fri, 12 Jul 2024 06:45:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c5d3649-c5f7-4c08-9215-253ae7db2c1c</guid><dc:creator>llly</dc:creator><description>&lt;p&gt;I have a new discovery.&lt;/p&gt;
&lt;p&gt;After loading LFS from an external flash, I used a logic analyzer to capture SPI data and printed SPI addresses through serial ports in the code. Upon comparison, I found that the addresses in the code were 4 bytes, but the SPI data still showed 3 bytes. It seems that even with the use of a file system, there is still an address length issue&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/thread/493541?ContentTypeID=1</link><pubDate>Fri, 12 Jul 2024 03:53:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92e1db2d-1c8f-488f-ad49-3a0bebd42af5</guid><dc:creator>llly</dc:creator><description>&lt;p&gt;Hi Hieu&lt;/p&gt;
&lt;p&gt;I have confirmed that we only need to use Littlefs. After loading LFS in external flash, I want to try saving a file larger than 16mb to test if LFS will encounter the problem of not being able to correctly handle 4-byte addresses (the maximum value corresponding to 3-byte addresses is 16mb) as mentioned earlier. But I found this not feasible because the flash write speed is too slow. I repeatedly write data in a loop and waited for a long time before writing tens of kb. If I want to write 16mb, I may not be able to do so for a day.&lt;/p&gt;
&lt;p&gt;Can you help me test if I still encounter the problem of 4-byte addresses being treated as 3-byte addresses when mounting LFS in external flash? Or my method is incorrect, is there a better testing method? In addition, I am not sure if my operation of changing the external flash capacity to 64MB is correct. I have shown my modification steps above. Perhaps these are two issues, but if necessary, I can issue a new ticket.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/thread/493323?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2024 08:30:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e83c67ff-8b28-45d1-9e30-3af4d3685da6</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi llly,&lt;/p&gt;
[quote user="llly"]What you said about NVS, I took a look and it&amp;#39;s a file system similar to LFS, right? If I use NVS, I should mount it to an external flash and use NVS just like using LFS, so I don&amp;#39;t need to use a flash driver, right?[/quote]
&lt;p&gt;NVS does somewhat the same job. Instead of storing files with path and content, it just stores elements with ID and content.&lt;/p&gt;
&lt;p&gt;I meant to link the documentation but ended up linking the sample last time. Here is NVS documentation:&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/zephyr/services/storage/nvs/nvs.html"&gt;Non-Volatile Storage (NVS) (nordicsemi.com)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As you might have known,&amp;nbsp;you can write to a specific flash address, but you cannot clear a small flash region. You need to clear the entire flash page. This makes updating records a little inconvenient.&lt;/p&gt;
&lt;p&gt;NVS is already setup to take care of that and&amp;nbsp;was also implemented with attention to wear leveling. Of course, the wear leveling is only in the region allocated to NVS.&lt;/p&gt;
&lt;p&gt;Would you like to give it a try? Or would you still want to pursue what is wrong with the flash API? If NVS works, I propose putting the flash API topic in low priority right now, as we are quite overloaded at the moment, and that any additional work would slow us from helping you with other questions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/thread/493260?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2024 01:41:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d719b20-49b6-453f-a6ea-ac5817cd905e</guid><dc:creator>llly</dc:creator><description>&lt;p&gt;Hi Hieu&lt;/p&gt;
&lt;p&gt;I am currently debugging the external flash in order to use other external flash chips on our product. I thought using the flash driver directly would also work properly.&lt;/p&gt;
&lt;p&gt;This is the partition report and config file&lt;/p&gt;
&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/6036.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/.config.rar"&gt;devzone.nordicsemi.com/.../.config.rar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What you said about NVS, I took a look and it&amp;#39;s a file system similar to LFS, right? If I use NVS, I should mount it to an external flash and use NVS just like using LFS, so I don&amp;#39;t need to use a flash driver, right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 9160dk external flash operation address length issue</title><link>https://devzone.nordicsemi.com/thread/493199?ContentTypeID=1</link><pubDate>Wed, 10 Jul 2024 14:36:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0de17f5d-64c3-463b-9b2e-3c3cd25555ab</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi llly,&lt;/p&gt;
&lt;p&gt;Why are you using the&amp;nbsp;Flash Driver directly&amp;nbsp;instead of a higher layer module/subsystem, such as &lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/zephyr/services/settings/index.html"&gt;Settings&lt;/a&gt; or &lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/zephyr/samples/subsys/nvs/README.html"&gt;NVS&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Could you please&amp;nbsp;run the Partition Manager report and share the result?&lt;/p&gt;
&lt;p&gt;Please also share the compiled Kconfig file (&amp;lt;build folder&amp;gt;/zephyr/.config).&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>