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.

Problems with .cmd file - move code to internal RAM

Genius 5820 points


Hi,

I have some troubles with my .cmd-file (Sitara CPU using StarterWare). I want to move a C-function and may be later some variables to internal RAM of the CPU. Thus I modified my .cmd- file as follows:

GROUP
{
     IRAM_CODE : { }
     IRAM_DATA : { }
}load=DDR_MEM, run=INT_MEM, START(iram_start), SIZE(iram_size), RUN_START(relocstart)
 
.text:DMTimerIsr : load > IRAM_CODE

IRAM_CODE points to start address of internal RAM which has a size of 0xFFFF. DMTimerIsr is the function I want to relocate. The whole thing fails during compilation with a warning

#10097 memory range not found: gpioLEDBlink.cmd /gpioLEDBlink line 87

and an error

#10099-D program will not fit into gpioLEDBlink.cmd /gpioLEDBlink line 87

for line

.text:DMTimerIsr : load > IRAM_CODE

So...what is wrong here? DMTimerIsr is smaller than 0xFFFF bytes (as well as the whole application). And where should iram_start, iram_size and relocstart be defined to specify the correct size of internal RAM? The StarterWare demo-application I have taken this example from does not define values for both...

Thanks!


  • I can explain what is wrong with ...

    Hans M��ller said:
    .text:DMTimerIsr : load > IRAM_CODE

    But I don't think that will help you.  There is probably a way to solve your problem designed into StarterWare.  Since I am not an expert on StartWare, I cannot tell you what that is.  I highly recommend you start another thread in the StarterWare forum asking about the best way to place a function in internal memory .

    Not because I think it is useful, but because I know curious readers are out there, here is what is wrong with ...

    Hans M��ller said:
    .text:DMTimerIsr : load > IRAM_CODE

    Bottom line: IRAM_CODE is not the name of a range of memory, but the name of an output section.  This line says create an output section named .text:DMTimerIsr.  The input sections which make up that output section are all the input sections with the name .text:DMTimerIsr.  It is most likely that there is only one such input section, and it contains the code for the function DMTimerIsr.  The load and run allocation for this output section is the same.  It tries to allocate to a memory range named IRAM_CODE, but there is no memory range with that name, thus the linker complains ...

    Hans M��ller said:
    #10097 memory range not found: gpioLEDBlink.cmd /gpioLEDBlink line 87

    I don't precisely know why this diagnostic appears ...

    Hans M��ller said:
    #10099-D program will not fit into gpioLEDBlink.cmd /gpioLEDBlink line 87

    But it doesn't seem surprising, given the earlier error.

    Thanks and regards,

    -George

  • Hi George, 

     

    George Mock said:

    But I don't think that will help you.  There is probably a way to solve your problem designed into StarterWare.  Since I am not an expert on StartWare, I cannot tell you what that is.  I highly recommend you start another thread in the StarterWare forum asking about the best way to place a function in internal memory .

     

    There is already such a thread at http://e2e.ti.com/support/embedded/starterware/f/790/p/303872/1062665.aspx#1062665 but with no answers...

     

    George Mock said:
     

    Bottom line: IRAM_CODE is not the name of a range of memory, but the name of an output section.

     

     

    OK, so I changed this line to

        .text:DMTimerIsr : load > 0x40300000

    where 0x40300000 is the starting address of the internal RAM. When I look into the resulting .out (ELF) file, DMTimerIsr is still at 0x80006348 (which is in DDR-RAM) but that may be OK since there is a call

        memcpy((void *)(&relocstart), (const void *)(&iram_start),(unsigned int)(&iram_size));

    which should do the code relocation. Unfortunately this does not work, the board does not start up.

    So any other helpful ideas? Or is there at least a documentation available somewhere that describes the syntax of the linker command file?

    Thanks!

     

  • The other forum thread says this ...

    Please refer the files slpWkup_gcc.S and demo.lds of demo project  which demonstrate the relocation of function saveRestoreContext() to internal memory.

    Please attach those two files to your next post.  I might be able to understand what is going on and give you useful advice.

    Thanks and regards,

    -George

  • Hi George,

    unfortunately the upload function in this webboard does not allow files with extenstion .lds or .cmd, this I used pastebin for that...

    The other thread pointed me to the GCC-examples while I'm using the TI-compiler. So find the following files for GCC here:

    - demo.lds: http://pastebin.com/xx0JFbV4

    - slpWkup_gcc.S: http://pastebin.com/uNb1g94k

    - demo.cmd (the same thing for TI-compiler): http://pastebin.com/i66A6rJ0

    - demoMain.c which might be interesting too since it performs relocation and uses the variables iram_start, iram_size and relocstart as defined in .CMD-file: http://pastebin.com/20V85R56

    Original examples use a statement

    .section IRAM_CODE, "ax"      @ a - Allocatable, x - Executable

    in assembler code in order to specify this codes position. Since ".section" can't be used in C-code I extended my .CMD-file with

    .text:DMTimerIsr : load > 0x40300000

    Thanks for your help!

  • Unfortunately, the TI web filters do not allow me access to pastebin.com.  I'm pretty sure you can attach a .zip file.  Please collect those files into a zip and attach that.

    Hans M��ller said:
    The other thread pointed me to the GCC-examples while I'm using the TI-compiler.

    I can help with the TI compiler, or the Linaro gcc compiler that comes with CCS 5.5.  I suspect they mean some other gcc compiler, and I cannot help you with that.

    Hans M��ller said:

    Original examples use a statement

    .section IRAM_CODE, "ax"      @ a - Allocatable, x - Executable

    in assembler code in order to specify this codes position. Since ".section" can't be used in C-code I extended my .CMD-file with

    .text:DMTimerIsr : load > 0x40300000

    That .section directive is GNU assembly syntax which says the following instructions are to be placed in a section named IRAM_CODE.  Is this being used to place the function DMTimerIsr in the section IRAM_CODE?  If so, the way to do this in C with the TI compiler is the #pragma CODE_SECTION.  Read about that pragma in the TI ARM compiler manual.  If you use this pragma, then remove the line with .text:DMTimerIsr in the link command file.  This might be the way you are supposed to do it in StarterWare.

    Thanks and regards,

    -George

  • Hi George,

    please find the requested files attached.

    I'll check out that pragma - and thanks for the link to the manual!

    Cheers

    Michael

    demo.zip
  • OK, pragma CODE_SECTION together with my .CMD-file did the trick - thanks!