<?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>FDS lifetime</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/26085/fds-lifetime</link><description>Hi,
I use SDK13.1 FDS example and have some questions about that.
Is there any influence about the lifetime of Flash when i use FDS function to write and delete the records.If it has,how to calculate the lifetime of Flash.Thanks.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 22 Feb 2020 18:25:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/26085/fds-lifetime" /><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/235825?ContentTypeID=1</link><pubDate>Sat, 22 Feb 2020 18:25:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:066ba011-a0b1-4789-9a0e-8541de05d561</guid><dc:creator>3Rsteven</dc:creator><description>&lt;p&gt;hi MatinBL&lt;/p&gt;
&lt;p&gt;i try to do&amp;nbsp;simple&amp;nbsp;Calculation with FDS lift time. is it right?(only two page ,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;on nrf52(one page is 4096B)&lt;/p&gt;
&lt;p&gt;with base case , only two page (one data and swap). to asset the swap page erase/write count about lifttime.&lt;/p&gt;
&lt;p&gt;if every one&amp;nbsp;minute ,and save one work data. with&amp;nbsp;2 page(1 data and 1 swap) ,do gc when full update&lt;/p&gt;
&lt;p&gt;&lt;span&gt;one FDS Record = TL Part+ IC Part+ Record ID and data(1W) ,is 4 words .&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;the data page and swap page 2Word,&amp;nbsp;0xDEADC0DE F11E01FE and&amp;nbsp;0xDEADC0DE F11E01FF&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;1. every page should be update 255 times/minute, 1024W - 2W(header) / 4 =255 (4.25 hours)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;then swap page and one of data page ,do fds_gc(erase then write )&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. Suppose 4.25 x ~10000(nrf52 minimum 10000 write/erase) , it should be about 5 years(4.9189).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3. if more than data page ,it will more and more ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102810?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 06:00:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38a6d315-5908-4fb1-8227-a11b7f1bbbde</guid><dc:creator>275508995</dc:creator><description>&lt;p&gt;it seem like resolve my problom,than you ,emdi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102811?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 09:11:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:711c4e18-7362-4bfb-a4e7-608c93ef20c8</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;I believe you have open records and that prevents garbage collection from cleaning up the flash.&lt;/p&gt;
&lt;p&gt;In fact, fds_stat() reports you have two records open.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102813?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 08:21:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66d5038c-2255-4050-8cc1-f468992db186</guid><dc:creator>275508995</dc:creator><description>&lt;p&gt;open_records=2 valid_records=38 dirty_records=16 words_reserved=0 words_used=1021 largest_contig=1024 freeable_words=493     this log means if call fds_gc ,it will reclaim 493 words?&lt;/p&gt;
&lt;p&gt;but  i call it ,still Prompt flash full，why？&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102808?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 07:44:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6ddf717-c9ea-4e2f-8ef8-e1203d5fc621</guid><dc:creator>275508995</dc:creator><description>&lt;ul&gt;
&lt;li&gt;i check  the  fds_record_open and fds_record_close is pair .&lt;/li&gt;
&lt;li&gt;my device connect to  the phone, i catch the log.  it show  PM_EVT_STORAGE_FULL ,then call fds_gc, still full&lt;/li&gt;
&lt;li&gt;virtual page is 3.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102809?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 07:27:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:567a617f-0c33-42f2-bfad-4213caed65cd</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see in the stat that you have two open records.
Make sure you don&amp;#39;t have open records before calling garbage collection or it won&amp;#39;t be able to free space. Every time you open a record using fds_record_open() you should close it by calling fds_record_close().&lt;/p&gt;
&lt;p&gt;Also, how large is the record you are trying to store? What virtual page size are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102812?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 05:38:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa3ad567-f3c4-4dae-95b4-2510e80da7ef</guid><dc:creator>275508995</dc:creator><description>&lt;p&gt;emdi:
fds_stat  show log below open_records=2 valid_records=38 dirty_records=16 words_reserved=0
words_used=1021 largest_contig=1024 freeable_words=493&lt;/p&gt;
&lt;p&gt;it looks have space ,but log  show flash is full,why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102806?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2017 08:58:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d27fe84-df04-4482-9957-442628df33cf</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;Then you could try to run fds_stat() and check the field &amp;#39;largest_contig&amp;#39;: it contains the size (in words) of largest record that you can write to flash at that moment.&lt;/p&gt;
&lt;p&gt;If you want to store let&amp;#39;s say 128 bytes, first convert that to words: 128/4 = 32. Then check that the resulting value is smaller than &amp;#39;largest_contig&amp;#39;. If it is, you can fit the data in flash, otherwise you will receive FDS_ERR_NO_SPACE_IN_FLASH. In that case, delete something, run garbage collection and retry.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102805?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2017 08:51:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b451f0c-acbd-48a3-8389-3d85ff4d52a2</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;Well, that error tells you that there is no space in flash.
You can obtain some information by reading the output of fds_stat() although it doesn&amp;#39;t directly tell you how much space is available, you&amp;#39;d have to do some math.  If you want to store more data in flash, delete an old record, run garbage collection and try again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102802?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2017 08:49:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93852dcc-7751-4846-89cd-c71619098776</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;To answer Challen&amp;#39;s questions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;How can i write records in allocate Flash circularly by using FDS library?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If I understand correctly, you are asking if fds automatically deletes the oldest record in flash to make space for a new one. In that case the answer is no, fds won&amp;#39;t do that, you have to implement that logic yourself.&lt;/p&gt;
&lt;ol start="2"&gt;
&lt;li&gt;You receive a synchronous FDS_ERR_NO_SPACE_IN_FLASH error when you try to write more data to flash.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102807?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2017 08:47:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d99a3fb-79bb-477f-b1ff-60f79e4f0599</guid><dc:creator>275508995</dc:creator><description>&lt;p&gt;thank you,emdi     how to check no space in flash? do you have a Good method？  i think i have enough space&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102804?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2017 08:42:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33d4868a-694e-4da3-959b-69f40f2d1d25</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;Probably becase you don&amp;#39;t have space in flash.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102803?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2017 03:35:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c25f92cd-b273-4092-812a-38e74c7047c9</guid><dc:creator>275508995</dc:creator><description>&lt;p&gt;I get the FDS_ERR_NO_SPACE_IN_FLASH error when trying to write to flash, then call  fds_gc()  ，the FDS callback return FDS_SUCCESS ，but when i write to flash again,still FDS_ERR_NO_SPACE_IN_FLASH  ,why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102801?ContentTypeID=1</link><pubDate>Fri, 20 Oct 2017 11:06:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9e73f58-85fc-4a60-9bbe-3ac9ddd9b23c</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Q1. The FDS library handles this for you.&lt;/p&gt;
&lt;p&gt;If the flash is full you get the  FDS_ERR_NO_SPACE_IN_FLASH error when trying to write to flash. In your code it seems like you are trying to handle this error by running a garbage collection, which is what you should do. However, fds_gc() is an asynchronous functions and you should wait for the FDS callback (as you do in the FDS_SUCCESS case) before trying to write again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102800?ContentTypeID=1</link><pubDate>Fri, 20 Oct 2017 04:56:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1017ba5e-8171-4843-a203-4bc4138a82ca</guid><dc:creator>Challen</dc:creator><description>&lt;p&gt;Hi,Martin,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;How can i write records in allocate Flash circularly by using FDS library?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How can i get the status when the allocate is full?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I write some code to deal with the proplem,is there any question about that?&lt;/p&gt;
&lt;p&gt; ret_code_t m_fds_write(uint16_t FileID,uint16_t RecordKey,uint32_t *rec_data,uint16_t length)
{
ret_code_t ret;
fds_record_desc_t   record_desc;
fds_record_t        fds_record;
fds_find_token_t    ftok = {0};&lt;br /&gt;
fds_record_chunk_t record_chunk = {.p_data = (void *)rec_data, .length_words = length,};&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; fds_record.file_id = FileID;
 fds_record.key     = RecordKey; 
 fds_record.data.p_chunks   = &amp;amp;record_chunk;
 fds_record.data.num_chunks = 1;
 WRITE_AGAIN:
 ret = fds_record_find(fds_record.file_id, fds_record.key, &amp;amp;record_desc, &amp;amp;ftok);     
 NRF_LOG_INFO(&amp;quot;FDS Write Start(0x%04X)&amp;gt;&amp;gt;\r\n&amp;quot;, ret);     
 if( ret == FDS_ERR_NOT_FOUND )
 {
 	ret = fds_record_write(&amp;amp;record_desc, &amp;amp;fds_record);
 }
 else
 {
 	ret = fds_record_update(&amp;amp;record_desc, &amp;amp;fds_record);
 }

 switch (ret)
 {
 	case FDS_SUCCESS:
 		while( m_fds_write_flag == false );
 		m_fds_write_flag = false;   
 		return NRF_SUCCESS;

 	case FDS_ERR_BUSY:
 	case FDS_ERR_NO_SPACE_IN_QUEUES:
 		return NRF_ERROR_BUSY;

 	case FDS_ERR_NO_SPACE_IN_FLASH:
 		ret = fds_gc();
 		if (ret)
 					{
 			NRF_LOG_ERROR(&amp;quot;fds_gc fail: %d\n&amp;quot;, ret);
 			return ret;
 		}    
 		goto WRITE_AGAIN;
 		return NRF_ERROR_STORAGE_FULL;

 	default:
 		return NRF_ERROR_INTERNAL;
 }       

 NRF_LOG_INFO(&amp;quot;FDS write successfully\r\n&amp;quot;);
 return ret;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; }&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS lifetime</title><link>https://devzone.nordicsemi.com/thread/102799?ContentTypeID=1</link><pubDate>Thu, 19 Oct 2017 11:19:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d471a7e3-61b4-4d57-a415-4e1aab19e71f</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The flash in the nRF52 series should tolerate minimum 10,000 write/erase cycles (&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/abs_max_ratings.html?cp=2_1_0_4#abs_max_ratings"&gt;specs&lt;/a&gt;) and the FDS library has a basic &lt;a href="https://en.wikipedia.org/wiki/Wear_leveling"&gt;wear leveling&lt;/a&gt;  mechanism to avoid wearing down the flash too soon. The lifetime of the flash depends on how much flash you allocate to the FDS library. Say for example that you only allocate one single page. Then old data will have to be overwritten much sooner than if you allocated e.g. 5 pages, effectively reducing the lifetime. Note also that the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.1.0/lib_fds_format.html?cp=4_0_0_3_50_2"&gt;FDS records&lt;/a&gt; has some overhead.&lt;/p&gt;
&lt;p&gt;Bottom line; assign as many pages you can to the FDS library, and try to minimize the effect of the overhead by storing as much data as you can in each record. In the end, how long your flash will last depends on your implementation and is hard to calculate without intimate knowledge of your application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>