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.

TMS570LS0432: Going to svcEntry during Flash Erase in bootloader

Part Number: TMS570LS0432
Other Parts Discussed in Thread: HALCOGEN

Hi,

Whenever i tried to erase flash of TMS570LS0432, it is going to svcEntry and halting there.

I am erasing bank 0, sector 13 and 14 with start address 0x00020000 and length 0x00040000

Execution going to svcEntry at  Fapi_issueAsyncCommandWithAddress function, kindly suggest any solution.

Code used is below for your reference:

status=Fapi_initializeFlashBanks((uint32_t)SYS_CLK_FREQ); /* used for API Rev2.01 */

    for (i = ucStartBank; i < (ucEndBank + 1); i++){
        Fapi_setActiveFlashBank((Fapi_FlashBankType)i);
        Fapi_enableMainBankSectors(0xFFFF);                 /* used for API 2.01*/
        while( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady );
    }

    for (i=ucStartSector; i<(ucEndSector+1); i++){
        Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, flash_sector[i].start);
        while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );
        while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);
    }

  • Hi Vinary,

    The LS0432 has only one flash bank, so the flash API related functions must be executed from SRAM.

    Please refer to the bootloader example for copying code to SRAM:

    http://software-dl.ti.com/hercules/hercules_docs/latest/hercules/Examples/Examples.html#bootloader

  • Hi Wang,

    I am facing same problem after modifying the code as per above referred software and it is going to

    b   #0x200F8 in intvec.asm

    I did below changes

    Linker command file:

    MEMORY
    {
        VECTORS    (X)   : origin=0x00000000 length=0x00000020
        FLASH_API  (RX)  : origin=0x00000020 length=0x000014E0
        FLASH0     (RX)  : origin=0x00001500 length=0x0005EB00   //LS04x and RM42 Flash size is 0x60000
        SRAM       (RW)  : origin=0x08002000 length=0x00006000   //LS04x and RM42 SRAM size is 0x8000
        STACK      (RW)  : origin=0x08000000 length=0x00002000
    }
    SECTIONS
    {
       .intvecs : {} > VECTORS
       flashAPI :
       {
         Fapi_UserDefinedFunctions.obj (.text)
         bl_flash.obj (.text)
         --library= ..\..\..\lib\F021_API_CortexR4_BE.lib (.text)
       } 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
    }

    intvecs.asm :

    ; interrupt vectors
    ; Please change the #0x???? for your specified image location defined in bl_config.h

            b   _c_int00               ;0x00
            b   #0x200F8               ;0x04; 0x200F8=$20100-0x8; 0x20100 is the application start addr
            b   #0x200F8               ;0x08, Software interrupt
            b   #0x200F8               ;0x0C, Abort (prefetch)
            b   #0x200F8               ;0x10, Abort (data)
    reservedEntry
            b   reservedEntry          ;0x14
            ldr pc,[pc, #-0x1b0]       ;0x18
            ldr pc,[pc, #-0x1b0]       ;0x1C

    Modified core.asm

    Added _copyAPI2RAM code

    ; Initialize Stack Pointers

        .def     _coreInitStackPointer_
        .asmfunc

    _coreInitStackPointer_

            cps   #17
            ldr   sp,       fiqSp
            cps   #18
            ldr   sp,       irqSp

            cps   #19
            ldr   sp,       svcSp
            cps   #23
            ldr   sp,       abortSp
            cps   #27
            ldr   sp,       undefSp
            cps   #31
            ldr   sp,       userSp

            bx    lr

    userSp  .word 0x08000000+0x00000200
    svcSp   .word 0x08000000+0x00000200+0x00001500
    fiqSp   .word 0x08000000+0x00000200+0x00001500+0x00000100
    irqSp   .word 0x08000000+0x00000200+0x00001500+0x00000100+0x00000200
    abortSp .word 0x08000000+0x00000200+0x00001500+0x00000100+0x00000200+0x00000100
    undefSp .word 0x08000000+0x00000200+0x00001500+0x00000100+0x00000200+0x00000100+0x00000100

    Startup.c modified as

    Added _copyAPI2RAM after systemInit();

    Kindly suggest me any other modifications do i need to do?

    There are lot other minor changes compared to referred code with my halcogen generated code.

  • Added _copyAPI2RAM after systemInit();

    Kindly suggest me any other modifications do i need to do?

    Is the function which is calling the flash API functions in RAM or FLASH?

    In CCS/RM46L852: jump to prefetchEntry when used Fapi_issueProgrammingCommand it was found that having the function which calls the flash API functions being in FLASH could cause a prefetch abort, even if the flash API functions themselves were already in RAM.

  • Hi Gillon,

    I am calling API functions from bl_flash.c, which i am calling from RAM.

  • Hi Wang,

    Any update?

  • Hi,

    Can any one tell me what are all changes need to do for running flash API's from RAM, Changes mentioned in above thread are ok or any modifications?

  • Hi Vinary,

    Please copy .data to SRAM too:

       flashAPI :
       {
         Fapi_UserDefinedFunctions.obj (.text, .data)
         bl_flash.obj (.text, .data)
         --library= ..\..\..\lib\F021_API_CortexR4_BE.lib (.text, .data)
       } load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)

  • Please use memcopy() or _copyAPI2RAM() to copy the flash API related file/data to SRAM:


    ;-------------------------------------------------------------------------------
    ;
    ; Copy the Flash API from flash to SRAM.
    ;
    .def _copyAPI2RAM_
    .ref apiLoadStart
    .ref apiRunStart
    .ref apiLoadSize

    .asmfunc

    _copyAPI2RAM_

    stmfd sp!, {lr}

    ldr r0, flash_load
    ldr r1, flash_run
    ldr r2, flash_size
    add r2, r1, r2
    copy_loop1:
    ldr r3, [r0], #4
    str r3, [r1], #4
    cmp r1, r2
    blt copy_loop1

    ldmfd sp!, {lr}

    bx lr

    flash_load .word apiLoadStart
    flash_run .word apiRunStart
    flash_size .word apiLoadSize

    .endasmfunc

  • Hi Wang,

    Thank you for your suggestion,

    Now it is working.

    Small change from your above suggestion

    instead of apiLoadStart "api_load" to be used in _copyAPI2RAM_ to match with linker command file, similarly for others(apiRunStart,apiLoadSize) .