<?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>Memory management with NVS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/101871/memory-management-with-nvs</link><description>Hi 
 I am using Nordic&amp;#39;s NVS system on an nRF5340. I have successfully got the code mounting, writing and reading from a user defined partition in flash memory. 
 For now, I am using just two sectors 
 The documentation here contains information on calculating</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Aug 2023 08:15:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/101871/memory-management-with-nvs" /><item><title>RE: Memory management with NVS</title><link>https://devzone.nordicsemi.com/thread/439185?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2023 08:15:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd9e34f7-ab7e-459b-bb90-325207655e99</guid><dc:creator>SwRa</dc:creator><description>&lt;p&gt;Hi Garrett,&lt;/p&gt;
[quote user="garrettb"]re-using the same records all the time [/quote]
&lt;p&gt;In this case, you don&amp;#39;t need to manually implement sector erasing since you are not saving it as a new record.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Swathy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory management with NVS</title><link>https://devzone.nordicsemi.com/thread/438825?ContentTypeID=1</link><pubDate>Fri, 28 Jul 2023 18:50:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:363b363a-e085-4db1-96d8-7e2ba6808383</guid><dc:creator>garrettb</dc:creator><description>&lt;p&gt;Hi SwRa,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think I understand what you are saying.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What I am saying is this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I will be saving about 10 variables in Flash.&lt;/li&gt;
&lt;li&gt;I will be reading them all, on power up.&lt;/li&gt;
&lt;li&gt;At run time, one or more of these variables will be updated, from time to time - depending on user interaction.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&amp;#39;s it.&lt;/p&gt;
&lt;p&gt;So in that case, I suppose I have 10 stored records - re-using the same records all the time (whenever user interactions determine that I need to update one or more variables).&lt;/p&gt;
&lt;p&gt;So do I have to manually look after sector erasing etc., or will that be done automatically by the NVS system?&lt;/p&gt;
&lt;p&gt;Thanks&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Garrett&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory management with NVS</title><link>https://devzone.nordicsemi.com/thread/438523?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2023 12:55:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a930168a-817e-44cb-92bc-dccb1d22d12c</guid><dc:creator>SwRa</dc:creator><description>&lt;p&gt;Hi Garret,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="garrettb"]My code will be writing to Flash to update a single variable, whenever that variable is changed.[/quote]
&lt;p&gt;It will only be updating a single value in an already stored record in this case right.? Or is it that you are planning to store the new value as a new record.?&lt;/p&gt;
&lt;p&gt;f you are just updating a value in the record, then it would be erased when a sector becomes full. You can read about flash wear here:&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/latest/services/storage/nvs/nvs.html#calculating-expected-device-lifetime"&gt;https://docs.zephyrproject.org/latest/services/storage/nvs/nvs.html#calculating-expected-device-lifetime&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, if you keep storing new data as a new record, then there is no mechanism to erase the old data to get space for new data.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Swathy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory management with NVS</title><link>https://devzone.nordicsemi.com/thread/436836?ContentTypeID=1</link><pubDate>Mon, 17 Jul 2023 17:01:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95d2f68a-e72e-429a-b6fc-c6fddc559abd</guid><dc:creator>garrettb</dc:creator><description>&lt;p&gt;Hi Swathy&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the response.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I read the post you refer to.&lt;/p&gt;
&lt;p&gt;The information is not too clear though.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From reading that post, it seems to state:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you are using only one variable, and you keep over-writing that variable, then the NVS system will look after tidy up / erasing, when a sector becomes full&lt;/li&gt;
&lt;li&gt;If you are continuously writing new data, the NVS system will NOT look after the tidy up / erasing. Instead, when it eventually runs out of space, the write function will return an error.&lt;/li&gt;
&lt;li&gt;If you have, say, 10 variables, and some of these are being updated from time to time, then...???&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the end, I have about 10 variables I want to store in Flash. My code will be writing to Flash to update a single variable, whenever that variable is changed.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Question: Will the tidy up / erasing be managed automatically by the NVS system, or will I eventually run out of space?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Garrett&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory management with NVS</title><link>https://devzone.nordicsemi.com/thread/436427?ContentTypeID=1</link><pubDate>Fri, 14 Jul 2023 09:34:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:176f77f0-e13c-4d98-9cdc-34fd492f0d0b</guid><dc:creator>SwRa</dc:creator><description>&lt;p&gt;HI Garrett,&lt;/p&gt;
&lt;p&gt;Take a look at this ticket:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/91317/nvs-sector-erase"&gt;NVS sector erase&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Swathy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>