Forum Discussion
Altera_Forum
Honored Contributor
16 years agoHow 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 varia...
Altera_Forum
Honored Contributor
16 years agoThere is something else. With your
int rawVideo __attribute__ ((section (".onchip_ram_100Kbytes.rwdata"))); line, you are only allocating an integer, which is 4 bytes. This means that each time you do a read of more than 4 bytes, you overwrite a part of memory that could be used for something else, causing random crashes. You need to allocate a buffer big enough for what you want to do. Something like:char rawVideo __attribute__ ((section (".onchip_ram_100Kbytes.rwdata"))); and then remove the & in front of rawVideo in the read call.