<?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 prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/106166/how-to-prevent-data-stored-in-non-volatile-storage-nvs-not-cleared-by-west-flash-command-or-ota</link><description>I use nvs_write() function to write data to Non-Volatile Storage (NVS). Is it possible to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 30 Nov 2023 12:41:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/106166/how-to-prevent-data-stored-in-non-volatile-storage-nvs-not-cleared-by-west-flash-command-or-ota" /><item><title>RE: How to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA</title><link>https://devzone.nordicsemi.com/thread/458290?ContentTypeID=1</link><pubDate>Thu, 30 Nov 2023 12:41:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea65e132-6a24-4a18-b8fd-0e85094865af</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;Thanks for your reply!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA</title><link>https://devzone.nordicsemi.com/thread/458283?ContentTypeID=1</link><pubDate>Thu, 30 Nov 2023 12:22:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d422ecd-698a-4c58-89fc-8592fa557a8b</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="snowuyl"]Is storage_partition erased by west flash command or OTA?[/quote]
&lt;p&gt;It will only be erased by west flash if you run &amp;quot;west flash --erase&amp;quot; or &amp;quot;west flash -recover&amp;quot;.&lt;/p&gt;
&lt;p&gt;It should not be erased by OTA, as OTA only should overwrite mcuboot_primary and mcuboot_secondary.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA</title><link>https://devzone.nordicsemi.com/thread/458148?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2023 14:46:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0ebb308-f6e7-41cf-89df-a8f5de1c19b7</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;Thanks for your reply! Since NVS is located at storage_partition. Is storage_partition erased by west flash command or OTA?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define NVS_PARTITION        storage_partition
#define NVS_PARTITION_DEVICE FIXED_PARTITION_DEVICE(NVS_PARTITION)
#define NVS_PARTITION_OFFSET FIXED_PARTITION_OFFSET(NVS_PARTITION)

int nvsInit(void) {
    int ret = 0;
    struct flash_pages_info info;

    /* define the nvs file system by settings with:
     *    sector_size equal to the pagesize,
     *    3 sectors
     *    starting at NVS_PARTITION_OFFSET
     */
    _gFs.flash_device = NVS_PARTITION_DEVICE;
    if (!device_is_ready(_gFs.flash_device)) {
        LOG_ERR(&amp;quot;NVS device %s is not ready\n&amp;quot;, _gFs.flash_device-&amp;gt;name);
        return ERROR_NVS_INITIALIZE_FAIL;
    }

    _gFs.offset = NVS_PARTITION_OFFSET;
    ret = flash_get_page_info_by_offs(_gFs.flash_device, _gFs.offset, &amp;amp;info);
    if (ret &amp;lt; 0) {
        LOG_ERR(&amp;quot;Unable to get page info\n&amp;quot;);
        return ERROR_NVS_INITIALIZE_FAIL;
    }
    _gFs.sector_size = info.size;
    _gFs.sector_count = 3U;
    
    ret = nvs_mount(&amp;amp;_gFs);
    if (ret &amp;lt; 0) {
        LOG_ERR(&amp;quot;nvs_mount() failed %d\n&amp;quot;, ret);
        return ERROR_NVS_INITIALIZE_FAIL;
    }

    _gNvsInitialzed = true;
 
    LOG_INF(&amp;quot;NVS has been initialized&amp;quot;);

    return 0;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA</title><link>https://devzone.nordicsemi.com/thread/458146?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2023 14:43:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a8c19b7-89b9-406e-8c09-4b5323302c8a</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;I see now that you use the nRF5340. If you enable the network core, the partition manager will automatically be enabled. So yes, I recommend this&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA</title><link>https://devzone.nordicsemi.com/thread/458129?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2023 14:13:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc243ca6-3496-46d7-9f51-3c174e7d1952</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;Thanks for your reply! I don&amp;rsquo;t use partition manager now. Do you suggest to use it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA</title><link>https://devzone.nordicsemi.com/thread/458106?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2023 13:18:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b1059a4-249f-4342-85e1-00f6ac455b74</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;NVS storage location can be configured. The configuration depends on if you use the partition manager or not.&lt;/p&gt;
&lt;p&gt;Do you project use the partition manager? (It may be enabled automatically, so check &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_PARTITION_MANAGER_ENABLED"&gt;CONFIG_PARTITION_MANAGER_ENABLED&lt;/a&gt;.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA</title><link>https://devzone.nordicsemi.com/thread/458081?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2023 12:18:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b2dbc9c-ac7b-4664-aeb6-adabcbf7dc65</guid><dc:creator>snowuyl</dc:creator><description>&lt;p&gt;Thanks for your reply! Does code and NVS locate in different flash sections?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA</title><link>https://devzone.nordicsemi.com/thread/458057?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2023 11:31:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a624ace2-e430-4eff-bc3d-dca97bcefcbc</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user=""] Is it possible to prevent data stored in Non-Volatile Storage (NVS) not cleared by west flash command or OTA?[/quote]
&lt;p&gt;I do not think it should erase the NVS data.&lt;/p&gt;
&lt;p&gt;Do you experience this?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>