<?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 stop softdevice so I can write to flash</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42080/how-to-stop-softdevice-so-i-can-write-to-flash</link><description>Hi, 
 I am working from an existing code base where I had to add the s130 softdevice and BLE scanning capabilities. I have an area of flash that stores application data that I need to update but the existing code base uses nrf_nvmc which locks up the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Jan 2019 17:42:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42080/how-to-stop-softdevice-so-i-can-write-to-flash" /><item><title>RE: How to stop softdevice so I can write to flash</title><link>https://devzone.nordicsemi.com/thread/164575?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 17:42:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0cda49d-4ef4-414f-b4d7-99e8c65108f1</guid><dc:creator>David Andresky</dc:creator><description>&lt;p&gt;I found the issue. We have a python script that generates a header file with a memory map. This memory map is referenced throughout our code, including our bootloader. The internal flash area that I am trying update stores the execution address for the main code. When I call sd_flash_erase(), the value for the execution address is temporarily all FF&amp;#39;s. When the softdevice generates the flash operation event it caused the bootloader to feed a bogus address to the interrupt handler causing the program counter to go off into the weeds. I hard coded the address in the bootloader and was able to get past this problem.&lt;/p&gt;
&lt;p&gt;We can close the issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop softdevice so I can write to flash</title><link>https://devzone.nordicsemi.com/thread/163858?ContentTypeID=1</link><pubDate>Thu, 03 Jan 2019 23:25:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:151c34a3-1c0c-483a-bc8f-3daec07b0763</guid><dc:creator>wpaul</dc:creator><description>&lt;p&gt;I&amp;#39;d be willing to bet that the SoftDevice is trying to deliver an event notification, but somewhere the handling for it isn&amp;#39;t set up property. As I said, you should get an SD_EVT_IRQn interrupt. This same vector is used to deliver both BLE protocol events and SoC events. When it triggers, you need to do an sd_evt_get() to read the status. I think for the Nordic SDK this involves using the NRF_SDH_SOC_OBSERVER() macro to install a handler. Somewhere there should be an nrf_sdh.c file in the SDK which contains an SD_EVT_IRQHandler() function (assuming you&amp;#39;re using interrupt-driven event dispatching) which calls nrf_sdh_evts_poll(). This should invoke handlers for ble, and or soc events. So if things work correctly, eventually nrf_sdh_soc_evts_poll() should be called and the event should be dispatched to a handler. If you have a debugger connected, I would try to set a breakpoint in one of those dispatch routines and see if you can trace down what happens from there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop softdevice so I can write to flash</title><link>https://devzone.nordicsemi.com/thread/163857?ContentTypeID=1</link><pubDate>Thu, 03 Jan 2019 22:13:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3a00c15-0b6a-4a74-af68-ce721ff1baa3</guid><dc:creator>David Andresky</dc:creator><description>&lt;p&gt;Update - the nrf_assert_callback was occurring due to a bug unrelated to the softdevice. I was running a self test on the SPI flash chip that was leaving it in a sleep state. When I tried to erase sectors there was an assert that was failing because it was asleep.&lt;/p&gt;
&lt;p&gt;I still have an issue trying to update the internal flash. When I call the sd_flash_erase() function a sys event is not being received. Instead, a couple seconds after calling sd_flash_erase(), the call stack goes to 0 and it can&amp;#39;t recover. The watchdog doesn&amp;#39;t even fire.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop softdevice so I can write to flash</title><link>https://devzone.nordicsemi.com/thread/163845?ContentTypeID=1</link><pubDate>Thu, 03 Jan 2019 20:24:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5db148cd-85f8-4216-9af5-979382b8b511</guid><dc:creator>wpaul</dc:creator><description>&lt;p&gt;One clarification: the nRF52 flash is not an &amp;quot;external flash chip&amp;quot; or &amp;quot;SPI chip.&amp;quot; It&amp;#39;s internal to the device and is not accessed via SPI bus. (If your flash was accessed via SPI bus, you wouldn&amp;#39;t be having this problem.)&lt;/p&gt;
&lt;p&gt;If other SoftDevice calls in your application work ok, then I don&amp;#39;t know why the flash APIs wouldn&amp;#39;t work too. One thing to note is that the sd_flash_write() and sd_flash_page_erase() APIs causes the SoftDevice to generate an event to indicate completion. See nrf_soc.h for more info. The event to expect is either NRF_EVT_FLASH_OPERATION_SUCCESS or NRF_EVT_FLASH_OPERATION_ERROR. The SoftDevice generates an interrupt via the SD_EVT_IRQn vector, and software must call sd_evt_get() to read the event info (this is for SoC events only -- there is a separate sd_ble_evt_get() API for BLE events). I don&amp;#39;t know if you&amp;#39;re using the Nordic SDK framework or your own custom code, but somewhere there should be a handler registered to drain and capture these events in order for things to work right.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop softdevice so I can write to flash</title><link>https://devzone.nordicsemi.com/thread/163833?ContentTypeID=1</link><pubDate>Thu, 03 Jan 2019 17:35:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:551bf7b0-9c93-4eab-a00e-39b878d49665</guid><dc:creator>David Andresky</dc:creator><description>&lt;p&gt;Thanks Einar,&lt;/p&gt;
&lt;p&gt;My first attempt at this was to use sd_flash_erase() and sd_flash_write(). After sending my question yesterday I went back to this and stopped trying to disable the softdevice.&lt;/p&gt;
&lt;p&gt;The problem I have been running into is the app_error_handler keeps getting called and the code locks up. Let me give a little more detail on what I am doing.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The legacy code I am working with has a function that updates an area of internal flash by calling&amp;nbsp;nrf_nvmc_page_erase() and&amp;nbsp;nrf_nvmc_write_words(). After calling those functions it continues on to erase a sector of flash in an external SPI flash chip. This worked until I added the softdevice and switched to&amp;nbsp;&lt;span&gt;sd_flash_erase() and sd_flash_write(). N&lt;/span&gt;ow it locks up. I am getting a call to nrf_assert_callback() with the 0xDEADBEEF message when I attempt to read the status register of the external flash chip.&lt;/p&gt;
&lt;p&gt;My thought process now is that I need to hold erasing the sector on the SPI chip until the update of internal flash completes. Maybe one is stepping on the other or interfering in some way. I don&amp;#39;t understand why but it is the only thing I can think of.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop softdevice so I can write to flash</title><link>https://devzone.nordicsemi.com/thread/163671?ContentTypeID=1</link><pubDate>Thu, 03 Jan 2019 09:27:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c2df4eb-deef-49b0-8a3b-934d2cc34c5e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As you have noted, the only way to access the NVMC directly is to disable the SoftDevice. That should not cause any problems, as long as you stop any active connections and stop scanning and advertising before you call &lt;a href="https://www.nordicsemi.com/DocLib/Content/SoftDevice_API_Doc/S130/v2-0-1/group_nrf_sdm_functions#ga45900ecbe6d5ebf9ae78894fe6c75b23"&gt;sd_softdevice_disable()&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A (better?) alternative could be to modify your code so that you call &lt;a href="https://www.nordicsemi.com/DocLib/Content/SoftDevice_API_Doc/S130/v2-0-1/group_nrf_soc_functions?1412#ga8b49f2e72e97291aecc18ce396956eed"&gt;sd_flash_write()&lt;/a&gt; instead of disabling the SoftDevice and using the NVMC directly.That should should not introduce a lot of changes in your code. Essentially you do the same thing as before, but you let the SoftDevice schedule the raw flash writes to happen when it has time (between BLE events).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>