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.

Problems erasing with F021 flash API on TMS570LS3137

Hello,

We are having some problems erasing flash with the F021 flash API.

Our bootloader sits in the first few sectors of bank 0 and we do not want to waste the area in the same bank above this. If I erase a sector in bank 1 everything works OK

I am aware that it is not possible to erase memory in the same bank that the code is running in so we are loading the flash API to RAM as described in the post at http://e2e.ti.com/support/microcontrollers/hercules/f/312/t/62954.aspx. I am also following the recommended flow defined in section 5 of the Flash API manual (SPNU501C).

When I try to erase a sector in the same bank, for example at address 0x160000, I get an undefined instruction exception.

If I single step past the FAPI erase function everythingworks fine. If I put a break immediately after the flow has completed but before returning from our erase function, everything works fine too. However if I put a break in the calling function at the line immediately after the call to our erase function then I am getting an undefined instruction exception.

Even though we have relocated the flash library to RAM, I notice that there are still some trampolines in flash. Is this a possible cause?

I have spent a long time trying to track this issue down. Any help would be greatly appreciated. I have attached our flash erase function.

Regards,

Richard

  • Richard,

    What functions are you copying into RAM?

    I would expect the following functions there:

    Fapi_setActiveFlashBank()

    Fapi_issueAsyncCommandWithAddress()

    Fapi_checkFsmForReady()

    Fapi_setupBankSectorEnable()

    and the internal functions

    _Fapi_setupFlashStateMachine() - This is called by Fapi_setActiveFlashBank() and this would be my primary suspect of causing the issue.

    _Fapi_issueFsmCommand()

  • Hi John,

    Thanks for the quick response. We copy the library to RAM at startup. We have included the following linker command to tell it that we want to run from RAM:

    .flashapi : load = CODE, run = RAM,
    LOAD_START(__PTR_FAPI_LOAD_START_C), LOAD_END(__PTR_FAPI_LOAD_END_C), LOAD_SIZE(__PTR_FAPI_LOAD_SIZE_C),
    RUN_START(__PTR_FAPI_RUN_START_C), RUN_END(__PTR_FAPI_RUN_END_C), RUN_SIZE(__PTR_FAPI_RUN_SIZE_C),
    {
    F021_API_CortexR4_BE_v3D16.lib(.text)
    }

    I have attached the parts of the map file relating to the flash API.

    As an aside, if you look at the previous code, the function will report success even if the set flash bank function fails. I have now corrected this.

    Regards,
    Richard

  • Hi Richard,

    In your map file you have the 3 user defined functions which are not in the object library running from Flash:

    0001023c   Fapi_serviceWatchdogTimer
    0001024c   Fapi_setupEepromSectorEnable
    00010278   Fapi_setupBankSectorEnable

  • Hi John,
    The problem is solved!

    Basically I placed the 3 functions you identified and the Fls_EraseSector function attached to my original post in the flashapi section using the syntax:

    #pragma CODE_SECTION(Fls_EraseSector, ".flashapi")

    Thanks for your help.

    Regards
    Richard

  • When I add .flashapi section - I get linking warning: 

    "../source/sys_link.cmd", line 33: warning #10068-D: no matching section

    any ideas how to fix it ?

  • You need to add a .flashapi section to your sys_link.cmd file.

    For Example:

    /*----------------------------------------------------------------------------*/
    /* TMS570LS313xFlashLnk.cmd                                                 */
    /*                                                                            */
    /* (c) Texas Instruments 2011, All rights reserved.                           */
    /*                                                                            */

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


    /*----------------------------------------------------------------------------*/
    /* Linker Settings                                                            */
    --retain="*(.intvecs)"

    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */
    MEMORY{
        VECTORS (X)  : origin=0x00000000 length=0x00000020
        FLASH0  (RX) : origin=0x00000020 length=0x0017FFE0
        FLASH1  (RX) : origin=0x00180000 length=0x00180000
        STACKS  (RW) : origin=0x08000000 length=0x00001300
        RAM     (RW) : origin=0x08001300 length=0x0003ED00
    }

    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */
    SECTIONS{
        .intvecs : {} > VECTORS
        .text    : {} > FLASH0 | FLASH1
        .const   : {} > FLASH0 | FLASH1
        .cinit   : {} > FLASH0 | FLASH1
        .pinit   : {} > FLASH0 | FLASH1
        .bss     : {} > RAM
        .data    : {} > RAM
        .flashapi : load > FLASH0 | FLASH1, run > RAM {F021_API_CortexR4_BE_v3D16.lib(.text)}
    }
    /*----------------------------------------------------------------------------*/

  • Hello John,

    When I edit the sys_link.cmd file as you described I get this warning :

    "../source/sys_link.cmd"

    <Linking>

    "../source/sys_link.cmd", line 36: warning #10068-D: no matching section

  • Hi Greg,

    I think it would be useful if we could see your sys_link.cmd file. Could you please post it?

    Regards,
    Richard

  • Hi Greg,

    I agree with Richard.  It would be easier to figure this out if you would post your sys_link.cmd file.