<?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>Combine BLE_UART and flash fstorage  code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/101711/combine-ble_uart-and-flash-fstorage-code</link><description>Hello , 
 i am trying to combine flash_fstorage_example sample code into ble uart code , my aim is write ble data (ex &amp;quot;12345678&amp;quot; ) into flash ,but while i am writing data into flash i am getting error which is mention in picture. i am using soft device</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 29 Jul 2023 08:47:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/101711/combine-ble_uart-and-flash-fstorage-code" /><item><title>RE: Combine BLE_UART and flash fstorage  code</title><link>https://devzone.nordicsemi.com/thread/438844?ContentTypeID=1</link><pubDate>Sat, 29 Jul 2023 08:47:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abcb5d95-c693-4b3e-87c0-bb3e15bbb832</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;closing this as the rest of the questions will be answered in your &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/102311/how-to-merge-ble-uart-and-bsp-sample-code"&gt;other ticket&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Combine BLE_UART and flash fstorage  code</title><link>https://devzone.nordicsemi.com/thread/438076?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2023 12:48:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad18063d-3909-4f5a-878d-d4ca5bdf09b8</guid><dc:creator>DG</dc:creator><description>&lt;p&gt;Hi Terje,&lt;/p&gt;
&lt;p&gt;I am writting data on flash using this function&amp;nbsp; nrf_fstorage_write(&amp;amp;fstorage,start_address,name,len_data,NULL) and reading data from flash using &lt;br /&gt;this function nrf_fstorage_read(&amp;amp;fstorage,start_address,&amp;amp;newname,read_data_len) and Erase data using this function nrf_fstorage_erase(&amp;amp;fstorage,strat_add,1, NULL)&amp;nbsp; where 1 is page number ,&lt;/p&gt;
&lt;p&gt;uint8_t flash_buff[100]=&amp;quot;6B9591A39B3B35118C6F9754EDD1C0309073&amp;quot;;&lt;/p&gt;
&lt;p&gt;1. i am writting&amp;nbsp; flash_buffer data 160 times using write function&lt;br /&gt;2. i am readding data 160 time using read function&lt;br /&gt;3. i erase data 160 times using erase function &lt;br /&gt;4 after erase data i read again no data found in this address&lt;/p&gt;
&lt;p&gt;my problem is i write 200 times same and read 200 times and erase 200 times after erasing data. i read again data so i got some data but how its possible because i erase data&lt;/p&gt;
&lt;p&gt;my start_address is 0x3e000 and last address is 0x6ffff.&lt;/p&gt;
&lt;p&gt;uint32_t result_erase = nrf_fstorage_erase(&amp;amp;fstorage,strat_add,1, NULL); // erase 1 page&lt;br /&gt; uint32_t result_erase1 = nrf_fstorage_erase(&amp;amp;fstorage,strat_add,2, NULL);&lt;br /&gt; uint32_t result_erase2 = nrf_fstorage_erase(&amp;amp;fstorage,strat_add,3, NULL);&lt;br /&gt; uint32_t result_erase3 = nrf_fstorage_erase(&amp;amp;fstorage,strat_add,4, NULL);&lt;br /&gt; uint32_t result_erase4 = nrf_fstorage_erase(&amp;amp;fstorage,strat_add,5, NULL);&lt;/p&gt;
&lt;p&gt;can you guide me why i am getting data after erase ?&lt;/p&gt;
&lt;p&gt;BR&amp;nbsp;&lt;/p&gt;
&lt;p&gt;DG&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Combine BLE_UART and flash fstorage  code</title><link>https://devzone.nordicsemi.com/thread/437348?ContentTypeID=1</link><pubDate>Wed, 19 Jul 2023 16:17:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46779830-c26d-462b-9bdc-5de734b6b68d</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have provided an answer for the fstorage related question. For these UART related questions, that are completely different from the original question in this thread, please create a new ticket. That way the question will be directly related to the subject, which is better for helping others with similar questions in the future, as well as the case will be assigned to an application engineer with better knowledge of UART, for following up. The opening question in this thread was directly related to fstorage, and general UART operation deserves to be its own topic.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Combine BLE_UART and flash fstorage  code</title><link>https://devzone.nordicsemi.com/thread/437347?ContentTypeID=1</link><pubDate>Wed, 19 Jul 2023 16:14:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb47538e-71dd-42d9-9c0b-5154f525005d</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The maximum end address depend on the amount of flash on the SoC, which in case of the nRF52832 is 256 kB or 512 kB (depending on function variant). For nRF52840 it is 1 MB. To get the last address on the last page of writable flash, you can use nrf5_flash_end_addr_get().&lt;/p&gt;
&lt;p&gt;Please note that depending on the flash layout on your device, the last pages may be used for other purposes and the end address should be adjusted accordingly. Also, if you use Flash Data Storage this will typically use a number of flash pages at the end of flash, and other uses of fstorage should then stay away from that area. There is a good overview of typical flash usage patterns in the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Flib_bootloader.html&amp;amp;anchor=lib_bootloader_memory"&gt;Memory layout&lt;/a&gt; section of the Bootloader documentation.&lt;/p&gt;
&lt;p&gt;To get more flash space for fstorage, you should typically change the start address, and not the end address, since the free free flash space is typically before the existing allocation, and not after.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Combine BLE_UART and flash fstorage  code</title><link>https://devzone.nordicsemi.com/thread/435918?ContentTypeID=1</link><pubDate>Wed, 12 Jul 2023 09:49:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87f2d3b4-aa4b-4a53-a991-ba1d218c7252</guid><dc:creator>DG</dc:creator><description>&lt;p&gt;Hi Terje ,&lt;/p&gt;
&lt;p&gt;if i will use&amp;nbsp;&lt;span&gt;cli_init(),&amp;nbsp;cli_start(),cli_process() , API in BLE_UART code to print data on putty terminal but getting error can you guide me why i am getting this error .error show in below picture and i change uart pin also but getting same error.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;void cli_init(void)&lt;br /&gt;{&lt;br /&gt; nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;&lt;br /&gt; //uart_config.pseltxd = TX_PIN_NUMBER;&lt;br /&gt; uart_config.pseltxd = ARDUINO_SCL_PIN;&lt;br /&gt; //uart_config.pselrxd = RX_PIN_NUMBER;&lt;br /&gt; uart_config.pselrxd = ARDUINO_SDA_PIN;&lt;br /&gt; uart_config.hwfc = NRF_UART_HWFC_DISABLED;&lt;/p&gt;
&lt;p&gt;ret_code_t rc = nrf_cli_init(&amp;amp;m_cli_uart, &amp;amp;uart_config, true, true, NRF_LOG_SEVERITY_INFO);&lt;br /&gt; APP_ERROR_CHECK(rc);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;void cli_start(void)&lt;br /&gt;{&lt;br /&gt; ret_code_t rc = nrf_cli_start(&amp;amp;m_cli_uart);&lt;br /&gt; APP_ERROR_CHECK(rc);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;void cli_process(void)&lt;br /&gt;{&lt;br /&gt; nrf_cli_process(&amp;amp;m_cli_uart);&lt;br /&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/pastedimage1689155106362v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Combine BLE_UART and flash fstorage  code</title><link>https://devzone.nordicsemi.com/thread/435851?ContentTypeID=1</link><pubDate>Wed, 12 Jul 2023 06:18:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c49b802-e9af-4af6-a822-6fd7cd809e56</guid><dc:creator>DG</dc:creator><description>&lt;p&gt;Hi Terje ,&lt;/p&gt;
&lt;p&gt;Can you tell me what is the max.value of end_addr so i can write and read&amp;nbsp; more data .&lt;/p&gt;
&lt;p&gt;NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =&lt;br /&gt;{&lt;br /&gt; /* Set a handler for fstorage events. */&lt;br /&gt; .evt_handler = fstorage_evt_handler,&lt;br /&gt; .start_addr = 0x3e000,&lt;br /&gt; .end_addr = 0x3ffff,&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;
&lt;p&gt;DG&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Combine BLE_UART and flash fstorage  code</title><link>https://devzone.nordicsemi.com/thread/435691?ContentTypeID=1</link><pubDate>Tue, 11 Jul 2023 11:27:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b15313a5-243b-4df4-ab04-5bd68418878d</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The error message in the terminal output indicates that the source address is not word aligned. This is not clear from the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Fgroup__nrf__fstorage.html&amp;amp;anchor=ga5a37147f85e54eb049d3cad8bf59c807"&gt;documentation for nrf_fstorage_write()&lt;/a&gt;, which only states the alignment requirement for dest. I see from the implementation in nrf_fstorage.c that also p_src is checked for word alignment.&lt;/p&gt;
&lt;p&gt;The variables used in the fstorage example are not necessarily word aligned for all toolchians. In order to ensure they are word aligned, add __ALIGN(4) in front of the declarations. For the fstorage example, this means changing from:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/* Dummy data to write to flash. */&lt;/code&gt;&lt;br /&gt;&lt;code&gt;static uint32_t m_data = 0xBADC0FFE;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;static char m_hello_world[] = &amp;quot;hello world&amp;quot;;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;To:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/* Dummy data to write to flash. */&lt;/code&gt;&lt;br /&gt;&lt;code&gt;__ALIGN(4) static uint32_t m_data = 0xBADC0FFE;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;__ALIGN(4) static char m_hello_world[] = &amp;quot;hello world&amp;quot;;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Please note also that for writing to flash, the values written must be in static variables. This is because flash writes are asynchronous; the operation is put in a queue, and will be executed at a later point in time. This means the source for the data to be written must stay in memory (and not be overwritten or changed) until the write operation is finished.&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If the above does not solve the issue, please note you should also make sure to use the correct backend for fstorage, depending on whether or not the SoftDevice is used. The flash_fstorage example uses the following code for initializing with the correct backend:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    nrf_fstorage_api_t * p_fs_api;

#ifdef SOFTDEVICE_PRESENT
    NRF_LOG_INFO(&amp;quot;SoftDevice is present.&amp;quot;);
    NRF_LOG_INFO(&amp;quot;Initializing nrf_fstorage_sd implementation...&amp;quot;);
    /* Initialize an fstorage instance using the nrf_fstorage_sd backend.
     * nrf_fstorage_sd uses the SoftDevice to write to flash. This implementation can safely be
     * used whenever there is a SoftDevice, regardless of its status (enabled/disabled). */
    p_fs_api = &amp;amp;nrf_fstorage_sd;
#else
    NRF_LOG_INFO(&amp;quot;SoftDevice not present.&amp;quot;);
    NRF_LOG_INFO(&amp;quot;Initializing nrf_fstorage_nvmc implementation...&amp;quot;);
    /* Initialize an fstorage instance using the nrf_fstorage_nvmc backend.
     * nrf_fstorage_nvmc uses the NVMC peripheral. This implementation can be used when the
     * SoftDevice is disabled or not present.
     *
     * Using this implementation when the SoftDevice is enabled results in a hardfault. */
    p_fs_api = &amp;amp;nrf_fstorage_nvmc;
#endif

    rc = nrf_fstorage_init(&amp;amp;fstorage, p_fs_api, NULL);
    APP_ERROR_CHECK(rc);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>