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: F021 API : Flash sector erase

Part Number: TMS570LC4357

Hello,

I use the “F021 flash API” in a program loaded and executed in SRAM via sections defined in the .cmd file.

My program starts with call of Fapi_initializeAPI(), Fapi_initializeFlashBanks(), Fapi_setActiveFlashBank() and Fapi_enableMainBankSectors() with all sectors enabled.

Then the program calls Fapi_issueAsyncCommandWithAddress() to erase a sector with the sector base address given, and the result status is "Fapi_Status_Success".

But values in the sectors are not equal to 0xFFFFFFFF : The “Fapi_EraseSector” command returns a "success status" without writing in the sector.

Can you indicate possible causes of the problem ?

Best Regards,

  • Hello Adama,

    What is the F021 Flash API version you are using? Can you share your .cmd file? What is the address of the sector you are trying to erase?

    There is a working Flash API example which runs in SRAM and you can use it as reference:

    http://git.ti.com/hercules_examples/hercules_examples/trees/master/Bootloaders

    best regards,

    David Zhou

  • Check this post for an explanation for why the Flash memory on TMS570LC43x does not read as all 1s when it is erased:

  • Thank you for this information.

    So which API commands to use to both program 0xFFFFFFFF and corresponding ECC code to observe 1s in debbuger ?

    Best Regards,

  • The flash main memory and corresponding ECC bits are in the same physical flash array, and are erased together to all 1s upon an erase operation. These are just mapped to separate regions in the CPU’s memory map.

    An erased flash array will not read all 1s in the debugger, as the ECC checking and single-bit error correction is always enabled on TMS570LC43x. This is the reason why some bits in an erased flash array will appear to not be erased when viewed with a debugger. The application can run a blank check using the API to ensure that the main array is indeed erased (all Fs).

    If you want to see all 1s in the debugger, you need to program the corresponding correct ECC values in the Flash memory.

  • To program the corresponding correct ECC, I start to erase the sector, then use Fapi_issueProgrammingCommand () to program 1s (64 bits) in the data area , then program the ECC code (8 bits) returned from Fapi_calculateECC ().

    However the ECC area is not updated and 1s are observed in ECC area.

    Can you indicate why ECC code are not updated ?

    Best Regards,

  • Must be the routine to program the ECC. I used the attached .asm file and the below linker command file to create a .out file that only programs the ECC region. The main array is expected to be erased (all Fs).

    6786.HL_sys_intvecs.asm

    /*----------------------------------------------------------------------------*/
    /* sys_link.cmd                                                               */
    /*                                                                            */
    /* 
    * Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com  
    * 
    * 
    *  Redistribution and use in source and binary forms, with or without 
    *  modification, are permitted provided that the following conditions 
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright 
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the 
    *    documentation and/or other materials provided with the   
    *    distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    /*                                                                            */
    /*----------------------------------------------------------------------------*/
    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    
    
    /*----------------------------------------------------------------------------*/
    /* Linker Settings                                                            */
    
    --retain="*(.intvecs)"
    
    /* USER CODE BEGIN (1) */
    /* USER CODE END */
    
    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */
    
    MEMORY
    {
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
        VECTORS (X)  : origin=0x00000000 length=0x00000020 vfill=0xFFFFFFFF
        FLASH0  (RX) : origin=0x00000020 length=0x001FFFE0 vfill=0xFFFFFFFF
        FLASH1  (RX) : origin=0x00200000 length=0x00200000 vfill=0xFFFFFFFF
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x0007EB00
    
        ECC_VEC (R)  : origin=0xf0400000 length=0x4 ECC={ input_range=VECTORS }
        ECC_FLA0 (R) : origin=0xf0400000 + 0x4 length=0x3FFFC ECC={ input_range=FLASH0 }
        ECC_FLA1 (R) : origin=0xf0440000 length=0x40000 ECC={ input_range=FLASH1 }
    
    /* USER CODE BEGIN (3) */
    /* USER CODE END */
    }
    
    /* USER CODE BEGIN (4) */
    ECC
    {
       algo_name : address_mask = 0xfffffff8
       hamming_mask = R4
       parity_mask = 0x0c
       mirroring = F021
    }
    
    /* USER CODE END */
    
    
    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */
    
    SECTIONS
    {
    /* USER CODE BEGIN (5) */
    /* USER CODE END */
        .intvecs : {} > VECTORS
        .text   align(8) : {} > FLASH0 | FLASH1
        .const  align(8) : {} > FLASH0 | FLASH1
        .cinit  align(8) : {} > FLASH0 | FLASH1
        .pinit  align(8) : {} > FLASH0 | FLASH1
        .bss     : {} > RAM
        .data    : {} > RAM
        .sysmem  : {} > RAM
    	.stack   : {} > RAM
    
    /* USER CODE BEGIN (6) */
    /* USER CODE END */
    }
    
    /* USER CODE BEGIN (7) */
    /* USER CODE END */
    
    
    /*----------------------------------------------------------------------------*/
    /* Misc                                                                       */
    
    /* USER CODE BEGIN (8) */
    /* USER CODE END */
    /*----------------------------------------------------------------------------*/
    
    

    Program the out file generated by this CCS code project into the part. This programs only the ECC values and not the main array. Then you should be able to see all Fs in the main array with the debugger.