<?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のトピックProblem with exiting the second bootloader and jumping to user application on i.MXRT1061.</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Problem-with-exiting-the-second-bootloader-and-jumping-to-user/m-p/1275638#M14187</link>
    <description>&lt;P&gt;Hi all,&lt;BR /&gt;I have a Second Bootloader and a burned user application (&lt;SPAN&gt;checked for correct burning)&lt;/SPAN&gt;. I want to exit bootloader and jump to the user application. After performing the void jump_to_application function (uint32_t applicationAddress, uint32_t stackPointer), the processor is reset immediately. Can anyone advise me on what I am doing wrong? I followed AN12604SW.&amp;nbsp;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b"&gt;&lt;SPAN&gt;The code is located in the SPI flash.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I use i.MXRT1061, MCUXpresso11.3, SDK2.9.1 and custom board.&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;#define APPLICATION_ADDRESS 0x60040000&lt;BR /&gt;#define STACK_POINTER 0x60040004&lt;/P&gt;&lt;P&gt;//! @brief Exits bootloader and jumps to the user application.&lt;BR /&gt;//AT_QUICKACCESS_SECTION_CODE(void jump_to_application(uint32_t applicationAddress, uint32_t stackPointer));&lt;BR /&gt;void jump_to_application(uint32_t applicationAddress, uint32_t stackPointer)&lt;BR /&gt;{&lt;BR /&gt;shutdown_cleanup(kShutdownType_Shutdown);&lt;/P&gt;&lt;P&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)0x60040000;//APP_VECTOR_TABLE; 0x60000000 0x60040000&lt;/P&gt;&lt;P&gt;// Set stack pointers to the application stack pointer.&lt;/P&gt;&lt;P&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;&amp;nbsp;&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;// Turn off global interrupt&lt;BR /&gt;///lock_acquire();&lt;BR /&gt;__disable_irq();&lt;/P&gt;&lt;P&gt;// Shutdown microseconds driver.&lt;BR /&gt;///microseconds_shutdown();&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 = 0;//kDefaultVectorTableAddress;&lt;/P&gt;&lt;P&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;LPUART_Deinit(LPUART1_PERIPHERAL);&lt;/P&gt;&lt;P&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for answer.&lt;/P&gt;&lt;P&gt;Jaroslav C.&lt;/P&gt;</description>
    <pubDate>Wed, 12 May 2021 12:36:25 GMT</pubDate>
    <dc:creator>cerma</dc:creator>
    <dc:date>2021-05-12T12:36:25Z</dc:date>
    <item>
      <title>Problem with exiting the second bootloader and jumping to user application on i.MXRT1061.</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Problem-with-exiting-the-second-bootloader-and-jumping-to-user/m-p/1275638#M14187</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;I have a Second Bootloader and a burned user application (&lt;SPAN&gt;checked for correct burning)&lt;/SPAN&gt;. I want to exit bootloader and jump to the user application. After performing the void jump_to_application function (uint32_t applicationAddress, uint32_t stackPointer), the processor is reset immediately. Can anyone advise me on what I am doing wrong? I followed AN12604SW.&amp;nbsp;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b"&gt;&lt;SPAN&gt;The code is located in the SPI flash.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I use i.MXRT1061, MCUXpresso11.3, SDK2.9.1 and custom board.&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;#define APPLICATION_ADDRESS 0x60040000&lt;BR /&gt;#define STACK_POINTER 0x60040004&lt;/P&gt;&lt;P&gt;//! @brief Exits bootloader and jumps to the user application.&lt;BR /&gt;//AT_QUICKACCESS_SECTION_CODE(void jump_to_application(uint32_t applicationAddress, uint32_t stackPointer));&lt;BR /&gt;void jump_to_application(uint32_t applicationAddress, uint32_t stackPointer)&lt;BR /&gt;{&lt;BR /&gt;shutdown_cleanup(kShutdownType_Shutdown);&lt;/P&gt;&lt;P&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)0x60040000;//APP_VECTOR_TABLE; 0x60000000 0x60040000&lt;/P&gt;&lt;P&gt;// Set stack pointers to the application stack pointer.&lt;/P&gt;&lt;P&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;&amp;nbsp;&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;// Turn off global interrupt&lt;BR /&gt;///lock_acquire();&lt;BR /&gt;__disable_irq();&lt;/P&gt;&lt;P&gt;// Shutdown microseconds driver.&lt;BR /&gt;///microseconds_shutdown();&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 = 0;//kDefaultVectorTableAddress;&lt;/P&gt;&lt;P&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;LPUART_Deinit(LPUART1_PERIPHERAL);&lt;/P&gt;&lt;P&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for answer.&lt;/P&gt;&lt;P&gt;Jaroslav C.&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 12:36:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Problem-with-exiting-the-second-bootloader-and-jumping-to-user/m-p/1275638#M14187</guid>
      <dc:creator>cerma</dc:creator>
      <dc:date>2021-05-12T12:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with exiting the second bootloader and jumping to user application on i.MXRT1061.</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Problem-with-exiting-the-second-bootloader-and-jumping-to-user/m-p/1283428#M14417</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The problem is solved. I finally used the function:&lt;/P&gt;&lt;P&gt;#define BL_APP_VECTOR_TABLE_ADDRESS 0x60040000&lt;BR /&gt;#define APP_VECTOR_TABLE ((uint32_t *)BL_APP_VECTOR_TABLE_ADDRESS)&lt;/P&gt;&lt;P&gt;void goToApp()&lt;BR /&gt;{&lt;BR /&gt;static void (*farewellBootloader)(void) = 0;&lt;BR /&gt;farewellBootloader = (void (*)(void))(APP_VECTOR_TABLE[1]);&lt;BR /&gt;SCB-&amp;gt;VTOR = (uint32_t)APP_VECTOR_TABLE;&lt;BR /&gt;__set_MSP(APP_VECTOR_TABLE[0]);&lt;BR /&gt;__set_PSP(APP_VECTOR_TABLE[0]);&lt;BR /&gt;farewellBootloader();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Jaroslav C.&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 11:35:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Problem-with-exiting-the-second-bootloader-and-jumping-to-user/m-p/1283428#M14417</guid>
      <dc:creator>cerma</dc:creator>
      <dc:date>2021-05-27T11:35:52Z</dc:date>
    </item>
  </channel>
</rss>

