<?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 write fail</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/24108/fds-write-fail</link><description>Hi all, 
 I have some problem with the FDS write function. 
 This is some example codes for my FDS write: 
 // Global variables
static uint16_t fileID; 
static uint16_t recordKey;
static fds_record_t record;
static fds_record_desc_t record_desc;</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 09 Aug 2017 02:48:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/24108/fds-write-fail" /><item><title>RE: FDS write fail</title><link>https://devzone.nordicsemi.com/thread/94912?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2017 02:48:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2ccffba-4123-467d-b068-bf5a120e9385</guid><dc:creator>Louis</dc:creator><description>&lt;p&gt;Based on your code, check addr. of saveData &amp;amp; saveData2 in map file. Suppose addr of saveData should be 4-byte alignment, but saveData2 not.
Moreover, write_flag should be reset be4 write operation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS write fail</title><link>https://devzone.nordicsemi.com/thread/94911?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2017 01:13:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ec7512d-60f8-4416-95fc-ce0fe2b9802c</guid><dc:creator>kian79</dc:creator><description>&lt;p&gt;Hi Louis,&lt;/p&gt;
&lt;p&gt;What do you mean the start address is word align? Can you give an example? Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS write fail</title><link>https://devzone.nordicsemi.com/thread/94910?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2017 01:11:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa781562-4786-4053-bb58-7f0b8ebf2361</guid><dc:creator>Louis</dc:creator><description>&lt;p&gt;Guess you got this error: FDS_ERR_UNALIGNED_ADDR. If the case, make sure the start addr. is word alignment.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS write fail</title><link>https://devzone.nordicsemi.com/thread/94909?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2017 00:51:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68f23611-5e67-451d-b834-f009bb87bff3</guid><dc:creator>kian79</dc:creator><description>&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;I managed to get it to work partially. Its a strange problem. Somehow, the write will fail if the data I am saving into Flash is not taking up a multiple of uint32_t memory and it needs to be at least 3 x uint32_t memory.&lt;/p&gt;
&lt;p&gt;So I had to do this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;struct
{
    uint8_t     	var1[7];
    uint8_t		dummy1;
    uint16_t		var2;
    uint16_t		dummy2;
} saveData2;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So this works. But WHY?&lt;/p&gt;
&lt;p&gt;I also have another weird problem. I am using both fds write and fds update to two different recordKey.&lt;/p&gt;
&lt;p&gt;Assuming I already have one record in recordKey 0x2001 and one record in recordKey 0x2000. And I call the following codes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// fds_update function
static ret_code_t fds_update(void)
{
    ret_code_t ret = fds_record_update(&amp;amp;record_desc, &amp;amp;record);
    if (ret != FDS_SUCCESS)
    {
        return ret;
    }
    while (update_flag==0);
    NRF_LOG_INFO(&amp;quot;Updating Record ID = %d \r\n&amp;quot;,record_desc.record_id);
    return NRF_SUCCESS;
} 

// inside main
fileID = 0x1000;
recordKey = 0x2001;
fds_write();

fileID = 0x1000;
recordKey = 0x2000;
fds_update();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When I do a record search, I end up with two records in recordKey 0x2000 and 1 recordKey in 0x2001. But this is wrong. I should have 2 records in recordKey2001 and have a new updated 1 record in recordKey 0x2000.&lt;/p&gt;
&lt;p&gt;*&lt;strong&gt;Update&lt;/strong&gt;
&lt;strong&gt;I solved the problem. I need to call fds_find_record first before calling fds_update. This worked for me&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS write fail</title><link>https://devzone.nordicsemi.com/thread/94908?ContentTypeID=1</link><pubDate>Mon, 07 Aug 2017 14:03:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cedc2842-b0a2-4402-ac15-27ab3e29e1cb</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Would it the same issue as in the question &lt;a href="https://devzone.nordicsemi.com/question/156756/fds-problems-in-sdk121/"&gt;here&lt;/a&gt; ?
I have an example of doing 2 writes in the case, it worked fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FDS write fail</title><link>https://devzone.nordicsemi.com/thread/94907?ContentTypeID=1</link><pubDate>Mon, 07 Aug 2017 07:25:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f0c8307-052d-4a66-ad36-4dd31c13249a</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;what error do you get?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>