DSPRelated.com
Forums

Declare large array in SDRAM

Started by niwd...@yahoo.com.hk March 19, 2007
Hi

I am using C6713 and need to declare a large 2D array, about 300 x 400 Uint32. How can I declare this array in SDRAM or other space which can store it, instead of internal ram?

Thank you for any help on this simple question !
I'm assuming that in C you are declaring this array similar to:

unsigned int LargeArray[300][400];

Do you have a linker command file with both a memory and a sections
portion?

I program in C++ and regularly use the #pragma
DATA_SECTION(".mydatasectionname") command before global variables to
declare what section they will get placed in.

The string .mydatasectionname is declared in the SECTIONS portion of my
linker file, and told witch memory location it will be placed into.
Here's a slightly modified example from my linker file.

MEMORY
{
L2RAM : org = 0x00003800, len = 0x0002C800
CACHE : org = 0x00030000, len = 0x00010000
SRAM : org = 0x80000000, len = 0x00100000
}

SECTIONS
{
.stack > L2RAM
.iram > L2RAM
{
-lrts6700.lib (.far)
-lcsl6713.lib (.far)
-lfastmath67x.lib
}
.l2ram > L2RAM
.cio > L2RAM
.switch > L2RAM /* The .switch section contains tables for
large switch statements. */
.pinit > L2RAM /* Table of Global Object Constructors. See
below for full description */
.data > L2RAM /* .data is not used by the C compiler */
.bss > L2RAM /* The .bss section reserves space for global and
static variables. When you specify the -c linker option, at program
startup, the C/C++ boot routine copies data out of the .cinit section
(which can be in ROM) it in the .bss section. The compiler defines the
global symbol $bss and assigns $bss the value of the starting address of
the .bss section. */
.far >> L2RAM | SRAM /* The .far section reserves space for
global and static variables that are declared far. */
.text >> L2RAM | SRAM /* Use the >> operator to indicate that an
output section can be split, if necessary, into the specified memory
ranges. */
.cinit > SRAM /* The .cinit section contains tables for
initializing variables and constants. I believe that this is only the
values that are used to initialize things at startup, and so are not
needed during runtime. */
.const > SRAM /* The .const section contains string literals,
floating-point constants, and data defined with the C/C++ qualifier
const (provided the constant is not also defined as volatile). */
.sysmem > SRAM /* The .sysmem section reserves space for
dynamic memory allocation. The reserved space is used by the malloc,
calloc, and realloc functions. If a C/C++ program does not use these
functions, the compiler does not create the .sysmem section. */
.mydatasectionname > SRAM
}

n...@yahoo.com.hk wrote:
> Hi
>
> I am using C6713 and need to declare a large 2D array, about 300 x 400 Uint32. How can I declare this array in SDRAM or other space which can store it, instead of internal ram?
>
> Thank you for any help on this simple question !
>
>
Thanks a lot!! I do not have the linker file, these things are done by the DSP/BIOS by default. Because I really not familiar with this!

Refer to your code, I have created the "linker.cmd" file and simply put the following code into the file:

SECTIONS
{
.mydata > SDRAM
}

I did not define the other sessions in the linker file because contridiction error occured when compile the program.

In the C file, I defined the array in this way:

#pragma DATA_SECTION(src,".mydata")
Uint32 src[M][N];

The array can be allocated in SDRAM now and the data seems correct, but I have not tested it with my application since the EDMA part is not ready. And I am not sure wheather my code is correct, is there any potential error? Many thanks!!

I'm assuming that in C you are declaring this array similar to:
>
>unsigned int LargeArray[300][400];
>
>Do you have a linker command file with both a memory and a sections
>portion?
>
>I program in C++ and regularly use the #pragma
>DATA_SECTION(".mydatasectionname") command before global variables to
>declare what section they will get placed in.
>
>The string .mydatasectionname is declared in the SECTIONS portion of my
>linker file, and told witch memory location it will be placed into.
>Here's a slightly modified example from my linker file.
>
>MEMORY
>{
> L2RAM : org = 0x00003800, len = 0x0002C800
> CACHE : org = 0x00030000, len = 0x00010000
> SRAM : org = 0x80000000, len = 0x00100000
>}
>
>SECTIONS
>{
> .stack > L2RAM
> .iram > L2RAM
> {
> -lrts6700.lib (.far)
> -lcsl6713.lib (.far)
> -lfastmath67x.lib
> }
> .l2ram > L2RAM
> .cio > L2RAM
> .switch > L2RAM /* The .switch section contains tables for
>large switch statements. */
> .pinit > L2RAM /* Table of Global Object Constructors. See
>below for full description */
> .data > L2RAM /* .data is not used by the C compiler */
> .bss > L2RAM /* The .bss section reserves space for global and
>static variables. When you specify the -c linker option, at program
>startup, the C/C++ boot routine copies data out of the .cinit section
>(which can be in ROM) it in the .bss section. The compiler defines the
>global symbol $bss and assigns $bss the value of the starting address of
>the .bss section. */
> .far > > L2RAM | SRAM /* The .far section reserves space for
>global and static variables that are declared far. */
> .text > > L2RAM | SRAM /* Use the > > operator to indicate that an
>output section can be split, if necessary, into the specified memory
>ranges. */
> .cinit > SRAM /* The .cinit section contains tables for
>initializing variables and constants. I believe that this is only the
>values that are used to initialize things at startup, and so are not
>needed during runtime. */
> .const > SRAM /* The .const section contains string literals,
>floating-point constants, and data defined with the C/C++ qualifier
>const (provided the constant is not also defined as volatile). */
> .sysmem > SRAM /* The .sysmem section reserves space for
>dynamic memory allocation. The reserved space is used by the malloc,
>calloc, and realloc functions. If a C/C++ program does not use these
>functions, the compiler does not create the .sysmem section. */
> .mydatasectionname > SRAM
>}
>
>n...@yahoo.com.hk wrote:
>> Hi
>>
>> I am using C6713 and need to declare a large 2D array, about 300 x 400 Uint32. How can I declare this array in SDRAM or other space which can store it, instead of internal ram?
>>
>> Thank you for any help on this simple question !
Edwin-

> Thanks a lot!! I do not have the linker file, these things are done by the
> DSP/BIOS by default. Because I really not familiar with this!
>
> Refer to your code, I have created the "linker.cmd" file and simply put
> the following code into the file:
>
> SECTIONS
> {
> .mydata > SDRAM
> }
>
> I did not define the other sessions in the linker file because contridiction
> error occured when compile the program.
>
> In the C file, I defined the array in this way:
>
> #pragma DATA_SECTION(src,".mydata")
> Uint32 src[M][N];
>
> The array can be allocated in SDRAM now and the data seems correct, but I
> have not tested it with my application since the EDMA part is not ready.
> And I am not sure wheather my code is correct, is there any potential
> error? Many thanks!!

The above steps look good. Next you might make sure you can enable L2 cache and
verify that your code can read/write data from the array. Then work on adding EDMA.

-Jeff
> I'm assuming that in C you are declaring this array similar to:
> >
> >unsigned int LargeArray[300][400];
> >
> >Do you have a linker command file with both a memory and a sections
> >portion?
> >
> >I program in C++ and regularly use the #pragma
> >DATA_SECTION(".mydatasectionname") command before global variables to
> >declare what section they will get placed in.
> >
> >The string .mydatasectionname is declared in the SECTIONS portion of my
> >linker file, and told witch memory location it will be placed into.
> >Here's a slightly modified example from my linker file.
> >
> >MEMORY
> >{
> > L2RAM : org = 0x00003800, len = 0x0002C800
> > CACHE : org = 0x00030000, len = 0x00010000
> > SRAM : org = 0x80000000, len = 0x00100000
> >}
> >
> >SECTIONS
> >{
> > .stack > L2RAM
> > .iram > L2RAM
> > {
> > -lrts6700.lib (.far)
> > -lcsl6713.lib (.far)
> > -lfastmath67x.lib
> > }
> > .l2ram > L2RAM
> > .cio > L2RAM
> > .switch > L2RAM /* The .switch section contains tables for
> >large switch statements. */
> > .pinit > L2RAM /* Table of Global Object Constructors. See
> >below for full description */
> > .data > L2RAM /* .data is not used by the C compiler */
> > .bss > L2RAM /* The .bss section reserves space for global and
> >static variables. When you specify the -c linker option, at program
> >startup, the C/C++ boot routine copies data out of the .cinit section
> >(which can be in ROM) it in the .bss section. The compiler defines the
> >global symbol $bss and assigns $bss the value of the starting address of
> >the .bss section. */
> > .far > > L2RAM | SRAM /* The .far section reserves space for
> >global and static variables that are declared far. */
> > .text > > L2RAM | SRAM /* Use the > > operator to indicate that an
> >output section can be split, if necessary, into the specified memory
> >ranges. */
> > .cinit > SRAM /* The .cinit section contains tables for
> >initializing variables and constants. I believe that this is only the
> >values that are used to initialize things at startup, and so are not
> >needed during runtime. */
> > .const > SRAM /* The .const section contains string literals,
> >floating-point constants, and data defined with the C/C++ qualifier
> >const (provided the constant is not also defined as volatile). */
> > .sysmem > SRAM /* The .sysmem section reserves space for
> >dynamic memory allocation. The reserved space is used by the malloc,
> >calloc, and realloc functions. If a C/C++ program does not use these
> >functions, the compiler does not create the .sysmem section. */
> > .mydatasectionname > SRAM
> >}
> >
> >n...@yahoo.com.hk wrote:
> >> Hi
> >>
> >> I am using C6713 and need to declare a large 2D array, about 300 x 400 Uint32. How can I declare this array in SDRAM or other space which can store it, instead of internal ram?
> >>
> >> Thank you for any help on this simple question !