<?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>Reading back uninitialised variable after soft reset nRF52 GCC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23085/reading-back-uninitialised-variable-after-soft-reset-nrf52-gcc</link><description>I&amp;#39;m trying to set a global variable in RAM as uninitialised so it can be read back after a soft reset condition: 
 uint32_t data __attribute__((section(&amp;quot;NoInit&amp;quot;), zero_init));
 
 Results in: 
 warning: &amp;#39;zero_init&amp;#39; attribute directive ignored [-Wattributes</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Jun 2017 12:18:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23085/reading-back-uninitialised-variable-after-soft-reset-nrf52-gcc" /><item><title>RE: Reading back uninitialised variable after soft reset nRF52 GCC</title><link>https://devzone.nordicsemi.com/thread/90831?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2017 12:18:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35effd27-416b-4277-bacf-44a23c54e1fc</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;it&amp;#39;s &amp;#39;lose&amp;#39; not &amp;#39;loose&amp;#39;.&lt;/p&gt;
&lt;p&gt;The datasheet doesn&amp;#39;t say a pin reset clears RAM. None of the resets clear RAM, RAM contents is not guaranteed to be preserved, but it&amp;#39;s not cleared, here&amp;#39;s the note from the datasheet&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Note: The RAM is never reset, but depending	on reset source, RAM content may be corrupted.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My experience has been it&amp;#39;s never corrupted either.&lt;/p&gt;
&lt;p&gt;You need to put a breakpoint on the reset handler, either your reset handler or the bootloader one. Find the address at 0x00000004 and breakpoint that (minus 1). You want the debugger to halt AS SOON as reset happens before even one instruction of code has been run. If your RAM location is zero then when it wasn&amp;#39;t before the reset, I&amp;#39;m wrong and you can&amp;#39;t do this. If it&amp;#39;s not zero, something is zeroing it. Never mind the nrf52 startup file, gcc has its own crt0 (or equivalent) which is doing loads of copies and zeroes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading back uninitialised variable after soft reset nRF52 GCC</title><link>https://devzone.nordicsemi.com/thread/90833?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2017 08:50:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:baa90ec0-7b07-4faa-88fe-9b9d330e0e32</guid><dc:creator>siliconwitch</dc:creator><description>&lt;p&gt;According to section 18.8 (page 83) of the nRF52 datasheet, the table shows that for both CPU lockup and soft reset, the RAM is preserved.&lt;/p&gt;
&lt;p&gt;The conditions where RAM may be corrupted are for power and pin reset reasons. This is fine because I report back POWER-&amp;gt;RESETREAS along with my stored data. If the reset was caused by a condition that would have corrupted RAM, then I ignore the saved data anyway. For the soft reset condition (which both app error and hardfault cause), I should be fine to read back the RAM&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading back uninitialised variable after soft reset nRF52 GCC</title><link>https://devzone.nordicsemi.com/thread/90835?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2017 00:50:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dd56e9c-c93e-45e1-af52-e0c462f7af93</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Thx, not erased (by itself) but &amp;quot;unpredictable&amp;quot; (and should be init during start-up sequence which hammerfet want&amp;#39;s to skip). My misunderstanding.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading back uninitialised variable after soft reset nRF52 GCC</title><link>https://devzone.nordicsemi.com/thread/90834?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2017 00:40:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c377439f-834c-4b9a-8afa-53a2c377852b</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;zero_init isn&amp;#39;t a defined GCC attribute so that&amp;#39;s why it&amp;#39;s ignored. Do you actually have a NoInit section in your linker file and if so what are its attributes. The most likely thing is it&amp;#39;s being placed in a section which is zero-erased on startup. You need to go debug the startup code which is called after the reset handler and find out which sections are neither zero-filled, nor loaded from flash.&lt;/p&gt;
&lt;p&gt;@endnode - RAM is not erased on reset. There&amp;#39;s no guarantee it doesn&amp;#39;t get corrupted but it&amp;#39;s not erased. My experience is I&amp;#39;ve never yet seen it corrupted either but I&amp;#39;m sure it happens.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading back uninitialised variable after soft reset nRF52 GCC</title><link>https://devzone.nordicsemi.com/thread/90832?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 23:52:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:943b5685-cdfe-4bba-b0cb-ecb02ad07c99</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;But soft reset works as any other reset = RAM is erased. I&amp;#39;m afraid this kind of information preserving won&amp;#39;t work... at least all similar systems of &amp;quot;Hard fault logging&amp;quot; on nRF5x I&amp;#39;ve seen so far were using NVM (= allocating one or more flash pages and implementing simpler or more complex systems how to log/retrieve/interpret/report/clean the fault events).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>