<?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: 2 Sections/Segments (one in RAM, one in ROM) containing the same data (CW 5.5.1272, 9S12DP256B) in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210238#M8243</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;To me it sounds as if the clean solution would be to have two objects, one constant for the flash content and one of the same type allocated in RAM, possibly in a NO_INIT segment. The type could be a struct, if the data consists in mutiple parts.&lt;BR /&gt;The copying has to be done manually as for the linker there is nothing which combines the two objects (for structs of identical type, C supports struct assignment).&lt;BR /&gt;&lt;BR /&gt;If there is one object with two addresses, then I wonder how a reference to it should resolved? I guess it should resolve to the RAM address, but I basically don't see the advantage of having the constant and the RAM incarnation bound together in the tools compared with having two objects and handling the binding in the source code.&lt;BR /&gt;&lt;BR /&gt;Well, if I understand the initial request right, then have a look at the RELOCATE_TO linker directive. Usually it is used for code which has to be executed in RAM but stored in ROM/FLASH, but there is no reason why the same thing could not be used for variable/constants too. (But I think having the initialization values in a distinct objects is better, its simpler).&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Dec 2008 04:11:05 GMT</pubDate>
    <dc:creator>CompilerGuru</dc:creator>
    <dc:date>2008-12-17T04:11:05Z</dc:date>
    <item>
      <title>2 Sections/Segments (one in RAM, one in ROM) containing the same data (CW 5.5.1272, 9S12DP256B)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210235#M8240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;I am trying to set up a calibration protocol (XCP over CAN) on my controller (9S12DP256B).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To be able to modify parameter data&amp;nbsp;online I need a section in RAM&amp;nbsp;which&amp;nbsp;contains all Parameters. At system startup&amp;nbsp;this RAM section must be initialized with&amp;nbsp;a Section in ROM containing the same&amp;nbsp;data and the same mapping. The values in&amp;nbsp;the&amp;nbsp;ROM section are initialized either at compile time&amp;nbsp;with the init-Values&amp;nbsp;used in code or with the&amp;nbsp;values from the last calibration session&amp;nbsp;stored from the RAM to the ROM section&amp;nbsp;after reception of a special XCP-Message.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My question: How can&amp;nbsp;I tell the linker to map the parameters&amp;nbsp;into RAM but having the same parameters (at&amp;nbsp;a location with constant offset)&amp;nbsp;stored in ROM?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I tried to map the parameters to RAM and&amp;nbsp;use the automatic generated .copy section but there are some problems:&lt;/DIV&gt;&lt;DIV&gt;* the .copy section&amp;nbsp;is optimized,&amp;nbsp;e.g.&amp;nbsp;parameters intialized to 0 in code are not member of&amp;nbsp;the .copy section&lt;/DIV&gt;&lt;DIV&gt;* inside the copy section there are some other variables used to init RAM-Variables&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp; -&amp;gt; the whole mapping of the parameters inside the .copy section is different to the RAM section&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;sample Code to&amp;nbsp;create/initialize&amp;nbsp;parameter:&lt;/DIV&gt;&lt;DIV&gt;#pragma DATA_SEG CALIBRATION_CONST&lt;BR /&gt;const volatile unsigned char SWITCH_TEST = 1;&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;sample prm-file:&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;...&lt;/DIV&gt;&lt;DIV&gt;SECTIONS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* internal RAM */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAL_RAM = READ_WRITE 0x3C00 TO 0x3CFF;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* unbanked FLASH ROM */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROM_4000 = READ_ONLY&amp;nbsp; 0x4000 TO 0x7FFF;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROM_C000 = READ_ONLY&amp;nbsp; 0xC040 TO 0xEF6F;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/DIV&gt;&lt;DIV&gt;END&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;PLACEMENT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _PRESTART, STARTUP,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROM_VAR, STRINGS,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VIRTUAL_TABLE_SEGMENT,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NON_BANKED, COPY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp; ROM_C000, ROM_4000;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEFAULT_RAM&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp; RAM;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALIBRATION_CONST&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp; CAL_RAM;&lt;BR /&gt;END&lt;/DIV&gt;&lt;DIV&gt;STACKSIZE 0x300&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks for your help!&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 17:23:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210235#M8240</guid>
      <dc:creator>m_wohlwender</dc:creator>
      <dc:date>2008-12-16T17:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: 2 Sections/Segments (one in RAM, one in ROM) containing the same data (CW 5.5.1272, 9S12DP256B)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210236#M8241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In CodeWarrior for HC12 V4.7, there is an option -OnCopyDown, which tells the compiler to generate copy down information for variables initialized with 0 as well.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 20:50:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210236#M8241</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-12-16T20:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: 2 Sections/Segments (one in RAM, one in ROM) containing the same data (CW 5.5.1272, 9S12DP256B)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210237#M8242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi CrasyCat,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;thanks for your help, I just tried the -OnCopyDown option of the Compiler, this had no influence on the mapping. I have found another option for the Linker -OCopyoff (ELF/DWARF: Do not optimise copy down), this one had the effect that all Variables/Parameters initalized to 0 are now in the .copy section.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But the main problem still is that I can not be sure that the mapping within the copy section is the same as in my RAM section because the .copy section contains more data than my CALIBRATION_CONST segment which is located to a RAM-Section. Another problem is that I cannot know where the data for my CALIBRATION_CONST section starts within the .copy section...&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Do you know another posibility to create a "mirror" section? Its no problem if I have to copy the content of the ROM-Section to the RAM-Section by myself, I do not have to use the startup Code for this.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Mario&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 21:32:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210237#M8242</guid>
      <dc:creator>m_wohlwender</dc:creator>
      <dc:date>2008-12-16T21:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: 2 Sections/Segments (one in RAM, one in ROM) containing the same data (CW 5.5.1272, 9S12DP256B)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210238#M8243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;To me it sounds as if the clean solution would be to have two objects, one constant for the flash content and one of the same type allocated in RAM, possibly in a NO_INIT segment. The type could be a struct, if the data consists in mutiple parts.&lt;BR /&gt;The copying has to be done manually as for the linker there is nothing which combines the two objects (for structs of identical type, C supports struct assignment).&lt;BR /&gt;&lt;BR /&gt;If there is one object with two addresses, then I wonder how a reference to it should resolved? I guess it should resolve to the RAM address, but I basically don't see the advantage of having the constant and the RAM incarnation bound together in the tools compared with having two objects and handling the binding in the source code.&lt;BR /&gt;&lt;BR /&gt;Well, if I understand the initial request right, then have a look at the RELOCATE_TO linker directive. Usually it is used for code which has to be executed in RAM but stored in ROM/FLASH, but there is no reason why the same thing could not be used for variable/constants too. (But I think having the initialization values in a distinct objects is better, its simpler).&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2008 04:11:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210238#M8243</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-12-17T04:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: 2 Sections/Segments (one in RAM, one in ROM) containing the same data (CW 5.5.1272, 9S12DP256B)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210239#M8244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi CompilerGuru,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I haven`t found the RELOCATE_TO directive within my linker documentation:-(&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I think I will try to&amp;nbsp;solve the problem within code:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1. Locate&amp;nbsp;the parameters to RAM within a user segment.&lt;/DIV&gt;&lt;DIV&gt;2. Reserve the same space within ROM.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;3. Locate space for&amp;nbsp;a (CRC)-Checksum behind the&amp;nbsp;ROM-area&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;4. The RAM-Section is initialised a system Startup with the values of the .copy section&lt;/DIV&gt;&lt;DIV&gt;5. If the Checksum of the ROM-area is ok then&amp;nbsp;overwrite the RAM with the ROM values. If there is a CRC-Error then flash the RAM-Content (init-Values from .copy section) to the ROM-area.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;With this&amp;nbsp;I should have always have correct (and the latest)&amp;nbsp;values for my parameters when the system is running.&lt;/DIV&gt;&lt;DIV&gt;The only disadvantage is that I do not have the parameter-values within the ROM-area inside of the .s19 coming from build process (calibration tools like ETAS INCA, Vector CANape... use this to be able to change parameters offline and writing them back to the .s19) but perhaps I find a possibility to get rid of this disadvantage by&amp;nbsp;patching the .s19 after the build process.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks for your help!&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Mario&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2008 16:58:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/2-Sections-Segments-one-in-RAM-one-in-ROM-containing-the-same/m-p/210239#M8244</guid>
      <dc:creator>m_wohlwender</dc:creator>
      <dc:date>2008-12-17T16:58:31Z</dc:date>
    </item>
  </channel>
</rss>

