<?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: OTFAD Problem in i.MX RT Crossover MCUs</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1236313#M12891</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;LeslieLee,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;About the OTFAD issues, please note these information:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. Reason&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;When OTFAD is enabled, if the encrypted app is XIP running, in the app, core frequency need to be higher than FlexSPI frequency. If core frequency is lower than flexSPI, when core access the encrypted Flash area, OTFA can't decrypte the code, and will case the instruction messing issues, will case the hardfault.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the&amp;nbsp;BOARD_BootClockRUN(), we can see the core frequency from 396Mhz to external OSC24 Mhz switch, it will make the core smaller than FlexSPI frequency, as you know, the slowest FlexSPI is 30Mhz. This is the root issue caused the OTFAD limit issues.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Solution&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; When configure the clock, don't switch to the external OSC then switch to the PLL, we can switch to PLL directly.&amp;nbsp; Put the Audio(Enet) Pll init code to the front side. The modification code is:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;void BOARD_BootClockRUN(void)&lt;BR /&gt;{&lt;BR /&gt;// 此处略去...&lt;BR /&gt;/* Set Oscillator ready counter value. */&lt;BR /&gt;CCM-&amp;gt;CCR = (CCM-&amp;gt;CCR &amp;amp; (~CCM_CCR_OSCNT_MASK)) | CCM_CCR_OSCNT(127);&lt;BR /&gt;- /* Setting PeriphClk2Mux and PeriphMux to provide stable clock before PLLs are initialed */&lt;BR /&gt;- CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 1); /* Set PERIPH_CLK2 MUX to OSC */&lt;BR /&gt;- CLOCK_SetMux(kCLOCK_PeriphMux, 1); /* Set PERIPH_CLK MUX to PERIPH_CLK2 */&lt;/P&gt;
&lt;P&gt;// delete...&lt;BR /&gt;/* Set IPG_PODF. */&lt;BR /&gt;CLOCK_SetDiv(kCLOCK_IpgDiv, 3);&lt;BR /&gt;+ /* Init Enet PLL. */&lt;BR /&gt;+ CLOCK_InitEnetPll(&amp;amp;enetPllConfig_BOARD_BootClockRUN);&lt;BR /&gt;+ /* Set preperiph clock source. */&lt;BR /&gt;+ CLOCK_SetMux(kCLOCK_PrePeriphMux, 3);&lt;/P&gt;
&lt;P&gt;// delete...&lt;BR /&gt;/* Enable Audio PLL output. */&lt;BR /&gt;CCM_ANALOG-&amp;gt;PLL_AUDIO |= CCM_ANALOG_PLL_AUDIO_ENABLE_MASK;&lt;BR /&gt;- /* Init Enet PLL. */&lt;BR /&gt;- CLOCK_InitEnetPll(&amp;amp;enetPllConfig_BOARD_BootClockRUN);&lt;BR /&gt;- /* Set preperiph clock source. */&lt;BR /&gt;- CLOCK_SetMux(kCLOCK_PrePeriphMux, 3);&lt;/P&gt;
&lt;P&gt;// delete...&lt;BR /&gt;/* Set SystemCoreClock variable. */&lt;BR /&gt;SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2021 05:34:35 GMT</pubDate>
    <dc:creator>kerryzhou</dc:creator>
    <dc:date>2021-02-25T05:34:35Z</dc:date>
    <item>
      <title>OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204230#M11869</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;My previous question:&amp;nbsp;&lt;A href="https://community.nxp.com/t5/i-MX-RT/Use-FlexSPI-while-decrypted-with-OTFAD/m-p/1203975/highlight/false#M11860" target="_self"&gt;Use FlexSPI while decrypted with OTFAD&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for posting a new thread for my problem, I am doing this as I found there are actually multiple problems stack together with OTFAD.&lt;/P&gt;&lt;P&gt;Right now I suspect that the way I change FlexRam is conflicting with OTFAD.&lt;/P&gt;&lt;P&gt;Here is some observation of my problem&lt;/P&gt;&lt;TABLE border="2" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;Result&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Modify FlexRam&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Calling ITCM Ram Func&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Using OTFAD&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;Not Running&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Yes&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Yes&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;Running&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;No&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Yes&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="26px"&gt;Running&lt;/TD&gt;&lt;TD width="25%" height="26px"&gt;Yes&lt;/TD&gt;&lt;TD width="25%" height="26px"&gt;No&lt;/TD&gt;&lt;TD width="25%" height="26px"&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;Running&lt;/TD&gt;&lt;TD height="25px"&gt;Yes/No&lt;/TD&gt;&lt;TD height="25px"&gt;Yes/No&lt;/TD&gt;&lt;TD height="25px"&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;So I believe FlexRam is the first problem avoiding the RT1011 running encrypted image.&lt;/P&gt;&lt;P&gt;I am using MCUXpresso IDE for development and I use the following codes in ResetISR function to change FlexRam Setting.&lt;/P&gt;&lt;PRE&gt;__attribute__ ((section(".after_vectors.reset")))&lt;BR /&gt;void ResetISR(void) {&lt;BR /&gt;&lt;BR /&gt;// Disable interrupts&lt;BR /&gt;__asm volatile ("cpsid i");&lt;BR /&gt;&lt;BR /&gt;/* SP reset */&lt;BR /&gt;__asm volatile ("MSR msp, %0" : : "r" (&amp;amp;_vStackTop) : );&lt;BR /&gt;__asm volatile ("MSR psp, %0" : : "r" (&amp;amp;_vStackTop) : );&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;/* config FlexRam */&lt;/STRONG&gt;&lt;BR /&gt;FLEXRAM-&amp;gt;TCM_CTRL = 4;&lt;BR /&gt;IOMUXC_GPR-&amp;gt;GPR17 = 0xAB;//0xAA;//0x6B;&lt;BR /&gt;IOMUXC_GPR-&amp;gt;GPR16 |= 0x7;&lt;/PRE&gt;&lt;P&gt;The whole startup.c file is attached.&lt;/P&gt;&lt;P&gt;I use&amp;nbsp;&lt;A href="https://github.com/JayHeng/NXP-MCUBootUtility" target="_self"&gt;MCUBootUtility&lt;/A&gt;&amp;nbsp;to build and flash the OTFAD encrypted image and reset the SP register suggested&amp;nbsp;&lt;A href="https://www.cnblogs.com/henjay724/p/13652875.html" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;May I know what is the proper way to change FlexRam when using OTFAD encryption at the same time?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;P.S.&lt;/P&gt;&lt;P&gt;Update 1:&lt;/P&gt;&lt;P&gt;The ram function can be executed if I add an&amp;nbsp;SDK_DelayAtLeastUs before it.&lt;/P&gt;&lt;P&gt;But OTFAD will still have a problem when the frequency adjustment code is placed in SRAM_ITC instead of non-encrypted flash region.&lt;/P&gt;&lt;P&gt;Update 2:&lt;/P&gt;&lt;P&gt;I create a new project in case there is other stuff in my original project causing the problem.&lt;/P&gt;&lt;P&gt;The new project shows that when the FlexRam is modified and only two peripheral(adc, adc_etc) is inited using MCUXpresso GUI, the program will work with no problem. However, when I added one more peripheral(lpi2c or lpspi), the program will crash.&lt;/P&gt;&lt;P&gt;Update 3:&lt;/P&gt;&lt;P&gt;When the encryption range is 0x60001000-0x60004000, the program based on the new project will work, but if the encryption range is 0x60001000-0x60005000, the program won't work.&lt;/P&gt;&lt;P&gt;Update 4:&lt;/P&gt;&lt;P&gt;By toggling the LED around the code and placing the trap code, I found that for the not working program, they crash at this function in clock_config.c&lt;/P&gt;&lt;PRE&gt;CLOCK_SetMux(kCLOCK_PeriphMux, 0);&lt;/PRE&gt;&lt;P&gt;And I found the reply about&amp;nbsp;&lt;A href="https://community.nxp.com/t5/i-MX-RT/XIP-through-OTFAD-problems-on-RT1011/m-p/1042223/highlight/true#M7648" target="_self"&gt;XIP through OTFAD problems on RT1011&lt;/A&gt;, this reply said that it is not working when they place the clock adjustment code in ram? So is placing clock adjustment code in not encrypted flash is the only way to keep OTFAD working? This could be a security problem as hackers may modify that not encrypted region and execute their own code to read the decrypted code. (consider no HAB enabled).&lt;/P&gt;&lt;P&gt;Update 5:&lt;/P&gt;&lt;P&gt;It turns out changing the FlexRam layout is not the actual cause of this problem, when I replace the three lines of code for changing FlexRam with this&lt;/P&gt;&lt;PRE&gt;__asm volatile ("nop");&lt;BR /&gt;__asm volatile ("nop");&lt;BR /&gt;__asm volatile ("nop");&lt;BR /&gt;__asm volatile ("nop");&lt;BR /&gt;__asm volatile ("nop");&lt;BR /&gt;__asm volatile ("nop");&lt;/PRE&gt;&lt;P&gt;The program will still crash.&lt;/P&gt;&lt;P&gt;Update 6:&lt;/P&gt;&lt;P&gt;I think one of the functions will have a problem when it is placing at one specific address. When I added three nop assembly in the main function, the chip won't work, but if I remove it, it works again. I attached the working project and not the working project. Please help me to find what causes this problem.&lt;/P&gt;&lt;P&gt;Update 7:&lt;/P&gt;&lt;P&gt;I had tested placing nop assembly according to the image table, and I observe this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeslieLee_0-1609047288811.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133532i09908A74411A10C7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeslieLee_0-1609047288811.png" alt="LeslieLee_0-1609047288811.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 27 Dec 2020 05:35:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204230#M11869</guid>
      <dc:creator>LeslieLee</dc:creator>
      <dc:date>2020-12-27T05:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204308#M11873</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;When doing things like changing FlexRAM layout or enabling/disabling encryption make sure that you work with data and instruction barriers,&lt;BR /&gt;eg.&lt;BR /&gt;&lt;STRONG&gt;asm volatile ("dsb 0xf":::"memory");&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;asm volatile ("isb 0xf":::"memory");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;to ensure that the commanded change actually terminated before subsequent code is executed (this might explain some dependencies on delays in the code).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also take a look at &lt;A href="https://www.utasker.com/iMX/RT1010.html" target="_blank"&gt;https://www.utasker.com/iMX/RT1010.html&lt;/A&gt; where all of your difficultes have been solved (allowing on-the-fly FlexRAM changes and safe, dynamic control of on-the-fly decryption) and also giving full compatibility with all i.MX RT 10xx devices (using either OTFAD or BEE). It is designed for professionals who need a proven solution rather than needing to re-solve typical real-world complications and thus achieving shortest time to market at lowest costs.&lt;/P&gt;&lt;P&gt;It includes an OTA and field updating of encrypted code, which adds flexibility to the basic concept (removes AES key management difficulties), whilst greatly reducing the technical complications for developers.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Dec 2020 23:54:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204308#M11873</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2020-12-25T23:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204310#M11874</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Adding data and instruction barriers still don't work.&lt;/P&gt;&lt;P&gt;I had tried adding&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;__asm volatile ("dsb 0xF":::"memory");&lt;BR /&gt;__asm volatile ("isb 0xF":::"memory");&lt;/PRE&gt;&lt;P&gt;after the FlexRam layout is changed.&lt;/P&gt;&lt;P&gt;And I also tried changing OTFAD w1 to w0 and add barriers afterward, and then execute&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CLOCK_SetMux(kCLOCK_PeriphMux, 0);&lt;/PRE&gt;&lt;P&gt;But it still doesn't work.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 26 Dec 2020 03:12:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204310#M11874</guid>
      <dc:creator>LeslieLee</dc:creator>
      <dc:date>2020-12-26T03:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204332#M11876</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I don't think it is the memory barrier problem.&lt;/P&gt;&lt;P&gt;Please check the attached two project, you will see that their difference is the three additional nop assemble in the main function, but one will work one won't.&lt;/P&gt;&lt;P&gt;Thanks a lot for your help&lt;/P&gt;</description>
      <pubDate>Sat, 26 Dec 2020 10:42:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204332#M11876</guid>
      <dc:creator>LeslieLee</dc:creator>
      <dc:date>2020-12-26T10:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204781#M11899</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class=""&gt;&lt;A id="link_12" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://community.nxp.com/t5/user/viewprofilepage/user-id/181728" target="_self"&gt;LeslieLee&lt;/A&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; Thanks a lot for your effort, your question conclusion is very good.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; In your newest attached otfad_work and otfad_not_work project, just the main code with or without the "nop"? I find in two projects, both the&amp;nbsp;ResetISR didn't add the configure FlexRAM code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp;When you check the code is working or not working, just check the GPIO is a toggle or not toggle?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;If you write the code like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt; while(1)&lt;BR /&gt;{&lt;BR /&gt;GPIO1-&amp;gt;DR_TOGGLE = 1&amp;lt;&amp;lt;23;&lt;BR /&gt;SDK_DelayAtLeastUs(500000, 500000000);&lt;BR /&gt;}&lt;BR /&gt;ram_test();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;The ram_test will not be called, or you just want to use :&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt; while(1)&lt;BR /&gt;{&lt;BR /&gt;GPIO1-&amp;gt;DR_TOGGLE = 1&amp;lt;&amp;lt;23;&lt;BR /&gt;SDK_DelayAtLeastUs(500000, 500000000);&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;Seems in your code, you didn't modify the flexRAM, or your newest code just for the code in ITCM not working with OTFAD?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;BTW, as this question is a little complicated, we need more time to do the checking.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;So, if you are working on this case for your company, could you please use your company's email create one new nxp.com account, then create the case about this question, that will help you level up the case, and we can put more time in your case.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;After you create the new company email account in the &lt;A href="http://www.nxp.com" target="_blank"&gt;www.nxp.com&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;You can use this method to create a new high-level case:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1. Open below SUPPORT site, click blue "Go to Tickets" in the middle.&lt;BR /&gt;&lt;A href="http://www.nxp.com/support/support:SUPPORTHOME" target="_blank"&gt;http://www.nxp.com/support/support:SUPPORTHOME&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2.Then you will be requested to Login, if you have no an account, please first Register with your business email.&lt;/P&gt;
&lt;P&gt;3.After login, please "Create New Cases" button in the middle, then you can submit your question.&lt;/P&gt;
&lt;P&gt;If you still want me to provide service for you, in the case content, you can write assign to kerry Zhou. Then I will help you do more checking, after I reproduce your issues, I will also check with our internal expert.&lt;/P&gt;
&lt;P&gt;Thanks a lot for your understanding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 07:27:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204781#M11899</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2020-12-29T07:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204798#M11900</link>
      <description>&lt;P&gt;Hi Kerry,&lt;/P&gt;&lt;P&gt;My current discovery is that the program not working had nothing to do with the FlexRam reconfiguration. So placing the same amount of nop instruction to replace the FlexRam layout configuration will reproduce the same problem.&lt;/P&gt;&lt;P&gt;And yes, I check if the project working or not by checking if the LED toggling. And the two LED toggle code wrapping BOARD_InitBootClocks is used to check if the MCU can execute that function successfully. In all the failure cases, the LED will always on, showing that it is failing somewhere inside&amp;nbsp;BOARD_InitBootClocks.&lt;/P&gt;&lt;P&gt;So there is nothing to do with the ram_test function call after the while(1) loop, it is just some leftover code I used to test whether the program failed due to the code in ITCM. (It is not the cause)&lt;/P&gt;&lt;P&gt;This is not the case for any company, right now I'm still an MPhil student, but I planned to sell this project once it is finished, so the failure in OTFAD encryption is an important problem to me.&lt;/P&gt;&lt;P&gt;And for your information, I am using MCUBootUtilityv2.4.0 to do the encryption and flashing,&amp;nbsp;MCUXpresso IDE v11.2.0 for development.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Leslie&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 07:50:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204798#M11900</guid>
      <dc:creator>LeslieLee</dc:creator>
      <dc:date>2020-12-29T07:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204815#M11901</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;LeslieLee&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; OK, thanks a lot for your information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If it is just related&amp;nbsp;&lt;SPAN&gt;to the clock, this is the known knowledge.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; I get the information from our internal side in the previous time, BOARD_BootClockRUN code in the flash area can't do the OTFAD encryption. You can put the&amp;nbsp; BOARD_BootClockRUN code in the not secured area.&lt;/SPAN&gt;&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>Tue, 29 Dec 2020 08:10:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204815#M11901</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2020-12-29T08:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204818#M11902</link>
      <description>&lt;P&gt;Hi Kerry,&lt;/P&gt;&lt;P&gt;Yeah, I already know the clock function cannot be run in an encrypted region.&lt;/P&gt;&lt;P&gt;That's why in the project there are extra linker scripts in the linkscripts folder, they are used to move all the clock function into ITCM and run it. I had debugged in non-encryption environment and proved that all the function is already executed in ITCM.&lt;/P&gt;&lt;P&gt;Also if the problem is just placing code in an encrypted region, then I will not faced a successful run when no nop instruction is added.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Leslie&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 08:18:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204818#M11902</guid>
      <dc:creator>LeslieLee</dc:creator>
      <dc:date>2020-12-29T08:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204911#M11906</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;LeslieLee&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If you add the &lt;SPAN&gt;nop&amp;nbsp;&lt;/SPAN&gt;in the unsecured flash, and add other function code, whether it has issues or not?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; In fact, when you call&amp;nbsp;&lt;SPAN&gt;BOARD_BootClockRUN&amp;nbsp;, not just one API, this API also contains a lot of other API, all that related API need to in the internal ITCM when you don't want to put in the flash. Do you also checked it?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 10:14:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204911#M11906</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2020-12-29T10:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204948#M11908</link>
      <description>&lt;P&gt;Hi Kerry,&lt;/P&gt;&lt;P&gt;If you check my update 7 you will see that I actually tried to place nop instruction everywhere in the program and only adding nop before one specific address will crash the program. And in update 3 you will also see that if I don't encrypt that address (0x60004000-0x60005000) no problem will happen.&lt;/P&gt;&lt;P&gt;And if I replace the nop with another function code, the error will still happen, for example, if I placed nop in after 0x60004000 and add a while loop&amp;nbsp;trap&lt;SPAN&gt;&amp;nbsp;at the nop's original place, the program will still not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I know that it is not enough to put the only BOARD_BootClockRUN in ITCM, so in the linker scripts, I put the clock_config.o and fsl_clock.o in ITCM to ensure all functions in clock_config.c and fsl_clock.c are in ITCM.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And I also checked that the suspect failing code&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;CLOCK_SetMux(kCLOCK_PeriphMux, 0);&lt;/PRE&gt;&lt;P&gt;even in disassembly, all the code is executing in ITCM(0x0000xxxx)&lt;/P&gt;&lt;P&gt;And there is one extra information you may want to know, my setting for OTFAD in MCUBootUtitlity are&lt;/P&gt;&lt;P&gt;Protected Region start: 0x60001000&lt;/P&gt;&lt;P&gt;Protected Region length: 0xFF000&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Leslie&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 12:14:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1204948#M11908</guid>
      <dc:creator>LeslieLee</dc:creator>
      <dc:date>2020-12-29T12:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1205084#M11919</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;LeslieLee,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;Thanks for your updated information.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;Now talk about your :&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In update 3 you will also see that if I don't encrypt that address (0x60004000-0x60005000) no problem will happen.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if the encryption range is 0x60001000-0x60005000, the program won't work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;Do you try to divide the OTFAD region to two: one is 0X60001000-0X60004000, another one is 0x60004000-0x60005000, as you know, in the MCUBootUtility, there has 4 OTFAD region. if you use two region, whether the issue happens or not?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Any updated information, please kindly let me know.&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 01:39:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1205084#M11919</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2020-12-30T01:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1205106#M11923</link>
      <description>&lt;P&gt;Hi Kerry,&lt;/P&gt;&lt;P&gt;Yes, I did try encrypting the program with a different region. I had tried the following two settings.&lt;/P&gt;&lt;P&gt;0x60001000-0x60004000 + 0x60004000-0x60005000 -&amp;gt; not working&lt;/P&gt;&lt;P&gt;0x60001000-0x60004000 + 0x60005000-0x60006000 -&amp;gt; working&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Leslie&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 02:50:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1205106#M11923</guid>
      <dc:creator>LeslieLee</dc:creator>
      <dc:date>2020-12-30T02:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1206055#M11985</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class=""&gt;&lt;A id="link_12" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://community.nxp.com/t5/user/viewprofilepage/user-id/181728" target="_self"&gt;LeslieLee&lt;/A&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; Thanks for your testing.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; Do you check the memory map, which detail code in the&amp;nbsp;&lt;SPAN&gt;0x60004000-0x60005000?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Kerry&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 09:59:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1206055#M11985</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2021-01-04T09:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1206061#M11987</link>
      <description>&lt;P&gt;Hi Kerry,&lt;/P&gt;&lt;P&gt;You may see the screenshot in Update 7 about what code is included in that region.&lt;/P&gt;&lt;P&gt;I don't see the relationship of those codes related to the crash.&lt;/P&gt;&lt;P&gt;And I am guessing the problem is the region boundary 0x60004000 with my nop insert test.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Leslie&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 10:06:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1206061#M11987</guid>
      <dc:creator>LeslieLee</dc:creator>
      <dc:date>2021-01-04T10:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1206509#M12020</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;LeslieLee,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;Thanks for your reply.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;Maybe really still have any other important points need to care about it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;When our secure expert back, I will check with him again.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;Any updated information from my side, I will let you know.&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, 05 Jan 2021 06:07:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1206509#M12020</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2021-01-05T06:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1236313#M12891</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;LeslieLee,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;About the OTFAD issues, please note these information:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. Reason&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;When OTFAD is enabled, if the encrypted app is XIP running, in the app, core frequency need to be higher than FlexSPI frequency. If core frequency is lower than flexSPI, when core access the encrypted Flash area, OTFA can't decrypte the code, and will case the instruction messing issues, will case the hardfault.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the&amp;nbsp;BOARD_BootClockRUN(), we can see the core frequency from 396Mhz to external OSC24 Mhz switch, it will make the core smaller than FlexSPI frequency, as you know, the slowest FlexSPI is 30Mhz. This is the root issue caused the OTFAD limit issues.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Solution&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; When configure the clock, don't switch to the external OSC then switch to the PLL, we can switch to PLL directly.&amp;nbsp; Put the Audio(Enet) Pll init code to the front side. The modification code is:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;void BOARD_BootClockRUN(void)&lt;BR /&gt;{&lt;BR /&gt;// 此处略去...&lt;BR /&gt;/* Set Oscillator ready counter value. */&lt;BR /&gt;CCM-&amp;gt;CCR = (CCM-&amp;gt;CCR &amp;amp; (~CCM_CCR_OSCNT_MASK)) | CCM_CCR_OSCNT(127);&lt;BR /&gt;- /* Setting PeriphClk2Mux and PeriphMux to provide stable clock before PLLs are initialed */&lt;BR /&gt;- CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 1); /* Set PERIPH_CLK2 MUX to OSC */&lt;BR /&gt;- CLOCK_SetMux(kCLOCK_PeriphMux, 1); /* Set PERIPH_CLK MUX to PERIPH_CLK2 */&lt;/P&gt;
&lt;P&gt;// delete...&lt;BR /&gt;/* Set IPG_PODF. */&lt;BR /&gt;CLOCK_SetDiv(kCLOCK_IpgDiv, 3);&lt;BR /&gt;+ /* Init Enet PLL. */&lt;BR /&gt;+ CLOCK_InitEnetPll(&amp;amp;enetPllConfig_BOARD_BootClockRUN);&lt;BR /&gt;+ /* Set preperiph clock source. */&lt;BR /&gt;+ CLOCK_SetMux(kCLOCK_PrePeriphMux, 3);&lt;/P&gt;
&lt;P&gt;// delete...&lt;BR /&gt;/* Enable Audio PLL output. */&lt;BR /&gt;CCM_ANALOG-&amp;gt;PLL_AUDIO |= CCM_ANALOG_PLL_AUDIO_ENABLE_MASK;&lt;BR /&gt;- /* Init Enet PLL. */&lt;BR /&gt;- CLOCK_InitEnetPll(&amp;amp;enetPllConfig_BOARD_BootClockRUN);&lt;BR /&gt;- /* Set preperiph clock source. */&lt;BR /&gt;- CLOCK_SetMux(kCLOCK_PrePeriphMux, 3);&lt;/P&gt;
&lt;P&gt;// delete...&lt;BR /&gt;/* Set SystemCoreClock variable. */&lt;BR /&gt;SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 05:34:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1236313#M12891</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2021-02-25T05:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1240810#M13020</link>
      <description>&lt;P&gt;Okay, so two months later I finally found the solution to this problem.&lt;/P&gt;&lt;P&gt;Following this &lt;A href="https://www.cnblogs.com/henjay724/p/14446183.html" target="_self"&gt;article&lt;/A&gt;, I modify the&amp;nbsp;BOARD_BootClockRUN function instead of putting it into the ITCM.&lt;/P&gt;&lt;P&gt;And&amp;nbsp;&lt;EM&gt;Wala,&amp;nbsp;&lt;/EM&gt;it works now.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 07:45:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1240810#M13020</guid>
      <dc:creator>LeslieLee</dc:creator>
      <dc:date>2021-03-05T07:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: OTFAD Problem</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1241430#M13034</link>
      <description>&lt;P&gt;Yes, that article is from our AE,&amp;nbsp; and it also report from you and I transfer to him, recently, our AE have the time, so he writes that article.&lt;/P&gt;
&lt;P&gt;If you find any issues, welcome to report to us, thanks for your contribution!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;kerry&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 02:18:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/OTFAD-Problem/m-p/1241430#M13034</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2021-03-08T02:18:33Z</dc:date>
    </item>
  </channel>
</rss>

