<?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: RT1020 resets original boot_data when returning from plugin function?</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1020-resets-original-boot-data-when-returning-from-plugin/m-p/1026590#M7013</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;SPAN class=""&gt;&lt;A _jive_internal="true" class="" data-content-finding="Community" data-userid="347737" data-username="rshipman" href="https://community.nxp.com/people/rshipman"&gt;rshipman,&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; Thanks for your updated detail information, I will check it on my side, please give me more time.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; Any updated information, I will let you know.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; Please keep patient, thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Kerry&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Nov 2019 08:02:10 GMT</pubDate>
    <dc:creator>kerryzhou</dc:creator>
    <dc:date>2019-11-13T08:02:10Z</dc:date>
    <item>
      <title>RT1020 resets original boot_data when returning from plugin function?</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1020-resets-original-boot-data-when-returning-from-plugin/m-p/1026587#M7010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IDE: MCUXpresso IDE v11.0.1 [Build 2563] [2019-09-01]&lt;/P&gt;&lt;P&gt;Platform: MIMXRT1020-evk eval board&lt;/P&gt;&lt;P&gt;Example project: demos/iled_blinky&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am experimenting with the boot plugin functionality of the RT1021 using the iled_blinky demo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a very quick first step, I created a simple plugin function that simply calls ResetISR (which then calls main() - which I modified to flash the led a couple of times and return 0).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both the plugin and application images are identical apart the following changes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The image as loaded into flash by MCUXpresso:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;IVT entry field points to my plugin function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;boot_data plugin field is set to 1 (plugin mode)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The image just before the plugin function returns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;IVT entry field points to ResetISR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;boot_data plugin field is set to 0 (plugin mode off)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both images run, but between the return from the plugin function and the (second) call to ResetISR the boot_data fields have been overwritten with the original values. So the boot_data plugin field is set to 1 again.&lt;/P&gt;&lt;P&gt;I have confirmed this using the MCUXpresso debugger.&lt;/P&gt;&lt;P&gt;I cannot see how this is possible as there is only one image in flash and none of the code is run between the end of the plugin function and the start of ResetISR as far as I am aware (seeing as one is an image exit point and the other is an image entry point).&lt;/P&gt;&lt;P&gt;Also when returning from execution of the second image it crashes with a hard fault. The entry field is now set to call ResetISR but the plugin field has been set to 1, so presumably all the arguments and return values the ARM bootloader is expecting from a plugin function are missing/garbage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that my plugin function simply calls ResetISR, sets the above fields and then sets up the function arguments before returning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The source mods follow (- they're not beautiful mods, just a quick experiment to get something working).&lt;/P&gt;&lt;P&gt;You may need to add a couple forward declarations etc:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In source/iled_blinky.c:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Near the top:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#include "fsl_flexspi_nor_boot.h"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the main function, change main &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;while (1)&lt;/SPAN&gt; loop to:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;/* Flash led n times */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; int n = 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;int i = n*2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;while (i--)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;return 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After main() function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;extern void ResetISR(void);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;int PluginFunction(void **start, uint32_t *bytes, uint32_t *ivt_offset)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; ResetISR();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; *start = (void*)boot_data.start;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; *bytes = boot_data.size;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; *ivt_offset = 0x1000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; // Reuse the same image, just not this plugin function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; // Bodge away const etc.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; *((uint32_t*)&amp;amp;(image_vector_table.entry)) = IMAGE_ENTRY_ADDRESS;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; *((uint32_t*)&amp;amp;(boot_data.plugin)) = 0; // This gets set back to 1. The MCUXpresso confirms this is set to 0 here. And set back to 1 by the start of the next call to ResetISR&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; // The following I added as experiments, the problem exists without these three lines.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; *((uint32_t*)&amp;amp;(boot_data.size)) -= 4; // Experiment - this gets overwritten.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; *((uint32_t*)&amp;amp;(image_vector_table.dcd)) = 0x60001234; // Experiment - this does not get overwritten.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; *((uint32_t*)&amp;amp;(boot_data.start)) = 0x60005678; // Experiment - this gets overwritten.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; return 1; // 1 is success&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In fsl_flexspi_nor_boot.c:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;const ivt image_vector_table = {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; IVT_HEADER, /* IVT Header */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; ((uint32_t)PluginFunction), // IMAGE_ENTRY_ADDRESS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp; :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In fsl_flexspi_nor_boot.h:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define PLUGIN_FLAG (uint32_t)1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In startup_mimxrt1021.c, comment out &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;while(1) {;}&lt;/SPAN&gt; loop at end of ResetISR function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will eventually have two separate images, so I think it is important to understand what is going on here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Nov 2019 16:57:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1020-resets-original-boot-data-when-returning-from-plugin/m-p/1026587#M7010</guid>
      <dc:creator>rshipman</dc:creator>
      <dc:date>2019-11-08T16:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: RT1020 resets original boot_data when returning from plugin function?</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1020-resets-original-boot-data-when-returning-from-plugin/m-p/1026588#M7011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" data-content-finding="Community" data-userid="347737" data-username="rshipman" href="https://community.nxp.com/people/rshipman"&gt;rshipman&lt;/A&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thank you for your interest in NXP MIMXRT product, I would like to provide service for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp; You mentioned: " but between the return from the plugin function and the (second) call to ResetISR the boot_data fields have been overwritten with the original values"&lt;/P&gt;&lt;P&gt;&amp;nbsp;And you also debug to confirm it, could you also share some debug result screenshot about the problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp; BTW, could you also attach your modified plug-in project, then I will also can try it to reproduce the problem, thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Waiting for your updated information.&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Kerry&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&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;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2019 07:41:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1020-resets-original-boot-data-when-returning-from-plugin/m-p/1026588#M7011</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2019-11-12T07:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: RT1020 resets original boot_data when returning from plugin function?</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1020-resets-original-boot-data-when-returning-from-plugin/m-p/1026589#M7012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kerry,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please find 3 zip archives uploaded:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;evkmimxrt1020_iled_blinky_plugin_for_nxp.zip&lt;/LI&gt;&lt;LI&gt;Screenshots with line 128 commented out.zip&lt;/LI&gt;&lt;LI&gt;Screenshots with line 128 NOT commented out.zip&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See notes regarding them below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Modifed iled_blinky project: evkmimxrt1020_iled_blinky_plugin_for_nxp.zip&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Files modifed:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;source/led_blinky.c&lt;/LI&gt;&lt;LI&gt;startup/startup_mimxrt1021.c&lt;/LI&gt;&lt;LI&gt;xip/fsl_flexspi_nor_boot.c&lt;/LI&gt;&lt;LI&gt;xip/fsl_flexspi_nor_boot.h&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;You will need to define the preprocessor symbol PLUGIN_MODE in MCUXpress project settings. To test, you can omit it and a normal iled_blinky demo should run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Screenshots with line 128 commented out.zip&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The unexpected change to the boot_data fields happens between screenshots&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;03_at_end_first_call_to_PluginFunction.png&lt;/LI&gt;&lt;LI&gt;04_second_entry_into_image_PluginFunction.png&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Screenshots with line 128 NOT commented out.zip&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The unexpected change to the boot_data fields happens between screenshots&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;04_at_end_first_call_to_PluginFunction.png&lt;/LI&gt;&lt;LI&gt;05_second_call_into_ResetISR.png&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that this is an unrealistic setup just to experiment with the plugin functionality.&lt;/P&gt;&lt;P&gt;The plugin and app images are identical, all I am doing is changing the IVT entry field and the plugin flag between the two invocations.&lt;/P&gt;&lt;P&gt;In reality the two images would be in different devices or different places in the same device.&lt;/P&gt;&lt;P&gt;But I need to understand what is going wrong here. Am I doing something daft (other than using an unrealistic setup)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2019 12:24:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1020-resets-original-boot-data-when-returning-from-plugin/m-p/1026589#M7012</guid>
      <dc:creator>rshipman</dc:creator>
      <dc:date>2019-11-12T12:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: RT1020 resets original boot_data when returning from plugin function?</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1020-resets-original-boot-data-when-returning-from-plugin/m-p/1026590#M7013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;SPAN class=""&gt;&lt;A _jive_internal="true" class="" data-content-finding="Community" data-userid="347737" data-username="rshipman" href="https://community.nxp.com/people/rshipman"&gt;rshipman,&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; Thanks for your updated detail information, I will check it on my side, please give me more time.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; Any updated information, I will let you know.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; Please keep patient, thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Kerry&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Nov 2019 08:02:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/RT1020-resets-original-boot-data-when-returning-from-plugin/m-p/1026590#M7013</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2019-11-13T08:02:10Z</dc:date>
    </item>
  </channel>
</rss>

