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.

RM46L852: copying data from flash to RAM at runtime

Part Number: RM46L852

We have defined memory section in linker file,

SECTION

{

.Data : palign=8 load = FLASH0


LOAD_START (__DATA_START_ROM),
LOAD_END (__DATA_END_ROM),
LOAD_SIZE (__DATA_SIZE_ROM),
run = RAM,PAGE= 0
RUN_START (__DATA_START),
RUN_END (__DATA_END),
RUN_SIZE (__DATA_SIZE),
table(BINIT)

}

I check in .map file,  CCS linker allocate the Memory. But i want to copy data from load address to its run address at runtime. I tried below code to use that

in Main.c file

extern unsigned int _DATA_START_ROM;
extern unsigned int _DATA_SIZE_ROM;
extern unsigned int _DATA_START;

 memcpy(& DATA_START , &DATA_START_ROM,(uint32_t )&DATA_SIZE_ROM);

but, CCS issues error undefined symbol. like DATA_SIZE_ROM, DATA_START_ROM,DATA_START. Please guide us .

  • Hello Pramod,

    Can you try to copy the section using the assembly code. This is my example code:

    .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

    And the section definition in 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)

    .text > FLASH0
    .const > FLASH0
    .cinit > FLASH0
    .pinit > FLASH0
    .data > SRAM
    .bss > SRAM
    }

  • QJ,

    i tried to implement the copy function in assembly language by defining the LOAD and Run symbol but still facing the same issue. while compiling still CCS through the "illegal mnemonic" error. 

    can you please comment, what is purpose behind suggesting the assembly coding?

  • QJ,

    i tried in C language and its working now. its my mistake in code.

    thanks for your help.