Error on array initialisation

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I using external SDRAM on EVK1100 and I have problem when try to initialize array as :

__attribute__((__section__(".data_sdram"))) static U16 array[2] = {1,2};

and

__attribute__((__section__(".data_sdram"))) static U16 var = 1;

working well.

I have thinking about a compiler option problem and try :

static U16 array[2] = {1,2};

by using internal SRAM, working well.

Then, may be there is something to add in the linker script but I don't know what. My script right now is :

MEMORY
{
    [...]
    SDRAM (wxa!ri) : ORIGIN = 0xD0000000, LENGTH = 0x02000000
}
PHDRS
{
    [...]
    SDRAM_AT_FLASH PT_LOAD;
    SDRAM PT_NULL;
}
SECTION
{
    [...]
    . = ORIGIN(SDRAM);
    .data_sdram     ORIGIN(SDRAM) :
    {
     PROVIDE(_data_sdram = .);
     *(.data_sdram)
     . = ALIGN(8);
     PROVIDE(_edata_sdram = .);
    } >SDRAM AT>SDRAM :SDRAM_AT_FLASH

    PROVIDE(_data_sdram_lma = ABSOLUTE(LOADADDR(.data_sdram)));
    [...]
}

If somebody have an idea ... I'm not blocked as I can use the internal SRAM but I prefer using SDRAM for all variables.

cpu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
If somebody have an idea ... I'm not blocked as I can use the internal SRAM but I prefer using SDRAM for all variables.
Sure about that, it will kill some performance? I would store often accessed variables and the stack in internal RAM, and use the external RAM for buffers and heap.

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi hce,

As I haven't performance problem, I have all variables in SDRAM but let the heap and stack in SRAM. It's enough fast for my use. In addition, arrays are temporary buffers as huge matrix hard coded. :(
Hope later this will be changed ...

cpu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not actually helping you to solve your issue, but are the matrices constant variables? Or do you perform calculations on them?

If they are read-only you could keep them in flash, just add the "const" word when defining the variables.

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In fact, arrays are really temporary, then after I put matrix as const in NVRAM in the initialization phase.

Just I need a system to fill matrix hard coded and then put them in NVRAM where access will be only read.

Thanks for your help, but I think I will let array in SRAM, statical in a function as I will retrieves my complete SRAM after this init phase.

cpu