<?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: MXRT1020-EVK bootloader+app in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/MXRT1020-EVK-bootloader-app/m-p/1390359#M184823</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.&lt;BR /&gt;1) What memory area is my bootloader decrypted to(maybe it FLEXSPI Alias: 0x800_0000..)? &lt;BR /&gt;-- The encrypted area starts 0x6000_1000 to 0x6040_0000.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jeremyzhou_0-1640137055315.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/165883i7D3277624F9104F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jeremyzhou_0-1640137055315.png" alt="jeremyzhou_0-1640137055315.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;2) Is it possible to run it yourself for execution APP(NON XIP image) knowing the address of its execution in flash(0x60032400).How addresses are mapped after bee encrypt XIP image? Or is it possible to execute the flash directly from this address without copying anywhere into memory?&lt;BR /&gt;-- It needs a secondary bootloader to jump to the application which resides 0x60032000~0x60400000, otherwise, it's impossible to run the application directly.&lt;BR /&gt;3) Will there be any problems without using LPC 4322?&lt;BR /&gt;-- No, it's okay to do it.&lt;BR /&gt;Have a great day,&lt;BR /&gt;TIC&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&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;</description>
    <pubDate>Wed, 22 Dec 2021 01:37:55 GMT</pubDate>
    <dc:creator>jeremyzhou</dc:creator>
    <dc:date>2021-12-22T01:37:55Z</dc:date>
    <item>
      <title>MXRT1020-EVK bootloader+app</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/MXRT1020-EVK-bootloader-app/m-p/1390218#M184811</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Good afternoon, thanks for the help in BEE encryption on the fly. I managed to encrypt(Bee AES encryption) and sign(SRK Hash) the application with a certificate. Application is XIP image. Let's call it bootloader. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Now there is a task to launch another application with a bootloader for execution. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;0x60000000..0x60031FFF - Bootloader(XIP image) 200Kb - load and work now&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;0x60032000..0x60400000 -APP(NON XIP image) 3,8МБ&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;0x60400000..0x60............ FAT16 file system(which is available by USB device). - 4Мб&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;The bootloader starts, it creates a usb device with a file system (which is physically located in the flash), various files can be dropped into this device, including an update of APP(NON XIP image).&amp;nbsp;This part work well.&amp;nbsp;Now the question is, where to download the APP(NON XIP image) and then execute it? &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;I create one encrypt region for the whole flash drive without FATFS part(0x60000000..0x604000000) - this is XIP image(signed with SRK hash)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;image_enc ifile=flexspi_nor_edma_transfer_signed.bin ofile=flexspi_nor_edma_transfer_signed_bee_encrypted.bin base_addr=0x60000000 region0_key=0123456789abcdeffedcba9876543210 region0_arg=1,[0x60001000,0x3FF000,0] region0_lock=0 use_zero_key=1 is_boot_image=1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;What memory area is my bootloader decrypted to(maybe it FLEXSPI Alias: 0x800_0000..)? is it possible to run it yourself for execution APP(NON XIP image) knowing the address of its execution in flash(0x60032400).&amp;nbsp;How addresses are mapped after bee encrypt XIP image?&amp;nbsp;Or is it possible to execute the flash directly from this address without copying anywhere into memory? &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;I don't want to create two separate encrypt regions, I only need one with the same SRK HASH(signature) and same AES key. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Second question:&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN&gt;The customer does not need the LPC 4322. I flash my FlexSPI using USB&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;#Load flashloader(kinetis) to memory&lt;BR /&gt;sdphost -t 50000 -u 0x1fc9,0x130 write-file 0x20208000 flashloader/ivt_flashloader.bin&lt;BR /&gt;#Execute flashloader&lt;BR /&gt;sdphost -t 50000 -u 0x1fc9,0x130 jump-address 0x20208400&lt;BR /&gt;#Fill and configure memory for FLEXSPI NOR&lt;BR /&gt;blhost -u 0x15a2,0x73 fill-memory 0x2000 4 0xc0000007&lt;BR /&gt;blhost -u 0x15a2,0x73 configure-memory 0x9 0x2000&lt;BR /&gt;#Erase memory region&lt;BR /&gt;blhost -u 0x15a2,0x73 flash-erase-region 0x60000000 0x10000&lt;BR /&gt;#Write demo app&lt;BR /&gt;blhost -u 0x15a2,0x73 write-memory 0x60000000 flexspi_nor_edma_transfer.bin&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Will there be any problems without using LPC 4322? I plan to write an update APP(NON XIP image) through my own USB device(FAT16), which is created in bootloader. Bootloader(XIP Image) will update only one time in production.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&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>Tue, 21 Dec 2021 15:03:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/MXRT1020-EVK-bootloader-app/m-p/1390218#M184811</guid>
      <dc:creator>vladimir_dolzhe</dc:creator>
      <dc:date>2021-12-21T15:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: MXRT1020-EVK bootloader+app</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/MXRT1020-EVK-bootloader-app/m-p/1390359#M184823</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.&lt;BR /&gt;1) What memory area is my bootloader decrypted to(maybe it FLEXSPI Alias: 0x800_0000..)? &lt;BR /&gt;-- The encrypted area starts 0x6000_1000 to 0x6040_0000.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jeremyzhou_0-1640137055315.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/165883i7D3277624F9104F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jeremyzhou_0-1640137055315.png" alt="jeremyzhou_0-1640137055315.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;2) Is it possible to run it yourself for execution APP(NON XIP image) knowing the address of its execution in flash(0x60032400).How addresses are mapped after bee encrypt XIP image? Or is it possible to execute the flash directly from this address without copying anywhere into memory?&lt;BR /&gt;-- It needs a secondary bootloader to jump to the application which resides 0x60032000~0x60400000, otherwise, it's impossible to run the application directly.&lt;BR /&gt;3) Will there be any problems without using LPC 4322?&lt;BR /&gt;-- No, it's okay to do it.&lt;BR /&gt;Have a great day,&lt;BR /&gt;TIC&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&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;</description>
      <pubDate>Wed, 22 Dec 2021 01:37:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/MXRT1020-EVK-bootloader-app/m-p/1390359#M184823</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2021-12-22T01:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: MXRT1020-EVK bootloader+app</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/MXRT1020-EVK-bootloader-app/m-p/1392262#M185067</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Found a way to start a second app from Flash with minimal effort.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN&gt;The main function is jump_to_application with two parameters, the address of the execution and stack pointer.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN&gt;Works with both regular applications and encrypted ones:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdint.h&amp;gt;&lt;BR /&gt;#include "fsl_common.h"&lt;BR /&gt;#include "fsl_debug_console.h"&lt;/P&gt;&lt;P&gt;//#define BL_APP_VECTOR_TABLE_ADDRESS (0x60002000u)&lt;BR /&gt;#define BL_APP_VECTOR_TABLE_ADDRESS (0x60032000u)&lt;BR /&gt;#define APP_VECTOR_TABLE ((uint32_t *)BL_APP_VECTOR_TABLE_ADDRESS)&lt;/P&gt;&lt;P&gt;enum _vector_table_entries&lt;BR /&gt;{&lt;BR /&gt;kInitialSP = 0, //!&amp;lt; Initial stack pointer.&lt;BR /&gt;kInitialPC = 1, //!&amp;lt; Reset vector.&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;typedef enum _shutdown_types&lt;BR /&gt;{&lt;BR /&gt;kShutdownType_Shutdown = 0,&lt;BR /&gt;kShutdownType_Cleanup = 1,&lt;BR /&gt;kShutdownType_Reset = 2,&lt;BR /&gt;} shutdown_type_t;&lt;/P&gt;&lt;P&gt;enum _vector_table_address&lt;BR /&gt;{&lt;BR /&gt;//! @brief Address of the default vector table, which is always 0.&lt;BR /&gt;kDefaultVectorTableAddress = 0&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;/** \brief Clear Enabled IRQs&lt;/P&gt;&lt;P&gt;The function clears all device IRQs&lt;BR /&gt;*/&lt;BR /&gt;__STATIC_INLINE void NVIC_ClearEnabledIRQs(void)&lt;BR /&gt;{&lt;BR /&gt;NVIC-&amp;gt;ICER[0] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICER[1] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICER[2] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICER[3] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICER[4] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICER[5] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICER[6] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICER[7] = 0xFFFFFFFF;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/** \brief Clear All Pending Interrupts&lt;/P&gt;&lt;P&gt;The function clears the pending bits of all external interrupts.&lt;/P&gt;&lt;P&gt;*/&lt;BR /&gt;__STATIC_INLINE void NVIC_ClearAllPendingIRQs(void)&lt;BR /&gt;{&lt;BR /&gt;NVIC-&amp;gt;ICPR[0] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICPR[1] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICPR[2] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICPR[3] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICPR[4] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICPR[5] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICPR[6] = 0xFFFFFFFF;&lt;BR /&gt;NVIC-&amp;gt;ICPR[7] = 0xFFFFFFFF;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void init_interrupts(void)&lt;BR /&gt;{&lt;BR /&gt;// Clear any IRQs that may be enabled, we only want the IRQs we enable to be active&lt;BR /&gt;NVIC_ClearEnabledIRQs();&lt;BR /&gt;// Clear any pending IRQs that may have been set&lt;BR /&gt;NVIC_ClearAllPendingIRQs();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void shutdown_cleanup(shutdown_type_t shutdown)&lt;BR /&gt;{&lt;BR /&gt;// If we are permanently exiting the bootloader, there are a few extra things to do.&lt;BR /&gt;if (shutdown == kShutdownType_Shutdown)&lt;BR /&gt;{&lt;BR /&gt;#if 0&lt;BR /&gt;// Shutdown microseconds driver.&lt;BR /&gt;microseconds_shutdown();&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;// Disable force ROM.&lt;BR /&gt;#if defined(RCM_FM_FORCEROM_MASK)&lt;BR /&gt;RCM-&amp;gt;FM = ((~RCM_FM_FORCEROM_MASK) &amp;amp; RCM-&amp;gt;FM) | RCM_FM_FORCEROM(0);&lt;BR /&gt;#elif defined(SMC_FM_FORCECFG_MASK)&lt;BR /&gt;#if defined(SMC0)&lt;BR /&gt;SMC0-&amp;gt;FM = ((~SMC_FM_FORCECFG_MASK) &amp;amp; SMC0-&amp;gt;FM) | SMC_FM_FORCECFG(0);&lt;BR /&gt;#else&lt;BR /&gt;SMC-&amp;gt;FM = ((~SMC_FM_FORCECFG_MASK) &amp;amp; SMC-&amp;gt;FM) | SMC_FM_FORCECFG(0);&lt;BR /&gt;#endif&lt;BR /&gt;#endif // defined(RCM_FM_FORCEROM_MASK)&lt;/P&gt;&lt;P&gt;// Clear status register (bits are w1c).&lt;BR /&gt;#if defined(RCM_MR_BOOTROM_MASK)&lt;BR /&gt;RCM-&amp;gt;MR = ((~RCM_MR_BOOTROM_MASK) &amp;amp; RCM-&amp;gt;MR) | RCM_MR_BOOTROM(3);&lt;BR /&gt;#elif defined(SMC_MR_BOOTCFG_MASK)&lt;BR /&gt;#if defined(SMC0)&lt;BR /&gt;SMC0-&amp;gt;MR = ((~SMC_MR_BOOTCFG_MASK) &amp;amp; SMC0-&amp;gt;MR) | SMC_MR_BOOTCFG(3);&lt;BR /&gt;#else&lt;BR /&gt;SMC-&amp;gt;MR = ((~SMC_MR_BOOTCFG_MASK) &amp;amp; SMC-&amp;gt;MR) | SMC_MR_BOOTCFG(3);&lt;BR /&gt;#endif&lt;BR /&gt;#endif // defined(RCM_MR_BOOTROM_MASK)&lt;/P&gt;&lt;P&gt;init_interrupts();&lt;/P&gt;&lt;P&gt;// Set the VTOR to default.&lt;BR /&gt;SCB-&amp;gt;VTOR = kDefaultVectorTableAddress;&lt;BR /&gt;#if 0&lt;BR /&gt;// Restore clock to default before leaving bootloader.&lt;BR /&gt;configure_clocks(kClockOption_ExitBootloader);&lt;/P&gt;&lt;P&gt;// De-initialize hardware such as disabling port clock gate&lt;BR /&gt;deinit_hardware();&lt;BR /&gt;#endif&lt;BR /&gt;// Restore global interrupt.&lt;BR /&gt;__enable_irq();&lt;/P&gt;&lt;P&gt;#if BL_FEATURE_BYPASS_WATCHDOG&lt;BR /&gt;// De-initialize watchdog&lt;BR /&gt;bootloader_watchdog_deinit();&lt;BR /&gt;#endif // BL_FEATURE_BYPASS_WATCHDOG&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Memory barriers for good measure.&lt;BR /&gt;__ISB();&lt;BR /&gt;__DSB();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void jump_to_application(uint32_t applicationAddress, uint32_t stackPointer)&lt;BR /&gt;{&lt;BR /&gt;shutdown_cleanup(kShutdownType_Shutdown);&lt;BR /&gt;// Create the function call to the user application.&lt;BR /&gt;// Static variables are needed since changed the stack pointer out from under the compiler&lt;BR /&gt;// we need to ensure the values we are using are not stored on the previous stack&lt;BR /&gt;static uint32_t s_stackPointer = 0;&lt;BR /&gt;s_stackPointer = stackPointer;&lt;BR /&gt;static void (*farewellBootloader)(void) = 0;&lt;BR /&gt;farewellBootloader = (void (*)(void))applicationAddress;&lt;/P&gt;&lt;P&gt;// Set the VTOR to the application vector table address.&lt;BR /&gt;SCB-&amp;gt;VTOR = (uint32_t)APP_VECTOR_TABLE;&lt;/P&gt;&lt;P&gt;// Set stack pointers to the application stack pointer.&lt;BR /&gt;__set_MSP(s_stackPointer);&lt;BR /&gt;__set_PSP(s_stackPointer);&lt;/P&gt;&lt;P&gt;// Jump to the application.&lt;BR /&gt;farewellBootloader();&lt;BR /&gt;// Dummy fcuntion call, should never go to this fcuntion call&lt;BR /&gt;shutdown_cleanup(kShutdownType_Shutdown);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void go_to_app(void)&lt;BR /&gt;{&lt;BR /&gt;uint32_t stackPointer = 0;&lt;BR /&gt;uint32_t applicationAddress = 0;&lt;/P&gt;&lt;P&gt;stackPointer = APP_VECTOR_TABLE[kInitialSP];&lt;BR /&gt;applicationAddress = APP_VECTOR_TABLE[kInitialPC];&lt;/P&gt;&lt;P&gt;PRINTF("Start application at addr =0x%X stackPointer=0x%X \r\n",applicationAddress,stackPointer);&lt;BR /&gt;jump_to_application(applicationAddress, stackPointer);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Dec 2021 12:08:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/MXRT1020-EVK-bootloader-app/m-p/1392262#M185067</guid>
      <dc:creator>vladimir_dolzhe</dc:creator>
      <dc:date>2021-12-27T12:08:53Z</dc:date>
    </item>
  </channel>
</rss>

