<?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 MicrocontrollersのトピックRe: Hard fault calling function in RAM</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-calling-function-in-RAM/m-p/229548#M4852</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All flash code that I have seen or written copies the routine from flash to ram explicitly.&lt;/P&gt;&lt;P&gt;It is considered unsafe to jump to code in ram that is put there by the C runtime initialization code, and it is not very portable.&lt;/P&gt;&lt;P&gt;So, you will be a pioneer.&lt;/P&gt;&lt;P&gt;You can use PE to generate flashing code - for Kinetis it copies it to a ram buffer. For coldfire it uses the stack.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Mar 2013 04:46:17 GMT</pubDate>
    <dc:creator>JimDon</dc:creator>
    <dc:date>2013-03-19T04:46:17Z</dc:date>
    <item>
      <title>Hard fault calling function in RAM</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-calling-function-in-RAM/m-p/229547#M4851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working on a flash driver for a K20 chip, and since it only has one page of memory I believe I have to move my sector erase function to RAM so I'm not accessing the bank while erasing part of it.&amp;nbsp; I'm using GCC and a custom linker script for my project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far I've done this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Use the attribute label to tell the linker to put the function in RAM:&lt;/P&gt;&lt;P&gt;bool erase_sector(uint32_t address) __attribute__((long_call, section(".ramfunctions")));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- and in the linker script:&lt;/P&gt;&lt;P&gt;. = 0x1FFFE000;&lt;/P&gt;&lt;P&gt;&amp;nbsp; .data ()&amp;nbsp;&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __data_start = . ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __data_start__ = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data .data.* .gnu.linkonce.d.*)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(32 / 8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SORT(CONSTRUCTORS)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(32 / 8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.ramfunctions) /* Place specified functions in RAM */&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;- Add -mlong-calls to my compiler arguments&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However when I run my code, I get a hard fault as soon as I call my erase_sector function.&amp;nbsp; Is there another step here that I'm missing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marlon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Mar 2013 21:38:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-calling-function-in-RAM/m-p/229547#M4851</guid>
      <dc:creator>marlonsmith</dc:creator>
      <dc:date>2013-03-18T21:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Hard fault calling function in RAM</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-calling-function-in-RAM/m-p/229548#M4852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All flash code that I have seen or written copies the routine from flash to ram explicitly.&lt;/P&gt;&lt;P&gt;It is considered unsafe to jump to code in ram that is put there by the C runtime initialization code, and it is not very portable.&lt;/P&gt;&lt;P&gt;So, you will be a pioneer.&lt;/P&gt;&lt;P&gt;You can use PE to generate flashing code - for Kinetis it copies it to a ram buffer. For coldfire it uses the stack.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 04:46:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-calling-function-in-RAM/m-p/229548#M4852</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2013-03-19T04:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Hard fault calling function in RAM</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-calling-function-in-RAM/m-p/229549#M4853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for reply Jim.&amp;nbsp; I created a separate section in the linker script for this purpose and then modified my startup code to copy the functions to RAM, and it seems to be working for me now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marlon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 19:51:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-calling-function-in-RAM/m-p/229549#M4853</guid>
      <dc:creator>marlonsmith</dc:creator>
      <dc:date>2013-03-19T19:51:59Z</dc:date>
    </item>
  </channel>
</rss>

