<?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>S12 / MagniV MicrocontrollersのトピックHCS12x Linker Command Automatic Checksum Generation</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12x-Linker-Command-Automatic-Checksum-Generation/m-p/571140#M12837</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 was using the Automatic Checksum Generation and&amp;nbsp;realized that there could be a bug with this&amp;nbsp;functionality.&lt;/P&gt;&lt;P&gt;My objective was to generate a checksum, CCITT method, for the whole program flash memory.&lt;/P&gt;&lt;P&gt;Interestingly, it seems that the linker is not generating the correcting checksum value for a section of memory if the addressing scheme is other than Local addressing.&lt;/P&gt;&lt;P&gt;So long as the range of memory the checksum is calculated is the same why is the calculation differing.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find below part of the linker command file entries with different addressing modes for the same block of memory.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same block of memory is used as an input and the results differ.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following two entries generated different checksum values:&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;// The local addressing generates a correct checksum value&amp;nbsp; -&amp;nbsp; THIS CALCULATES CORRECT VALUE&lt;/P&gt;&lt;P&gt;CHECKSUM&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECKSUM_ENTRY&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; METHOD_CRC_CCITT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OF READ_ONLY 0xC000 TO 0xFEF7&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO READ_ONLY 0xFEFC SIZE 2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNDEFINED 0xff&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;The following Global&amp;nbsp;Addressing generates a different checksum value that is identical to a&amp;nbsp;Local addressing input address.&lt;/P&gt;&lt;P&gt;// Input - Global Addressing&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; THIS DOES NOT GENEATE CORRECT VALUE&lt;/P&gt;&lt;P&gt;CHECKSUM&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECKSUM_ENTRY&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; METHOD_CRC_CCITT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OF READ_ONLY 0x7FC000'G TO 0x7FFEF7'G&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO READ_ONLY 0xFEFC SIZE 2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNDEFINED 0xff&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;BR /&gt;END&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;// Input - Logical Addressing&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - THIS DOES NOT GENERATE CORRECT VALUE&lt;/P&gt;&lt;P&gt;CHECKSUM&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECKSUM_ENTRY&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; METHOD_CRC_CCITT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OF READ_ONLY 0xFF8000 TO 0xFFBEF7&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO READ_ONLY 0xFEFC SIZE 2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNDEFINED 0xff&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ziggy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Aug 2016 19:55:43 GMT</pubDate>
    <dc:creator>zegeyealemu</dc:creator>
    <dc:date>2016-08-29T19:55:43Z</dc:date>
    <item>
      <title>HCS12x Linker Command Automatic Checksum Generation</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12x-Linker-Command-Automatic-Checksum-Generation/m-p/571140#M12837</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 was using the Automatic Checksum Generation and&amp;nbsp;realized that there could be a bug with this&amp;nbsp;functionality.&lt;/P&gt;&lt;P&gt;My objective was to generate a checksum, CCITT method, for the whole program flash memory.&lt;/P&gt;&lt;P&gt;Interestingly, it seems that the linker is not generating the correcting checksum value for a section of memory if the addressing scheme is other than Local addressing.&lt;/P&gt;&lt;P&gt;So long as the range of memory the checksum is calculated is the same why is the calculation differing.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find below part of the linker command file entries with different addressing modes for the same block of memory.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same block of memory is used as an input and the results differ.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following two entries generated different checksum values:&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;// The local addressing generates a correct checksum value&amp;nbsp; -&amp;nbsp; THIS CALCULATES CORRECT VALUE&lt;/P&gt;&lt;P&gt;CHECKSUM&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECKSUM_ENTRY&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; METHOD_CRC_CCITT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OF READ_ONLY 0xC000 TO 0xFEF7&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO READ_ONLY 0xFEFC SIZE 2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNDEFINED 0xff&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;The following Global&amp;nbsp;Addressing generates a different checksum value that is identical to a&amp;nbsp;Local addressing input address.&lt;/P&gt;&lt;P&gt;// Input - Global Addressing&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; THIS DOES NOT GENEATE CORRECT VALUE&lt;/P&gt;&lt;P&gt;CHECKSUM&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECKSUM_ENTRY&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; METHOD_CRC_CCITT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OF READ_ONLY 0x7FC000'G TO 0x7FFEF7'G&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO READ_ONLY 0xFEFC SIZE 2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNDEFINED 0xff&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;BR /&gt;END&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;// Input - Logical Addressing&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - THIS DOES NOT GENERATE CORRECT VALUE&lt;/P&gt;&lt;P&gt;CHECKSUM&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECKSUM_ENTRY&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; METHOD_CRC_CCITT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OF READ_ONLY 0xFF8000 TO 0xFFBEF7&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO READ_ONLY 0xFEFC SIZE 2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNDEFINED 0xff&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;BR /&gt;END&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ziggy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2016 19:55:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12x-Linker-Command-Automatic-Checksum-Generation/m-p/571140#M12837</guid>
      <dc:creator>zegeyealemu</dc:creator>
      <dc:date>2016-08-29T19:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12x Linker Command Automatic Checksum Generation</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12x-Linker-Command-Automatic-Checksum-Generation/m-p/571141#M12838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Zegeye,&lt;/P&gt;&lt;P&gt;The described generating method works fine on my side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However you have to take into account that linker do not know anything about page mirroring inside MCU.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, if you place data at address 0xC000, the linker do not know that the same data will be also at address 0xFF8000.&lt;/P&gt;&lt;P&gt;So, the first range works fine because page FF is defined as&lt;/P&gt;&lt;P&gt;ROM_C000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = READ_ONLY&amp;nbsp;&amp;nbsp; DATA_NEAR IBCC_NEAR&amp;nbsp; 0xC000 TO&amp;nbsp;&amp;nbsp; 0xFEFF;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The paged address range 0xFF8000 TO 0xFFBFFF is not defined in linker file (is commented out). The linker do not place any data into this area and linker will calculate “correct” checksum as it is empty space (all bytes 0xFF).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same is valid for range 0x7FC000'G TO 0x7FFEF7'G. The linker calculates checksum from fully erased area because you/linker didn’t place any data into this range.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, It has no sense define page FF as anything else than 0xC000~0xFFFF.&lt;/P&gt;&lt;P&gt;I tested this principle on page FD (0x4000~0x7FFF, 0xFD8000~0xFDBFFF, 0x7F4000'G~0x7F7FFF'G)&lt;/P&gt;&lt;P&gt;For example: I defined PAGE_FD segments in prm file as&lt;/P&gt;&lt;P&gt;SEGMENTS&lt;/P&gt;&lt;P&gt;&amp;nbsp; PAGE_FD&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= READ_ONLY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA_FAR IBCC_FAR&amp;nbsp; 0x7F4000'G TO 0x7F7FFF'G;&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;I created my user segment and place it into this page:&lt;/P&gt;&lt;P&gt;PLACEMENT&lt;/P&gt;&lt;P&gt;&amp;nbsp; MY_DATA DISTRIBUTE_INTO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PAGE_FD;&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;I placed data into this area in main code:&lt;/P&gt;&lt;P&gt;#pragma CONST_SEG MY_DATA&lt;/P&gt;&lt;P&gt;const unsigned char flash_array[] = {0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBD};&lt;/P&gt;&lt;P&gt;#pragma CONST_SEG DEFAULT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With that, the linker calculated correct checksum value:&lt;/P&gt;&lt;P&gt;CHECKSUM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHECKSUM_ENTRY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; METHOD_CRC_CCITT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OF READ_ONLY 0x7F4000'G TO 0x7F7EF7'G&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO READ_ONLY 0xFEFC SIZE 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNDEFINED 0xff&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I place this array at address 0x4000 (const unsigned char flash_array[] @0x4000) and calculate checksum at 0x4000 TO 0x7EF7, I will get the same checksum value.&lt;/P&gt;&lt;P&gt;The same is valid also for paged addresses (const unsigned char flash_array[] @0xFD8000, 0xFD8000 TO 0xFDBEF7).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, the checksum calculation works fine, but you have to manage that mirrored address spaces will be defined only one way and checksum will be defined at appropriate address ranges.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Aug 2016 12:53:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12x-Linker-Command-Automatic-Checksum-Generation/m-p/571141#M12838</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2016-08-30T12:53:59Z</dc:date>
    </item>
  </channel>
</rss>

