Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

Accessing FPGA RAM section

Dear all,

how is it possible to tell the linker to place variables in a RAM that is in the FPGA?

I have the following problem: I got a design with 12k RAM on FPGA and in my software project there is a buffer that has to be placed in this RAM. So what I do is:

UINT8 gc_buffer[8][1536] __attribute__ ((section ("int_ram")));

This places the variable into the RAM.

Then the linker complains that:

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc-lib/nios2-elf/3.3.3/../../../../nios2-elf/bin/ld section int_ram [0000621d -> 00006818] overlaps section .text [00000328 -> 00018537]

However in the linker file generated.lx in the syslib I can not find the segment overlap:

MEMORY

{

reset : ORIGIN = 0x01000000, LENGTH = 32

ext_sdram_UNUSED : ORIGIN = 0x00000000, LENGTH = 32

ext_sdram : ORIGIN = 0x00000020, LENGTH = 16777184

ext_flash : ORIGIN = 0x01000020, LENGTH = 8388576

int_ram : ORIGIN = 0x01800000, LENGTH = 12288

}

My question is does anybody have experience and got give me a top tip?

Thanks

nathan

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi nathan,

    Check your linker script file -- it probably isn't assigning the int_ram section

    to a memory region. You need something like the following

    int_ram      : { *(int_ram)    } > int_ram

    > UINT8 gc_buffer[8][1536] __attribute__ ((section ("int_ram")));

    >

    > This places the variable into the RAM.

    This instructs the compiler to put the variable into a section

    named "int_ram", it does not place the variable into a memory region.

    The linker then uses "int_ram" as an input section. If you don't explicitly specify

    an output section in your script, the linker will create an output section of the

    same name.

    Then, if the output section is not assigned to a specific region, the linker will

    attempt to match attributes to locate the output section in an appropriate

    memory region. In your case, it's being located to the same memory region

    as .text & the two address spaces overlap -- so you should also see a

    linker warning indicating that section int_ram isn't assigned to a memory

    region.

    Regards,

    --Scott
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Scott,

    thanks for your reply. I checked whether the section is defined as memory region. And this is true:

    MEMORY

    {

    ...

    int_ram : ORIGIN = 0x00808000, LENGTH = 20480

    ...

    }

    SECTIONS

    {

    ...

    .int_ram :

    {

    PROVIDE (_alt_partition_int_ram_start = ABSOLUTE(.));

    *(.int_ram)

    . = ALIGN(32 / 8);

    PROVIDE (_alt_partition_int_ram_end = ABSOLUTE(.));

    } > int_ram

    ...

    }

    It is very similar to the other memory regions such as SD-RAM and Flash. But I still get the warning that the section int_ram isn't assigned to a memory region.

    The linker script belongs to the syslib project. But I am using this special variable in my application. Could this be a problem?

    Or is there somewhere a checkbox to be ticked or a setting to be made that I forgot?

    Best regards,

    nathan
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hi nathan,

    I believe this is a case of "the missing dot syndrome" ... which has

    bitten me many, many times ;-) Try the following change:

    fm: UINT8 gc_buffer[8][1536] __attribute__ ((section ("int_ram")));

    to: UINT8 gc_buffer[8][1536] __attribute__ ((section (".int_ram")));

    Best Regards,

    --Scott
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Scott

    Thanks for your response! What a silly thing, now it works perfectly! Thanks again.

    Best regards

    nathan