<?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>nrf52840 flash endurance in long life span</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58431/nrf52840-flash-endurance-in-long-life-span</link><description>Hello, 
 I am working on a project that is using nrf52840 chip as a peripheral and the product is supposed to last and run for 25 years. During that period the device will receive connections at least once every day that results in about 25 x 365 = 9125</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 28 Feb 2020 11:52:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58431/nrf52840-flash-endurance-in-long-life-span" /><item><title>RE: nrf52840 flash endurance in long life span</title><link>https://devzone.nordicsemi.com/thread/237102?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2020 11:52:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c4b949e-868b-47c9-a10a-47c0b8a21218</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This should not be a problem.&lt;/p&gt;
[quote user=""]1.&amp;nbsp;We are using&amp;nbsp;FDS library to write to data to flash. If we write the same value (32-bit word) to the same memory location will it get through and result in a word erase? Which then reducing the life time of the flash? Or will it test and if the same value resides in memory it will skip writing it again?[/quote]
&lt;p&gt;FDS is a simple file system, so you cannot use it to write to a specific memory location. That is a good thing in this context. You refer to the data by a file ID and record&amp;nbsp;key, instead of the location. If you update a record, then in practice the old is flagged as dirty/deleted and a new record is written at a different location. In order to reuse the same location again the flash page need to be erased, and that happens when you do a garbage collection, which is typically something you only do when needed.&lt;/p&gt;
[quote user=""]I am working on a project that is&amp;nbsp;using nrf52840 chip as a peripheral and the product is supposed to last and run for 25 years. During that period&amp;nbsp;the device will receive connections at least once every day that results in about 25 x 365 = 9125 times. Total up time of the device during the life span is around 300 hours.[/quote]
&lt;p&gt;If you only plan to write up to 9125 times that is even within the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/nvmc.html?cp=4_0_0_3_2_9#unique_797338916"&gt;10,000&amp;nbsp;write/erase cycles that is specified for the nRF52840 flash&lt;/a&gt;. That said, using FDS you will get a &lt;em&gt;much&lt;/em&gt; lower value. FDS has 3 words (12 bytes) overhead per record and 2 (8 bytes) words overhead per page. So if the data is a 32 bit word, the effective number of bytes you can fit in a FDS page (1024 - 2 = 1022 wors) is 1022 / (1+3) = words 505 times per page erase. And if you use more pages for FDS this number becomes even larger.&lt;/p&gt;
[quote user=""]2.&amp;nbsp;Does softdevice write to flash during connection / events / disconnection phase that may wear out flash during its 9125+ communication periods?[/quote]
&lt;p&gt;The SoftDevice itself never writes to flash. But the peer manager library might write to flash, for instance when pairing or bonding, or when a bonded peer reconnected etc. It uses &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_fds.html"&gt;FDS&lt;/a&gt;&amp;nbsp;which has wear leveling as explained above, so I cannot imagine it will be a practical problem.&lt;/p&gt;
[quote user=""]3. Is there any guideline / best practice on preventing problems related to flash endurance in long run?[/quote]
&lt;p&gt;Avoid writing to flash directly if you can. Using FDS for all persistent storage is a good idea in most cases. Don&amp;#39;t do FDS garbage collection unless you need to, particularly don&amp;#39;t do it after every reset in case it could happen that your device ends up in a loop where it constantly resets (which is of course usually a bad sign for other reasons).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>