<?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>flash update just 1 byte</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/22958/flash-update-just-1-byte</link><description>Hi, I&amp;#39;m using nrf51 without ble. 
 I want to update flash but not want to delete PAGE every time. 
 NRF_NVMC-&amp;gt;ERASEPAGE = (uint32_t) page_address;
 
 How can i do?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Jun 2017 19:05:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/22958/flash-update-just-1-byte" /><item><title>RE: flash update just 1 byte</title><link>https://devzone.nordicsemi.com/thread/90328?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 19:05:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55b467f5-7614-4c29-a31b-0a951e97c6c6</guid><dc:creator>Oguz Emre</dc:creator><description>&lt;p&gt;You&amp;#39;re right.
Nordic :@&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: flash update just 1 byte</title><link>https://devzone.nordicsemi.com/thread/90327?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 16:20:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b4f5387-0c74-4870-ae0d-7938765d1905</guid><dc:creator>David</dc:creator><description>&lt;p&gt;Then you&amp;#39;ll have to write your own or modify fstorage or pstorage. Designing your own memory management can be very simple or very complicated depending on your requirements (e.g. how often are you writing data, how big is the data you need to store, whether you can tolerate pulling old data accidentally, ect).&lt;/p&gt;
&lt;p&gt;For example, I had a uint32_t variable that I knew would never be 0xFFFFFFFF (if it ever did, the system would break). I reserved a page of flash for this variable.&lt;/p&gt;
&lt;p&gt;After boot, I would find the value by searching for the last non-empty value (non 0xFFFFFFFF).&lt;/p&gt;
&lt;p&gt;When I wrote a new value, I would write to the first empty address in the page. When I reached the end of the page, I erased the page and started from the beginning again.&lt;/p&gt;
&lt;p&gt;My erases were infrequent enough that I would never exceed the 10,000 write/erase cycle limit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: flash update just 1 byte</title><link>https://devzone.nordicsemi.com/thread/90333?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 15:47:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d06a68f7-283b-4d5a-b2dd-e0de72c50283</guid><dc:creator>Oguz Emre</dc:creator><description>&lt;p&gt;Yes I know that.
Fstorage, pstroge use softdevice. but I&amp;#39;m using Nrf without ble&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: flash update just 1 byte</title><link>https://devzone.nordicsemi.com/thread/90332?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 15:38:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d35aee9a-9ac4-40f6-ac8a-63616fa2571a</guid><dc:creator>David</dc:creator><description>&lt;p&gt;So you have a write address that has already been written to and you want to change the value? You could attempt a second write, but as I said above, it would likely only change the &amp;#39;1&amp;#39;s to &amp;#39;0&amp;#39;s, you couldn&amp;#39;t change &amp;#39;0&amp;#39;s to &amp;#39;1&amp;#39;s without an erase. That&amp;#39;s a physical limitation of flash.&lt;/p&gt;
&lt;p&gt;The solution is to move the physical address of the data every time you need to write it. That way you limit your erases. Then the problem is managing where variable actually is.&lt;/p&gt;
&lt;p&gt;You could take a look at some of the flash managing libraries from Nordic. See &lt;a href="https://devzone.nordicsemi.com/question/75925/any-librabry-support-for-eeprom-emulation-on-nrf51-flash-memory/?answer=102272#post-id-102272"&gt;this answer&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: flash update just 1 byte</title><link>https://devzone.nordicsemi.com/thread/90331?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 15:06:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea7e343f-6ef5-45f9-b153-323395fa54a6</guid><dc:creator>Oguz Emre</dc:creator><description>&lt;p&gt;I am doing it this way and how do we update it? without erase?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: flash update just 1 byte</title><link>https://devzone.nordicsemi.com/thread/90330?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 15:03:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfacaff8-d179-4ed9-b18c-676f91ee7134</guid><dc:creator>David</dc:creator><description>&lt;p&gt;Here:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t* p_Write = (uint32_t*) addressToWriteTo;
        
// Enable write
NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}                  // Wait for flash ready

// Perform write
*p_Write = valueToWrite;
while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}                  // Wait for flash ready

// Disable write
NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Ren &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: flash update just 1 byte</title><link>https://devzone.nordicsemi.com/thread/90329?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 14:54:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c757edb-ff05-4260-b854-55f491c022b6</guid><dc:creator>Oguz Emre</dc:creator><description>&lt;p&gt;Thank you for your answer.
Can you give me an example?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: flash update just 1 byte</title><link>https://devzone.nordicsemi.com/thread/90326?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 14:41:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9978b516-7d26-4d87-b32c-76bde5c93210</guid><dc:creator>David</dc:creator><description>&lt;p&gt;If the specific address you&amp;#39;re writing to is already erased (i.e. its value is 0xFFFFFFFF) you don&amp;#39;t need to erase the whole page before the write.&lt;/p&gt;
&lt;p&gt;If the address is not erased, you may be able to write to it a second time. The &lt;a href="http://infocenter.nordicsemi.com/pdf/nRF51822_PS_v3.3.pdf#G8.1086636"&gt;absolute maximum ratings&lt;/a&gt; of the nRF51 state that an address can be written to 2 times without an erase. However, I believe you would be you could only change &amp;#39;1&amp;#39;s to &amp;#39;0&amp;#39;s on the second write.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>