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.

TMS570LS1114: How to copy the flash code into ram in order to operate the read and write data based on TMS570LS1114?

Part Number: TMS570LS1114

I want to copy the flash code into the ram ,but I am not familiar with the steps,could you give me some advice about how to achive my goal?

Qiuchi

2017/12/29

  • Hello Qiu,

    1. Define the memory location for flash API in cmd file

    For example:  FLASH_API  (RX)  : origin=0x00000020 length=0x000014E0

    2. Define the section for flash API in cmd file

    For example: 

    /* creates an output section named flashAPI */
    /* Load the code to FLASH_API (defined in memory{} */
    /* Run the code in SRAM */
    /* The value of the symbol api_load is the starting load address */
    /* The value of api_run is the starting run address */
    flashAPI :
    {
      Fapi_UserDefinedFunctions.obj (.text)
      flash_operation.obj (.text)          /* your flash erase/program/read etc obj files*/
      --library= ..\..\..\lib\F021_API_CortexR4_BE.lib (.text)  
    } load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)

    3. Define a function to copy flashAPI section to SRAM (assembly code)

    For example:

    ;-------------------------------------------------------------------------------
    ;
    ; 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

    3. Call the function in your main() 

    For example:

    _copyAPI2RAM_();

        

  • Hello QJ Wang:
    I'm so glad to receive your answer to resolve my questions,but I still have a trouble about how to add a asm file into my project.My step is te following:
    1.in the cmd,add the instroctions,"
    SECTIONS
    {
    .intvecs : {} > VECTORS
    .text : {} > FLASH0
    .const : {} > FLASH0
    .cinit : {} > FLASH0
    .pinit : {} > FLASH0
    .calRom : {} > CAL_ROM
    .bss : {} > RAM
    .data : {} > RAM
    .sysmem : {} > RAM
    .calRam : {} > CAL_RAM
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    }

    calRom_API:
    {
    Fapi_UserDefinedFunctions.obj (.text)
    FLASH.obj(.text) //your flash erase/program/read etc obj files
    --library=..\..\lib\F021_API_CortexR4_BE.lib (.text)
    }
    load=calRom,run=RAM,LOAD_START(api_load),RUN_START(api_run), SIZE(api_size)
    "
    2.add the example code into my project.I want to explain if the assembly code include a header file and a asm file?
  • flash_load.word api_load
    flash_run.word api_run
    flash_size.word api_size
    These code is unsigned int?
  • Hello,

    In you cmd file, the section calRom_API should be placed in CAL_ROM rather than another section calRom.

    In the copyAPI2RAM assembly function:
    1. add apace between "flash_load" and ".word"
    2. add apace between "flash_run" and ".word"
    3. add apace between "flash_size" and ".word"
  • Sorry ,QJ .This topic have been solved ,but I forget check its state.