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: ti-cgt-arm_18.12.1.LTS

Tool/software: TI C/C++ Compiler

Hello All, 

I have a question concerning sections (.txt, .data & .bss) allocation in memory:

1) Is there any global definitions or macros that save the start address and the size of each section, so that I can use them in my application ??

2) Where those sections are allocated in (TCMA or TCMB) by default ??

  • The answers to both questions presume some knowledge of the linker command file, which you can get by reading the article Linker Command File Primer.

    Bishoy Michael1 said:
    Is there any global definitions or macros that save the start address and the size of each section, so that I can use them in my application ??

    No such symbols are created automatically.  Please consider these two different methods for solving the problem.  Use whichever method you prefer.

    First method ... Create symbols for each section of interest with linker operators like RUN_START(sym_name1) and RUN_SIZE(sym_name2).  Please search the ARM assembly tools manual for the sub-chapter titled Address and Dimension Operators.  To understand how to use these symbols in your C/C++ code, please search the same manual for the sub-chapter titled Using Linker Symbols in C/C++ Applications.  

    Second method ... The linker command file supports preprocessor symbols like #define SYMBOL_NAME 100.  So, create some symbols in a header file dedicated to this purpose.  Something similar to this ...

    /* memory_definitions.h */
    
    #define RAM_START   0x2000
    #define RAM_SIZE    0x1000
    #define FLASH_START 0x4000
    #define FLASH_SIZE  0x1000
    /* and so on */

    Include memory_definitions.h in both C/C++ code and the linker command file.  Use those preprocessor symbol names as needed.

    Bishoy Michael1 said:
    Where those sections are allocated in (TCMA or TCMB) by default ??

    You can see that in both the linker command file and the linker map file.  In a CCS project, the map file usually has the same name as the name of the project, with the file extension .map.  

    Thanks and regards,

    -George

  • Hello George,

    I will try those two methods & I will give you a feedback.

    But for the second point, the .bss & .txt sections are allocated in the (TCMA, program RAM), I thought that .txt section will be in TCMA, program RAM and .bss will be in TCMB, data RAM, are my thoughts right ?? if not right, what is the function of TCMB ??

    Thanks for your support. 

  • Hello George, 

    For the first method, it is so useful btw, do you know how could I use these symbols in an assembly file ??

    For the second method, does it depend on where I want to allocate the sections in the memory, should I know the values of these macros ??

    Thanks in advance :)

  • Bishoy Michael1 said:
    the .bss & .txt sections are allocated in the (TCMA, program RAM), I thought that .txt section will be in TCMA, program RAM and .bss will be in TCMB, data RAM, are my thoughts right ?? if not right, what is the function of TCMB ??

    Unfortunately, I do not recognize the terms TCMA and TCMB.  I suppose they are different ranges of memory in your system.  When you start a new project in CCS, you tell it which system your program runs on.  This choice, in turn, causes the automatic selection of many project settings.  One of these settings is a linker command file.  I am confident this linker command file has memory ranges named TCMA and TCMB.  Take a look and see.

    Thanks and regards,

    -George

  • Bishoy Michael1 said:
    For the first method, it is so useful btw, do you know how could I use these symbols in an assembly file ??

    They are like any other global symbol.  Just keep in mind that you are interested in the value of the symbol, and not contents of the memory location with that value.

    Bishoy Michael1 said:
    For the second method, does it depend on where I want to allocate the sections in the memory, should I know the values of these macros ??

    As described in my previous post, I presume you already have a linker command file that defines some memory ranges.  I'm suggesting you take the numbers for these existing memory ranges, and create preprocessor symbols with those same numbers.  Then use those preprocessor symbols in both the C code and the linker command file.

    Thanks and regards,

    -George