<?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: Jump from bootloader to application in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692175#M27910</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;I found that it all works if I comment out the function call &amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;Board_SetupClocking&lt;/SPAN&gt;() &amp;nbsp;in &amp;nbsp;&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;Board_SystemInit&lt;/SPAN&gt;, that is called by&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;SystemInit&lt;/SPAN&gt;, called by &amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;ResetISR&lt;/SPAN&gt;. This way I have the initialisation from Flash and the clock was already initialised by the SBL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More precisely, the offending lines inside&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;Board_SetupClocking&lt;/SPAN&gt; are the call to&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;Chip_SetupXtalClocking&lt;/SPAN&gt; and the always dangerous&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;while (!Chip_Clock_IsUSBPLLLocked()) {}&lt;/SPAN&gt;. Just if anyone else stumbles on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Still wondering why an apparent repeated clock setup would cause a problem ?!?!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another bit of a worry is that this makes me to have two software frame versions, standalone with clock setup and bootloader-launched without.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I noticed there are some USB clock initialisation. My LPC1519 hasn't got USB. I'm not sure but I'm just assuming that initialisation has no effect for that MCU.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Jul 2017 14:13:08 GMT</pubDate>
    <dc:creator>juanabelaira</dc:creator>
    <dc:date>2017-07-25T14:13:08Z</dc:date>
    <item>
      <title>Jump from bootloader to application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692168#M27903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm getting a hard fault when jumping from my bootloader to the app. It's on an LPC1519 and the bootloader resides at 0x0000 - 0x1FFF, while the application starts at 0x2000. I'm using LPCXpresso.&lt;/P&gt;&lt;P&gt;I've seen this question asked and apparently answered somewhere else but none of the solutions proposed worked for me. Here is the code I use for the jump:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;SCB-&amp;gt;VTOR = (0x2000);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;asm volatile("ldr r0, =0x2000");&amp;nbsp;&amp;nbsp;&amp;nbsp;// Code start address&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; asm volatile("ldr sp, [r0]");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;asm volatile("ldr r0, [r0, #4]");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; //asm volatile("add r0, r0, 1");&amp;nbsp;// tried this as I read address has to be odd for thumb&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; asm volatile("mov pc, r0");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; //asm volatile ("bx r0");&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// tried this as I read is not safe to load PC&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I debug it, everything goes fine until the PC load or BX, where it goes to the hard fault loop.&lt;/P&gt;&lt;P&gt;Anything can point the right direction?&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited: If I edit the application 'ld' file to have the main as entry point, as below, then it works, but I'd like to know what the difference makes skipping the ResetISR function (the bootloader ran it anyways).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*ENTRY(ResetISR)*/&lt;BR /&gt;ENTRY(main)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jul 2017 09:05:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692168#M27903</guid>
      <dc:creator>juanabelaira</dc:creator>
      <dc:date>2017-07-11T09:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Jump from bootloader to application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692169#M27904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Juan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think that is the correct fix, it will only work correctly if the debugger is attached. I would recommend you to use the LPC1700 secondary USB bootloader as reference:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://cache.nxp.com/docs/en/application-note/AN10866.zip?fsrch=1&amp;amp;sr=1&amp;amp;pageNum=1" title="http://cache.nxp.com/docs/en/application-note/AN10866.zip?fsrch=1&amp;amp;sr=1&amp;amp;pageNum=1"&gt;http://cache.nxp.com/docs/en/application-note/AN10866.zip&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the function used by the bootloader to jump to the application:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__asm void boot_jump( uint32_t address ){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; LDR SP, [R0]&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;;Load new stack pointer address&lt;BR /&gt;&amp;nbsp;&amp;nbsp; LDR PC, [R0, #4]&amp;nbsp;&amp;nbsp; &amp;nbsp;;Load new program counter address&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you tried debugging your application startup code and see if ts is another instruction inside this function causing the hardfault?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope it helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Carlos Mendoza&lt;BR /&gt;Technical Support Engineer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 19:06:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692169#M27904</guid>
      <dc:creator>Carlos_Mendoza</dc:creator>
      <dc:date>2017-07-13T19:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Jump from bootloader to application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692170#M27905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Carlos. Could you tell me&amp;nbsp;what difference makes your code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp;&amp;nbsp; LDR SP, [R0]&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;;Load new stack pointer address&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&amp;nbsp;&amp;nbsp; LDR PC, [R0, #4]&amp;nbsp;&amp;nbsp; &amp;nbsp;;Load new program counter address&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;instead of mine? I see it functionally identical.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; font-family: terminal, monaco, monospace;"&gt;&lt;SPAN style="border: 0px;"&gt;asm volatile("ldr sp, [r0]");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="border: 0px;"&gt;asm volatile("ldr r0, [r0, #4]");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="border: 0px;"&gt;asm volatile("mov pc, r0");&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="border: 0px; background-color: #ffffff; color: #51626f; font-family: arial, helvetica, sans-serif;"&gt;Yes,&amp;nbsp;I first debug then ask. It crashes right after the PC register is loaded. I checked the r0 register has the right value beforehand (the ResetISR address).&amp;nbsp;But in this case I don't think debugging helps as I have&amp;nbsp;the application flashed and what I debug is the bootloader, so the debugger doesn't know anything about the application after the "mov pc".&amp;nbsp;I wonder if there is a way of debugging two independent applications.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="border: 0px; background-color: #ffffff; color: #51626f; font-family: arial, helvetica, sans-serif;"&gt;Facts so far are:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="border: 0px; background-color: #ffffff; color: #51626f; font-family: arial, helvetica, sans-serif;"&gt;- The bootloader executes fine until it jumps to the ResetISR [seen with debugger]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="border: 0px; background-color: #ffffff; color: #51626f; font-family: arial, helvetica, sans-serif;"&gt;- The bootloader does jump to the ResetISR [reason below]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="border: 0px; background-color: #ffffff; color: #51626f; font-family: arial, helvetica, sans-serif;"&gt;- If at the beginning of the ResetISR function I call main, then it works, but I'm skipping the RAM initialisation&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="border: 0px; background-color: #ffffff; color: #51626f; font-family: arial, helvetica, sans-serif;"&gt;Because of the above, I think my problem is with the RAM initialisation, but I can't see why copying from flash to RAM causes a hang.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jul 2017 07:58:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692170#M27905</guid>
      <dc:creator>juanabelaira</dc:creator>
      <dc:date>2017-07-14T07:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Jump from bootloader to application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692171#M27906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV class=""&gt;&lt;P&gt;Hi Juan,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;Yes, they are functionally identical. There could also be a problem with the SystemInit function, I would recommend you to debug both the bootloader and the application by adding the following command to your debug Run Commands:&lt;/DIV&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;EM&gt;add-symbol-file filename address&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;EM&gt;As an example:&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;add-symbol-file C:\\Users\\b38285\\Documents\\MCUXpressoIDE_10.0.0_344\\workspace\\MK64FN1M0xxx12_Project_2\\Debug\\MK64FN1M0xxx12_Project_2.axf 0x80000&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/25167iBF3F3AC39FD957FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The address 0x80000 corresponds to the first flash section of the second project which was previously flashed to the MCU:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/25210i7E2D843766AED299/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;BR /&gt;Hope it helps!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Carlos Mendoza&lt;BR /&gt;Technical Support Engineer&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jul 2017 14:35:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692171#M27906</guid>
      <dc:creator>Carlos_Mendoza</dc:creator>
      <dc:date>2017-07-14T14:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Jump from bootloader to application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692172#M27907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe this is not write place to ask my question. sorry for that but how did you manage to load the bootload and application at the same time in different memory locations ?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jul 2017 12:20:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692172#M27907</guid>
      <dc:creator>salmansattar</dc:creator>
      <dc:date>2017-07-18T12:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Jump from bootloader to application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692173#M27908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's at least a side-topic. Anyways, the question is direct and easy, I first flashed the application with offset, like writing data on flash, then I flashed the bootloader then when reset it runs and jumps to the app. Remember not to use the 'erase all flash' option. There are more elegant ways, like the one pointed above here by Carlos.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jul 2017 07:16:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692173#M27908</guid>
      <dc:creator>juanabelaira</dc:creator>
      <dc:date>2017-07-19T07:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Jump from bootloader to application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692174#M27909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mmm, I'm using LPC Link2, not Jagger, so I can't find the equivalent for my environment&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jul 2017 08:00:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692174#M27909</guid>
      <dc:creator>juanabelaira</dc:creator>
      <dc:date>2017-07-25T08:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Jump from bootloader to application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692175#M27910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;I found that it all works if I comment out the function call &amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;Board_SetupClocking&lt;/SPAN&gt;() &amp;nbsp;in &amp;nbsp;&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;Board_SystemInit&lt;/SPAN&gt;, that is called by&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;SystemInit&lt;/SPAN&gt;, called by &amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;ResetISR&lt;/SPAN&gt;. This way I have the initialisation from Flash and the clock was already initialised by the SBL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More precisely, the offending lines inside&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;Board_SetupClocking&lt;/SPAN&gt; are the call to&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;Chip_SetupXtalClocking&lt;/SPAN&gt; and the always dangerous&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;while (!Chip_Clock_IsUSBPLLLocked()) {}&lt;/SPAN&gt;. Just if anyone else stumbles on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Still wondering why an apparent repeated clock setup would cause a problem ?!?!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another bit of a worry is that this makes me to have two software frame versions, standalone with clock setup and bootloader-launched without.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I noticed there are some USB clock initialisation. My LPC1519 hasn't got USB. I'm not sure but I'm just assuming that initialisation has no effect for that MCU.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jul 2017 14:13:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Jump-from-bootloader-to-application/m-p/692175#M27910</guid>
      <dc:creator>juanabelaira</dc:creator>
      <dc:date>2017-07-25T14:13:08Z</dc:date>
    </item>
  </channel>
</rss>

