<?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>CodeWarrior for MCU中的主题 Re: relocating code</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/relocating-code/m-p/278184#M10337</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found the answer!&lt;/P&gt;&lt;P&gt;As it might be interesting for other people as well, here is the solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1) Don't copy&amp;amp;paste code from a pdf document into your code.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I copied code from AN4329 into my code which did not work.&lt;/P&gt;&lt;P&gt;At some point, I noticed that the section definition ".MY_SECTION" was black instead of blue.&lt;/P&gt;&lt;P&gt;Erased the quotation marks and typed them manually, now they are blue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The quotation marks are not recognized as quotation marks, and to make it worse, when they appear in a pragma statement there is no syntax error. The pragma statement is simply ignored and you get a totally uncomprehensible error message when you try to refer to that previous pragma.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case: the section definition had the wrong quotation marks&lt;/P&gt;&lt;P&gt;The __declspec referring to the previously (not) defined section produced an error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2) Don't put the function in main.c &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;It was just a little test program.&lt;/P&gt;&lt;P&gt;A small function which resides in the same file as the calling function is optimized away (function inlining).&lt;/P&gt;&lt;P&gt;The section definition is ignored without notice. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Jun 2013 15:49:17 GMT</pubDate>
    <dc:creator>martinpi</dc:creator>
    <dc:date>2013-06-06T15:49:17Z</dc:date>
    <item>
      <title>relocating code</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/relocating-code/m-p/278183#M10336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to locate code partially in flash and partially in RAM.&lt;/P&gt;&lt;P&gt;I found AN4329 which explains how to do it.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are two ways to do it:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;__declspec()&lt;/LI&gt;&lt;LI&gt;#pragma section xxx begin / end&lt;/LI&gt;&lt;/UL&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I copied the code examples from AN4329 into main.c and into the lcf-file of an empty bareboard project.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the __declspec() I get a&amp;nbsp; compiler error "illegal type qualifier(s)", both in the function prototype and in the function itself.&lt;/P&gt;&lt;P&gt;Interestingly, in the kinetis_sysinit.c, __declspec() is used to tie the exception table to the vectortable section.&lt;/P&gt;&lt;P&gt;I can compile kinetis_sysinit.c without problems.&lt;/P&gt;&lt;P&gt;This is contary to AN4329, as it says that it is &lt;STRONG&gt;not&lt;/STRONG&gt; possible to use __declspec() to relocate &lt;STRONG&gt;data&lt;/STRONG&gt; (page 9). &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I tried the #pragma version, I was able to compile and link. But the code is placed into the .text section as usual, ignoring my section directive. I can see this in the xmap file. The function which I want to relocate is where it would normally be, and in the memory map I see that the section which should hold the function is empty (size=0).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;Regards, Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 13:45:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/relocating-code/m-p/278183#M10336</guid>
      <dc:creator>martinpi</dc:creator>
      <dc:date>2013-06-06T13:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: relocating code</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/relocating-code/m-p/278184#M10337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found the answer!&lt;/P&gt;&lt;P&gt;As it might be interesting for other people as well, here is the solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1) Don't copy&amp;amp;paste code from a pdf document into your code.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I copied code from AN4329 into my code which did not work.&lt;/P&gt;&lt;P&gt;At some point, I noticed that the section definition ".MY_SECTION" was black instead of blue.&lt;/P&gt;&lt;P&gt;Erased the quotation marks and typed them manually, now they are blue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The quotation marks are not recognized as quotation marks, and to make it worse, when they appear in a pragma statement there is no syntax error. The pragma statement is simply ignored and you get a totally uncomprehensible error message when you try to refer to that previous pragma.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case: the section definition had the wrong quotation marks&lt;/P&gt;&lt;P&gt;The __declspec referring to the previously (not) defined section produced an error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2) Don't put the function in main.c &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;It was just a little test program.&lt;/P&gt;&lt;P&gt;A small function which resides in the same file as the calling function is optimized away (function inlining).&lt;/P&gt;&lt;P&gt;The section definition is ignored without notice. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jun 2013 15:49:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/relocating-code/m-p/278184#M10337</guid>
      <dc:creator>martinpi</dc:creator>
      <dc:date>2013-06-06T15:49:17Z</dc:date>
    </item>
  </channel>
</rss>

