<?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 problem when turning power off</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8430/pstorage-problem-when-turning-power-off</link><description>I&amp;#39;m currently using the pstorage functions to be able to store permenant data when turning off the power, it works good with me while writing or reading but when I turn off the power, the data is erased from the memory, I think it may be it&amp;#39;s a volatile</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 31 Jul 2015 14:12:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8430/pstorage-problem-when-turning-power-off" /><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30678?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 14:12:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f1afaac-8a1b-4516-a5cb-11e045e8d992</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;thank you for your effort by the way&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30677?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 13:36:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1461bb1-69ad-4e08-9bbe-e199aad8c2b0</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;please put a breakpoint in pstorage.c flash_write function. Write down the memory address of the destination and check what you are writing to it.&lt;/p&gt;
&lt;p&gt;similarly put a breakpoint in pstorage_load near the memcpy and check if it is the same address you are reading from. This curiosity of mine in this task took all day, i have to now do something productive for Nordic :)&lt;br /&gt;
Good luck&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30676?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 13:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5586a490-bb50-43d5-a337-df062f2d232d</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;yes, I changed my code to use the update instead of store but it didn&amp;#39;t work, the re-loaded data is 0xff while the stored data before power off is 0x01&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30675?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 13:06:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59c7d612-5018-4c5e-8699-143bff8e2b5d</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I am 100% sure that it should give the same handles to same address. That part has been well tested. There is no argument with it. did you change your code to use pstorage_update?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30674?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 13:04:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe89d855-a8a6-42f6-8d5a-3ad458465fd1</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;&amp;quot;after the system reset, when you do pstorage_register again in main, this is ok as it will be considered as first registration and it will give you the handles of memory that you stored your data &amp;quot;&lt;/p&gt;
&lt;p&gt;this doesn&amp;#39;t happen !!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30673?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 13:01:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7b802f0-b16c-42aa-ac2b-a02e01e7c931</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;no, system reset will not reset your flash memory. Flash memory will not be touched,  all your data there will not be changed, and after the system reset, when you do pstorage_register again in main, this is ok as it will be considered as first registration and it will give you the handles of memory that you stored your data. Again, use pstorage_update instead of store if you write multiple times to the same address. Do not use pstorage_store in your case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30672?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 12:58:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97eac169-6b55-4759-9717-cc543def57fb</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;thank you very much for your great help,
this is applicable &amp;quot;I mean system reset will cause reset to flash memory&amp;quot; with sd_flash_write();&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30671?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 12:55:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6b9f1a8-2691-481a-b5e3-cd982c6c8849</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;My apologies, I should have been more clear at that point.
I did not tell there about the SystemOFF, sorry for that. When the system wakes up from system off, there is a reset. When your system wakes up from sleep (WFE/WFI) there is no reset, it just continues from next instruction of the sleep (after servicing interrupts).
you can just call sd_nvic_SystemReset() instead of calling main and then you will get the behaviour you need.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30670?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 12:53:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0ea161b-8be4-4c38-8e83-70b27f70bc2d</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;I comment the main function in the LPCOMp_IRQHandler and get the same result, it gives me a fresh copy of another memory&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30669?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 12:50:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2d5f858-f68f-4028-af20-ac90500d1d6b</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;what about if I made a reset by removing the battery then putting it again? it will result to the same problem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30668?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 12:47:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:964b2eee-7822-4d40-8c24-d7cb7871b2d9</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;the main function is called again to start the system after wake up, I asked about the wake up Aryan because of that, I mean when the system wakeup, it start running the main again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30667?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 12:32:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19b9bf0f-a500-4769-bfba-a307b83af226</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Why are you calling main from LPCOMP_IRQHAndler? instead just do a SD_NVIC_SYSTEMRESET.
By calling main from LPCOMP_IRQHandler, you are reregistering on the top of already registered pstorage. This is why you see different memory.
I will try to explain you in simple.
system reset -&amp;gt; reset_handler-&amp;gt;main-&amp;gt;pstorage_register -&amp;gt;system_reset-&amp;gt;reset_handler-&amp;gt;main-&amp;gt;pstorage_register
In this above sequence, because there is a system reset, all RAM contents are lost and pstorage register will always give you same handles to same memory&lt;/p&gt;
&lt;p&gt;This is what you are trying to do
SYSTEM_RESET-&amp;gt;RESET_HANDLER-&amp;gt;MAIN-&amp;gt;PSTORAGE_REGISTER-&amp;gt;SOMETHING-&amp;gt;LPCOMP_IRQ-&amp;gt;MAIN-&amp;gt;PSTORAGE_REGISTER&lt;/p&gt;
&lt;p&gt;This is wrong as the second pstorage register knows that there has been a registration before as all the RAM contents are intact, so it will give you different handles and different blocks with different memory. hence you get a fresh copy of memory and you think it is erased. it is not erased, it is just fresh copy of another memory for your fresh pstorage_registration&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30663?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 11:40:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:040454ca-d1dd-4dbc-ba9b-2d60e6e2c767</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;I attached the full code in next answer, thank you for ur great effort&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30662?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 11:34:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d852467f-e670-4a2a-86db-4a743d0d309a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;you do not have to store the block_ids in flash memory, What you are trying to do is the basic functionality for which pstorage was designed. If you can attach your full code, maybe I will look at it. But it is already friday afternoon here ;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30661?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 11:32:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93c88a77-3b41-4ef4-8dbc-5b4455b015c9</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;no problem, it failed to work by the way, I don&amp;#39;t know the reason for causing that, I thinking to save the block ids in the flash memory with sd_flash_write &amp;amp; call it after every power off &amp;amp; not to re init or re-register blocks in memory again, there isn&amp;#39;t anything cause or save in flash in my code except psgtorage function&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30660?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 11:26:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec130dae-a2e2-49e4-8336-1f0a05e61eef</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I did not understand what burning code to chip using the bootloader means?
If you just want to flash, you can use keil/IAR to flash it, you can also use nrfjprog or Segger tools to flash. I am sorry, but I did not get exactly what you mean.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30659?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 11:20:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2178db78-21a5-4ace-861f-069084604405</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;shall I use the bootloader when I burn my code to the chip ? ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30658?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 10:13:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b4571cf-6990-4ed6-ad6b-9c2ff876a5de</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;no, flash memory is non-volatile, it wont be erase with reset, there is something else in your code which is not what you have showed here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30657?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 10:07:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38c9670a-4611-49ca-8e19-c1d0883b19a6</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;and the reset will cause memory erasing !!!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30656?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 09:54:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64d888f6-4c9c-466e-b964-6dc3a762da82</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Yes, wakeup from the poweroff will reset the core, so it loose all the handle values. You should register it again like it was done before poweroff to get same handles and same memory block_id&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30655?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 09:51:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f7bf9e1-62ad-40a9-a514-17221338c03a</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;I have a question: shall I init the pstorage &amp;amp; register it after every power off ? ? I&amp;#39;m little confused, I guessed that&amp;#39;s the reason for erasing the data&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30654?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 09:37:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b0142b1-b457-4526-b7f3-ce0e83ab7d51</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;debug into the pstorage library and check what address you are writing to? poweroff does not erase flash memory. Pstorage will not do that atleast. For Sure
You have to find out at what point the memory you are trying to write is being erased. Normal debugger is enough to track this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30653?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 09:02:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3a27b92-d203-4009-a636-321f6beb921b</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;also I tried to disconnect the device &amp;amp; the mobile as I thought that is the reason for not storing in the flash memory then connect it again and turned off the power then turned it on but no gain alsO!!!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30652?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 09:00:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fae0913-d882-4207-8116-f8bb5cd62e63</guid><dc:creator>Mohamed O.Abouzeid</dc:creator><description>&lt;p&gt;it didn&amp;#39;t make difference in case of power off &amp;amp; the memory is already erased !!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage problem when turning power off</title><link>https://devzone.nordicsemi.com/thread/30651?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 08:54:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea596a64-e324-437f-a29d-d901391824fc</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;instead of storing(pstorage_store) the data, use update(pstorage_update) function. Storing data on already written flash memory will corrupt it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>