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: Programming Flash in same Bank

Part Number: TMS570LS3137

Hello, 

I am trying to program Flash Bank0 Sector14. My application code loaded on Flash Bank0 Sector0.

I could program Flash Bank1 sectors but I cannot program Flash Bank0. The code stacks at __undefentry

Is there any way to do it?

Osman. 

Thanks in advance.

  • Hello Osman,

    All of the Flash APIs that program, erase, blank check or margin verify must be called from a bank other than the one in which code is being executed. If programming or erasing bank 0 of the device which has only one flash bank, these routines must be executed in RAM.

  • Hello, 

    I have two question: 

    1. Should I erase all bank when executing Flash APIs from same bank? I mean, for example Flash APIs executes from bank0 sector0. I just want to erase bank0 sector14. Is there a way to do it?

    2. How can I execute Flash APIs from RAM?

    Osman

    Thanks in advance. 

  • Hello,

    Is there any idea to proceed? 

    Osman

    Thanks in advance.

  • Hello Osman,

    Yes, you can erase sector 14 of bank 0. As you already knew, you have to copy the API related code to SRAM ,and execute those code from SRAM. Please refer to TI example code of CAN bootloader.

    How can I execute Flash APIs from RAM?

    1. In linker cmd file: 

    SECTIONS

    {

           .intvecs : {} > VECTORS

    flashAPI:
    {
              .\source\Fapi_UserDefinedFunctions.obj (.text)
              .\source\bl_flash.obj (.text)
             --library= "c:\ti\Hercules\F021 Flash API\02.01.01\F021_API_CortexR4_BE.lib" (.text)
    } palign=8 load = FLASH0, run = SRAM, LOAD_START(apiLoadStart), RUN_START(apiRunStart), SIZE(apiLoadSize)

    2. in main.c

    extern unsigned int apiLoadStart;
    extern unsigned int apiLoadSize;
    extern unsigned int apiRunStart;

            memcpy(&apiRunStart, &apiLoadStart, (uint32)&apiLoadSize);

  • Hello QJ, 

    Thanks for the reply. 

    I already did the changes you mentioned. Also disable interrupts when using Flash API functions. But the code still stacked at prefetch entry. 

    I read IFSR and DFSR and both registers have the value of 0x409. This value points out a Synchronous Parity/ECC Error according to ARM documentations. So I tried to disble ECC by using 

    _coreDisableFlashEcc_ and _CoreDisableRamEcc_ functions. 

    How can i solve this problem? 

    Osman

    Thanks in advance

  • LS3137 has 2 flash bank: bank 0 and bank 1. The bank 1 starts at 0x00180000. Can you please check if any error occurs if erasing one sector of bank 1?

  • Hello QJ, 

    Thanks for your quick reply, 

    I tried for two sectors (first and last) of Bank1. No error occurs when writing or erasing Bank1. 

    Osman

    Thanks in advance. 

  • Hello,

    Thanks for testing in bank1. 

    1. Please copy the flash API related code to SRAM  -- you did

    2. Please copy the const to SRAM too (same as copying flash API).

        in Linker cmd file:

           .const : {} palign=8 load=FLASH0, run = SRAM, LOAD_START(constLoadStart), RUN_START(constRunStart), SIZE(constLoadSize)

        in main.c:

            extern unsigned int constLoadStart;
            extern unsigned int constLoadSize;
            extern unsigned int constRunStart;

            memcpy(&constRunStart, &constLoadStart, (uint32)&constLoadSize);

    3. Disable the interrupt before calling the flash APIs

  • Hello, 

    Thanks for the reply. I did exactly as you described. I could erase bank0 sector14. However this time code stacked at Fapi_issueProgrammingCommand. When I stop the code, PC shows prefechEntry. Then I tried to step the Fapi function from dissassemly. By this way, I could program Sector14. I could not understand why the code stack when running and works when stepping.

    Can you help me ?

    Osman

  • Hello Osman,

    Before calling Fapi_issueProgrammingCommand, did you check CHECK_FSM_READY_BUSY? The code needs to wait until FSM becomes ready.

  • Hello, 

    Yes, I checked. 

    Osman, 

    Thanks in advance

  • Hi Osman,

    Can you please try the example code in CAN bootloader for LS31x device? bl_flash.c has several functions for erasing flash and program code to flash.