<?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 MQX TWRMCF54418 Boot Loader Bug in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MQX-TWRMCF54418-Boot-Loader-Bug/m-p/570604#M12921</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;The NAND FLASH boot loader code in the TWRMCF54418 bsp has a bug that prevents bit errors from being corrected when firmware images are transferred from FLASH to RAM.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px; color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN&gt;In the file mqx/source/bsp/twrmcf54418/bootstrap.c t&lt;/SPAN&gt;he&amp;nbsp;page transfers are configured for &lt;SPAN&gt;2kb plus the full spare data length (2kb + 64 bytes) but this overloads the ECC engine and causes it to always report 32-bit errors and prevents it from correcting actual bit errors. The correct transfer length is&lt;/SPAN&gt;&amp;nbsp;2kb + 60 bytes which includes the exact number of ECC bytes and no extra bytes.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #51626f; border: 0px; font-weight: inherit;"&gt;nfc_ptr-&amp;gt;SECSZ = BSP_PHYSICAL_PAGE_SIZE + NANDFLASH_SPARE_AREA_SIZE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;needs to be changed to&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #51626f; border: 0px; font-weight: inherit;"&gt;nfc_ptr-&amp;gt;SECSZ = BSP_PHYSICAL_PAGE_SIZE + 60;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;I've checked MQX 4.0 to 4.2 and all versions were affected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Aug 2016 14:39:20 GMT</pubDate>
    <dc:creator>dwarkentin</dc:creator>
    <dc:date>2016-08-29T14:39:20Z</dc:date>
    <item>
      <title>MQX TWRMCF54418 Boot Loader Bug</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MQX-TWRMCF54418-Boot-Loader-Bug/m-p/570604#M12921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;The NAND FLASH boot loader code in the TWRMCF54418 bsp has a bug that prevents bit errors from being corrected when firmware images are transferred from FLASH to RAM.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px; color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN&gt;In the file mqx/source/bsp/twrmcf54418/bootstrap.c t&lt;/SPAN&gt;he&amp;nbsp;page transfers are configured for &lt;SPAN&gt;2kb plus the full spare data length (2kb + 64 bytes) but this overloads the ECC engine and causes it to always report 32-bit errors and prevents it from correcting actual bit errors. The correct transfer length is&lt;/SPAN&gt;&amp;nbsp;2kb + 60 bytes which includes the exact number of ECC bytes and no extra bytes.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #51626f; border: 0px; font-weight: inherit;"&gt;nfc_ptr-&amp;gt;SECSZ = BSP_PHYSICAL_PAGE_SIZE + NANDFLASH_SPARE_AREA_SIZE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;needs to be changed to&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #51626f; border: 0px; font-weight: inherit;"&gt;nfc_ptr-&amp;gt;SECSZ = BSP_PHYSICAL_PAGE_SIZE + 60;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;I've checked MQX 4.0 to 4.2 and all versions were affected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2016 14:39:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MQX-TWRMCF54418-Boot-Loader-Bug/m-p/570604#M12921</guid>
      <dc:creator>dwarkentin</dc:creator>
      <dc:date>2016-08-29T14:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: MQX TWRMCF54418 Boot Loader Bug</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MQX-TWRMCF54418-Boot-Loader-Bug/m-p/570605#M12922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, we had awared this already. We have examined and compared the sources of the BSP driver and the NFC driver included in the FFS/MFS-driver. There are several differences between the two, most of it due to the FFS/MFS-driver also reading some meta-data with every read. The two drivers appear to use different definitions of the ECC status word. It therefore seem to us that we are missing some information.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2016 08:20:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MQX-TWRMCF54418-Boot-Loader-Bug/m-p/570605#M12922</guid>
      <dc:creator>miduo</dc:creator>
      <dc:date>2016-09-13T08:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: MQX TWRMCF54418 Boot Loader Bug</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MQX-TWRMCF54418-Boot-Loader-Bug/m-p/570606#M12923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was mistaken about the exact cause of the ECC engine failure. The actual cause was the even number being written to the SECSZ register. The MCF54418 TWR board uses 16-bit NAND FLASH memory and the NFC in the MCF54418 requires an odd number in the SECZ register for 16-bit devices. See section 22.3.13 in the MCF54418 Reference Manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The corrected line of code is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nfc_ptr-&amp;gt;SECSZ = NANDFLASH_PHYSICAL_PAGE_SIZE + NANDFLASH_SPARE_AREA_SIZE + 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and here is the entire bootstrap_sram_read_data function including the ECC engine result.&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE&gt;/*FUNCTION*-------------------------------------------------------------------
*
* Function Name : bootstrap_sram_read_data
* Returned Value : void
* Comments : Read data from the NAND Flash memory. Block# and page#
* must be specified.
* This code must be linked to Internal SRAM memory.
*
*END*----------------------------------------------------------------------*/
__declspec(bootstrap_sram_code)
static void bootstrap_sram_read_data(uint32_t block,uint32_t page)
{
 NFC_MemMapPtr nfc_ptr;
 uint32_t i;

/* Get the pointer to nfc registers structure */
 nfc_ptr = (&amp;amp;((VMCF5441_STRUCT_PTR)_PSP_GET_IPSBAR())-&amp;gt;NFC);

/* Clearing interrupts bits */
 nfc_ptr-&amp;gt;ISR |= (NFC_ISR_DONECLR_MASK |
 NFC_ISR_DONEEN_MASK |
 NFC_ISR_IDLECLR_MASK |
 NFC_ISR_IDLEEN_MASK);

/* Clearing buf in use */
 //for(i=0;i&amp;lt;NANDFLASH_PHYSICAL_PAGE_SIZE;i++)
 // NFC_SRAM_B0_REG(nfc_ptr, i) = 0;


 /* setting ROW and COLUMN address */
 page &amp;amp;= 0x3F;
 block &amp;amp;= 0x7FF;
 nfc_ptr-&amp;gt;RAR = 0x11000000 + page + (block&amp;lt;&amp;lt;6);
 nfc_ptr-&amp;gt;CAR = 0x00000000;

nfc_ptr-&amp;gt;CMD1 = NFC_CMD1_BYTE2(NANDFLASH_CMD_PAGE_READ_CYCLE2);
 nfc_ptr-&amp;gt;CMD2 = NFC_CMD2_BYTE1(NANDFLASH_CMD_PAGE_READ_CYCLE1) |
 NFC_CMD2_CODE(0x7EE0) |
 NFC_CMD2_BUFNO(0);

/* configuring Sector size */
 nfc_ptr-&amp;gt;SECSZ = NANDFLASH_PHYSICAL_PAGE_SIZE + NANDFLASH_SPARE_AREA_SIZE + 1;

/* 32bit ECC, 16bit data bus, 1 page cnt */
 nfc_ptr-&amp;gt;CFG = ( NFC_CFG_ECCAD((BSP_PHYSICAL_PAGE_SIZE + NANDFLASH_SPARE_AREA_SIZE)&amp;gt;&amp;gt;3) |
 NFC_CFG_ECCSRAM_MASK |
 NFC_CFG_ECCMODE(7) |
 NFC_CFG_IDCNT(5) |
 NFC_CFG_TIMEOUT(6) |
 NFC_CFG_BITWIDTH_MASK |
 NFC_CFG_PAGECNT(1));

/* Sending START */
 nfc_ptr-&amp;gt;CMD2 |= NFC_CMD2_BUSY_START_MASK;

/* Polling for cmd done IRQ*/
 while(!(nfc_ptr-&amp;gt;ISR &amp;amp; NFC_ISR_IDLE_MASK))
 {
 }

 _bit_error_count = NFC_SRAM_B0_REG( nfc_ptr, BSP_PHYSICAL_PAGE_SIZE + NANDFLASH_SPARE_AREA_SIZE + 7);

}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_bit_error_count is a global variable instead of a return value which was necessary to reduce code size due to the very limited amount of boot code memory.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Sep 2016 15:29:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MQX-TWRMCF54418-Boot-Loader-Bug/m-p/570606#M12923</guid>
      <dc:creator>dwarkentin</dc:creator>
      <dc:date>2016-09-20T15:29:46Z</dc:date>
    </item>
  </channel>
</rss>

