<?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>NVS Storage Cannot Properly Read Stored Data After Reboot. NRF9160DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103985/nvs-storage-cannot-properly-read-stored-data-after-reboot-nrf9160dk</link><description>I used the NVS example for the NRF9160. It worked very well. I can run the example, without any issue. 
 However, I then integrated the NVS example into my actual project. Most things work. I can write to the device, and then read it. No problem. 
 But</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Sep 2023 14:44:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103985/nvs-storage-cannot-properly-read-stored-data-after-reboot-nrf9160dk" /><item><title>RE: NVS Storage Cannot Properly Read Stored Data After Reboot. NRF9160DK</title><link>https://devzone.nordicsemi.com/thread/447120?ContentTypeID=1</link><pubDate>Thu, 21 Sep 2023 14:44:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac97ba18-a328-406e-a07c-93e306757cde</guid><dc:creator>Maria Gilje</dc:creator><description>&lt;p&gt;Hi Steve,&lt;/p&gt;
[quote user=""]1. nvs_read() ALWAYS returns a size of 254, even before anything is written to it (right after a fresh erase &amp;amp; flash). In the NVS example code, there is a test to see if there is any data in the given address ID. [/quote]
&lt;p&gt;How do you read the value of the return? Is it possible that nvs_read is returning a negative error code, but you are reading it as an unsigned int?&lt;/p&gt;
[quote user=""]2. Once I DO write to the given ID with nvs_write(), I can then read it back without issue, during the same session. Upon reboot (not re-flash), however, the program is back to always returning 254 as the size, whether or not something had been written there before rebooting. In this case there should be have been something there, a struct of size 228 byes.[/quote]
&lt;p&gt;I don&amp;#39;t have details for you right now, but I can elaborate later.&lt;/p&gt;
&lt;p&gt;Note that Zephyr Settings storage has a partition in NVS. You can share the partition with Zephyr Settings storage by defining the partitions in .yaml. See &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/77781/problem-to-read-back-flash-with-nvs-when-concurrent-use-with-bluetooth/331360"&gt;this reply&lt;/a&gt; in a previous ticket. &lt;/p&gt;
&lt;p&gt;Please let me know if this is helpful. If you are having trouble still, I will help you more.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Maria&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>