Forum Discussion

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

How can I allocate a variable to a specific section?

I want a variable to be allocated in the on-chip RAM. I have all sections

(.text, .rodata, .rwdata, .heap, and .stack) in DDR2_SDRAM in the auto-generated linker script.

I define a global variable "rawVideo" as I have seen in many examples:

--- Quote Start ---

int rawVideo __attribute__ ((section (".onchip_ram_100Kbytes.rwdata")));

--- Quote End ---

where the on-chip is specified in the system.h:

onchip_ram_100kbytes_name "/dev/onchip_ram_100kbytes"

Then I copy some data from the flash device to it:

--- Quote Start ---

alt_read_flash( flash, offset, (void*) ( &rawVideo ), size);

--- Quote End ---

but the program execution suspends with error when applying the reading command!

I made sure that the on-chip RAM size fits on the copy.

So am I allocating the variable in a non-existed section or using a wrong syntax?

16 Replies