<?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 fails on nRF52840 Dongle, fine on nRF52840 DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/76280/writing-to-flash-fails-on-nrf52840-dongle-fine-on-nrf52840-dk</link><description>My problem is similar to this 
 https://devzone.nordicsemi.com/f/nordic-q-a/64696/projects-for-writing-into-flash-memory-does-not-work-on-nrf52840-dongle/264746#264746 
 except for one major difference. I am using only SoftDevice and I disable SoftDevice</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 30 Aug 2021 12:07:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/76280/writing-to-flash-fails-on-nrf52840-dongle-fine-on-nrf52840-dk" /><item><title>RE: Writing to flash fails on nRF52840 Dongle, fine on nRF52840 DK</title><link>https://devzone.nordicsemi.com/thread/327205?ContentTypeID=1</link><pubDate>Mon, 30 Aug 2021 12:07:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51563f02-9a42-4f3f-a0d8-cf5f97dda617</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;You are correct. The problem was I was overwriting the MBR on the dongle. The DK doesn&amp;#39;t have one. That solves the problem. Yes, the documentation is pretty clear about the differences of the disable calls with SoftDevice disabled.&lt;/p&gt;
&lt;p&gt;So the big issue was the overwrite of the bootrecord sitting at the top of flash on the dongle. It led to many red herrings just trying to do work arounds.&lt;/p&gt;
&lt;p&gt;With the flash write fixed, I now do the System Reset when flash has to be written, If the current flash data is the same as the data I want to save after a disconnect (no pairing key changes or no CCCD state changes, I skip the flash and skip the system reset. All is now working hunky-dory!&lt;/p&gt;
&lt;p&gt;The real answer and full thread of issues is here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/78993/sd_softdevice_is_enabled-returns-false-but-then-nrf_sdh_enable_request-returns-error-8-softdevice-already-enabled"&gt;devzone.nordicsemi.com/.../sd_softdevice_is_enabled-returns-false-but-then-nrf_sdh_enable_request-returns-error-8-softdevice-already-enabled&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to flash fails on nRF52840 Dongle, fine on nRF52840 DK</title><link>https://devzone.nordicsemi.com/thread/327198?ContentTypeID=1</link><pubDate>Mon, 30 Aug 2021 11:55:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8eeddf0d-2614-42c2-90e7-81d025c652a4</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Indeed, I wasn&amp;#39;t aware, but specific to the&amp;nbsp;&lt;strong&gt;sd_flash_page_erase&lt;/strong&gt;&lt;span&gt;()&amp;nbsp; and&amp;nbsp;&lt;strong&gt;sd_flash_write&lt;/strong&gt;() is that the SoftDevice isn&amp;#39;t required to be enabled to run these functions.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As to why the functions work correctly on the nRF52840 DK but not the Dongle is that you&amp;#39;re trying to overwrite or erase pages where the Dongle&amp;#39;s bootloader is located for example. What address(es) is it that you&amp;#39;re trying to write to exactly?&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to flash fails on nRF52840 Dongle, fine on nRF52840 DK</title><link>https://devzone.nordicsemi.com/thread/327068?ContentTypeID=1</link><pubDate>Sat, 28 Aug 2021 20:03:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63f99746-0475-46ac-8acf-c1c1ef247226</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;After a bunch of other issues which I have finally ironed out everything comes back down to this. Yes, the flash write works great on the DK. I did some extensive tests where I wrote to the flash and then read it right back, and it worked great. Of course on the DK, I have the ability to use NRF_LOG so I can see this in action.&lt;/p&gt;
&lt;p&gt;The documentation states that&amp;nbsp;&lt;strong&gt;sd_flash_page_erase&lt;/strong&gt;&lt;span&gt;()&amp;nbsp; and&amp;nbsp;&lt;strong&gt;sd_flash_write&lt;/strong&gt;()&amp;nbsp;will do their thing and then return when it is done&amp;nbsp; IF SoftDevice is disabled. The alternative is to leave SoftDevice enabled but this requires handling an event each call and then returning back to where one made the call to continue. That adds a great deal of complexity to the code as I am already tightly engaged using the&amp;nbsp;sd_app_evt_wait() and&amp;nbsp;sd_ble_evt_get() to handle fragmented notifications. That is the core part of this application and the last thing I want to do is place additional code in that loop to check for flash complete events. Writing to flash occurs rarely, only on disconnect if needed, whereas fragmented notifications happen repeatedly. That loop needs to be as efficient as possible especially when sending waveforms.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;IN any case, the documentation states I can clearly use these calls when SoftDevice is disabled, and the use of these calls is very simple. No complex asynchrony to handle.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have two projects that experience&amp;nbsp;the same problem (Not surprising&amp;nbsp;as they are based on the same code). Both work fine on the DK. The far more complicated project is the Generic Health Sensor which is configurable.. One can set defines to create different types of devices (Blood pressure, glucose meter, thermometer, Spirometer, weight scale, and pulse oximeter. Every time I switch projects a complete re-write of flash needs to be done as they have different pairing keys. On the DK this works. ON the dongle, the application dies right when I call&amp;nbsp;&lt;strong&gt;sd_flash_page_erase&lt;/strong&gt;()&amp;nbsp; which is the first part of the flash write. If I return just before this call, a system reset is done and the dongle lives and begins advertising again as it should.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I do switch from&amp;nbsp;&amp;nbsp;BOARD_PCA10056 to BOARD_PCA10059 as I go from DK to dongle.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The dongle does work like a charm until the disconnect and I do the flash write. If I power cycle the dongle, my GHS health device will restart but it will not have the correct pairing information, so I have to clear the pairing on my Android cliient app to work with it (No surprise). All I am saying here, is everything else works fine on the dongle. Death is on the&amp;nbsp; &lt;strong&gt;sd_flash_page_erase&lt;/strong&gt;() call.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to flash fails on nRF52840 Dongle, fine on nRF52840 DK</title><link>https://devzone.nordicsemi.com/thread/315131?ContentTypeID=1</link><pubDate>Mon, 14 Jun 2021 12:25:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:608b5a69-6807-4076-a3ac-461942724a65</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;You&amp;#39;re sure it&amp;#39;s running as expected when using an nRF52840 DK, right? Because it seems like you&amp;#39;re calling SoftDevice functions like&amp;nbsp;&lt;strong&gt;sd_flash_page_erase&lt;/strong&gt;() and&amp;nbsp;&lt;strong&gt;sd_flash_write&lt;/strong&gt;() after disabling the SoftDevice. Are you positive that the SoftDevice is disabled as expected? And why would you have to disable the SoftDevice? As long as you&amp;#39;re not connected to another device or advertising, there should be a limited amount of SoftDevice interrupts occurring while writing to flash.&lt;/p&gt;
&lt;p&gt;Have you adapted the project to work on a Dongle as explained in the Dongle programming tutorial by changing the preprocessor definition BOARD_PCA10056 to BOARD_PCA10059? Also, where&amp;nbsp;in the flash memory are you writing to? You might be running into examples on the Dongle if you&amp;#39;re trying to I.E. overwrite the bootloader&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>