<?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 record update increments record ID, and calls event handler twice</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54847/fds-record-update-increments-record-id-and-calls-event-handler-twice</link><description>Hello, 
 SDK: 15.3.0 
 nRF52840-DK 
 s140 
 I have taken the flash_fds_s140_pca10056 example and modified it for our own use. I would like to store versioning information, number of system resets, system on time, and various other system related information</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Nov 2019 09:48:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54847/fds-record-update-increments-record-id-and-calls-event-handler-twice" /><item><title>RE: FDS record update increments record ID, and calls event handler twice</title><link>https://devzone.nordicsemi.com/thread/222559?ContentTypeID=1</link><pubDate>Thu, 28 Nov 2019 09:48:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a872679f-16e8-47fd-8eb3-9188037f568d</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Paul&lt;/p&gt;
&lt;p&gt;Yes, I guess record count would be a more descriptive name of it. The Record ID is indeed an internal ID used to &amp;quot;keep track of&amp;quot; every record and a way to see where the previous records are written are in relation to one another. It is exposed so that people may use this to keep track of their records as well, but for your specific use case, it seems like file_id and record_key would be better suited.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS record update increments record ID, and calls event handler twice</title><link>https://devzone.nordicsemi.com/thread/222388?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2019 14:07:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ed4c007-0d19-49ba-8e51-862ca851bd9d</guid><dc:creator>BEplane</dc:creator><description>&lt;p&gt;So the Record ID isn&amp;#39;t really an ID, but more of a Record Count, or Record Update Count?&lt;/p&gt;
&lt;p&gt;And in this case the data wouldnt be considered duplicate, as it is being discarded, or marked as dirty. And the record persists in a different physical memory location, but the record/data is still intended to be the same. The Record ID seems to an internal FDS feature being exposed? It is my understanding that the FDS API is suppose to provide high level functionality for the fstorage. So the valid or expected use of the record ID is unclear?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS record update increments record ID, and calls event handler twice</title><link>https://devzone.nordicsemi.com/thread/222271?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2019 09:58:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86c60274-6eca-44d2-9585-5a7e5dc6663c</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Paul&lt;/p&gt;
&lt;p&gt;Sorry about causing any confusion, I thought those threads would be helpful, but obviously, they weren&amp;#39;t in your case.&lt;/p&gt;
&lt;p&gt;So, the reason you&amp;#39;re seeing two (and three) record IDs is that the fds_record_update first writes a new record to flash, then deletes the old record. Described in the documentation under &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__fds.html&amp;amp;anchor=gaa71e86ec4e3022063eb08c3411636561"&gt;fds_record_update &lt;/a&gt;This is due to the physical properties of the flash memory, as you are only able to erase full pages, so when you want to update a record you&amp;#39;ll have to write a new one and mark the old one as dirty.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;This means that it won&amp;#39;t be possible to have just one set of data in the FDS I&amp;#39;m afraid, as the data will technically be duplicated, as it is marked as dirty during an update and will stay until you call a garbage collection. Even though the record and file ID aren&amp;#39;t guaranteed to be unique, won&amp;#39;t this be sufficient to identify your data correctly? You can alternatively, set your own ID as part of the data for identification.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS record update increments record ID, and calls event handler twice</title><link>https://devzone.nordicsemi.com/thread/222140?ContentTypeID=1</link><pubDate>Tue, 26 Nov 2019 14:34:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afd91002-0044-467f-b156-4699d3b3b95e</guid><dc:creator>BEplane</dc:creator><description>&lt;p&gt;I did not link any threads in my post, but I have seen both of these threads before and liked them. Also neither of the threads have a definitive explanation to clear up how the Record ID, Record Key, and File Key can be used. Linking to other threads that are not properly answered only creates a web of confusion. This helps no one.&lt;/p&gt;
&lt;p&gt;I do not see where the thread speaks about the record ID increasing. Can you explain this in more depth?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="8164" url="~/f/nordic-q-a/35843/flash-data-storage-fds-what-is-the-point-of-files-and-records/138084"]That is correct. You have two sets of identifiers, one named file and the other named record, that you can use however you want to &amp;quot;tag&amp;quot; the entries.[/quote]
&lt;p&gt;&lt;strong&gt;File Key&lt;/strong&gt;, and &lt;strong&gt;Record Key&lt;/strong&gt;, are the identifiers I can use &amp;#39;however&amp;#39; I would like.&lt;/p&gt;
&lt;p&gt;I would like a single structure stored in persistent flash. I would like to update the values of this structure and get the values of the structure. I do not want to create multiple &lt;strong&gt;Record IDs&lt;/strong&gt;, or in other words duplicate data, I only want 1 set of data. Is this possible with the FDS?&lt;/p&gt;
&lt;p&gt;Additionally, why is the Record ID Increasing? and does this in fact mean there is a duplicate record?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS record update increments record ID, and calls event handler twice</title><link>https://devzone.nordicsemi.com/thread/222094?ContentTypeID=1</link><pubDate>Tue, 26 Nov 2019 13:02:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f2f5564-3039-4c93-b5d5-55abc1c07a3f</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;The record ID (and record key for that matter), are discussed and explained thoroughly in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/47587/difference-between-fds-record-key-and-record-id"&gt;this thread&lt;/a&gt; and the thread linked to. I hope this will help you understand why the record ID is increasing.&lt;/p&gt;
&lt;p&gt;As for why FDS_EVT_UPDATE occurs twice, that has to be because the update is called twice somewhere in your application whether you&amp;#39;re aware of it or not.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>