<?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>PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9722/pstorage-event-handler-problems</link><description>Hello! 
 I have been experiencing some trouble with the PStorage API. I have browsed every example and similar question I can find and none seem to match the continuing issues that I am having. 
 I have been very sure to register the pstorage event</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 Oct 2015 06:24:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9722/pstorage-event-handler-problems" /><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35995?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2015 06:24:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e379bf3-82b9-4bf6-8443-dccb5230ebdb</guid><dc:creator>ChrisG</dc:creator><description>&lt;p&gt;It was, I suppose, a mixture of the bootloader and application interaction with the softdevice. We were calling a master boot record command in the initilisations of the application instead of in the bootloader. Since we use external flash, the complications this led to were not visible until we tried to use the PStorage module.&lt;/p&gt;
&lt;p&gt;The softdevice was enabled but functioning incorrectly as flash event were not being posted and the system could only tolerate one flash operation per reset, all others returned with success but never actually managed to perform the operation.&lt;/p&gt;
&lt;p&gt;By moving the mbr command to the bootloader this was resolved and allowed the flash operations to complete properly and give the neccessary events.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35994?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 12:45:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fb87ff7-d98b-4466-bc04-414623a16d72</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Good that it is working now, thanks for your feedback.&lt;/p&gt;
&lt;p&gt;Can I ask what specifically was the problem with the bootloader? Just thinking if it could help &lt;a href="https://devzone.nordicsemi.com/users/2855/torsten-robitzki/"&gt;Torsten&lt;/a&gt; on &lt;a href="https://devzone.nordicsemi.com/question/54077/sd_evt_get-sd_flash_page_erase-and-not-all-events/"&gt;his case&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35993?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 12:39:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b4273bf-93ac-41cf-9318-62a1809d772b</guid><dc:creator>ChrisG</dc:creator><description>&lt;p&gt;Thanks for all your comments and suggestions on this. I tested today without our bootloader and it worked correctly so I was able to narrow down the problem to be caused by bootloader.&lt;/p&gt;
&lt;p&gt;With a few changes to the bootloader this seems to be working correctly now.&lt;/p&gt;
&lt;p&gt;Thanks,
Chris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35992?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 12:07:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03e9a6ec-a4e8-4fa2-aa3a-be6bb4d3a1c4</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Have you registered the system handler, as documented &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/lib_pstorage.html?cp=4_1_0_3_13_4#pstorage_implement_specifics"&gt;here&lt;/a&gt; and pointed out on &lt;a href="https://devzone.nordicsemi.com/question/52213/writing-to-flash/"&gt;this thread&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35991?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 13:38:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7e622d1-ca4f-401b-9902-71d1510c9235</guid><dc:creator>ChrisG</dc:creator><description>&lt;p&gt;The system events do not appear to be being generated, and the pstorage handler is never being called. I have meanwhile been testing a little with &lt;code&gt;sd_flash_write();&lt;/code&gt; as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sd_flash_write((uint32_t*)0x36C00, (uint32_t*)test_data_store, 1);
nrf_delay_ms(200);
sd_flash_write((uint32_t*)0x36C04, (uint32_t*)test_data_store, 1);
nrf_delay_ms(200);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This writes directly one word at a time to the area assigned for pstorage, the first operation succeeds and the memory location is correctly written to with the values provided. The second operation apparently succeeds, debugging through it shows no errors and it returns as NRF_SUCCESS however the memory location is still in an erased state, not written to.&lt;/p&gt;
&lt;p&gt;There is some kind of fundamental error here that is not allowing more than one flash operation per reset of the chip. This goes for erase as well, following an erase, no store actually writes anything.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35990?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 13:27:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69e1e9b5-d638-47d8-933e-511479e16d8e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Yes, sorry, we in Nordic use Stack in reference to softdevice, so i got little confused at the first look.
You are right, they both are different entities, so the call back should work just fine if softdevice is enabled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35989?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 13:22:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5695747e-18d7-4458-893b-db3701e8a7cd</guid><dc:creator>ChrisG</dc:creator><description>&lt;p&gt;Yes, the BLE stack is disabled, bluetooth / radio are not activated but the softdevice is enabled. They are two seperate entities that can be independently enabled if I have not misunderstood, or atleast that the softdevice can be enabled without the bluetooth stack.&lt;/p&gt;
&lt;p&gt;I have double checked and the softdevice is definitely enabled.&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35988?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 13:07:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8580533a-9b23-4e0a-8536-7cee47ae7bfa</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;but you said &lt;code&gt;&amp;quot;BLE Stack is disabled &amp;quot;&lt;/code&gt; in your comment one hour before this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35987?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 12:24:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cf589b6-4eb3-4a7a-89b0-c435f542e8cf</guid><dc:creator>ChrisG</dc:creator><description>&lt;p&gt;I have the Softdevice enabled, and have confirmed that it is definitely enabled with &lt;code&gt;sd_softdevice_is_enabled(&amp;amp;sd_enabled)&lt;/code&gt; As far as the cheap trick method is concerned, it appears to work for a single element in queue but no subsequent queue elements that I add later function correctly.&lt;/p&gt;
&lt;p&gt;I have debugged right through the subsequent store operation and ensured it reached the call to sd_flash_write, which did return NRF_SUCCESS however checking the memory location showed that it had not done anything.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35986?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 11:56:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9195fb3-880f-4de8-bd8b-6a0abccdbd2b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Pstorage Library is designed to work with Softdevice enabled because it uses sd_flash_xxx functions inside it.&lt;/p&gt;
&lt;p&gt;sd_flash_xxx functions can work even if the softdevice is disabled, but they do not give the callbacks.&lt;/p&gt;
&lt;p&gt;You wont get any events from softdevice (when it is disabled) because flash requests are completed synchronously as there do not have any competition for CPU time and AHB bus
That means that when pstorage function call is returned your operation is already complete.&lt;/p&gt;
&lt;p&gt;This is clearly given in the API documentation inside nrf_soc.h&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**@brief Flash Write
*
* Commands to write a buffer to flash
*
* If the SoftDevice is enabled:
*  This call initiates the flash access command, and its completion will be communicated to the
*  application with exactly one of the following events:
*      - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
*      - @ref NRF_EVT_FLASH_OPERATION_ERROR   - The command could not be started.
*
* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the write has been completed
*
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In short if softdevice is disabled, then your flash operation is completed immediately and it will never fail. If you still want to use pstorage with softdevice disabled, then you need use your so called &amp;quot;cheap_trick&amp;quot; function. I think the subsequent store operation should also pass if you call the cheap_trick() everytime you do a pstorage request. Could you debug more and see what blocked that subsequent store operation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35985?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 11:31:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28eb23d2-3042-4226-ba4f-60536f9c379f</guid><dc:creator>ChrisG</dc:creator><description>&lt;p&gt;Thank you for your quick response. BLE Stack is disabled and I am not using any radio notifications. I am using nRF51 SDK v9.0.0. I should also mention, I am using a bootloader if that can have any bearing here as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PStorage Event Handler Problems</title><link>https://devzone.nordicsemi.com/thread/35984?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 11:16:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e76b22c-efae-4180-87d6-25474ce0cabd</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Are you using radio notifications?
It would be helpful to give information about the SDK version you  are using.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>