<?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 garbage. Invalid offset on new page.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12191/fds-garbage-invalid-offset-on-new-page</link><description>SDK 4.0.0-2.alpha 
 When run garbage collection, sometimes invalid offset on new page is present.
Adding next string fix this.
m_swap_page.write_offset = FDS_PAGE_TAG_SIZE; // [FIX] 
 I did correctly? 
 Full function text: 
 static ret_code_t gc_swap</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Mar 2016 12:27:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12191/fds-garbage-invalid-offset-on-new-page" /><item><title>RE: fds garbage. Invalid offset on new page.</title><link>https://devzone.nordicsemi.com/thread/46132?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2016 12:27:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cce2b71-13fe-4fb9-8e92-767b9916fb7a</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Petr,&lt;/p&gt;
&lt;p&gt;I can confirm the issue that you are seeing, and the validity of your workaround.&lt;/p&gt;
&lt;p&gt;I had a chat with the developers of FDS, and looked into the internal repository.
They have actually implemented the same fix that you have found, and this will be included in the next release of the SDK.&lt;/p&gt;
&lt;p&gt;Best regards,
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fds garbage. Invalid offset on new page.</title><link>https://devzone.nordicsemi.com/thread/46131?ContentTypeID=1</link><pubDate>Wed, 09 Mar 2016 06:24:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a183689-bd42-4cc1-b87f-666405fbcb05</guid><dc:creator>Petr</dc:creator><description>&lt;p&gt;Hi!
I save bond data and periodic save my custom parameters.
When save my custom parameters and the flash page ends, fds_write() return FDS_ERR_NO_SPACE_IN_FLASH. It runs fds_gc().
In the second iteration, result of fds_gc() is erased page and new page with data at error offset, see pics. This error offset equal length of bond data.
FDS_VIRTUAL_PAGES =2 for simplify.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://i10.pixs.ru/storage/9/8/8/GCjpg_6543296_21023988.jpg" alt="image description" /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bool saveFile (dataFile_t &amp;amp;data)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{
ret_code_t         retval;
fds_record_key_t   key;
fds_record_chunk_t chunk;
fds_record_desc_t  descriptor;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clearFile(data);

// Fill in the record keys.
key.type     = SETUP_PARAMETERS_TYPE;
key.instance = data.fileId;

// Initialize the record chunk, pointing it to the data to be stored.
chunk.p_data       = data.pointer;
chunk.length_words = data.length;

// Write the record to flash.
retval = fds_write /*fds_update*/ (&amp;amp;descriptor,
                   key,
                   1,
                   &amp;amp;chunk);

if (retval != NRF_SUCCESS)
{
    if (retval == FDS_ERR_NO_SPACE_IN_FLASH)
    {
        //Garbage collection reclaims the flash space occupied by records which have been cleared using fds_clear
        fds_gc();
        vTaskDelay(GC_WAIT_100MLS);
        // Write the record to flash.
        retval = fds_write (&amp;amp;descriptor,
                            key,
                            1,
                            &amp;amp;chunk);
        if (retval != NRF_SUCCESS) return false;
    }
    else return false;
}
return true;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fds garbage. Invalid offset on new page.</title><link>https://devzone.nordicsemi.com/thread/46130?ContentTypeID=1</link><pubDate>Wed, 02 Mar 2016 15:22:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88d4e5ab-0043-4b89-a690-ee3abeb17ea3</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you post a test-snippet on how you are re-creating this scenario?
Is it storing+erasing data, storing+erasing, then running a GC?&lt;/p&gt;
&lt;p&gt;Cheers,
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>