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.

CCS/TMS570LS1224: flash sector erasing loops with TMSTAT=0x0990

Part Number: TMS570LS1224
Other Parts Discussed in Thread: TMS570LC4357

Tool/software: Code Composer Studio

Hi,

I am trying to erase a flash memory sector in TMS570LS1224
(Hercules LaunchPad) with use of the library F021 v2.1.1.

1) Fapi_initializeFlashBanks(180);
2) Fapi_setActiveFlashBank(0);
3) Fapi_enableMainBankSectors(0xFF80);
4) wait for not busy
5) Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t*)0x20000);
6) wait for not busy
7) wait for success

In step 6) the program loops forever. The value of the register FMSTAT after
a time is equal to 0x0990. It is strange, because the bit 0x0800 is described
in spnu515b.pdf as Reserved R-0, and reads as 1. Other bits set are: CSTAT,
ERS, and BUSY.

Programming of the flash memory with use of F021 functions runs correctly.
The sectors erasing during programming a program from CCS also runs fine.
The procedure above runs from RAM with disabled interrupts.

Please help. Maybe I should do something before running the procedure
for sector erasing.

Thanks.

  • Hello,

    Please add bl_flash.obj (.const) into the flashAPI section because the flash_sector[] data table (constant data) is used by bl_flash.c.

    SECTIONS

    {

      .intvecs : {} > VECTORS

      /* Place the outputsection“flashAPI".  It is composed of the input sections:  */

      /* Fapi_UserDefinedFunctions.obj, bl_flash.obj, and F021_API_CortexR4_BE.lib  */

      /* It has two different allocations. It allocated to FLASH_API for loading, and allocated to SRAM for running. */

      /* This output section is placed in the output file so that, when the program is loaded, */

      /* it is in the FLASH_API memory range. Sometime during system execution, before anything in flashAPI is used, */

      /* the application copies it from FLASH_API to SRAM. Note this copy is not done automatically. */

      /* I must be taken in the application code. Any other section that uses flashAPI (either calls its functions or */

      /* refers to its data) acts as if flashAPI is already in SRAM. The LOAD_START etc. statements establish symbols */

      /* that are used to implement the copy. The value of the symbol api_load is the starting load address. */

      /* Likewise, api_end has the ending load address, and api_run has the starting run address. */

      /* api_size is the size */

      flashAPI :

      {

        Fapi_UserDefinedFunctions.obj (.text)

        bl_flash.obj (.text)

        bl_flash.obj (.const)

        --library= ..\..\..\lib\F021_API_CortexR4_BE.lib (.text)

      } load = FLASH_API, run = SRAM, LOAD_START(api_load), LOAD_END(api_end), RUN_START(api_run), SIZE(api_size)

      .text  > FLASH0

      .const > FLASH0

      .cinit > FLASH0

      .pinit > FLASH0

      .data  > SRAM

      .bss   > SRAM

    }

  • Hi,

    I am not using functions in bl_flash at all, only the functions from F021_API_CortexR4_BE_L2FMC_V3D16.lib.  

    I think that my sequence reproduces exactly what I see in bl_flash.c. 

    In the first line there is 160MHz,  180 is my typing error in the post.  

    Thanks,

    Grzegorz

  • Hi Grzegorz,

    Do you copy your function containing step 1~7 and its CONST to SRAM, and execute this sequence from SRAM?
  • Hi,

    Yes, the API is copied to RAM. When I trace the program in debugger I see that it
    runs from RAM and is correct.

    Please se below:

    #################### linker file ###########################

    --retain="*(.intvecs)"
    MEMORY
    {
    VECTORS (X) : origin=0x00000000 length=0x00000020
    FLASH_API (RX) : origin=0x00000020 length=0x000014E0
    FLASH0 (RX) : origin=0x00001500 length=0x0013EB00 /*140000-1500*/
    SRAM (RW) : origin=0x08001500 length=0x0002EB00
    STACK (RW) : origin=0x08000000 length=0x00001500
    }
    SECTIONS
    {
    .intvecs : {} > VECTORS
    flashAPI :
    {
    .\F021\source\Fapi_UserDefinedFunctions.obj (.text)
    .\F021\source\Fapi_UserDefinedFunctions.obj (.const)
    .\appsrc\drv_flash.obj (.text)
    .\appsrc\drv_flash.obj (.const)

    --library= F021_API_CortexR4_BE_L2FMC_V3D16.lib < *.obj > (.text)
    --library= F021_API_CortexR4_BE_L2FMC_V3D16.lib < *.obj > (.const)
    } load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)

    .text > FLASH0
    .const > FLASH0
    .cinit > FLASH0
    .pinit > FLASH0
    .data > SRAM
    .bss > SRAM
    }

    ######################## helper assembler file for loading API to RAM #################

    .text
    .def flashApiRomAddr,flashApiRamAddr,flashApiSize
    .ref api_load, api_run, api_size

    flashApiRomAddr .word api_load
    flashApiRamAddr .word api_run
    flashApiSize .word api_size

    ################# function loading API to RAM #################################

    void appCopyFlashApiFromRomToRam(void) {
    uint32_t *ptFrom = (uint32_t*)flashApiRomAddr;
    uint32_t *ptTo = (uint32_t*)flashApiRamAddr;
    uint32_t i, count = flashApiSize >> 2;
    for (i=0; i<count; ++i) ptTo[i] = ptFrom[i];
    }

    ##############################################################################

    Thanks,
    Grzegorz
  • Hi Grzegorz,

    You use a wrong library:
    F021_API_CortexR4_BE_L2FMC_V3D16.lib. is for TMS570LC4357
    F021_API_CortexR4_BE_V3D16.lib is for TMS570LS12x device.

    I just noticed. Sorry for that.
  • Hi,

    It works now.  THANK YOU VERY MUCH !

    There is a related issue, byt I will open a new post.  

    Grzegorz