<?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>Basic FDS Question</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108671/basic-fds-question</link><description>System Details: 
 Chipset: nRF52840 SDK: nRF52 SDK v17.0.2 Using Zephyr: No 
 Overview: 
 The documentation for FDS has been very helpful, and with that, I was able to get something running pretty quickly, but I would like to ask a couple of questions</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Mar 2024 13:43:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108671/basic-fds-question" /><item><title>RE: Basic FDS Question</title><link>https://devzone.nordicsemi.com/thread/472729?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2024 13:43:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b79b4335-7177-4085-8b82-8017bf29e608</guid><dc:creator>Birt</dc:creator><description>&lt;p&gt;I will create a separate ticket for this and close the issue with your verified answer. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Basic FDS Question</title><link>https://devzone.nordicsemi.com/thread/471310?ContentTypeID=1</link><pubDate>Wed, 28 Feb 2024 13:10:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d052ddc0-7374-4e79-8fde-b1a7fc489a88</guid><dc:creator>Birt</dc:creator><description>&lt;p&gt;I really appreciate the response!&lt;br /&gt;&lt;br /&gt;I see what you mean now with regard to records. Based on the extra info you provided, I think it&amp;#39;s safe to say that FDS is really a collection of records indexed by the key/file ID combination, as seen in the Nordic docs below&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-components-multipleuploadfilemanager/5d50a394_2D00_61ed_2D00_4ea6_2D00_80cf_2D00_e051e300d8a4-130633-complete/pastedimage1709050081607v1.png" /&gt;&lt;br /&gt;Since I can&amp;#39;t reserve a specific size, I&amp;#39;m wondering if maybe I can reserve a certain number of records instead.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;For example, for wear leveling, let&amp;#39;s say I reserve ten records for logging; each record will have a unique record key, 1-10, and share the same file ID.&lt;br /&gt;&lt;br /&gt;Kind of something like this:&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1709126037150v1.png" alt=" " /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The logic for those ten slots would be the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If a log already exists in one of the ten records, then the &amp;quot;occurrence count&amp;quot; for that specific log is incremented and the existing log will be updated.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;If the log doesn&amp;#39;t exist, and one of the ten records is available, then the new log will be written. This process continues until all ten records are filled.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;If all ten slots are filled with unique logs, and a new log that does not exist comes in, then it will be dropped.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I know this is purely an implementation question, but I&amp;#39;m curious if FDS would allow for a paradigm like this.&lt;/p&gt;
&lt;p&gt;Also, I say &amp;quot;wear leveling,&amp;quot; but I haven&amp;#39;t convinced myself that I am using that term correctly. Mainly because an FDS update is really still a write, and I think it invalidates the previous record. So, the FDS design I mentioned about reserving ten records might not actually save me anything. &lt;br /&gt;&lt;br /&gt;Again, I know this is more of an implementation question, but can you confirm if I am on the right track?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Basic FDS Question</title><link>https://devzone.nordicsemi.com/thread/471094?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2024 15:41:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e42897db-7fc3-4825-81b3-8d1537f9227c</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]Is there a way to specify how many pages per file? For example, say I wanted to reserve 4K for logs, and 1K for the reset count, each of which would be separate files, with multiple records.[/quote]
&lt;p&gt;This is not quite how FDS works. All data in FDS is stored in records, where each record is tagged with a &amp;quot;file ID&amp;quot; and a &amp;quot;record key&amp;quot;. The name &amp;quot;file ID&amp;quot; indicates that all records marked with the same file ID is part of the same collection of data, but physically the records can be spread between all FDS data pages. There is no limit to the total flash space used by records of a specific file ID, no. If you want to keep the total amount of records (or space used by records) below a certain threshold, then I am afraid you must implement that yourself.&lt;/p&gt;
[quote user=""]Does my logic above make sense, where you would use one file for (n) number of records, or in my case, logs? If so, is there a maximum number of records per file? Or any sort of rollover that is required?[/quote]
&lt;p&gt;Yes, using file ID for discerning between different collections of data stored by FDS makes sense. This is for instance how the peer manager module stores information about BLE peers, bonding data, etc. Each file ID is used for one type of data, and record keys are used for labelling different pieces of data of that same type.&lt;/p&gt;
&lt;p&gt;There is no maximum number of records (other than the need for enough flash space for storing the records.) Typically one would want to use the &amp;quot;record key&amp;quot; field for discerning between records belonging to the same file, but there is nothing preventing you from storing multiple records with the same file ID and record key combination (in which case you may want to encode some information in the record data itself, for keeping the data organized.)&lt;/p&gt;
&lt;p&gt;If you use the record key for ordering log messages, each message with its own unique record key, then the maximum number of log entries will be 2^16 - 1 = 65535. If you use the record key for marking different levels, sources, etc. of logs, and rather timestamp or number your log entries in the messages themselves, then you will only be limited by the amount of flash pages configured for use by FDS.&lt;/p&gt;
[quote user=""]This could certainly be a misunderstanding on my end, but I noticed that the examples hardcoded the record key. For example:[/quote]
&lt;p&gt;(...)&lt;/p&gt;
[quote user=""]In my case, I thought each log would have its own record key to prevent overwriting the last entry, but maybe that&amp;#39;s not how it works. I&amp;#39;m just thinking of the case where you have a single file, which contains 100 logs. I thought each log would be considered a record, so I hoped not to specify the key.[/quote]
&lt;p&gt;You can choose yourself, whether to use an incrementing record key (for making each log message individually unique) or if you want to use a scheme where multiple (or all) log messages share the same record key (and then fetch out all entries and sort them by the message contents or ortherwise based on the record data.) Both are possible.&lt;/p&gt;
&lt;p&gt;If you search for a file ID / record key combination, you will get the first record found in flash, that matches that combination. Then, for consecutive searches, you can start from the previous match and search for the next entry. This way you can fetch all records of a given file ID / record key combination. Please note however that there is no guarantee to the order in which you get the matches, only that if you follow this procedure you will fetch out all matching entries (in some order.) Therefore, if there is an order to the records, then you will either have to use record key for marking this order, or have some information in the record data itself describing the order.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>