<?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 update returns or changes some part of data randomly.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52532/fds-update-returns-or-changes-some-part-of-data-randomly</link><description>Hi, 
 We are using NRF 15.03 SDK and used NUS application for the project. We need to store some data into flash and we are using FDS example based code to do the same. 
 We are storing two files. File 1 has 6KB data (divided into 500 records of 12 Bytes</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Sep 2019 08:29:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52532/fds-update-returns-or-changes-some-part-of-data-randomly" /><item><title>RE: FDS update returns or changes some part of data randomly.</title><link>https://devzone.nordicsemi.com/thread/211976?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2019 08:29:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9549667f-a615-4fe9-84b2-03bd9399742e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Bharath Gopal"]If it is so, why does it fail only some time? I am using a global buffer every time and the address is always same.[/quote]
&lt;p&gt;I cannot explain that. Can you double-check?&lt;/p&gt;
[quote user="Bharath Gopal"]If it is a address alignment issue, how to make sure that the buffer is word aligned?[/quote]
&lt;p&gt;This is only an issue if you are using non-4 byte data types, or for instance structs with some members that are not 4 bytes. Then depending on the packing of the struct, the data may not be aligned. See &lt;a href="https://devzone.nordicsemi.com/members/pellepl"&gt;this post&lt;/a&gt; for how to fix it in that case. If that does not help, please share some code showing the data structure you are trying to write to flash and how you write it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS update returns or changes some part of data randomly.</title><link>https://devzone.nordicsemi.com/thread/211949?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2019 06:52:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53433f6d-7b16-4e13-90fa-b5cc24a132eb</guid><dc:creator>Bharath Gopal</dc:creator><description>&lt;p&gt;If it is so, why does it fail only some time? I am using a global buffer every time and the address is always same.&lt;/p&gt;
&lt;p&gt;If it is a address alignment issue, how to make sure that the buffer is word aligned?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS update returns or changes some part of data randomly.</title><link>https://devzone.nordicsemi.com/thread/211853?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2019 13:29:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e414014-a605-4e0b-8f1a-a2bc842d8943</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This means that you are providing a pointer to an address that is not a multiple of 4. This is invalid since all flash operations must be word-aligned, and the flash words are 4 byte-sized.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS update returns or changes some part of data randomly.</title><link>https://devzone.nordicsemi.com/thread/211759?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2019 10:10:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22f21a7f-92e2-47bd-bf34-afdc76b17b6c</guid><dc:creator>Bharath Gopal</dc:creator><description>&lt;p&gt;Thanks for the update Einar.&lt;/p&gt;
&lt;p&gt;I am calling write function from UART interrupt on receiving some commands. Also, the update pending write is called from FDS_EVT handler.&lt;/p&gt;
&lt;p&gt;When I check for the return code inside FDS_EVT&amp;nbsp; handler, it returns code 3 (FDS_ERR_UNALIGNED_ADDR).&lt;/p&gt;
&lt;p&gt;What does this error mean?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;Bharath&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS update returns or changes some part of data randomly.</title><link>https://devzone.nordicsemi.com/thread/211713?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2019 08:24:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c5c8e23-6814-48af-a9dc-159b9a8249ab</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Bharath,&lt;/p&gt;
&lt;p&gt;Good to hear you fixed the initial issue.&lt;/p&gt;
[quote user="Bharath Gopal"]At some point when the fds_gc gets called, the callback function calls &amp;quot;FDS_EVT_GC&amp;quot; &amp;amp; I call my write pending function to write back the pending data. But the callback never gets called for update complete after this .[/quote]
&lt;p&gt;It is difficult to say anything specific without seeing your code. But another typical issue when people test FDS is problems with interrupt priorities. Do you by any chance call the write function from the event handler (or a function that is called from there or in another interrupt context)? If so, and if you also wait for the event in a loop, then you will have a deadlock. This is all just guesses though. Please share and explain your code if it does not fit so that I can see what you are actually doing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS update returns or changes some part of data randomly.</title><link>https://devzone.nordicsemi.com/thread/211573?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2019 14:04:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73b85d5a-3945-48a4-b6aa-22429e044d4a</guid><dc:creator>Bharath Gopal</dc:creator><description>&lt;p&gt;Hi Einar Thorsrud,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;I added a variable to check if the write/update is complete in the fds_evnt_callback switch cases. Every time, the variable becomes true and I write data, it succeeds.&lt;/p&gt;
&lt;p&gt;At some point when the fds_gc gets called, the callback function calls &amp;quot;FDS_EVT_GC&amp;quot; &amp;amp; I call my write pending function to write back the pending data. But the callback never gets called for update complete after this .&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;Bharath&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS update returns or changes some part of data randomly.</title><link>https://devzone.nordicsemi.com/thread/211518?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2019 11:31:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6adce705-c0c8-46ff-87dc-3748f8d9ed32</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Bharath,&lt;/p&gt;
&lt;p&gt;It sounds like you may be reading back the data before the updated record has actually been written. Have you remembered to wait for the event indicating that the flash write operation has completed (succeeded or failed)? This is the&amp;nbsp;FDS_EVT_UPDATE for a record update, or the&amp;nbsp;FDS_EVT_WRITE event when writing a new record.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>