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.

TMS570LS3137-EP: F021 API Fails with Function Call

Part Number: TMS570LS3137-EP
Other Parts Discussed in Thread: TMS570LS3137

Hi,

We are having an issue with the F021 Flash API on the TMS570LS3137. We are following the procedure outlined in spnu501h to erase flash via the following example:

...

flashStatus = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,
(uint32_t*)(BANK_0_SEC_7_ADDR +
(BYTES_PER_ERASE_SECTOR * numSectors)));

// Wait for flash to be done
while (FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady)
{
// Do nothing
}

// Check for status of flash erase
if ((FAPI_GET_FSM_STATUS != 0U) ||
(flashStatus != Fapi_Status_Success))
{
// Set return status to fail if flash failed and break from the erase loop
retVal = ST_FAIL;
break;
}
.....
The problem is that this code is not unit testable in the while loop. So we changed it to use the following function:
bool_t isFlashReady(void)
{
     return FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady;
}
.....
// Wait for flash to be done
while (!isFlashReady())
{
// Do nothing
}
....
This type of change fails and the flash driver no longer works. The flash erase fails.
We are copying the Flash API to RAM at the beginning of the process so I was wondering if the issue might be related to where this new function is running from.
Any thoughts on this?
Thanks so much for your time.
  • Hi Justin,

    TMS570LS3137 has two flash banks. If your code can erase the flash bank 1, but can not erase bank 0, some API related functions and variables are not copied to SRAM, and executed from SRAM.

    Is bool_t isFlashReady(void) function executed from SRAM?

  • It should be executed from SRAM as it is in the same file as the other API related functions and we do add that object file to the Flash API that is copied to SRAM. The following is from the linker file that includes them into the Flash API that is then copied to SRAM during initialization.

    SECTIONS
    {
    .intvecs : {} > BOOT_VECTORS
    .boot_version : {} > BOOT_VERSION
    flashAPI :
    {
    ..\Debug__TI\Fapi_UserDefinedFunctions.obj (.text)
    ..\Debug__TI\flashdrv.obj (.text)
    ..\Debug__TI\external_watchdog.obj (.text)

    --library= ../ext/F021_Flash_API_02.01.01/F021_API_CortexR4_BE_V3D16.lib (.text)
    } load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)

    Is there a way to tell that isFlashReady is being run from SRAM?

  • We do call  _copyAPI2RAM_(); during init to move everything in FLASH_API to SRAM.

  • The map file will tell you where the isFlashReady(void) is located