<?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>how to over write data in same offset into internal flash on zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116092/how-to-over-write-data-in-same-offset-into-internal-flash-on-zephyr</link><description>Hi, 
 I am using the nRF Connect SDK 2.6.1 with the nRF5340 board. 
 I referred to the soc_flash_nrf example to read and write data into flash. 
 I need to overwrite data at the same offset, but when I try this in the soc_flash_nrf example, I don&amp;#39;t get</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 Nov 2024 11:49:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116092/how-to-over-write-data-in-same-offset-into-internal-flash-on-zephyr" /><item><title>RE: how to over write data in same offset into internal flash on zephyr</title><link>https://devzone.nordicsemi.com/thread/509226?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2024 11:49:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60b5adbc-f832-4467-8579-ac464759cee4</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;Hi, thanks for your support! Using NVS, I was able to successfully overwrite the data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to over write data in same offset into internal flash on zephyr</title><link>https://devzone.nordicsemi.com/thread/509184?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2024 23:55:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:522f5f22-29ad-4a0f-94d2-a881eb7c53ab</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;You would need to erase the entire page, on nRF5340 app core each page is&amp;nbsp;&lt;span&gt;4 kB.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
[quote user="ChiragBhavsar"]Additionally, could you provide an example of using NVS (Non-Volatile Storage) for storing data?[/quote]
&lt;p&gt;See this sample:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/subsys/nvs"&gt;https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/subsys/nvs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to over write data in same offset into internal flash on zephyr</title><link>https://devzone.nordicsemi.com/thread/509156?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2024 15:43:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e64aa64-d9e9-436b-b0c7-a043e71180b4</guid><dc:creator>ChiragBhavsar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am able to erase the flash using &lt;code&gt;flash_erase(flash_dev, TEST_PARTITION_OFFSET, FLASH_PAGE_SIZE)&lt;/code&gt;. However, when I use &lt;code&gt;flash_erase(flash_dev, offset, sizeof(uint32_t))&lt;/code&gt;, the flash does not erase as expected. What could be the reason behind this?&lt;/p&gt;
&lt;p&gt;After erasing the flash, I write data (e.g., &lt;code&gt;1234&lt;/code&gt;) and can successfully read it back. However, when I write new data (e.g., &lt;code&gt;1122&lt;/code&gt;) to the same offset, I still read back the original value (&lt;code&gt;1234&lt;/code&gt;). Is there a method to properly overwrite data at the same offset?&lt;/p&gt;
&lt;p&gt;Additionally, could you provide an example of using NVS (Non-Volatile Storage) for storing data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to over write data in same offset into internal flash on zephyr</title><link>https://devzone.nordicsemi.com/thread/509121?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2024 13:31:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26bacb4c-1bea-4183-b948-24c955072641</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;&lt;span&gt;A flash write can only flip bits from &amp;#39;1&amp;#39; to &amp;#39;0&amp;#39;. When erasing a flash page, all zeroes are reset to &amp;#39;1&amp;#39;. Therefore, it is necessary to erase the flash before updating existing data. I suggest using e.g. nvs&amp;nbsp;for your use-case.&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/latest/services/storage/nvs/nvs.html"&gt;https://docs.zephyrproject.org/latest/services/storage/nvs/nvs.html&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>