This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LC4357: not able to erase flash using F021 API

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hello,

I am trying to port working RM48 bootloader code to the TMS570LC4357.  The bootloader uses QJ Wang's bl_flash.c, bl_ymodem.c, etc files to download a file via UART and write it to flash.  For the TMS570LC4357, I am using F021 library F021_API_CortexR4_BE_L2FMC_V3D16.lib.  I verified that Registers.h is including Registers_FMC_BE.h. (big endian mode).  The library and bl_flash, bl_ymodem, etc objects are relocated at boot time and execute out of RAM.  Execution from RAM is working as expected.

The bootloader attempts to download a file and program it to flash starting at bank 0 sector 4 = flash address 0x20000.  This code runs fine on the RM48 HDK but not on the TMS570LC43x HDK board.

When I run the code and download a file the Fapi_initializeFlashBanks(), Fapi_setActiveFlashBank(), Fapi_enableMainBankSectors(), and Fapi_issueAsyncCommandWithAddress() execute and return success codes.  And the following while loops checking for FSM readybusy and status are executed and complete as expected.

while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );

while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);

But the call to Flash_Erase_Check() fails. The CCS debugger memory window shows many words starting at location 0x20000 that are not all 0xFFFFFFFF.  I read a post that implies ECC, so I tried calling Fapi_disableAutoEccCalculation() just after the call to Fapi_initializeFlashBanks().  But that did not help the problem.  

I attached a screenshot of the debugger memory window after the erase operation showing the non-erased memory.  I also attached the slightly modified file bl_flash.c.  My changes are indicated with the tag //KRB

What is needed to erase flash on the 570LC4357?

Thank you,

Keith

5710.bl_flash.c

  • Hello Keith,

    On this R5 based device, ECC is enabled by default, and can not be disabled. ECC is not calculated or programmed during an erase operation. After an erase operation the ECC values are FF. When you read the flash content, the data is "corrected" based on the ECC data and displayed on memory browser.
  • QJ,

    Thank you. 

    1.Are you saying that I should not attempt to perform a manual blank check?   How do I verify that the operation succeeded? 

    2. Also, my bootloader needs to perform a CRC check over my application image that starts at location 0x20000 in flash.  How does it do that (and get the expected value) if the ECC bits are visible during the flash memory read?

    3. Here are my Halcogen settings.  I assume that the F021 API can write to flash, even though Region 2 permissions are read-only ?

    Thanks,

    Keith

  • Hi Keith,

    1. I suggest to use Linker command to generate ECC for the whole flash for both bootloader and application.
    2. You can calculate the CRC using CRC HW module. The link for the example code is in the following application note
    www.ti.com/.../spna235.pdf