<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Erasing/filling RAM at startup in MCUXpresso IDE</title>
    <link>https://community.nxp.com/t5/MCUXpresso-IDE/Erasing-filling-RAM-at-startup/m-p/796039#M2771</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is quite simple to do with a simple piece of C code in the startup file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are going to want to do this in the ResetISR code, before anything else. You will want code something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #7f0055; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;STRONG&gt;extern&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;int&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; __base_RAM;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #7f0055; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;STRONG&gt;extern&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;int&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; __top_RAM;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;//*****************************************************************************&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;// Reset entry point for your code.&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;// Sets up a simple runtime environment and &lt;SPAN style="text-decoration: underline;"&gt;initializes&lt;/SPAN&gt; the C/C++&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;// library.&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;//*****************************************************************************&lt;/P&gt;&lt;P style="color: #2a00ff; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;__attribute__&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; ((section(&lt;/SPAN&gt;".after_vectors"&lt;SPAN style="color: #000000;"&gt;)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #7f0055; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;STRONG&gt;ResetISR&lt;/STRONG&gt;(&lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;) {&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;int&lt;/STRONG&gt;&lt;/SPAN&gt; *baseRAM = &amp;amp;__base_RAM ;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;while&lt;/STRONG&gt;&lt;/SPAN&gt; (baseRAM &amp;lt; &amp;amp;__top_RAM){&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;*baseRAM++ = 0 ;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;...&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;I haven't tested this, but I'm sure you get the idea. Do not make any C library calls as it will not have been set up. Also, be careful with the stack. You can do something similar for each RAM block.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Sep 2018 09:03:55 GMT</pubDate>
    <dc:creator>converse</dc:creator>
    <dc:date>2018-09-26T09:03:55Z</dc:date>
    <item>
      <title>Erasing/filling RAM at startup</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/Erasing-filling-RAM-at-startup/m-p/796038#M2770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got a (hopefully) simple question for once:&amp;nbsp; What's the best way to zero out RAM at startup?&amp;nbsp; I'm chasing what seems to be a stack-related problem and I need to know what's actually been written to.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I seem to remember this being easy with the HCS08's linker parameter file.&amp;nbsp; I know you can fill non-volatile memory with the gcc linker, but that doesn't work with RAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obviously this could be done in the startup code, but I'm not really proficient in Cortex assembly.&amp;nbsp; Is there a gdb command to do this?&amp;nbsp; Or can it be done through some other scripting mechanism?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Sep 2018 17:41:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/Erasing-filling-RAM-at-startup/m-p/796038#M2770</guid>
      <dc:creator>scottm</dc:creator>
      <dc:date>2018-09-25T17:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Erasing/filling RAM at startup</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/Erasing-filling-RAM-at-startup/m-p/796039#M2771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is quite simple to do with a simple piece of C code in the startup file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are going to want to do this in the ResetISR code, before anything else. You will want code something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #7f0055; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;STRONG&gt;extern&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;int&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; __base_RAM;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #7f0055; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;STRONG&gt;extern&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;int&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; __top_RAM;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;//*****************************************************************************&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;// Reset entry point for your code.&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;// Sets up a simple runtime environment and &lt;SPAN style="text-decoration: underline;"&gt;initializes&lt;/SPAN&gt; the C/C++&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;// library.&lt;/P&gt;&lt;P style="color: #3f7f5f; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;//*****************************************************************************&lt;/P&gt;&lt;P style="color: #2a00ff; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;__attribute__&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; ((section(&lt;/SPAN&gt;".after_vectors"&lt;SPAN style="color: #000000;"&gt;)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #7f0055; margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;STRONG&gt;ResetISR&lt;/STRONG&gt;(&lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;) {&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;int&lt;/STRONG&gt;&lt;/SPAN&gt; *baseRAM = &amp;amp;__base_RAM ;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;while&lt;/STRONG&gt;&lt;/SPAN&gt; (baseRAM &amp;lt; &amp;amp;__top_RAM){&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;*baseRAM++ = 0 ;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;...&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;I haven't tested this, but I'm sure you get the idea. Do not make any C library calls as it will not have been set up. Also, be careful with the stack. You can do something similar for each RAM block.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2018 09:03:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/Erasing-filling-RAM-at-startup/m-p/796039#M2771</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2018-09-26T09:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Erasing/filling RAM at startup</title>
      <link>https://community.nxp.com/t5/MCUXpresso-IDE/Erasing-filling-RAM-at-startup/m-p/796040#M2772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem with doing it that way is that baseRAM itself gets overwritten with 0.&amp;nbsp; I worked around that by using the 'register' keyword in my pointer variable declaration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, my startup code is not the default - I've got a minimal startup.s in assembly that I think I had to switch to when I started using a custom build of Newlib Nano.&amp;nbsp; So I have to put the call to my C function in the assembly code, and hope that it always uses the link register to return and doesn't need the stack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I feel like there must be a way to do this in scripting.&amp;nbsp; From the memory view's import option I can load a blank memory image in a second or two, and I've used scripts to set individual GPIO registers before, so I'm pretty sure it must be possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2018 21:02:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-IDE/Erasing-filling-RAM-at-startup/m-p/796040#M2772</guid>
      <dc:creator>scottm</dc:creator>
      <dc:date>2018-09-26T21:02:16Z</dc:date>
    </item>
  </channel>
</rss>

