<?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: jumping to application from bootloader in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/jumping-to-application-from-bootloader/m-p/1325275#M61272</link>
    <description>&lt;P&gt;Thanks for the link it was helpful.&lt;/P&gt;&lt;P&gt;I did following and was able to successfully jump to application from bootloader.&lt;/P&gt;&lt;P&gt;1. defined the application vector table address in the linker config file.&lt;/P&gt;&lt;P&gt;2. Created a vector structure containing two members 1. stackpointer 2. the location of program counter.&lt;/P&gt;&lt;P&gt;3. typecast the linker defined symbol to an object created from above structure.&lt;/P&gt;&lt;P&gt;4. disabled the interrupts.&lt;/P&gt;&lt;P&gt;5. configure the stack pointer value.&lt;/P&gt;&lt;P&gt;6. set the VTOR.&lt;/P&gt;&lt;P&gt;7. jump to application.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample code for help&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;typedef void (application_t) (void);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;typedef struct vector&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;uint32_t&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;stack_addr;&amp;nbsp; &amp;nbsp;// intvec[0] is initial Stack Pointer&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;application_t *func_p;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// intvec[1] is initial Program Counter&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;} vector_t;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;extern const uint32_t app_intvect; // Application vector address symbol from&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// the linker configuration file&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;int main(void)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;const vector_t * vector_p = (vector_t *) &amp;amp;app_intvect;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;__enable_interrupt();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;__disable_interrupt(); // 1. Disable interrupts&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;__set_MSP(vector_p-&amp;gt;stack_addr); // 2. Configure stack pointer&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;SCB-&amp;gt;VTOR = (uint32_t) &amp;amp;app_intvect; // 3. Configure VTOR&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;vector_p-&amp;gt;func_p(); // 4. Jump to application&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;}&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Aug 2021 07:25:02 GMT</pubDate>
    <dc:creator>niket_zope</dc:creator>
    <dc:date>2021-08-18T07:25:02Z</dc:date>
    <item>
      <title>jumping to application from bootloader</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/jumping-to-application-from-bootloader/m-p/1324400#M61248</link>
      <description>&lt;P&gt;hello I'm making a bootloader Getting issue of hardfault&amp;nbsp; &amp;amp; configuring stack pointer.&lt;/P&gt;&lt;P&gt;Doing :&lt;/P&gt;&lt;P&gt;start boot flash 0x00000000&amp;nbsp;&lt;/P&gt;&lt;P&gt;start appflash&amp;nbsp; 0x00001000&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;can any one suggest what's bad with the code ? I am new to bootloader.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;typedef void (application_t) (void);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;typedef struct vector&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;uint32_t stack_addr;&amp;nbsp; &amp;nbsp;// intvec[0] is initial Stack Pointer&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;application_t *func_p; // intvec[1] is initial Program Counter&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;} vector_t;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;extern const uint32_t app_intvect; // Application vector address symbol from&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// the linker configuration file&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//&amp;nbsp; value =&amp;nbsp;0x00001000&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;int main(void)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;const vector_t * vector_p = (vector_t *) &amp;amp;app_intvect;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;// volatile uint32_t stack_arr[100] = {0}; // Allocate some stack&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;__enable_interrupt();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;printf("Hello from bootloader!\n");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;printf("MSP BEFORE: %x \n", __get_MSP());&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;printf("PSP BEFORE: %x \n", __get_PSP());&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;__disable_interrupt(); // 1. Disable interrupts&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;__set_SP(vector_p-&amp;gt;stack_addr); // 2. Configure stack pointer&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;SCB-&amp;gt;VTOR = (uint32_t) &amp;amp;app_intvect; // 3. Configure VTOR&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;printf("MSP AFTER: %x \n", __get_MSP());&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;printf("PSP AFTER: %x \n", __get_PSP());&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;vector_p-&amp;gt;func_p(); // 4. Jump to application&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 06:41:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/jumping-to-application-from-bootloader/m-p/1324400#M61248</guid>
      <dc:creator>niket_zope</dc:creator>
      <dc:date>2021-08-17T06:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: jumping to application from bootloader</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/jumping-to-application-from-bootloader/m-p/1324444#M61249</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You can refer this &lt;A href="https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDMK64F-SD-Bootloader/ta-p/1099807" target="_self"&gt;article&lt;/A&gt;.&lt;/P&gt;
&lt;P&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;- We are following threads for 7 days 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>Tue, 17 Aug 2021 07:23:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/jumping-to-application-from-bootloader/m-p/1324444#M61249</guid>
      <dc:creator>nxf56274</dc:creator>
      <dc:date>2021-08-17T07:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: jumping to application from bootloader</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/jumping-to-application-from-bootloader/m-p/1325275#M61272</link>
      <description>&lt;P&gt;Thanks for the link it was helpful.&lt;/P&gt;&lt;P&gt;I did following and was able to successfully jump to application from bootloader.&lt;/P&gt;&lt;P&gt;1. defined the application vector table address in the linker config file.&lt;/P&gt;&lt;P&gt;2. Created a vector structure containing two members 1. stackpointer 2. the location of program counter.&lt;/P&gt;&lt;P&gt;3. typecast the linker defined symbol to an object created from above structure.&lt;/P&gt;&lt;P&gt;4. disabled the interrupts.&lt;/P&gt;&lt;P&gt;5. configure the stack pointer value.&lt;/P&gt;&lt;P&gt;6. set the VTOR.&lt;/P&gt;&lt;P&gt;7. jump to application.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample code for help&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;typedef void (application_t) (void);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;typedef struct vector&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;uint32_t&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;stack_addr;&amp;nbsp; &amp;nbsp;// intvec[0] is initial Stack Pointer&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;application_t *func_p;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// intvec[1] is initial Program Counter&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;} vector_t;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;extern const uint32_t app_intvect; // Application vector address symbol from&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// the linker configuration file&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;int main(void)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;const vector_t * vector_p = (vector_t *) &amp;amp;app_intvect;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;__enable_interrupt();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;__disable_interrupt(); // 1. Disable interrupts&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;__set_MSP(vector_p-&amp;gt;stack_addr); // 2. Configure stack pointer&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;SCB-&amp;gt;VTOR = (uint32_t) &amp;amp;app_intvect; // 3. Configure VTOR&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;vector_p-&amp;gt;func_p(); // 4. Jump to application&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;}&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 07:25:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/jumping-to-application-from-bootloader/m-p/1325275#M61272</guid>
      <dc:creator>niket_zope</dc:creator>
      <dc:date>2021-08-18T07:25:02Z</dc:date>
    </item>
  </channel>
</rss>

