<?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 use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63116/how-to-use-nvs_read-and-nvs_write-in-aws_fota-app</link><description>I would like to use nvs_read and nvs_write in aws_fota app to store a mode value inside, but it doesn&amp;#39;t work. Any help? 
 I added the following lines to aws_fota prj.conf 
 &amp;lt;prj.conf&amp;gt; 
 
 I added the following code to aws_fota maiin.c 
 
 I have inspected</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 17 Jul 2020 10:27:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63116/how-to-use-nvs_read-and-nvs_write-in-aws_fota-app" /><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/260540?ContentTypeID=1</link><pubDate>Fri, 17 Jul 2020 10:27:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8dc4faa-2590-4d61-95b8-56d754d98e35</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;It seems like the settings driver is used in ncs\v1.3.0\nrf\subsys\dfu\src\dfu_target_mcuboot.c, and only if CONFIG_DFU_TARGET_MCUBOOT_SAVE_PROGRESS=y. I suggest you to read about the config &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/kconfig/CONFIG_DFU_TARGET_MCUBOOT_SAVE_PROGRESS.html?highlight=config_dfu_target_mcuboot_save_progress#cmdoption-arg-config-dfu-target-mcuboot-save-progress"&gt;here&lt;/a&gt;, and if that is something you want. If you set it to n, I don&amp;#39;t think you&amp;#39;ll get any conflicts.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/260110?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 10:38:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79494aca-0723-4da3-9f81-ddf5285554a8</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;not really. Just remove the two lines and working out so far. I&amp;#39;m not sure this is fine or not&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/260107?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 10:27:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:205ca9ef-2173-4161-8af8-c29a2503fd9c</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Have you made any progress on this lately?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/259270?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2020 16:13:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:339da64b-8467-4ce9-b75a-836e3c7ee0c2</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I am sorry for the late reply. Currently, a huge portion of the support team is on summer vacation (including many of the nRF9160 experts), so you may experience delayed answers. I will look into your issue in the upcoming days.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/258499?ContentTypeID=1</link><pubDate>Mon, 06 Jul 2020 03:44:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa55e2a1-7ef9-4a6a-9d88-26ca2f6ace19</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;u8_t mode = 2;
ret = nvs_write(&amp;amp;nvs_fs, NVS_ID_MODE, &amp;amp;mode, 1);
if (ret &amp;lt; 0) {
	return;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I get -22 errno in nvs_write when I add it to aws_fota.&lt;/p&gt;
&lt;p&gt;This comes from line 179&lt;span&gt;&amp;nbsp;in&amp;nbsp;&lt;/span&gt;ncs\v1.3.0\zephyr\drivers\flash\soc_flash_nrf.c&lt;/p&gt;
&lt;p&gt;is_regular_addr_valid(addr, len) apparently fails.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static int flash_nrf_read(struct device *dev, off_t addr,
			    void *data, size_t len)
{
	if (is_regular_addr_valid(addr, len)) { /* This fails */
		addr += DT_REG_ADDR(SOC_NV_FLASH_NODE);
	} else if (!is_uicr_addr_valid(addr, len)) {
		return -EINVAL; /* HERE */
	}

	if (!len) {
		return 0;
	}

#if CONFIG_ARM_NONSECURE_FIRMWARE &amp;amp;&amp;amp; CONFIG_SPM &amp;amp;&amp;amp; USE_PARTITION_MANAGER
	if (addr &amp;lt; PM_APP_ADDRESS) {
		return spm_request_read(data, addr, len);
	}
#endif

	memcpy(data, (void *)addr, len);

	return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In addition, I printed out parameters.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static inline bool is_regular_addr_valid(off_t addr, size_t len)
{
	size_t flash_size = nrfx_nvmc_flash_size_get();

        printk(&amp;quot;flash_size = %u\n&amp;quot;, flash_size); /* ADD HERE */
        printk(&amp;quot;addr = %ld\n&amp;quot;, addr); /* ADD HERE */
        printk(&amp;quot;len = %u\n&amp;quot;, len); /* ADD HERE */

	if (addr &amp;gt;= flash_size ||
	    addr &amp;lt; 0 ||
	    len &amp;gt; flash_size ||
	    (addr) + len &amp;gt; flash_size) {
		return false;
	}

	return true;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;* without CONFIG_SETTINGS = y&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;flash_size = 1048576
addr = 1028040
len = 8
flash_size = 1048576
addr = 1028048
len = 8
flash_size = 1048576
addr = 1028056
len = 8
flash_size = 1048576
addr = 1028064
len = 8
flash_size = 1048576
addr = 1028072
len = 8
flash_size = 1048576
addr = 1024004
len = 1&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;* with&amp;nbsp;&lt;span&gt;CONFIG_SETTINGS = y&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;flash_size = 1048576
addr = 1044464
len = 8
flash_size = 1048576
addr = 1052664
len = 8

=&amp;gt; errno -22 occurs&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The following formula&amp;nbsp;fails with&amp;nbsp;CONFIG_SETTINGS = y.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(addr) + len &amp;gt; flash_size&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any advice to solve this issue?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/258495?ContentTypeID=1</link><pubDate>Mon, 06 Jul 2020 02:51:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b307fbe9-dab6-4d48-aad7-787a144e4d92</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for the detail and I&amp;#39;m reading this page&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/nrf_desktop/doc/settings_loader.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/nrf_desktop/doc/settings_loader.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;but I&amp;#39;m not really understanding the&amp;nbsp;settings loader module..&amp;nbsp;Th&lt;span&gt;e&amp;nbsp;settings loader module seems to be similar to nvs library.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://docs.zephyrproject.org/latest/reference/storage/nvs/nvs.html"&gt;https://docs.zephyrproject.org/latest/reference/storage/nvs/nvs.html&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;gt;Please also make sure that you write CONFIG_SETTINGS=y, not SETTING.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;oh, sorry it&amp;#39;s typo. Yes, it&amp;#39;s&amp;nbsp;&lt;span&gt;CONFIG_SETTINGS=y.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I tried aws_fota app commenting out these two lines and it apparently works out.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;lt;prj.conf&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;# CONFIG_SETTINGS=y
# CONFIG_SETTINGS_NVS=y&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you think it is ok to remove these lines. If so,&amp;nbsp;we can use nvs in aws_fota app.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/257712?ContentTypeID=1</link><pubDate>Wed, 01 Jul 2020 07:03:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22a39b49-6425-4d21-8768-5ac118818db2</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Yusuke&lt;/p&gt;
&lt;p&gt;The settings loader module is enabled for every nRF Desktop device with Zephyr&amp;#39;s&amp;nbsp;:ref:`zephyr:settings_api` enabled. The :ref:`zephyr:settings_api` subsystem is enabled with the :option:`CONFIG_SETTINGS` Kconfig option. Zephyr&amp;#39;s Bluetooth stack does not load the zephyr:settings_api data on its own, as Zephyr assumes that the application will call&amp;nbsp;:cpp:func:`settings_load` after completing all necessary initialization. This function is called on the settings loader module initialization.&lt;/p&gt;
&lt;p&gt;Please also make sure that you write CONFIG_SETTINGS=y, not SETTING.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/257531?ContentTypeID=1</link><pubDate>Tue, 30 Jun 2020 10:20:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e29f3c1-ade8-41ec-9396-07a60185e6a7</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;&amp;gt;Can you please specify what you mean by this?&lt;/p&gt;
&lt;p&gt;OK. I&amp;#39;ll explain. Please look over this zip folder. This is an app testing nvs.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I add &amp;quot;CONFIG_SETTING=y&amp;quot; to prj.conf file, the app causes an error. That&amp;#39;s why.&lt;/p&gt;
&lt;p&gt;&amp;gt;&lt;span&gt;Have you done any further debugging to see where the &amp;quot;Error -22&amp;quot; comes from and what this error means?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;According to this page, it means &amp;quot;Invalid argument&amp;quot;. That&amp;#39;s only what I know.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/intel/zephyr/blob/master/lib/libc/minimal/include/errno.h"&gt;https://github.com/intel/zephyr/blob/master/lib/libc/minimal/include/errno.h&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/257491?ContentTypeID=1</link><pubDate>Tue, 30 Jun 2020 07:21:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68651e58-c5e3-4855-b632-928cc9cdfe6b</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi again&lt;/p&gt;
&lt;p&gt;[quote user=""][/quote]&lt;/p&gt;
&lt;p&gt;I have inspected a while and it seems that this line in prj.conf&amp;nbsp;causes the issue.&lt;/p&gt;
&lt;p&gt;CONFIG_SETTING=y&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Can you please specify what you mean by this?&lt;/p&gt;
&lt;p&gt;Have you done any further debugging to see where the &amp;quot;Error -22&amp;quot; comes from and what this error means?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nvs_read and nvs_write in aws_fota app?</title><link>https://devzone.nordicsemi.com/thread/257422?ContentTypeID=1</link><pubDate>Mon, 29 Jun 2020 13:54:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d77dc1e-5763-4661-856f-c14d5159d3c3</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I will have to get back to you tomorrow to provide a satisfactory answer here. Sorry about the delay! In the meantime, you can check out&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/52095/nrf9160dk-storing-to-and-reading-from-flash?ReplySortBy=CreatedDate&amp;amp;ReplySortOrder=Ascending"&gt;this&lt;/a&gt;, and &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/59912/possible-to-pre-load-data-to-nvs-when-the-nrf9160-is-programmed/244979#244979"&gt;this case&lt;/a&gt;. Which might be related to your implementation of NVS.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>