Forum Discussion

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

question about __attribute__

There are two memory section in my Nios system, one external chip SDRAM and another onchip memory:a 16K byte ram which is generated by the SOPC tool. Our project need to put one function code in the ram section, all other codes are put in SDRAM. So I use the code like this:

int DataChange(int data) __attribute__ ((section (".onchip_mem")));

int DataChange(int data)

{

return (data+10);//This is just an example and it doesn't mean that my function is as simple as this

}

When I refer to the objdump file, it actually stays in the onchip_mem(the base address is 0x08004000). However, when I run the program it doesn't work at all. I try to debug the program, when DataChange is needed, program seems to fly away.

What's wrong with this?How should I resolve this problem?

I am a greenhand and looking forward to your reply, thank you very much!

1 Reply

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

    Hello,

    How are your code sections being initialised? It may be that your on-chip memory has not been loaded. In my system I use flash to store the code images, which are then loaded into RAM by the bootloader at startup. My main code is loaded into an external RAM and I have an ISR which is loaded into on-chip RAM (specified using the __attribute__ keyword as you have described).

    I'm not 100% sure, but your setup may require you to re-compile your Quartus project (or update RAM contents at least) so that your on-chip RAM is initialised by the FPGA configuration. You should find that the IDE has created a file called onchip_mem.hex in your hardware folder which is used to set the initial contents of your on-chip RAM.

    I hope this helps.

    Cheers