<?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>Writing to flash in the nus example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48844/writing-to-flash-in-the-nus-example</link><description>Hi 
 I am using the nrf53832 dk. 
 In the nus example once the data is received from the phone(central) I want to write this data to the flash. I referred to the fstorage example for flash write. 
 I made the following changes to the nus_data_handler</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 24 Jun 2019 12:48:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48844/writing-to-flash-in-the-nus-example" /><item><title>RE: Writing to flash in the nus example</title><link>https://devzone.nordicsemi.com/thread/194377?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 12:48:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d8b2200-0c1e-4ece-bc20-c6c7595d2166</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Please have a look at this &lt;a href="https://www.youtube.com/watch?v=uP8RYgYGRvI"&gt;video tutorial&lt;/a&gt;. If logging is not set up in the project, it requires quite a lot of files and configs to be added, if it is set up, it can be enabled by setting NRF_LOG_ENABLED to 1 in the sdk_config.h file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to flash in the nus example</title><link>https://devzone.nordicsemi.com/thread/194303?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 11:10:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18e2f2df-de33-48df-8094-3ccf85dfec6d</guid><dc:creator>Dcrossd</dc:creator><description>&lt;p&gt;how do i setup the debug flag and enable logging on ses?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to flash in the nus example</title><link>https://devzone.nordicsemi.com/thread/194274?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 09:24:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10ab1dae-c565-4740-aa90-f75abe6a752a</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Some function returned an error code. The error codes are normally passed to APP_ERROR_CHECK macro, which will call the error handler in case of non-zero error code (not NRF_SUCCESS). If you set the DEBUG flag, and have logging enabled, the error code and line number will be output to the log. You can also check the variables directly when debugging.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to flash in the nus example</title><link>https://devzone.nordicsemi.com/thread/194261?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 08:48:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:249f52ab-d874-4dcc-9508-9646830287cf</guid><dc:creator>Dcrossd</dc:creator><description>&lt;p&gt;when i run the above code in debug mode in ses&amp;nbsp;&lt;/p&gt;
&lt;p&gt;the app_error_weak.c file opens and execution stops at&amp;nbsp;NRF_BREAKPOINT_COND;&lt;/p&gt;
&lt;p&gt;and the comment next to this statement states that &amp;quot;&amp;nbsp; On assert, the system can only recover with a reset.&amp;quot;&lt;/p&gt;
&lt;p&gt;why is this happening?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to flash in the nus example</title><link>https://devzone.nordicsemi.com/thread/194071?ContentTypeID=1</link><pubDate>Fri, 21 Jun 2019 11:11:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4cdb0dc-b0c7-4764-9b37-a7a4297d19aa</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;As mentioned by &lt;a href="https://devzone.nordicsemi.com/members/ashish28"&gt;Ashish&lt;/a&gt;&amp;nbsp;you can use FDS, but note that this does &lt;strong&gt;not&lt;/strong&gt; provide any better integration with softdevice than what fstorage does. FDS is a higher layer library that builds on top of fstorage, they both support asynchronous write/erase, and both softdevice and NVMC backends. What &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_fds.html?cp=5_1_3_55"&gt;FDS&lt;/a&gt; does provide, is simpler access and organization of stored data, in addition to wear leveling and content integration management.&lt;/p&gt;
&lt;p&gt;If you want to keep using fstorage, I would recommend that &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/10729/my-device-is-freezing-and-restarting"&gt;debug the application&lt;/a&gt; to check for error codes. It sounds like the chip resets, which is the default behavior if it ends up in the error handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to flash in the nus example</title><link>https://devzone.nordicsemi.com/thread/193997?ContentTypeID=1</link><pubDate>Fri, 21 Jun 2019 06:55:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb00bc4c-2189-4f5e-9e23-0508d00d369f</guid><dc:creator>Ashish</dc:creator><description>&lt;p&gt;Hey,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you are using BLE and flash write together, try&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_fds.html"&gt;FDS&lt;/a&gt;&amp;nbsp;instead of fstorage. FDS has asynchronous callbacks and should work better with SoftDevice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to flash in the nus example</title><link>https://devzone.nordicsemi.com/thread/193986?ContentTypeID=1</link><pubDate>Fri, 21 Jun 2019 05:54:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cfc24ac-afc9-4488-8532-d21a54377383</guid><dc:creator>Dcrossd</dc:creator><description>&lt;p&gt;I forgot to set the code snippet to C format&amp;nbsp;&lt;/p&gt;
&lt;p&gt;here is the snippet&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void nus_data_handler(ble_nus_evt_t * p_evt)
{
    char wagon[20];//string i added 
    if (p_evt-&amp;gt;type == BLE_NUS_EVT_RX_DATA)
    {
        uint32_t err_code;

        NRF_LOG_DEBUG(&amp;quot;Received data from BLE NUS. Writing data on UART.&amp;quot;);
        NRF_LOG_HEXDUMP_DEBUG(p_evt-&amp;gt;params.rx_data.p_data, p_evt-&amp;gt;params.rx_data.length);
        strcpy(wagon,p_evt-&amp;gt;params.rx_data.p_data);//string copy
        for (uint32_t i = 0; i &amp;lt; p_evt-&amp;gt;params.rx_data.length; i++)
        {
            do
            {
                err_code = app_uart_put(p_evt-&amp;gt;params.rx_data.p_data[i]);
                if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (err_code != NRF_ERROR_BUSY))
                {
                    NRF_LOG_ERROR(&amp;quot;Failed receiving NUS message. Error 0x%x. &amp;quot;, err_code);
                    APP_ERROR_CHECK(err_code);
                }
            } while (err_code == NRF_ERROR_BUSY);
        }
        if (p_evt-&amp;gt;params.rx_data.p_data[p_evt-&amp;gt;params.rx_data.length - 1] == &amp;#39;\r&amp;#39;)
        {
            while (app_uart_put(&amp;#39;\n&amp;#39;) == NRF_ERROR_BUSY);
        }
    }
    //changes i made 
    ret_code_t rc;
    nrf_fstorage_api_t * p_fs_api;
    p_fs_api = &amp;amp;nrf_fstorage_sd;
    rc = nrf_fstorage_init(&amp;amp;fstorage, p_fs_api, NULL);
    APP_ERROR_CHECK(rc);
    rc = nrf_fstorage_write(&amp;amp;fstorage, 0x3e000, wagon, strlen(wagon), NULL);
    APP_ERROR_CHECK(rc);

}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>