<?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: LPC804: Run the user code from your own bootloader in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-Run-the-user-code-from-your-own-bootloader/m-p/1245569#M44280</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;There is a jump function from bootloader to application code, you can refer to:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;//-----------------------------------------------------------------------------&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// FUNCTION: JumpToUserApplication&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// SCOPE: Bootloader application system function&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// DESCRIPTION: The function startup user application&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// PARAMETERS: pointer on user vector table&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// RETURNS: function never go back&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;//-----------------------------------------------------------------------------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;void JumpToUserApplication(LWord userSP, LWord userStartup)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;// set up stack pointer&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;__asm("msr msp, r0");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;__asm("msr psp, r0");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;// Jump to PC (r1)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;__asm("mov pc, r1"); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;Before jump, you'd better disable interrupt, and call this jump function like below:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;// relocate vector table&lt;BR /&gt;SCB_VTOR = RELOCATED_VECTORS; &lt;BR /&gt;AppIDC = 0;&lt;BR /&gt;// Jump to user application&lt;BR /&gt;JumpToUserApplication(*((unsigned long*)RELOCATED_VECTORS), *((unsigned long*)(RELOCATED_VECTORS+4))); &lt;BR /&gt;return 0;&lt;/FONT&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;About Copy Flash to RAM, I think you need copy before mian of application project, you can&amp;nbsp; refer to the file startup_lpc804.c of SDK demos. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;BR&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;Alice&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Mar 2021 09:01:10 GMT</pubDate>
    <dc:creator>Alice_Yang</dc:creator>
    <dc:date>2021-03-15T09:01:10Z</dc:date>
    <item>
      <title>LPC804: Run the user code from your own bootloader</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-Run-the-user-code-from-your-own-bootloader/m-p/1244648#M44260</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have a project based on LPC804 in MCUxpresso, which consists of two parts. The first is the bootloader and the second is the user code. The bootloader is used to upload data and user code. The user code is at the address on flash memory 0x500, which I run with the following code:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;// Load new stack pointer address&lt;BR /&gt;asm volatile ("ldr r0, = 0x500");&lt;BR /&gt;asm volatile ("ldr r0, [r0]");&lt;BR /&gt;asm volatile ("mov sp, r0");&lt;BR /&gt;// Load new program counter address&lt;BR /&gt;asm volatile ("ldr r0, = 0x504");&lt;BR /&gt;asm volatile ("ldr r0, [r0]");&lt;BR /&gt;asm volatile ("mov pc, r0");&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I want to ask, is that right?&lt;/P&gt;&lt;P&gt;I need to move the interrupt vector table in the user code. I'm moving it to RAM using this code:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;uint32_t * src, * dst;&lt;BR /&gt;int32_t size;&lt;BR /&gt;__disable_irq ();&lt;BR /&gt;// copy vector table&lt;BR /&gt;src=(uint32_t *) VTOR_OFFSET; // 0x500&lt;BR /&gt;dst = (uint32_t *) 0x10000000;&lt;BR /&gt;size = 192;&lt;BR /&gt;while (size&amp;gt; 0) {&lt;BR /&gt;* dst ++ = * src ++;&lt;BR /&gt;size - = 4;&lt;BR /&gt;}&lt;BR /&gt;LPC_SYSCON-&amp;gt; SYSMEMREMAP = 0x1; // Remap to internal RAM&lt;BR /&gt;__enable_irq ();&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Is it right? Is it possible to move this table elsewhere on the flash memory within the user code? Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 06:56:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-Run-the-user-code-from-your-own-bootloader/m-p/1244648#M44260</guid>
      <dc:creator>masterboy</dc:creator>
      <dc:date>2021-03-12T06:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804: Run the user code from your own bootloader</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-Run-the-user-code-from-your-own-bootloader/m-p/1245569#M44280</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;There is a jump function from bootloader to application code, you can refer to:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;//-----------------------------------------------------------------------------&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// FUNCTION: JumpToUserApplication&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// SCOPE: Bootloader application system function&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// DESCRIPTION: The function startup user application&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// PARAMETERS: pointer on user vector table&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;// RETURNS: function never go back&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;//-----------------------------------------------------------------------------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;void JumpToUserApplication(LWord userSP, LWord userStartup)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;// set up stack pointer&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;__asm("msr msp, r0");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;__asm("msr psp, r0");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;// Jump to PC (r1)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;__asm("mov pc, r1"); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;Before jump, you'd better disable interrupt, and call this jump function like below:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;// relocate vector table&lt;BR /&gt;SCB_VTOR = RELOCATED_VECTORS; &lt;BR /&gt;AppIDC = 0;&lt;BR /&gt;// Jump to user application&lt;BR /&gt;JumpToUserApplication(*((unsigned long*)RELOCATED_VECTORS), *((unsigned long*)(RELOCATED_VECTORS+4))); &lt;BR /&gt;return 0;&lt;/FONT&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;About Copy Flash to RAM, I think you need copy before mian of application project, you can&amp;nbsp; refer to the file startup_lpc804.c of SDK demos. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;BR&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;Alice&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 09:01:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-Run-the-user-code-from-your-own-bootloader/m-p/1245569#M44280</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2021-03-15T09:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804: Run the user code from your own bootloader</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-Run-the-user-code-from-your-own-bootloader/m-p/1281825#M45125</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/27788"&gt;@Alice_Yang&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;As you have mentioned "&lt;SPAN&gt;JumpToUserApplication&lt;/SPAN&gt;" function, so where can i find this code?&lt;/P&gt;&lt;P&gt;Because i have downloaded LPC804 SBL examples from following link:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.nxp.com/docs/en/application-note-software/AN12378SW.zip" target="_blank"&gt;https://www.nxp.com/docs/en/application-note-software/AN12378SW.zip&lt;/A&gt;&lt;/P&gt;&lt;P&gt;In that only "bootValidApp" function available to jump to application from bootloader and it is also in assembly.&lt;/P&gt;&lt;P&gt;Can you give me C code example for jump to application. Also in above link SBL project is based on keil. Can you give me SBL project which is based on&amp;nbsp; MCUExpresso.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rahul Shah&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 12:29:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-Run-the-user-code-from-your-own-bootloader/m-p/1281825#M45125</guid>
      <dc:creator>rahulshah</dc:creator>
      <dc:date>2021-05-25T12:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804: Run the user code from your own bootloader</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-Run-the-user-code-from-your-own-bootloader/m-p/1281828#M45126</link>
      <description>&lt;P&gt;The code for&amp;nbsp;&lt;SPAN&gt;JumpToUserApplication is in the post from Alice. It is in C, but uses inline assembler as this is the only way to provide the required call sequence.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 12:33:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-Run-the-user-code-from-your-own-bootloader/m-p/1281828#M45126</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2021-05-25T12:33:30Z</dc:date>
    </item>
  </channel>
</rss>

