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: Erasing Flash using F021 Flash API library doesn't show all the erased flash locations as 0xFFFFFFFF

Part Number: TMS570LC4357
Other Parts Discussed in Thread: UNIFLASH

Hi,

We are using the F021 flash library to program or erase the TMS570LC4357 controller.

However, when we erase a flash location, we don't see all locations have 0xFF's and instead we see 0xFFF7FFFF  or some other bits in the erase flash locations are zeros.

We understand that it could be due to the flash ECC issue but not sure which function to call for enabling ECC or autogenerate ECC when erasing flash using the F021 library.

Also, we load images using the UNIFLASH tool with the auto ECC enabled option and could see all the flash regions erase by the UNIFLASH tool have FFs, but when erase using the F021 library it is not the case.

Note: Flas API functions used: fapi_issue_async_cmd_with_addres() funciton with FAPI_ERASE_SECTOR command

Please let me know if we are missing anything.

  • Hello Srihari,

    Yes, it is caused by the flash ECC. When main flash is erased, the ECC space is also erased. This means that the erased flash has invalid ECC.

    You can generate the ECC for the whole flash using linker cmd file.

    http://software-dl.ti.com/hercules/hercules_docs/latest/hercules/How_to_Guides/HowToGuides.html

    Attached is the example of linker cmd file used for LC43x device:

    /*----------------------------------------------------------------------------*/
    /* Linker Settings */

    --retain="*(.intvecs)"

    /* USER CODE BEGIN (1) */
    /* USER CODE END */

    /*----------------------------------------------------------------------------*/
    /* Memory Map */

    MEMORY
    {
    /* USER CODE BEGIN (2) */
    //#if 0
    /* USER CODE END */
    /*
    VECTORS (X) : origin=0x00000000 length=0x00000020
    FLASH0 (RX) : origin=0x00000020 length=0x001FFFE0
    FLASH1 (RX) : origin=0x00200000 length=0x00200000
    STACKS (RW) : origin=0x08000000 length=0x00001500
    RAM (RW) : origin=0x08001500 length=0x0007EB00
    */
    /* USER CODE BEGIN (3) */
    //#endif

    //#if 1
    VECTORS (X) : origin=0x00000000 length=0x00000020 fill = 0xffffffff
    FLASH0 (RX) : origin=0x00000020 length=0x001FFFE0 vfill = 0xffffffff
    FLASH1 (RX) : origin=0x00200000 length=0x00200000 vfill = 0xffffffff
    /* Bank 7 (128kB, FEE) */
    FLASH7 (R) : origin=0xF0200000 length=0x00020000 vfill = 0xffffffff

    STACKS (RW) : origin=0x08000000 length=0x00001500
    RAM (RW) : origin=0x08001500 length=0x0002EB00
    /* Bank 0 ECC */
    ECC_VEC (R) : origin=(0xf0400000 + (start(VECTORS) >> 3))
    length=(size(VECTORS) >> 3)
    ECC={algorithm=algoL2R5F021, input_range=VECTORS}

    ECC_FLA0 (R) : origin=(0xf0400000 + (start(FLASH0) >> 3))
    length=(size(FLASH0) >> 3)
    ECC={algorithm=algoL2R5F021, input_range=FLASH0 }

    /* Bank 1 ECC */
    ECC_FLA1 (R) : origin=(0xf0400000 + (start(FLASH1) >> 3))
    length=(size(FLASH1) >> 3)
    ECC={algorithm=algoL2R5F021, input_range=FLASH1 }

    /* Bank 7 ECC */
    ECC_FLA7 (R) : origin=0xF0100000
    length=(size(FLASH7) >> 3)
    ECC={algorithm=algoL2R5F021, input_range=FLASH7 }
    //#endif
    /* USER CODE END */
    }

    /* USER CODE BEGIN (4) */
    #if 1
    ECC {
    algoL2R5F021 : address_mask = 0xfffffff8 /* Address Bits 31:3 */
    hamming_mask = R4 /* Use R4/R5 build in Mask */
    parity_mask = 0x0c /* Set which ECC bits are Even and Odd parity */
    mirroring = F021 /* RM57Lx and TMS570LCx are build in F021 */
    }
    #endif
    /* USER CODE END */


    /*----------------------------------------------------------------------------*/
    /* Section Configuration */

    SECTIONS
    {
    /* USER CODE BEGIN (5) */
    #if 0
    /* USER CODE END */
    /*
    .intvecs : {} > VECTORS
    .text align(32) : {} > FLASH0 | FLASH1
    .const align(32) : {} > FLASH0 | FLASH1
    .cinit align(32) : {} > FLASH0 | FLASH1
    .pinit align(32) : {} > FLASH0 | FLASH1
    .bss : {} > RAM
    .data : {} > RAM
    .sysmem : {} > RAM

    FEE_TEXT_SECTION : {} > FLASH0 | FLASH1
    FEE_CONST_SECTION : {} > FLASH0 | FLASH1
    FEE_DATA_SECTION : {} > RAM
    */
    /* USER CODE BEGIN (6) */
    #endif

    #if 1
    .intvecs : {} palign=8 > VECTORS

    .text : {} palign=8 > FLASH0 | FLASH1 /* Executable code and constants */
    .const : {} palign=8 > FLASH0 | FLASH1 /* Global and static const variables that are explicitly initialized */
    .cinit : {} palign=8 > FLASH0 | FLASH1 /* Tables for explicitly initialized global and static variables */
    #ifdef __TI_EABI_SUPPORT__
    .init_array : {} palign=8 > FLASH0 | FLASH1 /* C++ global constructor addresses */
    #else /* TI_ARM9_ABI and TIABI */
    .pinit : {} palign=8 > FLASH0 | FLASH1 /* C++ global constructor addresses */
    #endif
    .stack : {} > STACKS /* Stack */

    .bss : {} > RAM /* Uninitialized global and static variables */
    .data : {} > RAM /* Global and static non-const variables that are explicitly initialized. */
    .sysmem : {} > RAM /* Memory pool (heap) for dynamic memory allocation */

    #endif

    /* USER CODE END */
    }

  • Hello QJ Wang, We are able to see FF's with linker generated ECC file. But, after erase operation over flash with F021 library is still not showing all FF's. Is it the expected behavior of library erase even with linker generated ECC file?

    We had a requirement to have FF's after erase. so, tried a work around like programming FF's immediately after erase to meet the requirements and then program the actual image which is working fine. Do you see any issues over the workaround of erase followed by two program commands?

    Requesting you to please provide your inputs for above queries.

    Regards,

    Baba.

  • Hello,

    The content of flash is 0xFF after it is erased with F021 APIs. When you read the content, the returned value may bot be 0xFF because of the invalid ECC value. But the content of flash is not changed, it is 0xFF.

  • If you program a application image to a flash sector, the flash sector should be erased first. 

    When you compile the application image, you can fill the unused portion of the sector with 0xFF in linker cmd file, and generated .out file or .bin file contains the data (0xFF) of unused flash portion. For example, you want to program the application image to sector 6 (0x18000), the size of sector 6 is 32KB, and your application size is around 0x20KB. 

    Linker cmd file:

    MEMORY

    {

            .............

            APPLICATION_IMAGE (RX) : origin=0x00018000 length=0x8000 fill=0xFFFFFFFF /* used for application */

            .......

    }

    SECTIONS
    {
          .intvecs : {} > VECTORS
          .text align(32) : {} > APPLICATION_IMAGE
          .const align(32) : {} > APPLICATION_IMAGE
          .cinit align(32) : {} > APPLICATION_IMAGE
          .pinit align(32) : {} > APPLICATION_IMAGE
          .bss : {} > RAM
          .data : {} > RAM
          .sysmem : {} > RAM
    }

    The Flash API: Fapi_issueProgrammingCommand(dst, src, bytes,0,0,Fapi_AutoEccGeneration); will generated the ECC value for the unused flash portion which is included in the bin file generated through the CCS.

  • Thank you QJ Wang, As per your response, I understand once the flash sector is erased, we can program by using Fapi_issueProgarmmingCommand api method with linker file by filling unused locations with FF's without an erase request in later stage. So, Once loaded the program, Does it work (showing FF's) even for further erase calls after the initial loading?

    Regards,

    Baba.

  • Hi QJ Wang,

    We are waiting for your response. Please respond.

    Regards,

    Baba.

  • I have the same answer as on Feb 9.

    1. compile you application image, and check the file size from map file

       for example, the application size is 0x7000

    2. modify the linker cmd file, allocate a memory region (x*sectors size) for the application, and fill it with zero

         APPLICATION_IMAGE (RX) : origin=0x00018000 length=0x8000 fill=0xFFFFFFFF /* 2 sectors; used for application */

    3. after compile/link, the file is padded with 0xFF until read the end of the flash sector

         the size of the file with padded value is 0x8000

    4. bootloader program the application and its ECC:  Fapi_issueProgrammingCommand(dst, src, bytes,0,0,Fapi_AutoEccGeneration)

    5. so the flash sectors which contain the application correct ECC.