<?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>Storing user data to flash and avoiding overwrite on application update</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96116/storing-user-data-to-flash-and-avoiding-overwrite-on-application-update</link><description>I made an example based on the NVS sample code (Connect SDK 2.2.0) which simply reads a value from the storage partition if it exists, then updates it if either it&amp;#39;s different than a specific value or it didn&amp;#39;t exist in the first place. That works great</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 07 Dec 2024 09:27:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96116/storing-user-data-to-flash-and-avoiding-overwrite-on-application-update" /><item><title>RE: Storing user data to flash and avoiding overwrite on application update</title><link>https://devzone.nordicsemi.com/thread/513914?ContentTypeID=1</link><pubDate>Sat, 07 Dec 2024 09:27:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6bbdcfc-ea65-4a97-8ce2-f15e2518e133</guid><dc:creator>lara</dc:creator><description>&lt;p&gt;hi&lt;/p&gt;
&lt;p&gt;can you provide me the simple example code for nvs settings? as iam kept on facing errors,,somewhere i collapsed everything&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Storing user data to flash and avoiding overwrite on application update</title><link>https://devzone.nordicsemi.com/thread/407645?ContentTypeID=1</link><pubDate>Wed, 01 Feb 2023 19:51:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0af42932-7730-42c3-8838-ee84a0c8ec53</guid><dc:creator>Anthony W</dc:creator><description>&lt;p&gt;Ahhh okay this was the problem. I started from the NVS demo and didn&amp;#39;t look at the CMake config. Now it works perfectly, thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Storing user data to flash and avoiding overwrite on application update</title><link>https://devzone.nordicsemi.com/thread/407141?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2023 14:29:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7eedc8e0-8409-499e-9033-53ee1f3d49a0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi again,&amp;nbsp;&lt;br /&gt;It worth mentioning that if you have a v3 chip that has &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/working-with-the-nrf52-series-improved-approtect"&gt;upgraded APPROTECT&lt;/a&gt; on both hardware and software and if in the software you don&amp;#39;t&amp;nbsp;deliberately disable APPROTECT , you will need to recover the chip (eraes all) every time you flash new firmware to it. In VS Code you will most likely receive a popup saying that the chip need to be recovered.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please double check.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Storing user data to flash and avoiding overwrite on application update</title><link>https://devzone.nordicsemi.com/thread/407140?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2023 14:24:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f2ada7a-b33c-483e-b61a-067029d9d7de</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Anthony,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Which sample are you testing with ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;By default if you click on the flash icon with one arrow (Flash only), it will only erase the sectors occupied by the new application, not the whole flash. So the NVS storage area shouldn&amp;#39;t be affected.&lt;/p&gt;
&lt;p&gt;If you click on the flash icon with 2 arrows (Erase and Flash) it will erase the whole flash and then flash the application image.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1675088597511v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;However if you use the NVS, there is a setting in CmakeLists.txt that apply erase in both cases:&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

macro(app_set_runner_args)
  board_runner_args(dfu-util &amp;quot;--dfuse-modifiers=force:mass-erase&amp;quot;)
  board_runner_args(pyocd &amp;quot;--erase&amp;quot;)
  board_runner_args(nrfjprog &amp;quot;--erase&amp;quot;)
endmacro()

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(nvs)


target_sources(app PRIVATE src/main.c)
target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/fs/nvs)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you remove the macro that do --erase it should work fine.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;You can also test using nrfjprog.exe command line tool. Do a --sectorerase when programming will not make the NVS data to be erased.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Storing user data to flash and avoiding overwrite on application update</title><link>https://devzone.nordicsemi.com/thread/406983?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2023 01:53:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:864f9bed-572d-4f0c-a4e8-4410ee0fa753</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;I&amp;#39;ve got NVS in my application, and can maintain values I have stored from one DFU to the next.&amp;nbsp; I can even get these to carry over from one application (my &amp;quot;factory&amp;quot; code) to a completely different application (my &amp;quot;operational&amp;quot; code) without issues.&amp;nbsp; I&amp;#39;m also using VSC and nRF Connect v2.2.0.&lt;/p&gt;
&lt;p&gt;Two things that come to mind (but I may be totally on the wrong track here):&lt;/p&gt;
&lt;p&gt;1. Are you doing a plain flash (Flash to Board) and not an erase + flash ( Erase and Flash to Board) from within VSC?&lt;/p&gt;
&lt;p&gt;2. I have fixed partitions for my flash storage (I have settings_storage for BLE, etc and user_storage for my data).&amp;nbsp; Not sure if having fixed partitions helps to ensure the data carries across reliably&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>