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: watchdog cleared by assembly function moving flash API to RAM

Part Number: TMS570LS3137

I'm using the flash api. The assembly code I am using was found in another post here.

;-------------------------------------------------------------------------------
;
; Copy the Flash API from flash to SRAM.
;

    .def     _copyAPI2RAM_
    .asmfunc

_copyAPI2RAM_

   .ref    api_load
flash_load   .word api_load
   .ref    api_run
flash_run   .word api_run
    .ref    api_size
flash_size  .word api_size

     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
      bx     lr

    .endasmfunc

I have found that the watchdog flag is reset upon entering this RAM copying function.

I'm checking the watchdog flag in the SYS_EXCEPTION register (addr 0xFFFFFFE4). When I trigger a watchdog reset, the flag is set correctly prior to this stmdaeq function.

Then when I step pass flash_run, the watchdog flag is cleared.

why is this happening?

  • Hello,

    You need to define api_load, api_run, and api_size in linker.cmd file.

    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)

  • Thanks for the response. They are defined already with this:

    SECTIONS
    {
       .intvecs : {} > VECTORS
       flashAPI :
       {
         Fapi_UserDefinedFunctions.obj (.text)
         bl_flash.obj (.text)
    
         --library= F021_API_CortexR4_BE.lib < FlashStateMachine.IssueFsmCommand.obj
         									  FlashStateMachine.SetActiveBank.obj
         									  FlashStateMachine.InitializeFlashBanks.obj
         									  FlashStateMachine.EnableMainSectors.obj
         									  FlashStateMachine.IssueFsmCommand.obj
         									  FlashStateMachine.ScaleFclk.obj
                                              Init.obj
                                              Utilities.CalculateEcc.obj
                                              Utilities.WaitDelay.obj
                                              Utilities.CalculateFletcher.obj
                                              Read.MarginByByte.obj
                                              Read.Common.obj
                                              Read.FlushPipeline.obj
         									  Read.WdService.obj
                                              Async.WithAddress.obj
                                              Program.obj > (.text)
       } load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)
    

    This does function correctly as far as my reading/writing to flash. Is there something wrong how I'm doing it?

  • Hello,

    It is correct. 

    You can try memcpy to copy flash APIs to SRAM:

    extern unsigned int api_load;

    extern unsigned int api_run;

    extern unsigned int api_size;

    main(){

         memcpy(&api_run, &api_load, (uint32)&api_size);

         .....

    }