Forum Discussion

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

how to place firmware in ROM

I use NIOSII IDE ( Version: 1.1.0 Build: 137 ) to write c software for a design consisting of SRAM, peripherals and a PCI-Interface. Booting is done via EPCS and a short programme initializes all peripherals and PCI. Now the SRAM is mapped into PCI space to load the actual software for NIOS by a linux host. In the meantime NIOS runs in internal ROM (in a wait loop) until download has finished.

How can I force the compiler / linker to place one function into this internal ROM? Adding __attribute__ ((section (".waitrom"))) doesn't work with functions. It's no problem with variables and constants so I've created an const array filled with assemby code. But how can I do this with a standard c-function?

Mike

3 Replies

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

    You can do it with functions, but you must put the attribute on the declaration, not the definition. So your code would look something like this:

    void function(void) __attribute__ ((section (".memory_name")));
    void function(void)
    {
        /* stuff */
    }

    Of course the declaration will often be in a header file.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    wombat,

    next time I'll ask you earlier.

    Thanks for your help.

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

    Hi

    This works fine for me as well, but when I try to place a variable in the same memory, I get an error about causing a section type conflict.

    Just to make clear: I have a program running from sdram. Then I want to have a variable in onchip memory as well as another function in onchip memory. Here is the code

    int var __attribute__ ((section (".onchip_ram")))=0;
    int func(void) __attribute__ ((section (".onchip_ram")));

    Is there any known problem placing both of these in the same memory ?

    Nir