<?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>Kinetis Software Development KitのトピックRe: K64 Bootloader Pre-jump Checklist</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/K64-Bootloader-Pre-jump-Checklist/m-p/489638#M4374</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jorge,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for my late reply. I have been off of this section of the project for a while, but have now had a chance to look into the issue further.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I initially looked into this problem, I had noticed that if I jumped to the program immediately (not called many other functions in main) it worked correctly. It was only when I, for example, would check if files existed on the SD card that the jump would not correctly work. I figured that the difference was SRAM usage, and tried using memset on m_data, which was successful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I perform this memset on m_data right before calling the jump instructions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I looked into the register at &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;0xE000ED04, which read 0x03F04004, indicating a MemManage exception. The MemManage fault status register is 0x00, and the MemManage fault address register is 0xF8ED00E0. This only occurs when I do not set the SRAM.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;If you have any other suggestions for what I can look into, please let me know.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jared&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Feb 2016 20:52:10 GMT</pubDate>
    <dc:creator>kyati</dc:creator>
    <dc:date>2016-02-25T20:52:10Z</dc:date>
    <item>
      <title>K64 Bootloader Pre-jump Checklist</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/K64-Bootloader-Pre-jump-Checklist/m-p/489636#M4372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been continuing a bootloader project, which i had described in &lt;A _jive_internal="true" data-containerid="11234" data-containertype="14" data-objectid="379517" data-objecttype="1" href="https://community.nxp.com/thread/379517" rel="nofollow noopener noreferrer" target="_blank"&gt;K64 FTFE Operations Across PFlash Blocks&lt;/A&gt; , by adding some different decision making on when to update the application. The example I based the project off, &lt;A _jive_internal="true" data-containerid="11213" data-containertype="14" data-objectid="106069" data-objecttype="102" href="https://community.nxp.com/docs/DOC-106069" rel="nofollow noopener noreferrer" target="_blank"&gt;SD Card Bootloader :how to using SD card to update existing firmware on CodeWarriror or KDS&lt;/A&gt; , uses a gpio to determine when to update the program, whereas I want to update if the specific file is detected on the SD card and then delete the file when completed.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code which used a gpio to trigger the update and jump had no issues. The new update which calls f_stat() from FATFS to check if the file exists or not does not always jump to the program. If I continually restart the code after the file is erased and the app is written, (solely checking that the file is not there, turning off peripherals and interrupts, and jumping to app) the app will only run some of the time. When failing, the application code ends up in the application's default ISR after the jump. I feel that this is due to an interrupt being left on, but I globally disabled them and any active peripherals before the jump.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One method that causes the code to work properly 100% of the time is setting the first part of the SRAM, including the RAM vector copy, to 0 (0x1FFF0000 to 0x1FFFFFFF).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The linker file for my bootloader looks as such:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;&amp;nbsp; m_interrupts&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (RX)&amp;nbsp; : ORIGIN = 0x00000000, LENGTH = 0x00000400 &amp;nbsp; m_flash_config&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (RX)&amp;nbsp; : ORIGIN = 0x00000400, LENGTH = 0x00000010 &amp;nbsp; m_interrupts_ram&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (RW)&amp;nbsp; : ORIGIN = 0x1FFF0000, LENGTH = 0x00000400 &amp;nbsp; m_text&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; (RX)&amp;nbsp; : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0 &amp;nbsp; m_data&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; (RW)&amp;nbsp; : ORIGIN = 0x1FFF0400, LENGTH = 0x0000FC00 &amp;nbsp; m_data_2&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; (RW)&amp;nbsp; : ORIGIN = 0x20000000, LENGTH = 0x00030000&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The application code is then offset by 0x10000:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;&amp;nbsp; m_interrupts&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (RX)&amp;nbsp; : ORIGIN = 0x00010000, LENGTH = 0x00000400 &amp;nbsp; m_flash_config&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (RX)&amp;nbsp; : ORIGIN = 0x00010400, LENGTH = 0x00000010 &amp;nbsp; m_interrupts_ram&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (RW)&amp;nbsp; : ORIGIN = 0x1FFF0000, LENGTH = 0x00000400 &amp;nbsp; m_text&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; (RX)&amp;nbsp; : ORIGIN = 0x00010410, LENGTH = 0x000EFBF0 &amp;nbsp; m_data&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; (RW)&amp;nbsp; : ORIGIN = 0x1FFF0400, LENGTH = 0x0000FC00 &amp;nbsp; m_data_2&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; (RW)&amp;nbsp; : ORIGIN = 0x20000000, LENGTH = 0x00030000&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the following assembly to jump to the application by passing 0x10000 and 0x10004 as arguments, respectively:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;static void JumpToUserApplication(uint32_t userSP, uint32_t userStartup) { &amp;nbsp; __asm("msr msp, r0"); &amp;nbsp; __asm("msr psp, r0");&amp;nbsp; __asm("mov pc,&amp;nbsp; r1"); }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using KDS 3.1 with baremetal KSDK 1.3 and FATFS on a custom K64 board. I used processor expert to set up the SDHC and sd card peripherals as well as some gpios for status LEDS. I have received some useful information from &lt;A _jive_internal="true" data-containerid="2019" data-containertype="14" data-objectid="336321" data-objecttype="1" href="https://community.nxp.com/thread/336321" rel="nofollow noopener noreferrer" target="_blank"&gt;Bootloader for Kinetis K64 (Cortex M4)&lt;/A&gt; on what to do before jumping to the application, but still feel I am missing something. What exactly does clearing the SRAM do that makes the code work? Is there any checklist of tasks I should perform with the KSDK functions before the jump that I may be missing based on my setup?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jared&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2016 23:01:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/K64-Bootloader-Pre-jump-Checklist/m-p/489636#M4372</guid>
      <dc:creator>kyati</dc:creator>
      <dc:date>2016-02-04T23:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: K64 Bootloader Pre-jump Checklist</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/K64-Bootloader-Pre-jump-Checklist/m-p/489637#M4373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jared Evans:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In regards to your issue:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Exactly at what point do you clear the SRAM?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not see how this resolves the issue, unless the application uses the same vectors than the bootloader, which are not valid for the application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- If the application ends up in an unhandled interrupt, you should be able to inspect the &lt;STRONG&gt;ICSR&lt;/STRONG&gt; register at address 0xE000ED04 to see which interrupt vector is active:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/36922i1C7901D05324E0E7/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- In your call to the jump function the arguments 0x10000 and 0x10004 are only correct if you use them as &lt;STRONG&gt;pointer to 32-bit&lt;/STRONG&gt; &lt;STRONG&gt;int&lt;/STRONG&gt; and pass the value received from dereferencing them. Otherwise these parameters are wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us know if you find any more symptoms that help tracking the issue.&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>Thu, 11 Feb 2016 22:19:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/K64-Bootloader-Pre-jump-Checklist/m-p/489637#M4373</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2016-02-11T22:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: K64 Bootloader Pre-jump Checklist</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/K64-Bootloader-Pre-jump-Checklist/m-p/489638#M4374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jorge,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for my late reply. I have been off of this section of the project for a while, but have now had a chance to look into the issue further.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I initially looked into this problem, I had noticed that if I jumped to the program immediately (not called many other functions in main) it worked correctly. It was only when I, for example, would check if files existed on the SD card that the jump would not correctly work. I figured that the difference was SRAM usage, and tried using memset on m_data, which was successful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I perform this memset on m_data right before calling the jump instructions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I looked into the register at &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;0xE000ED04, which read 0x03F04004, indicating a MemManage exception. The MemManage fault status register is 0x00, and the MemManage fault address register is 0xF8ED00E0. This only occurs when I do not set the SRAM.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;If you have any other suggestions for what I can look into, please let me know.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jared&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2016 20:52:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/K64-Bootloader-Pre-jump-Checklist/m-p/489638#M4374</guid>
      <dc:creator>kyati</dc:creator>
      <dc:date>2016-02-25T20:52:10Z</dc:date>
    </item>
  </channel>
</rss>

