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.

F021 Flash API

Other Parts Discussed in Thread: TMS570LS3137

I am trying to flash code using F021 Flash API. I was successful to do so with F035 API for TMS570LS2026 processor, but TMS570LS3137 with F021 API the function FlashProgram() returns Fapi_Error_AsyncIncorrectDataBufferLength.

My flashing program is located in RAM after it was copied there from flash and after the RAM and the flash were swapped. The Erase of the needed sectors works correctly, but the programming fails.

The following parameters are passed to FlashProgram():

pu32StartAddress  = 0x08010000

pu8DataBuffer = 0x00018000

u8DataBufferSizeInBytes = 30528

pu8EccBuffer - NULL


u8EccBufferSizeInBytes = 0

oMode  = Fapi_AutoEccGeneration

The FlashProgram() is located at 0x00007E34

Can someone tell me if I'm doing anything wrong, or maybe the F021 API has an issue programming the fash when RAM and flash are swapped?

Thanks,

Alex

  • Hi,

    I have forwarded you thread to an expert in the team. They will be responding shortly.

    - Forum support

  • Hello Alex,

    When programming 65nm device (F021) when the RAM and Flash memories are swapped, you still need to use the original Flash addresses.  Additionally, unlike the F035 API which had synchronous and asynchronous programming functions, the F021 API only has asynchronous functions.  Fapi_issueProgrammingCommand() will only accept a buffer size up to the bank width.  On the TMS570LS3137 device, this is 144 bits (16 bytes + 2 bytes ECC).

    So for your given information, you should set up something like this:

    unsigned long * pu32StartAddress  = 0x10000;

    unsigned char * pu8DataBuffer = 0x00018000;

    u8DataBufferSizeInBytes = 30528

    while (u8DataBufferSizeInBytes > 15)

    {

        Fapi_issueProgrammingCommand(pu32StartAddress,pu8DataBuffer,16,NULL,0,Fapi_AutoEccGeneration);

        while((FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY ? Fapi_Status_FsmBusy : Fapi_Status_FsmReady) != Fapi_Status_FsmReady);

        pu32StartAddress +=4;

        pu8DataBuffer += 16;

        u8DataBufferSizeInBytes -=16;

    }

  • John,

    Thanks for your help.

    I assumed that bank width is a bank size and that was my only mistake.

    You are incorrect regarding the Flash address after memory swap. If I put it the way you toold me the program crashes, but it works the way I set it up originally.

    I have another question. Do I have to verify the ECC proramming? If so, I need to recalculate it from the source buffer and then verify. Is there any easier way?

    Thanks,

     

    Alex

  • Alex,

    I am not incorrect about the Flash Address.  The Flash Memory Controller (FMC) always uses original memory map addresses for operations (Erase and Program).  It just so happens if you use the RAM address it is masking off the upper address bits as it only uses bits 23:0 of the address unless it begins with 0xF0xx_xxxx.  For reading the Flash, you would use the swapped address.  Also, any Flash address above 0xF000_0000 is never swapped and always uses it original addressing.

    On verifying the ECC, it is up to you on how thorough you want to be.  If you program the data with AutoGeneration (which uses the same hardware to calculate the ECC that is used to verify the ECC) and if ECC detection and correction is enable during the data verify, then an incorrectly programmed ECC value will generate an ECC error.  Recalculating from the source and then directly verifying the ECC is the most thorough method available.