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.

C28 linker command file



Hello,

 

I have a problem with the CMD linker command file for a C2802x project. In short, I don't know how to align an array to a 0x0100 byte boundary so it can be used as a buffer with circular addressing. I have already read the help files and done some experiments with the cmd files from example projects, but I can't make the array to get aligned properly. These are the relevant parts of the cmd file:

 

in the MEMORY block:

...

PAGE 1 :

   /* For this example, L0 is split between PAGE 0 and PAGE 1 */
   RAMM1       : origin = 0x000480, length = 0x000380     /* on-chip RAM block M1 */
   DRAML0      : origin = 0x008900, length = 0x000700        
   L0L1RAM(RW) : origin = 0x008000, length = 0x800

...

 

in the SECTIONS block:

...

 ddstab   align(0x100)> L0L1RAM  PAGE = 1

...

 

The C source includes a line like this:

//#pragma DATA_SECTION(sintab_fh, "ddstab");

 

Yet, the sintab_fh array lands on address 0x08980, not aligned to 0x0100. There is no error or warning in the build.

This is a test project that I just made to experiment with cmd files, so the rest of the CMD is just that of an example project. The directives habe been copied from an example project from the TI FIR library. In the CCS help files it is not clear at all what precisely is the format of the cmd file so I'm reduced to blind copy-pasting trial and error.

I hope somebody can point me to a good reference on linker command files.

 

Thank you!

 

 

 

  • What is the size of the "ddstab" section? You can create a link map file to view the sizes of the different output sections.

    For some background on what might be happening here: All uninitialized sections created by the F28x compiler are "blocked", and when a section is blocked the linker needs to place it either within a 64-byte page or at a page boundary. Blocking ensures that each variable is fully contained in a page if it is smaller than the page size. If the variable is bigger than the page size, blocking guarantees that it starts at the page boundary. The compiler uses this information to optimize the DP load. For ex, compiler can safely load DP for an array once and access all its elements (or the first 64-bytes) without reloading DP. If blocking is not enabled the compiler has to load DP for accessing each element leading to much more inefficiencies in terms of code size and performance.

    If the size of the "ddstab" section is too large for it to honor the align directive and keep the section "blocked", it might be ignoring it.

    Documentation on linker command files can be found in C28x Assembly Language Tools Users Guide, http://www-s.ti.com/sc/techlit/spru513

  • Are you absolutely sure sintab_fh has address 0x8980?  That address lies outside L0L1RAM, and inside DRAML0.   Check the DATA_SECTION pragma.  Is it commented out as it appears in your quote?  If so, it will have no effect

  • Hello,

     

    Thanks for the link, somehow I missed it. A thorough reading of the documentation has clarified things a lot, as was to be expected :)

    I think you were right; I was trying to put the aligned data struct into a RAM block which was already being used for other data; the aligned block did not fit.

    I'm not 100% sure this is the explaination because I am now using a different approach (I have reserved a whole block for data which is to be accessed from C and assembly code, and fill the block with a single struct).

     

    Thanks, and sorry for taking so long to reply!

  • My mistake!

    I had blindly assumed that the #pragma directive had to be placed within a comment line; a quick look at the online help would have saved me quite a bit of time -- and you too :)

     

    Thank you very much! (and sorry about the long delay in replying)