<?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: Kinetis Bootloader from Application Code in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-Bootloader-from-Application-Code/m-p/902666#M53081</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I will give that a try. &amp;nbsp;I'm not sure I understand why disabling ports would affect the bootloader though. &amp;nbsp;I'll see if I can find it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Apr 2019 14:04:24 GMT</pubDate>
    <dc:creator>JBM</dc:creator>
    <dc:date>2019-04-22T14:04:24Z</dc:date>
    <item>
      <title>Kinetis Bootloader from Application Code</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-Bootloader-from-Application-Code/m-p/902664#M53079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been following this thread:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/496982" rel="nofollow noopener noreferrer" target="_blank"&gt;Kinetis bootloader start from application&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and have implemented everything (I think). &amp;nbsp;I'm using the Freedom Bootloader with a K22 Freedom development board. &amp;nbsp;I did the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Downloaded the bootloader source, MCUXpresso IDE&lt;/P&gt;&lt;P&gt;2) Compiled the bootloader source&lt;/P&gt;&lt;P&gt;3) Created some LED blinking applications (one red, one green and one blue) to load (these were created with KDS)&lt;/P&gt;&lt;P&gt;4) Tested it on an FRDMK22 board -- it works. &amp;nbsp;I can install the bootloader, talk to it with blhost.exe and the KinetisFlashTool. &amp;nbsp;I can send applications to be loaded and it loads them successfully and the leds blink as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I need to be able to call it from application code, I made the following changes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) We only need serial, so I configured a BCA to only use serial (I had to move the BCA address in the bootloader startup to make room for the K22 interrupt table and the flash config). &amp;nbsp;I also disabled the bootloader timeout and crc checking.&lt;/P&gt;&lt;P&gt;2) Modified my applications to set RFSYS_REG0 to 0x01 just before calling NVIC_SystemReset() and to reset when switch on the development board is pressed. &amp;nbsp;Here is that section of code (it is in main.c in the blink.zip file) -- I disable interrupts, set the bit in the register file and reset the system.&lt;/P&gt;&lt;PRE&gt;DisableInterrupts;
/*
 * Tell the boot loader to start
 */
 RFSYS_REG0 |= 0x01; /* Signal for boot loader */
 NVIC_SystemReset();&lt;/PRE&gt;&lt;P&gt;3) Modified the boot loader to look at RFSYS_REG0 by adding a function to call -- analogous to the boot pin check:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #7f0055;"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/SPAN&gt; (!(is_reg_file_set(true) || is_boot_pin_asserted()) &amp;amp;&amp;amp; is_application_ready_for_executing(applicationAddress))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thinking was that my bit in the register file could act just like the boot pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems to work with one exception. &amp;nbsp;I can start the boot loader, load application code, and execute it. &amp;nbsp;When I press switch 2, the application code exits, but the boot loader will not talk over the serial port. &amp;nbsp; The blhost.exe message looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;Error: UartPeripheral() cannot open PC UART port(COM13), speed(57600 Hz).&lt;/PRE&gt;&lt;P&gt;Similarly, the KinetisFlashTool error is:&lt;/P&gt;&lt;PRE&gt;Error: Connect device failed(Error: Initial ping failure: No response received for ping command.).&lt;/PRE&gt;&lt;P&gt;If I reset the board, I can talk to the bootloader again. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have code in the blink application that opens the serial port (default UART1 on Port E 0 &amp;amp; 1 -- same as the boatload). &amp;nbsp;I thought that might be a problem and ran a test with it commented out -- didn't matter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using a USB to serial converter cable to talk to the board (trying to match our desired hardware configuration as much as possible). &amp;nbsp;I program with a PEMicro Multilink Universal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was trying to attach the debugger to the running bootloader to see what it was doing, but didnt' have any luck (maybe I'm just not doing it right).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Apr 2019 16:38:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-Bootloader-from-Application-Code/m-p/902664#M53079</guid>
      <dc:creator>JBM</dc:creator>
      <dc:date>2019-04-19T16:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis Bootloader from Application Code</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-Bootloader-from-Application-Code/m-p/902665#M53080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I tested your code. It seems the problem lies in blink. You call ports_done, this cause system fall into a isolated and unknown status. I think is step can be omited. NVIC_SystemReset() can make all pin back to default status.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2019 08:45:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-Bootloader-from-Application-Code/m-p/902665#M53080</guid>
      <dc:creator>jingpan</dc:creator>
      <dc:date>2019-04-22T08:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis Bootloader from Application Code</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-Bootloader-from-Application-Code/m-p/902666#M53081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I will give that a try. &amp;nbsp;I'm not sure I understand why disabling ports would affect the bootloader though. &amp;nbsp;I'll see if I can find it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2019 14:04:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-Bootloader-from-Application-Code/m-p/902666#M53081</guid>
      <dc:creator>JBM</dc:creator>
      <dc:date>2019-04-22T14:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis Bootloader from Application Code</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-Bootloader-from-Application-Code/m-p/902667#M53082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It was a stupid mistake on my part. &amp;nbsp;I wasn't clocking port B, so I was probably getting a fault in ports_done() and the bootloader was never started.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2019 18:04:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Kinetis-Bootloader-from-Application-Code/m-p/902667#M53082</guid>
      <dc:creator>JBM</dc:creator>
      <dc:date>2019-04-22T18:04:34Z</dc:date>
    </item>
  </channel>
</rss>

