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.

Compiler/LAUNCHXL-F28379D: Load at One Address, Run from a Different Address problem

Part Number: LAUNCHXL-F28379D

Tool/software: TI C/C++ Compiler

I want to place some code to RAM, because it works faster them from flash.

I use this code in interrupt.

void target_func __attribute__((ramfunc)) (void); works ok, but it is only 2k from RAMLS0, and if I have a bit more code linker says:

"./lnk.cmd", line 48: error #10099-D: program will not fit into available memory. placement with alignment fails for section ".text" size 0x2b12 . Available memory ranges: FLASH size: 0x1000 unused: 0xe56 max hole: 0xe56

even if I have "RUN = RAMLS0 | RAMLS1 | RAMLS3"

#ifdef __TI_COMPILER_VERSION__
   #if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc : {} LOAD = FLASHD,
                         RUN = RAMLS0 | RAMLS1 | RAMLS3,
                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_SIZE(_RamfuncsLoadSize),
                         LOAD_END(_RamfuncsLoadEnd),
                         RUN_START(_RamfuncsRunStart),
                         RUN_SIZE(_RamfuncsRunSize),
                         RUN_END(_RamfuncsRunEnd),
                         PAGE = 0, ALIGN(4)
   #else
   ramfuncs            : LOAD = FLASHD,
                         RUN = RAMLS0 | RAMLS1 | RAMLS3,
                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_SIZE(_RamfuncsLoadSize),
                         LOAD_END(_RamfuncsLoadEnd),
                         RUN_START(_RamfuncsRunStart),
                         RUN_SIZE(_RamfuncsRunSize),
                         RUN_END(_RamfuncsRunEnd),
                         PAGE = 0, ALIGN(4)   
   #endif

so, I want to do own section:

    .coderam :    LOAD = FLASHE,
                  RUN = RAMLS2,
                 LOAD_START(_codeRamLoadStart),
                   LOAD_SIZE(_codeRamLoadSize),
                   LOAD_END(_codeRamLoadEnd),
                   RUN_START(_codeRamRunStart),
                   RUN_SIZE(_codeRamRunSize),
                  RUN_END(_codeRamRunEnd),
                PAGE = 0, ALIGN(4)

and using with void target_func __attribute__((section(".coderam"))) (void);

But it crushes when executing and falls into ILLEGAL_ISR()

  • Ok, I found the solution here: ii.pw.edu.pl/.../spra958h.pdf

    (SPRA958H Running an Application from Internal Flash Memory on the TMS320F28xxx DSP   4.4 )

    "Finally, the section must be copied from flash to RAM at runtime. As in Sections 4.1 - 4.3, the function memcpy() from the compiler runtime support library can be used"

    I've add

    memcpy(&codeRamfuncsRunStart, &codeRamfuncsLoadStart, (size_t)&codeRamfuncsLoadSize); to InitSysCtrl() in F2837xD_SysCtrl.c

    and

    extern Uint16 codeRamfuncsLoadStart;
    extern Uint16 codeRamfuncsLoadEnd;
    extern Uint16 codeRamfuncsLoadSize;
    extern Uint16 codeRamfuncsRunStart;
    extern Uint16 codeRamfuncsRunEnd;
    extern Uint16 codeRamfuncsRunSize;

    in device.h and also in F2837xD_GlobalPrototypes.h

    Pay attention "codeRa....." are without "_" byt in .cmd - with.