<?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>MCU BootloaderのトピックRe: Jumping from bootloader to user application</title>
    <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613283#M150</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kevin Luty,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All of the comments by Bob are valid for the ROM Bootloader implementation and it is correct that things are slightly different for the flash-resident bootloader in your device (MK22F512VLH12).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case to jump to the bootloader from the application you can read the values for reset vector (entry point) and initial stack pointer from the bootloader's vector table. This corresponds to approach &lt;STRONG&gt;(2)&lt;/STRONG&gt; of the Reference Manual. The next code can be used:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;runBootloader&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;run_bootloader&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
uint32_t runBootloaderAddress&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;// Read the entry point from bootloader's vector table&lt;/SPAN&gt;
runBootloaderAddress &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_t&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0x00000004&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
runBootloader &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;runBootloaderAddress&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;runBootloader&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then call &lt;STRONG&gt;run_bootloader&lt;/STRONG&gt;&lt;STRONG&gt;()&lt;/STRONG&gt; at the required point in the application's code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps. Let me know if you have questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Sep 2016 23:57:21 GMT</pubDate>
    <dc:creator>Jorge_Gonzalez</dc:creator>
    <dc:date>2016-09-19T23:57:21Z</dc:date>
    <item>
      <title>Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613276#M143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using KBOOT v2.0 and a MK22F512VLH12 chip.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently have my user application placed at 0xA000 and it is running &lt;STRONG&gt;MQX&lt;/STRONG&gt;. &amp;nbsp;Direct boot is currently enabled, so at power-up, it skips the bootloader and goes straight into user application. &amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I want to be able to go from my user application into the bootloader. &amp;nbsp;I've tried using the code found in the bootloader manual however that seems to be unsuccessful:&lt;/P&gt;&lt;PRE&gt;
// Variables
uint32_t runBootloaderAddress;
void (*runBootloader)(void * arg);

void run_bootloader(void * arg)
{
 // Read the function address from the ROM API tree.
 runBootloaderAddress = **(uint32_t **)(0x0000001CUL);
 runBootloader = (void (*)(void * arg))runBootloaderAddress;
 runBootloader(NULL);
}

And then I eventually call:&lt;/PRE&gt;&lt;PRE&gt;run_bootloader(NULL);&lt;/PRE&gt;&lt;P&gt;What am I doing wrong? &amp;nbsp;How can I jump back into bootloader successfully?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2016 20:32:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613276#M143</guid>
      <dc:creator>kevinlfw</dc:creator>
      <dc:date>2016-09-12T20:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613277#M144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is&amp;nbsp;0x0000001CUL the correct address for that part? &amp;nbsp;That address indicates ROM at address zero.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2016 20:15:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613277#M144</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2016-09-13T20:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613278#M145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought I'd want to jump to address 0x0 or 0x1C, what I perceive as the start of the bootloader code. &amp;nbsp;I added some of the hopefully relevant information below. &amp;nbsp;I'm curious if I'm jumping to the code, its reading the Direct Enable as true, and just continuing to jump straight to the user application&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This comes from the map file after building my &lt;STRONG&gt;freedom_bootloader&lt;/STRONG&gt; project (found in &lt;STRONG&gt;bootloader.eww&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;"A0": &amp;nbsp;place at 0x00000000 { ro section .intvec, ro section .noinit };&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; Section &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Kind &amp;nbsp; &amp;nbsp; &amp;nbsp;Address &amp;nbsp; &amp;nbsp; Size &amp;nbsp; Object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; ------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ---- &amp;nbsp; &amp;nbsp; &amp;nbsp;------- &amp;nbsp; &amp;nbsp; ---- &amp;nbsp; ------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;"A0": &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; 0x470&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; .intvec &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0x00000000 0x410 &amp;nbsp;&amp;lt;Block&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; &amp;nbsp; .intvec &amp;nbsp; &amp;nbsp; &amp;nbsp; ro code &amp;nbsp; &amp;nbsp;0x00000000 0x410 &amp;nbsp;startup_MK22F51212.o [1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; .noinit &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ro code &amp;nbsp; &amp;nbsp;0x00000410 0x58 &amp;nbsp; crt0.o [1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&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;- 0x00000468 0x468&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This comes from the map file after building my user application code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;"A0": place at 0x0000a000 { ro section .intvec };&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;"P1": place in [from 0x0000a400 to 0x0000a40f] { section FlashConfig };&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;"P2": place in [from 0x0000a000 to 0x0000a3ff] |&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[from 0x0000a410 to 0x0007ffff] { ro };&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;Section &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Kind &amp;nbsp; &amp;nbsp; &amp;nbsp;Address &amp;nbsp; &amp;nbsp; Size &amp;nbsp; Object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ---- &amp;nbsp; &amp;nbsp; &amp;nbsp;------- &amp;nbsp; &amp;nbsp; ---- &amp;nbsp; ------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;"A0": &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; 0x400&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; .intvec &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ro code &amp;nbsp; &amp;nbsp;0x0000a000 0x400 &amp;nbsp;startup_MK22F51212.o [4]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&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;- 0x0000a400 0x400&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;"P1": &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;0x10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp; FlashConfig &amp;nbsp; &amp;nbsp; ro code &amp;nbsp; &amp;nbsp;0x0000a400 &amp;nbsp;0x10 &amp;nbsp; startup_MK22F51212.o [4]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&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;- 0x0000a410 &amp;nbsp;0x10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And this comes from the memory_map_K22F512.c file, also found in bootloader.eww:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;memory_map_entry_t g_memoryMap[] = {&lt;BR /&gt; { 0x00000000, 0x0007ffff, kMemoryIsExecutable, &amp;amp;g_flashMemoryInterface }, // Flash array (512KB)&lt;BR /&gt; { 0x1fff8000, 0x2000ffff, kMemoryIsExecutable, &amp;amp;g_normalMemoryInterface }, // SRAM (96KB for KV31, 128KB for K22)&lt;BR /&gt; { 0x40000000, 0x4007ffff, kMemoryNotExecutable, &amp;amp;g_deviceMemoryInterface }, // AIPS peripherals&lt;BR /&gt; { 0x400ff000, 0x400fffff, kMemoryNotExecutable, &amp;amp;g_deviceMemoryInterface }, // GPIO&lt;BR /&gt; { 0xe0000000, 0xe00fffff, kMemoryNotExecutable, &amp;amp;g_deviceMemoryInterface }, // M4 private peripherals&lt;BR /&gt; { 0 } // Terminator&lt;BR /&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2016 20:36:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613278#M145</guid>
      <dc:creator>kevinlfw</dc:creator>
      <dc:date>2016-09-13T20:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613279#M146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is another chunk of code that I tried, which I took from the bootloader project. &amp;nbsp;This jumps to the bootloader, however I have to disable the direct enable boot in the BCA, which also means it doesn't boot directly into the user application at startup like I want it to: &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;static uint32_t s_stackPointer = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; s_stackPointer = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; static void (*enterBootloader)(void) = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;enterBootloader = (void (*)(void))0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;// Set the VTOR to the application vector table address.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; SCB-&amp;gt;VTOR = (uint32_t)0x1FFF0000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;// Set stack pointers to the application stack pointer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; __set_MSP(s_stackPointer);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt; __set_PSP(s_stackPointer);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;// Jump to the application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;enterBootloader();&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2016 20:41:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613279#M146</guid>
      <dc:creator>kevinlfw</dc:creator>
      <dc:date>2016-09-13T20:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613280#M147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I thought I'd want to jump to address 0x0 or 0x1C"&lt;BR /&gt;&lt;BR /&gt;What that bootloader code does is read the ADDRESS of the bootloader from location 0x1CUL then jump to the address read.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;The parts that do have ROM do not place them at zero. &amp;nbsp; &amp;nbsp;Have to check the data sheet to find this indirection address for each part.&lt;BR /&gt;&lt;BR /&gt;Also what is at address zero is the ADDRESS of the the code that starts at reset, not the code itself. &amp;nbsp;0x4UL has the top of stack pointer address.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;It is usually best to issue a reset instruction, as discussed in the other thread, than jump to the the reset function&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;BR /&gt;If FOPT is set to start the user application then, assuming it is live and well, it can set FORCEROM in the Reset Control Module to enable the bootloader, then issue the software reset which will start the bootloader:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;void __attribute__ ((noreturn)) reset_mcu( void )&lt;BR /&gt;{&lt;BR /&gt; /*&lt;BR /&gt; * A DSB is required before generating self-reset to ensure all&lt;BR /&gt; * outstanding transfers are completed.&amp;nbsp;&lt;BR /&gt; */&lt;BR /&gt; irq_disable();&lt;BR /&gt; sync_barrier_data();&lt;/P&gt;&lt;P&gt;SCB_AIRCR = (SCB_AIRCR_VECTKEY(0x05FAU) | SCB_AIRCR_SYSRESETREQ_MASK);&lt;/P&gt;&lt;P&gt;for(;;)&lt;BR /&gt; {&lt;BR /&gt; ;&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:33:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613280#M147</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2016-09-14T12:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613281#M148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've only worked with the KL series. &amp;nbsp;On the assumption it works the same as your part it is FOPT is what controls boot to flash or boot to ROM bootloader (Does your part have the bootloader in ROM?). &amp;nbsp;BCA only needs changed if want to do something like a custom USB VID/PID or custom bootloader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What the above C code is doing is moving the vector table to address&amp;nbsp;&lt;SPAN style="background-color: #ffffff; color: #51626f; font-size: 14px;"&gt;0x1FFF0000; , setting the Stack Pointer to Zero which makes no sense unless the _set_XSP() are doing something odd, then jumping to address&amp;nbsp;0x1FFF0000 which is also odd. &amp;nbsp;I can't say any of this is wrong without knowing what "bootloader Project" code does, however to me it is highly&amp;nbsp;suspicious&amp;nbsp;code.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2016 12:47:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613281#M148</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2016-09-14T12:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613282#M149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using the flash-resident bootloader, so I'm not jumping to a ROM bootloader like I think you are used to. &amp;nbsp;The image below shows the memory map for flash-resident bootloader. &amp;nbsp;So how can I set up the system correctly to start executing the bootloader code, when I'm already running the user application. &amp;nbsp;What I think I'm looking for, is how to figure out the Bootloader Entry Point address because the manual (#2) says you can just call into the bootloader entry point:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P style="padding-left: 30px;"&gt;There are two ways to get into the flash-resident bootloader.&lt;BR /&gt;1. If the vector table at the start of internal flash holds a valid PC and SP, the hardware&lt;BR /&gt;boots into the bootloader.&lt;BR /&gt;2. A user application running on flash or RAM calls into the Kinetis bootloader entry&lt;BR /&gt;point address in flash to start the Kinetis bootloader execution.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Capture.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/5187i6190C2B22860E979/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2016 15:31:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613282#M149</guid>
      <dc:creator>kevinlfw</dc:creator>
      <dc:date>2016-09-19T15:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613283#M150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kevin Luty,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All of the comments by Bob are valid for the ROM Bootloader implementation and it is correct that things are slightly different for the flash-resident bootloader in your device (MK22F512VLH12).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case to jump to the bootloader from the application you can read the values for reset vector (entry point) and initial stack pointer from the bootloader's vector table. This corresponds to approach &lt;STRONG&gt;(2)&lt;/STRONG&gt; of the Reference Manual. The next code can be used:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;runBootloader&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;run_bootloader&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
uint32_t runBootloaderAddress&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;// Read the entry point from bootloader's vector table&lt;/SPAN&gt;
runBootloaderAddress &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_t&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0x00000004&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
runBootloader &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;runBootloaderAddress&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;runBootloader&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then call &lt;STRONG&gt;run_bootloader&lt;/STRONG&gt;&lt;STRONG&gt;()&lt;/STRONG&gt; at the required point in the application's code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps. Let me know if you have questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2016 23:57:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613283#M150</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2016-09-19T23:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613284#M151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code doesn't compile. &amp;nbsp;I changed it to this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;uint32_t runBootloaderAddress&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;// Read the entry point from bootloader's vector table&lt;/SPAN&gt;
runBootloaderAddress &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_t&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0x00000004&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
runBootloader &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;runBootloaderAddress&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;runBootloader&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionally, it doesn't help. &amp;nbsp;The code is executed and nothing happens. &amp;nbsp;When I "break" after the above code runs, it just shows me that the MQX idle task is running. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a chance a demo could be put together that is running MQX, uses the BCA w/ the flash-resident bootloader, and sets the direct boot enable flag (0xFE)? &amp;nbsp;The user application should run immediately at startup, and when some interrupt occurs (like button pushed) it enters into bootloader. &amp;nbsp;Running and testing this on a FRDM-K22F board would be ideal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there isn't, what should my next attempt be?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EDIT:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Using your code did in fact compile, it must've been my error copying it over. &amp;nbsp;Although it compiled, and in fact jumps to the bootloader code, because the bootloader direct boot flags in BCA is set to 0xFE to skip the bootloader at startup, it also skips the bootloader because the flags are still set when you jump to the bootloader. &amp;nbsp;With that being said, how should I change either the BCA or the bootloader project so that I skip the bootloader at startup, but so I can still jump to the bootloader from my user application?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Sep 2016 14:48:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613284#M151</guid>
      <dc:creator>kevinlfw</dc:creator>
      <dc:date>2016-09-20T14:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613285#M152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kevin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the update. Indeed if &lt;STRONG&gt;bootFlags&lt;/STRONG&gt; = 0xFE then the bootloader is skipped. You need to modify the bootloader code to have an extra decision parameter apart from the flag. There might be several options to do this but a simple solution I can think of is to reserve 4 bytes at the end of RAM in both linker files (bootloader and application). Then from the application you store a custom value in such RAM space before jumping to bootloader. Finally the bootloader checks the value in RAM and executes the bootloading process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The check of &lt;STRONG&gt;bootFlags&lt;/STRONG&gt; is made by function &lt;STRONG&gt;is_direct_boot()&lt;/STRONG&gt; called from &lt;STRONG&gt;bl_main.c&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if this solution does not work for you or if you have doubts to implement it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Sep 2016 17:04:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613285#M152</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2016-09-20T17:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Jumping from bootloader to user application</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613286#M153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;"In your case to jump to the bootloader from the application you can read the values for reset vector (entry point) and initial stack pointer from the bootloader's vector table"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Hello Jorge,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I am trying to achieve jumping to bootloader mode during application run-time. Could you please let me know how I would go about reading the reset vectors and stack pointer and where I should update these values before running the&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="" style="color: #000000; background: #f5f2f0; border: 0px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;"&gt;run_bootloader();&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;function. Please advice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Niyanth.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jul 2017 18:48:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/Jumping-from-bootloader-to-user-application/m-p/613286#M153</guid>
      <dc:creator>nkp</dc:creator>
      <dc:date>2017-07-11T18:48:50Z</dc:date>
    </item>
  </channel>
</rss>

