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.

Place text section into RAM



I would like to execute "text" section in RAM on Hercules MCU(LS12).

For example,I changed the linker command file(.cmd) from :

/*----------------------------------------------------------------------------*/
/* Linker Settings                                                            */
--retain="*(.intvecs)"

/*----------------------------------------------------------------------------*/
/* Memory Map                                                                 */
MEMORY{
    VECTORS (X)  : origin=0x00000000 length=0x00000020
    FLASH0  (RX) : origin=0x00000020 length=0x0013FFE0
    STACKS  (RW) : origin=0x08000000 length=0x00001300
    RAM     (RW) : origin=0x08001300 length=0x0002ED00
}

/*----------------------------------------------------------------------------*/
/* Section Configuration                                                      */
SECTIONS{
    .intvecs : {} > VECTORS
    .text    : {} > FLASH0
    .const   : {} > FLASH0
    .cinit   : {} > FLASH0
    .pinit   : {} > FLASH0
    .bss     : {} > RAM
    .data    : {} > RAM

/* USER CODE BEGIN (1) */
    .constdata   : {} > FLASH0
/* USER CODE END */
}
/*----------------------------------------------------------------------------*/

to :

/*----------------------------------------------------------------------------*/
/* Linker Settings                                                            */
--retain="*(.intvecs)"

/*----------------------------------------------------------------------------*/
/* Memory Map                                                                 */
MEMORY{
    VECTORS (X)  : origin=0x00000000 length=0x00000020
    FLASH0  (RX) : origin=0x00000020 length=0x0013FFE0
    STACKS  (RW) : origin=0x08000000 length=0x00001300
    RAM     (RW) : origin=0x08001300 length=0x0002ED00
}

/*----------------------------------------------------------------------------*/
/* Section Configuration                                                      */
SECTIONS{
    .intvecs : {} > VECTORS
    .text    : {} > RAM
    .const   : {} > FLASH0
    .cinit   : {} > FLASH0
    .pinit   : {} > FLASH0
    .bss     : {} > RAM
    .data    : {} > RAM

/* USER CODE BEGIN (1) */
    .constdata   : {} > FLASH0
/* USER CODE END */
}
/*----------------------------------------------------------------------------*/

but an error occured on CCS.

The error message is :

"../TMS570LS122xFlashLnk.cmd", line 27: error #10099-D: program will not fit

   into available memory.  placement with alignment fails for section
   ".intvecs" size 0x20 .  Available memory ranges:
   VECTORS      size: 0x20         unused: 0x20         max hole: 0x20     
error #10010: errors encountered during linking;

Is there any way to change the linker command file with another method,

or is there any "copy text section from flash to ram before execution" method

(I'd see about this issue on TI community) ?

I'll appriciate if someone would reply to my question.

Regards,

Hiroyasu

  • Hiroyasu,

    Apparently your code (.text) is too big to fit in RAM.
    To be sure that it is the problem, can you use the original linker command file (using flash for .text) and look in the .map file how much flash is used. If it is more than the RAM available in this device than you can do it.

    Please can you share the .map file so I can have a look?

    Let me know your finding.

  • Jean-Marc,

    Thank you for your reply.

    The size of text section is "not" too bit to fit it to ram.

    The size of text section is 6472 (in hex),and unused ram area length is 2cf60(in hex).

    Sorry,I would like to know how to copy the text section from flash to ram and execute text section in ram.

    (Because,I would like to be the text section to remain in the flash area( wouldn't be cleared if the power supply

    would be finished.)

    There is any way to copy the text section from flash to ram and execute it in ram,

    and I read some post about this issue,but I could'nt understand yet.

    Could anyone tell me , for example,how to modify the linker command file, or modify the c code to load

    the text section from flash to ram?

    Regards,

    Hiroyasu.

  • Hello Hiroyasu,

    maybe you can find some inspiration in following forum threads:

    http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/147475/594932.aspx#594932

    http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/210010/744998.aspx#744998

    http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/195611/700678.aspx

    Good luck and best regards,

    Jiri

  • "../TMS570LS122xFlashLnk.cmd", line 27: error #10099-D: program will not fit

       into available memory.  placement with alignment fails for section
       ".intvecs" size 0x20 .  Available memory ranges:
       VECTORS      size: 0x20         unused: 0x20         max hole: 0x20     
    error #10010: errors encountered during linking;

    I have found when I see this error it is because one of the abort or interrupt handlers is compiled into Thumb code and the linker needs to add a veneer function to call the Thumb handler.  But it does not tell you about the extra bytes it needs for the veneer.  Which is why it looks like it should fit but it does not. 

  • Hello jiri,

    Thank you for you reply.

    I did two things by reading the sites you introduced.

    1.modified the linker command to "run on RAM,load to Flash".

    2.copy the codes from Flash to Ram.

    I expected that the execution would be faster by executing on RAM,but the result is , the execution time

    is the same as when the code was executed on Flash.

    ( The codes are executed in Interrupt routine.)

    Did I fail to place code to RAM ?

    Should I do other things to execute codes on RAM ?

    Could anyone tell me what should I do ?

    I'll appriciate if someone could reply to my question.

    Hiroyasu

  • Hello Hiroyasu,

    your measurement is probably correct. Code execution time is almost identical  for both manners - running from flash or RAM. Yes, there are some presumptions to be configured in the flash controller as an activated pipeline, proper wait state timing, etc.

    During your development phase it can be useful to run code from RAM - at least aster code upload (via JTAG or program loader) and reduced erase/write cycles of flash memory.

    But I mean that code for production series should run from flash - maybe except Flash API library code (obviously flash library code must be executed from RAM or from a flash bank which is not just being erased and programmed). 

    In the end, if you compare a size of flash and RAM embedded in the TMS570 devices there is no doubt where the code should be located ;-)

    Best regards,

    Jiri

  • Hello Jean-Mark,

    I attached the .map file.1581.TMS570LS1227_instaspin_bldc.zip

    The .map file is compressed ( zip format).

    I'm sorry to be late for update it.

    Regards,

    Hiroyasu