<?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>RAM retention between system resets (#pragma NOINIT replacement)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39290/ram-retention-between-system-resets-pragma-noinit-replacement</link><description>Hi, 
 
 My application is based of ble_freertos_hrs example (SDK 14.2, nRF52832) and I need some variables to survive an assertion. 
 It appears that Keil has deprecated #pragma NO_INIT that did just that. 
 
 I&amp;#39;ve noticed a post dealing with same issues</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Oct 2018 11:06:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39290/ram-retention-between-system-resets-pragma-noinit-replacement" /><item><title>RE: RAM retention between system resets (#pragma NOINIT replacement)</title><link>https://devzone.nordicsemi.com/thread/152338?ContentTypeID=1</link><pubDate>Wed, 10 Oct 2018 11:06:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b566fb74-b0e7-49df-b866-16f052eea7b9</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I forgot that the source files setting applied to all .bss variables in that file. I&amp;#39;m not sure if it is possible to set noninit on one specific variable without touching the scatter file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Alternative proposals:&lt;/p&gt;
&lt;p&gt;1. (Probably easiest) Store the data to an unallocated part of RAM memory like we do in the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/ram_retention_example.html?cp=4_0_0_4_5_30"&gt;ram retention&lt;/a&gt; example.&lt;/p&gt;
&lt;p&gt;2. Use the Keil scatter file (linker script): Open options for target and click on the Linker tab. Then untick the checkbox for &amp;quot;Use Memory Layout from target Dialog and modify the scatter file so it looks something like this:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-bb68f3fc189c4e0083df6db0d6b598b9/pastedimage1539169490551v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM retention between system resets (#pragma NOINIT replacement)</title><link>https://devzone.nordicsemi.com/thread/152251?ContentTypeID=1</link><pubDate>Tue, 09 Oct 2018 15:05:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6103b84c-c9fd-4620-ab7b-866f4c4aecee</guid><dc:creator>eyalasko</dc:creator><description>&lt;p&gt;Dear Vidar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;THANK YOU.&lt;/p&gt;
&lt;p&gt;Your answer saved me hours of googling (on top of the hours already spent)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Further question:&lt;/p&gt;
&lt;p&gt;What would be the way to &amp;#39;uninit&amp;#39; specific variables rather than all variables within a file?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Again, many many thanks for your prompt response&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM retention between system resets (#pragma NOINIT replacement)</title><link>https://devzone.nordicsemi.com/thread/152234?ContentTypeID=1</link><pubDate>Tue, 09 Oct 2018 13:42:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d31b06c4-44e6-4254-8a5e-3092e481a29b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;We used to allocate a no init section in our legacy bootloader for sharing data between application and bootloader (pre-SDK12). You can copy this approach to your example, it doesn&amp;#39;t require you to edit any linker/scatter files.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Steps:&lt;/p&gt;
&lt;p&gt;1. Define the variable you want to keep retained with&amp;nbsp;&amp;nbsp;__attribute__((section(&amp;quot;NoInit&amp;quot;), zero_init)); .e.g,&amp;nbsp;static uint32_t dummy&amp;nbsp;__attribute__((section(&amp;quot;NoInit&amp;quot;), zero_init));&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. Open option for target options allocate a new memory segment and tick the &amp;quot;NoInit&amp;quot; checkbox.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-bb68f3fc189c4e0083df6db0d6b598b9/pastedimage1539092202274v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;3. Right click on the source file you defined the variable in and select &amp;quot;options for File..&amp;quot;. Then select the new ram section you created from the dropdown menu for Zero initialized data.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-bb68f3fc189c4e0083df6db0d6b598b9/pastedimage1539092339562v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;4. Dummy variable should now be linked to the IRAM2 section.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RAM retention between system resets (#pragma NOINIT replacement)</title><link>https://devzone.nordicsemi.com/thread/152233?ContentTypeID=1</link><pubDate>Tue, 09 Oct 2018 13:42:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bceeea08-d9db-4fa1-8d69-d4865bfd6fb5</guid><dc:creator>awneil</dc:creator><description>[quote userid="27169" url="~/f/nordic-q-a/39290/ram-retention-between-system-resets-pragma-noinit-replacement"]It appears that Keil has deprecated &lt;a href="http://www.keil.com/support/man/docs/ca/ca_noinit.htm"&gt;#pragma NO_INIT &lt;/a&gt;that did just that.[/quote]
&lt;p&gt;I think you misunderstand?&lt;/p&gt;
&lt;p&gt;The page you linked to is for Keil&amp;#39;s old CARM compiler, which has long been discontinued - hence the &amp;#39;Discontinued&amp;#39; note at the top of that page.&lt;/p&gt;
&lt;p&gt;You need to see the documentation for the current &lt;strong&gt;MDK&lt;/strong&gt;&amp;nbsp;tools.&lt;/p&gt;
&lt;p&gt;For questions on how to use Keil products, you&amp;#39;d be better asking on the Keil forum:&amp;nbsp;&lt;a href="http://www.keil.com/forum/"&gt;http://www.keil.com/forum/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Don&amp;#39;t forget to post links between the threads when cross-posting&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;EDIT&lt;/p&gt;
[quote userid="27169" url="~/f/nordic-q-a/39290/ram-retention-between-system-resets-pragma-noinit-replacement"]I&amp;#39;ve noticed a post dealing with same issues &lt;a style="background-color:transparent;color:#0066cc;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;" href="https://devzone.nordicsemi.com/f/nordic-q-a/35488/losing-noinit-ram-contents-on-a-soft-reset-nrf52832-sdk-14-0-0-gcc/"&gt;here&lt;/a&gt;,[/quote]
&lt;p&gt;That&amp;#39;s about GCC - so not applicable to Keil anyhow.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>