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.

Memory allocation

Hi,

I begin to develop with dsp and I have some problems with memory allocation. I have written simple program like this one

void main ( void )

{

unsigned char Tab[400];

Tab[0]   = 1;

return ;

}

I compile and load this program on a developement board C6211. I look for the Tab addres and it is created in 0xCxxxxxxx part of the memory. When I try to load data in memory (CCS --> File/Data/Load) my file is rapidely loaded but when I check the content of memory at the load address (View\Memory) memory is empty ( 0x00000000). I'm able to load sucessfully the same file in other memory part (example at 0xB00, but I think it is program memory ). I think my data memory address is set to 0x80000000 in the .cmd file. I'm able to load my file at this address. Why my variable is not created in the data memory part? Where can I find more information about memory allocation and memory parts?

 

Thank you

  • Welcome to the world of DSP. The first program is always a fun learning curve, so I applaud you for starting with something simple like this, which is slightly easier than a "Hello, world!" app.

    You will have a Technical Reference document for your C6211 development board; usually it comes on the CD with the board, or you can get it from the board vendor's website. This will tell you about any external memory resources, what addresses they are mapped to and what size they are. Any external memories will be available for both program and data space.

    The datasheet for the C6211 will tell you exactly what internal memory resources are available. These are also shared between program and data.

    If you use DSP/BIOS, you will use a pre-built template or create your own, but will need to make sure the memory devices are described correctly within the DSP/BIOS GUI. If you are not using DSP/BIOS, then you will supply your own linker cmd file that specifies the MEMORY regions you have available to you.

    The fact that your Tab address is in reserved space (0xCxxxxxxx) means that the linker cmd file is not correct for your chip and board. This could also be the reason your program is not showing up.

    If changing your cmd file fixes everything, that will be great. If not, please include the exact board identification plus your CCS version, CodeGen tools version, and DSP/BIOS version.

  • Thank you for your awnser. I will try this.

  • I have found the the memory map for the C6211 board.

     

    I use this .cmd file mostly from a TI example.

    -c
    -heap  0x500
    -stack 0x500 /* very large stack for DSP programs. */
    -lrts6200.lib
     
    MEMORY
    {
        vecs:       o = 00000000h   l = 00000200h
        I_HS_MEM:   o = 00000200h   l = 00000020h
        IRAM:       o = 00000220h   l = 0000FDE0h                          
        CE0:         o = 80000000h    l = 01000000h
    }

    SECTIONS
    {
        "vectors"   >       vecs
        my_DataSect >       I_HS_MEM
        .cinit      >       IRAM
        .text       >       IRAM
        .stack      >       IRAM
        .bss        >       IRAM
        .const      >       IRAM
        .data       >       IRAM
        .far        >       IRAM
        .switch     >       IRAM
        .sysmem     >       CEO
        .tables     >       IRAM
        .cio        >       IRAM
    }

     

    I have changed the .sysmem from IRAM to CEO. I have change that because I would like the system allocate the memory in the External RAM.

    The linker gives me this error

    warning: can't find a memory area named 'CEO' on page 0 for allocation of
                '.sysmem'
    >>   error: can't find any memory areas for allocation of '.sysmem'
    >>   error: can't allocate '.sysmem' into 'CEO' (page 0)
    >>   error: errors in input - ./Debug/P3.out not built

     

  • The memory declaration is not CEO (as in the letter O), but CE0 (as in the number zero).

    Please modify your linker command file to the following for allocating .sysmem.

        .sysmem     >       CE0

  • I corrected my little problem ( CEO --> CE0 ). If I change sysmem my vector (Tab) is alaways allocated at 0x00000D00. If I change .stack --> CE0 it is ok and Tab is allocated in the 0x80000000 range. But the problem is resolve only for small vector. (around 1500 unsigned char ) When I try to allocate a larger vector like 16384 unsigned char the vector is allocated at 0x7FFFFB54. Why it is not allocated in the 0x80000000 range?

     

    thank you

  • You also mentioned in your original post where you could find out more about the sections, etc.  You can obtain this information in the TMS320C6000 Optimizing Compiler v6.1 User's Guide (SPRU187) which is appropriate for the C62xx devices.
    Specifically, I would recommend Chapter 7 on the Run Time Environment.

    Something that would help clarify what is being included in the various sections is selecting the option in the Build options to generate a mapfile.  If you use the Project Build Options, on the Linker tab there should be an option to generate a mapfile.
    This is an ASCII text file which provides information regarding how the linker allocated memory, where it placed sections and generally what is included in those sections.

    EDIT : As you noted, the vector Tab[] would be allocated to the stack.  However, in your linker command file, you are only specifying a stack size of 0x500.  When you Tab[] vector is of size 16384, it is too large for the stack.  The Stack Pointer starts at the end of the stack (higher memory address).  When main() attempts to index Tab[0], it would have to substract 16384 from the Stack Pointer which places it into reserved memory below 0x80000000.