<?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: RT1176 ROM code does not set stack pointer correctly in i.MX RT Crossover MCUs</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1394111#M17841</link>
    <description>&lt;P&gt;Udo,&lt;/P&gt;&lt;P&gt;I don't think you are being totally fair.&lt;/P&gt;&lt;P&gt;As I wrote previously, in section 10.3.5 in the reference manual &lt;STRONG&gt;it is clearly written what the boot ROM does&lt;/STRONG&gt;. If you had read that, you would not have been in doubt if you needed to set the MSP or not.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jan 2022 09:04:06 GMT</pubDate>
    <dc:creator>carstengroen</dc:creator>
    <dc:date>2022-01-04T09:04:06Z</dc:date>
    <item>
      <title>RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1388830#M17638</link>
      <description>&lt;P&gt;I found out (the hard way) that RT1176 ROM code when starting my firmware image (via reset vector) does not set the stack pointer register (MSP) to the value defined by my vector table. Instead it sets MSP to&amp;nbsp;0x20241da0.&lt;/P&gt;&lt;P&gt;According to ARM's specification on how an Cortex-M CPU boots, MSP should be initialized with the value VECT[0]. Hence I would consider this to be a bug in the ROM code. I cannot find a related record in the errata sheet.&lt;/P&gt;&lt;P&gt;In the RT1170 sample code one can find this statement at the beginning of&amp;nbsp;ResetISR:&lt;/P&gt;&lt;P&gt;__asm volatile ("MSR MSP, %0" : : "r" (&amp;amp;_vStackTop) : );&lt;/P&gt;&lt;P&gt;which fixes the issue. But there is no comment nor other hint that this is a workaround for a ROM code bug.&lt;/P&gt;&lt;P&gt;My code failed because it was ported over from RT10xx and did not have this workaround in place.&lt;/P&gt;&lt;P&gt;Is this a known issue in RT1170 ROM code? Is this going to be fixed in future revisions?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 13:28:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1388830#M17638</guid>
      <dc:creator>udoeb</dc:creator>
      <dc:date>2021-12-17T13:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1389239#M17646</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/152354"&gt;@udoeb&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;In fact, it is not the ROM issue, it is just the feature.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; So, after you jump, you can reset the SP in the MCUXPresso IDE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-C hljs"&gt;    &lt;SPAN class="hljs-comment"&gt;/* 新增SP重设代码 */&lt;/SPAN&gt;
    &lt;SPAN class="hljs-function"&gt;__asm &lt;SPAN class="hljs-title"&gt;volatile&lt;/SPAN&gt; &lt;SPAN class="hljs-params"&gt;(&lt;SPAN class="hljs-string"&gt;"MSR msp, %0"&lt;/SPAN&gt; : : &lt;SPAN class="hljs-string"&gt;"r"&lt;/SPAN&gt; (&amp;amp;_vStackTop) : )&lt;/SPAN&gt;&lt;/SPAN&gt;;
    &lt;SPAN class="hljs-function"&gt;__asm &lt;SPAN class="hljs-title"&gt;volatile&lt;/SPAN&gt; &lt;SPAN class="hljs-params"&gt;(&lt;SPAN class="hljs-string"&gt;"MSR psp, %0"&lt;/SPAN&gt; : : &lt;SPAN class="hljs-string"&gt;"r"&lt;/SPAN&gt; (&amp;amp;_vStackTop) : )&lt;/SPAN&gt;&lt;/SPAN&gt;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;More details, our AE write it in the chinese formula, not the English, maybe you can translate it and check it:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.cnblogs.com/henjay724/p/13652875.html" target="_blank"&gt;https://www.cnblogs.com/henjay724/p/13652875.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wish it helps you!&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2021 04:04:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1389239#M17646</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2021-12-20T04:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393707#M17818</link>
      <description>&lt;P&gt;Hi Kerry,&lt;/P&gt;&lt;P&gt;Thanks for your reply. I don't understand Chinese so please post comments in English.&lt;/P&gt;&lt;P&gt;I do not consider this a feature. It's non-compliant behavior. The Arm documentation clearly specifies that on reset the Cortex M7 CPU loads the stack pointer (MSP) from index 0 in the vector table. See also the Cortex M7 user guide, section 2.3.4 Vector table:&lt;BR /&gt;&lt;A href="https://documentation-service.arm.com/static/5ea95fba9931941038df3bbe?token=" target="_blank"&gt;https://documentation-service.arm.com/static/5ea95fba9931941038df3bbe?token=&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The RT1176 does not behave this way. This should be documented in the reference manual, the errata document, or elsewhere.&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Udo&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 09:21:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393707#M17818</guid>
      <dc:creator>udoeb</dc:creator>
      <dc:date>2022-01-03T09:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393796#M17821</link>
      <description>&lt;P&gt;Technically, it is the (NXP) ROM that starts your code and "not the CPU as part of its reset sequence". In this case, NXP requires you to set the MSP when the ROM starts your code (which can be placed many different places according to the BOOT configuration etc.)&lt;BR /&gt;In the same way the ROM also sets a lot of other things, QSPI, SDRAM etc, these are also not part of the "Cortex M7 user guide".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 14:29:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393796#M17821</guid>
      <dc:creator>carstengroen</dc:creator>
      <dc:date>2022-01-03T14:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393816#M17822</link>
      <description>&lt;P&gt;Of course it's the ROM code which emulates the reset. But it does it in a way that's different than specified by ARM. This should be documented somewhere. Specifically because behavior seems to be different in RT10xx and RT11xx. When existing code is ported from RT10 to RT11 (as in my case) this behavior is a pitfall and cost me hours of debugging.&lt;/P&gt;&lt;P&gt;Where is the CPU startup implemented by ROM code documented?&lt;/P&gt;&lt;P&gt;Udo&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 15:47:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393816#M17822</guid>
      <dc:creator>udoeb</dc:creator>
      <dc:date>2022-01-03T15:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393819#M17823</link>
      <description>&lt;P&gt;It says that it "Loads and jumps to an address derived from the program image" for (as an example) the internal boot mode. It does not say that it load the MSP for you etc...&lt;BR /&gt;If stuff crashes during boot, it is always a good idea to check MSP/PSP as well as stack sizes, we have all been bitten by that &lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="carstengroen_0-1641225524364.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/166589i64EE55C86FAC0C98/image-size/medium?v=v2&amp;amp;px=400" role="button" title="carstengroen_0-1641225524364.png" alt="carstengroen_0-1641225524364.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 16:00:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393819#M17823</guid>
      <dc:creator>carstengroen</dc:creator>
      <dc:date>2022-01-03T16:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393991#M17831</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/152354"&gt;@udoeb&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Happy New Year!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Thanks to&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/105884"&gt;@carstengroen&lt;/a&gt;&amp;nbsp;reply, you are totally correct!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; When the MCUXrpesso startup didn't reset the SP, and the IVT entry is the reset handler, the BootROM jump to the APP will still use the BootROM's stack, from the RM system boot chapter, BootROM stack is put in the OCRAM, then, if the app code also put the RW,ZI section into that OCRAM, then when the App run and use the stack, it may cause the App RW, ZI data break issues, then the app may run into the abnormal.&lt;/P&gt;
&lt;P&gt;So, normally, we will do :&lt;/P&gt;
&lt;P&gt;reset SP&lt;BR /&gt;systemInit()&lt;BR /&gt;data/bss/ramfunc initialize&lt;BR /&gt;Jump to main&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact, in the old SDK MCUXpresso IDE project, we didn't add this reset SP code, so I also meet one issue when testing the RT10XX&amp;nbsp;&lt;SPAN&gt;dev_cdc_vcom_freertos demo, when using the IVT as the reset handler address, then the code runs abnormal, at last, we find we need to reset the SP to solve this issues, so in the new SDK MCUXPresso IDE project, we add it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Wish it helps you!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;kerry&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 06:18:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1393991#M17831</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2022-01-04T06:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1394103#M17839</link>
      <description>&lt;P&gt;It's interesting to know that you were affected by this issue as well. As I said, ROM code behavior should be better documented. I suggest NXP publishes the sources of the ROM code or at least relevant parts of it. This would be the best documentation you can get.&lt;/P&gt;&lt;P&gt;Udo&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 08:49:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1394103#M17839</guid>
      <dc:creator>udoeb</dc:creator>
      <dc:date>2022-01-04T08:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1394111#M17841</link>
      <description>&lt;P&gt;Udo,&lt;/P&gt;&lt;P&gt;I don't think you are being totally fair.&lt;/P&gt;&lt;P&gt;As I wrote previously, in section 10.3.5 in the reference manual &lt;STRONG&gt;it is clearly written what the boot ROM does&lt;/STRONG&gt;. If you had read that, you would not have been in doubt if you needed to set the MSP or not.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 09:04:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1394111#M17841</guid>
      <dc:creator>carstengroen</dc:creator>
      <dc:date>2022-01-04T09:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: RT1176 ROM code does not set stack pointer correctly</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1394135#M17843</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/152354"&gt;@udoeb&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ROM code is not published to the customer, to be honest, even I, also don't have that code, so, you can see that code confidential level!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;In fact, to us, we just need to use it, you just need to reset the SP, then everything will go well!&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 09:25:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1176-ROM-code-does-not-set-stack-pointer-correctly/m-p/1394135#M17843</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2022-01-04T09:25:43Z</dc:date>
    </item>
  </channel>
</rss>

