<?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: After bootloading a program, how to automatically start it on reboot?</title>
    <link>https://community.nxp.com/t5/MCU-Bootloader/After-bootloading-a-program-how-to-automatically-start-it-on/m-p/705550#M545</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe the answer posted in &lt;A href="https://freescale.jiveon.com/thread/450269"&gt;How to make KBOOT jump to main()?&lt;/A&gt;&amp;nbsp;gives me the answer I need. &amp;nbsp;Although, upon reflection, I don't need it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case, I realized that what I need is really to embed the bootloader directly into my application: After the system reboots, it waits for a preset amount of time (e.g. 10 seconds) for a valid bootloader command. &amp;nbsp; If received, it enters bootloader mode, and will stay there until the user (or blhost) issues a `reset` command. &amp;nbsp;If no valid bootloader command is received within the ten second window, it will simply call the main entry point of my code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the bootloader is compiled along with my application code, the entry point is automatically known.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In short, the guts of the bootloader are unchanged. &amp;nbsp;Only the way is it invoked is non-standard. &amp;nbsp;This feels like a clean and simple approach.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 17 Sep 2017 00:31:14 GMT</pubDate>
    <dc:creator>robertpoor</dc:creator>
    <dc:date>2017-09-17T00:31:14Z</dc:date>
    <item>
      <title>After bootloading a program, how to automatically start it on reboot?</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/After-bootloading-a-program-how-to-automatically-start-it-on/m-p/705549#M544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H1 id="toc-hId-1984394303"&gt;Summary:&lt;/H1&gt;&lt;P&gt;Once I've downloaded a program using the flash bootloader, how do I arrange things so on the next reboot, it launches the program (rather than the bootloader)?&lt;/P&gt;&lt;H1 id="toc-hId--567762658"&gt;Details:&lt;/H1&gt;&lt;P&gt;I've adapted a flash bootloader for the KL27Z. &amp;nbsp;As far as I can tell, it has successfully downloaded a small test program:&lt;/P&gt;&lt;BLOCKQUOTE&gt;[~]$ blhost -p /dev/cu.usbmodem219,115200 flash-image blinky.hex 1&lt;BR /&gt;Ping responded in 1 attempt(s)&lt;BR /&gt;Inject command 'flash-image'&lt;BR /&gt;Successful generic response to command 'flash-erase-region'&lt;BR /&gt;Successful generic response to command 'flash-erase-region'&lt;BR /&gt;Wrote 192 bytes to address 0x8000&lt;BR /&gt;Successful generic response to command 'write-memory'&lt;BR /&gt;(1/2)100% Completed!&lt;BR /&gt;Successful generic response to command 'write-memory'&lt;BR /&gt;Wrote 7756 bytes to address 0x8400&lt;BR /&gt;Successful generic response to command 'write-memory'&lt;BR /&gt;(2/2)100% Completed!&lt;BR /&gt;Successful generic response to command 'write-memory'&lt;BR /&gt;Response status = 0 (0x0) Success.&lt;/BLOCKQUOTE&gt;&lt;P&gt;Note that blinky.hex has slightly non-standard memory map: I've modified the MKL27Z64xxx4_flash.ld so the code starts at 0x8000 rather than the normal 0x0000 so it doesn't overwrite the resident flash loader:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE&gt;/* Specify the memory areas */
MEMORY
{
&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;m_interrupts&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(RX)&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;: ORIGIN = 0x00008000, LENGTH = 0x00000200
&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;m_flash_config&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(RX)&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;: ORIGIN = 0x00008400, LENGTH = 0x00000010
&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;m_text&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(RX)&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;: ORIGIN = 0x00008410, LENGTH = 0x0000FBF0
&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;m_usb_sram&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(RW)&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;: ORIGIN = 0x040FE000, LENGTH = 0x00000200
&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;m_data&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;(RW)&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;: ORIGIN = 0x1FFFF000, LENGTH = 0x00004000
}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;After loading the blinky.hex file, the flash boloader is still resident, and it gets started upon reboot. &amp;nbsp;It examines the valued stored for sp and pc to decide if there's a valid program to run:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt; *vectorTable = (&lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt;*)APPLICATION_BASE;
&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt; sp = vectorTable[0];
&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt; pc = vectorTable[1];&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So I believe my real questions are:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;How do I discover the proper values for sp and pc in order to launch&amp;nbsp;blinky.hex?&lt;/LI&gt;&lt;LI&gt;How do I insert sp and pc into memory addresses APPLICATION_BASE[0] and APPLICATION_BASE[1] in the .hex file so they are properly set up after the .hex file is loaded? &amp;nbsp;Ideally this would be automatic, rather than a manual edit.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Or is this the wrong way to go about it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Sep 2017 15:59:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/After-bootloading-a-program-how-to-automatically-start-it-on/m-p/705549#M544</guid>
      <dc:creator>robertpoor</dc:creator>
      <dc:date>2017-09-16T15:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: After bootloading a program, how to automatically start it on reboot?</title>
      <link>https://community.nxp.com/t5/MCU-Bootloader/After-bootloading-a-program-how-to-automatically-start-it-on/m-p/705550#M545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe the answer posted in &lt;A href="https://freescale.jiveon.com/thread/450269"&gt;How to make KBOOT jump to main()?&lt;/A&gt;&amp;nbsp;gives me the answer I need. &amp;nbsp;Although, upon reflection, I don't need it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case, I realized that what I need is really to embed the bootloader directly into my application: After the system reboots, it waits for a preset amount of time (e.g. 10 seconds) for a valid bootloader command. &amp;nbsp; If received, it enters bootloader mode, and will stay there until the user (or blhost) issues a `reset` command. &amp;nbsp;If no valid bootloader command is received within the ten second window, it will simply call the main entry point of my code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the bootloader is compiled along with my application code, the entry point is automatically known.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In short, the guts of the bootloader are unchanged. &amp;nbsp;Only the way is it invoked is non-standard. &amp;nbsp;This feels like a clean and simple approach.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Sep 2017 00:31:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCU-Bootloader/After-bootloading-a-program-how-to-automatically-start-it-on/m-p/705550#M545</guid>
      <dc:creator>robertpoor</dc:creator>
      <dc:date>2017-09-17T00:31:14Z</dc:date>
    </item>
  </channel>
</rss>

