<?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>fstorage: writting and then reading &amp;#39;wrong&amp;#39; data?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48193/fstorage-writting-and-then-reading-wrong-data</link><description>Env: nrf52, sdk15, ubuntu, SES 
 
 Hi First steps on fstorage. As I just need to store and read an array of some bytes I have chosen fstorage 
 
 
 
 and I got this as output: 
 fstorage example started. SoftDevice is present. Initializing nrf_fstorage_sd</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Jun 2019 14:23:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48193/fstorage-writting-and-then-reading-wrong-data" /><item><title>RE: fstorage: writting and then reading 'wrong' data?</title><link>https://devzone.nordicsemi.com/thread/191160?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 14:23:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dde05b34-e886-4672-830c-ffff15e48c2e</guid><dc:creator>Alex Co</dc:creator><description>&lt;p&gt;Same output, I meant this:&lt;/p&gt;
&lt;p&gt;fstorage example started.&lt;br /&gt;SoftDevice is present.&lt;br /&gt;Initializing nrf_fstorage_sd implementation...&lt;br /&gt;Done.Reading &amp;quot;746f6e20&amp;quot; from flash.&lt;br /&gt;Template example started.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;which means that even if I just read, the value read is not ffffffff (last written). That could be justified by: as I never did an erase, and tried to write lots of things i could never get the expected vaue (ffffffff) because of the reason pointed by Jorgen.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now If I erase and then if I write ffffffff and can read ffffffff! :-)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Solved!&lt;/p&gt;
&lt;p&gt;I was missing that flash property about &amp;quot;A flash write operation can only change bits from 1 to 0, to change a 0 to a 1 requires a erase operation,&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks to all&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage: writting and then reading 'wrong' data?</title><link>https://devzone.nordicsemi.com/thread/191108?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 12:34:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b308e5f0-d792-4262-a2a9-222351c553c9</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;Well of course you&amp;#39;re going to get&amp;nbsp;the same output if you read twice the same address without writing in between. What did you expect?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage: writting and then reading 'wrong' data?</title><link>https://devzone.nordicsemi.com/thread/191098?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 12:15:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da49c868-8abf-41ff-8723-5d2bb280bdd7</guid><dc:creator>Alex Co</dc:creator><description>&lt;p&gt;I tried to read without writing in the same iteration but got the same output.&lt;/p&gt;
&lt;p&gt;I have just an array to write so I am going to try to erase the page always before writing the array and find out if the problem is that. It could be that reason as I never erase page and I have tested with different contents for array&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage: writting and then reading 'wrong' data?</title><link>https://devzone.nordicsemi.com/thread/191079?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 11:48:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a92c7d9e-ed16-4b31-a654-c0da64eac62e</guid><dc:creator>awneil</dc:creator><description>[quote userid="14926" url="~/f/nordic-q-a/48193/fstorage-writting-and-then-reading-wrong-data/191068"]A flash write operation can only change bits from 1 to 0, to change a 0 to a 1 requires a erase[/quote]
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/alexco"&gt;Alex Co&lt;/a&gt;: FDS builds on fstorage - including managing stuff like this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage: writting and then reading 'wrong' data?</title><link>https://devzone.nordicsemi.com/thread/191068?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 11:37:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b9bc235-308a-4d7d-86cc-ea1db933e7d3</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Did you try reading the area before writing, to make sure it is empty? A flash write operation can only change bits from 1 to 0, to change a 0 to a 1 requires a erase operation, which again can only be performed on an entire page. Do you get any errors in the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/structnrf__fstorage__evt__t.html#a94b26bc36883f315061ae3f5271cc437"&gt;result&lt;/a&gt;&amp;nbsp;field in the event handler?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage: writting and then reading 'wrong' data?</title><link>https://devzone.nordicsemi.com/thread/191060?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 11:25:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ad58639-0be6-47ab-960c-061eaf15aed3</guid><dc:creator>Alex Co</dc:creator><description>&lt;p&gt;Ok, I got it, like the preamble in comm messages. Thanks!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What about wrong read data. any ideas?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage: writting and then reading 'wrong' data?</title><link>https://devzone.nordicsemi.com/thread/191037?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 09:43:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:644a9e24-b720-410f-aa2a-b301c02a89c3</guid><dc:creator>awneil</dc:creator><description>[quote userid="20031" url="~/f/nordic-q-a/48193/fstorage-writting-and-then-reading-wrong-data"]How Do we know if the flash is being written for the first time or not?[/quote]
&lt;p&gt;The usual way is to write some &amp;quot;marker&amp;quot; pattern:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the pattern is present, you know that the flash has previously been written;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;If the pattern is &lt;em&gt;&lt;strong&gt;not&lt;/strong&gt; &lt;/em&gt;present, you know that the flash has &lt;em&gt;&lt;strong&gt;not&lt;/strong&gt; &lt;/em&gt;yet been written - so you write the pattern.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;This is a common approach with any form of storage - not just Flash, and not specific to Nordic.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>