<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-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>Problems writing/reading struct to NVS</title><link>https://test-devzone.nordicsemi.com/f/nordic-q-a/87109/problems-writing-reading-struct-to-nvs</link><description>I&amp;#39;ve been slowly adding NVS functionality to my code. Has been working fine, up until today when I attempted to write a struct I have for storing historical data to flash. 
 This is the struct: 
 
 I then have an array of this struct. At this point, MAX_STRIKE_RECORDS</description><dc:language>en-US</dc:language><generator>Telligent Community 13 Non-Production</generator><lastBuildDate>Wed, 20 Apr 2022 22:48:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/87109/problems-writing-reading-struct-to-nvs" /><item><title>RE: Problems writing/reading struct to NVS</title><link>https://test-devzone.nordicsemi.com/thread/364043?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 22:48:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3759ca1a-6ab0-4fba-abf5-887a27fa5d74</guid><dc:creator>user109035</dc:creator><description>&lt;p&gt;Thanks Haakonsh.&lt;/p&gt;
&lt;p&gt;If I simplify what I&amp;#39;m trying to write to NVS, it seems to work OK.&amp;nbsp; I changed my data structure to just a simple array:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint16_t lsr_strike_log[9];&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And if I write/read this to NVS, I can see that the data is being stored.&amp;nbsp; I&amp;#39;m still getting weird values for the return value from nvs_write() and nvs_read() though.&lt;/p&gt;
&lt;p&gt;This is the log info I see when writing the simple array:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://test-devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1650494870009v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;If I try and write my struct to NVS in the form I ultimately want to, I crash my DK and it keeps rebooting.&lt;/p&gt;
&lt;p&gt;In my code I initialse NVS before I initialise anything to do with BLE, so not sure if the BLE initialisation then changes what I&amp;#39;ve done when setting up NVS?&lt;/p&gt;
&lt;p&gt;Thanks and regards,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems writing/reading struct to NVS</title><link>https://test-devzone.nordicsemi.com/thread/363989?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 14:20:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e7c45ec-9155-4b83-adbf-01e9467d415a</guid><dc:creator>user13562</dc:creator><description>&lt;p&gt;I think NVS might already be initialized by the bluetooth stack, it uses it to store certain settings. I&amp;#39;ll do some digging and see what I can find.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>