<?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>i.MX RT Crossover MCUsのトピックRe: Crash when using RAMFUNCs</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Crash-when-using-RAMFUNCs/m-p/1046727#M7824</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Felipe&lt;/P&gt;&lt;P&gt;Yes I have seen this section in the manual. But to me, it says that the linker automatically creates these "veneers" and I don't have to do the calls via function pointer.&lt;/P&gt;&lt;P&gt;Only to work around the debug problem, calls via function pointers are necessary.&lt;/P&gt;&lt;P&gt;Or do I get this wrong?&lt;/P&gt;&lt;P&gt;The problem we have does not only happen when we debug, it also happens with a normal run of the firmware.&lt;/P&gt;&lt;P&gt;We have a lot of functions moved to RAM. It would be very ugly if we have to do all these calls via function pointers?&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Jul 2020 06:28:27 GMT</pubDate>
    <dc:creator>dh1</dc:creator>
    <dc:date>2020-07-03T06:28:27Z</dc:date>
    <item>
      <title>Crash when using RAMFUNCs</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Crash-when-using-RAMFUNCs/m-p/1046725#M7822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;To optimize for performance, we move a set of functions to ITCM memory.&lt;BR /&gt;We do this with __RAMFUNC(RAM2)&lt;/P&gt;&lt;P&gt;Now we randomly experience crashes with this. Randomly means, we change anything somewhere in the firmware, not necessarily in a RAM function, recompile and rerun it, and then the problem appears.&lt;/P&gt;&lt;P&gt;Often, we then have to add one more function to RAMFUNC, or remove one, and the problem disappears.&lt;/P&gt;&lt;P&gt;When we debug, we see that the program comes to a "veneer", and there instead jump to the respective function, go on to the next veneer and execute that function call. Then it crashes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is the call of the function TCA9555_WriteOutput&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/114195iE5CCDC020EC3E0BB/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Then I do instruction stepping. One step later:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/114196iA5F58F5188CEAD24/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Three steps later&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/114197i9113552089FA7E6C/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_4.png" alt="pastedImage_4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I'd expect it to go to the function in RAM now, but instead it goes to the next veneer:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/114198i75FF48A4D385C24F/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_5.png" alt="pastedImage_5.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Then I'm stepping further, and it even goes to the next veneer:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/114199i03BAC987E056E9D5/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_6.png" alt="pastedImage_6.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This call is then actually executed (which is not the actual program flow at all):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/114200i130B721EBBF4A627/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_7.png" alt="pastedImage_7.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't make any sense of this.&lt;/P&gt;&lt;P&gt;I attached the .map file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance and regards,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2020 11:52:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Crash-when-using-RAMFUNCs/m-p/1046725#M7822</guid>
      <dc:creator>dh1</dc:creator>
      <dc:date>2020-06-30T11:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Crash when using RAMFUNCs</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Crash-when-using-RAMFUNCs/m-p/1046726#M7823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check the below extract from &lt;A href="https://www.nxp.com/docs/en/user-guide/MCUXpresso_IDE_User_Guide.pdf"&gt;MCUXpresso IDE User Guide&lt;/A&gt; that explains the behavior you are facing.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;EM&gt;Due to the distance in the memory map between Flash memory and RAM, you will typically require a “long branch veneer” between the function in RAM and the calling function in Flash. The linker can automatically generate such a veneer for direct function calls, or you can effectively generate your own by using a call via a function pointer. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;One point to note is that debugging code with a linker generated veneer can sometimes cause problems. This veneer will not have any source level debug information associated with it, so that if you try to step in to a call to your code in RAM, typically the debugger will step over it instead. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;You can work around this by single stepping at the instruction level, setting a breakpoint in your RAM code, or by changing the function call from a direct one to a call via a function pointer.&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Note:&lt;/P&gt;&lt;P&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored.&lt;/P&gt;&lt;P&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;/P&gt;&lt;P&gt;------------------------------------------------------------------------------&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2020 23:12:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Crash-when-using-RAMFUNCs/m-p/1046726#M7823</guid>
      <dc:creator>FelipeGarcia</dc:creator>
      <dc:date>2020-07-02T23:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Crash when using RAMFUNCs</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Crash-when-using-RAMFUNCs/m-p/1046727#M7824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Felipe&lt;/P&gt;&lt;P&gt;Yes I have seen this section in the manual. But to me, it says that the linker automatically creates these "veneers" and I don't have to do the calls via function pointer.&lt;/P&gt;&lt;P&gt;Only to work around the debug problem, calls via function pointers are necessary.&lt;/P&gt;&lt;P&gt;Or do I get this wrong?&lt;/P&gt;&lt;P&gt;The problem we have does not only happen when we debug, it also happens with a normal run of the firmware.&lt;/P&gt;&lt;P&gt;We have a lot of functions moved to RAM. It would be very ugly if we have to do all these calls via function pointers?&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2020 06:28:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Crash-when-using-RAMFUNCs/m-p/1046727#M7824</guid>
      <dc:creator>dh1</dc:creator>
      <dc:date>2020-07-03T06:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Crash when using RAMFUNCs</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Crash-when-using-RAMFUNCs/m-p/1046728#M7825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are correct. The veneers are automatically created by the linker. However, according to your description you are stepping in to your function in RAM. This sometimes will cause you issues, the recommended workaround in the one mentioned in my previous reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2020 15:19:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Crash-when-using-RAMFUNCs/m-p/1046728#M7825</guid>
      <dc:creator>FelipeGarcia</dc:creator>
      <dc:date>2020-07-07T15:19:04Z</dc:date>
    </item>
  </channel>
</rss>

