<?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>flash read/write on nRF52840 dongle</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69117/flash-read-write-on-nrf52840-dongle</link><description>Hello there, 
 
 I&amp;#39;m ripping my hair out hear reading everything I can to get the non volatile memory reading and writing. 
 
 I have a nFR52840 dongle and I dont want to brick it or stuff it up in any way so I&amp;#39;m stuck on what to do. 
 All I want to do</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Jun 2021 09:20:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69117/flash-read-write-on-nrf52840-dongle" /><item><title>RE: flash read/write on nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/315057?ContentTypeID=1</link><pubDate>Mon, 14 Jun 2021 09:20:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4f904f5-9409-40b6-b51b-11fd38951919</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Just to rule out if there is a conflict with the bootloader it would be good to know which page this fails with?&lt;/p&gt;
[quote user="brianreinhold"]It&amp;#39;s clearly never hit even though SoftDevice has been disabled before these writes are attempted.[/quote]
&lt;p&gt;You cannot call&amp;nbsp;sd_flash_page_erase() when the SoftDevice is disabled.&amp;nbsp;When not using a SoftDevice you should sue for instance&amp;nbsp;nrf_nvmc_page_erase() instead.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: flash read/write on nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/314969?ContentTypeID=1</link><pubDate>Fri, 11 Jun 2021 16:12:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a036f6b7-7cf0-4ec7-bc16-d5668932c65d</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;I have a similar problem and I DO have an nRF52840 DK and the flash write works fine on the DK. I am using fstorage to store pairing keys, CCCD info, and stored measurements.&lt;/p&gt;
&lt;p&gt;However, when I port the code over to the nRF52840 dongle, everything works fine until the disconnect at which point I disable SoftDevice and store my data to flash. The program freezes, deadlocks, or somehow dies in the first while loop to write the data (it probably croaks on the first page erase but I have no sure way of telling). I have written to the LEDs using different color patterns to try and see where it actually dies. It&amp;#39;s a tedious chore and I have gotten as far as the first while loop and note it dies in there&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        while(true)
        {
            err_code = sd_flash_page_erase(pg_num);
            if (err_code == NRF_SUCCESS)
            {
                break;
            }
            if (err_code != NRF_ERROR_BUSY)
            {
                NRF_LOG_DEBUG(&amp;quot;Erasing data returned error %u.&amp;quot;, err_code);
                APP_ERROR_CHECK(err_code);
            }
        }
        bsp_board_led_on(CONNECTED_LED);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When I put the LED write before the while loop it was called but it does not get called after. I don&amp;#39;t think I am messing the bootloader here as I am able to continue to program the dongle. MY gut feeling is that I continuously get BUSY and it tags the CPU as my primary for loop in main has a reset when it sees SoftDevice disabled. It&amp;#39;s clearly never hit even though SoftDevice has been disabled before these writes are attempted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: flash read/write on nRF52840 dongle</title><link>https://devzone.nordicsemi.com/thread/283565?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2020 13:56:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:495a205e-eeb8-4eb6-a6e0-191d04efe3ae</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]I have a nFR52840 dongle and I dont want to brick it or stuff it up in any way so I&amp;#39;m stuck on what to do.[/quote]
&lt;p&gt;&amp;nbsp;What you need to watch out for is to not write to the memory inside (or used by) the bootloader on the dongle.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I guess you have no way of debugging or monitoring the log of the dongle either, but in case you do, you can check the bootloader address the following way from your application:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void print_bootloader_start_addr(void)
{
    uint32_t bl_address;
    bl_address = *NRF_UICR-&amp;gt;NRFFW;
    NRF_LOG_INFO(&amp;quot;Bootloader start addr: 0x%08x&amp;quot;, bl_address);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can also check the bootloader address using nRF Connect for Desktop -&amp;gt; Programmer:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2021.pastedimage1607346224639v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Note that this bootloader address is not the same as the bootloader start address of the bootloader in the SDK. The dongle has a customized version. On my dongle, the bootloader address is 0x000E0000, but double check this on your dongle, in case there are multiple versions of the bootloader out there. (I remember that there were some updates since launch).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So I still want to point to the examples SDK\examples\peripheral\flash_fstorage and SDK\examples\peripheral\flash_fds. They do not have pca10059 projects. If you do not already have an nRF52840 DK, I would recommend that you get hold of one before you start this project, because development without the possibility to debug is very difficult. Save your hair, and get a DK.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So as you may understand there are two approaches. FDS and fstorage. FDS uses fstorage, but handles everything you need to think of when dealing with flash.&lt;/p&gt;
&lt;p&gt;Some basics:&lt;/p&gt;
&lt;p&gt;Flash can only be changed from physical 1&amp;#39;s to 0&amp;#39;s. This means that a &amp;quot;clean flash&amp;quot; is 0xffffffff. If you want to write a value to a flash address, you it needs to be 0xffffffff before you can do so. When you have written to that address, you need to erase the entire page before you can write to it again. FDS handles this for you. If you choose to use fstorage directly, you need to erase the page before you can write to it again. If you loose power, or reset at the wrong time, you may loose the data you stored in flash.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So, is that important in your application? What happens if you are in the middle of an update, and loose power?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Other than that I can only point to the examples. Look at what the CLI commands does in these examples.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BR,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>