Forum Discussion

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

Outsource a funktion to a flash device

Hallo together,

I have a QSys System with a Nios II and an EPCS controller, using a Cyclone IV. The CIV boots from an EPCS-Flash and starts the Software.

Now I want to outsource some Functions to the free memory of the EPCS-Flash. So that functions which are used rare, are running from flash. Is this possible? How?

I thought I could do it in a way like this:

int custom_func(int n) __attribute__ ((section((".onchipmem")))

int custom_func(int n)

{

}

But which section must be used for the epcs flash. And how to call a function which lies in the flash?

Last but not least, how could I specify the used region in the flash? Because the Hw-image and the Sw-image should not be destroyed?

Thanks

Sim

3 Replies

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

    Code can't be executed from a serial flash. How is this supposed to work? It must be loaded to RAM before.

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

    Ok, and how could I do so?

    How could I locate some functions in the epcs flash and copy them temporary in the onchip memory to execute?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    While technically possible, you'll need to write a lot of infrastructure to do this. Code overlays haven't been used much since 32bit address spaces and paged memory became common.

    I'm not even sure the gnu linker will put multiple code blocks at the same physical adress, but at different virtual addresses.

    You might be better off trying to reduce the code size by ensuring everything is compiled with the optimiser (try -O2, -O3 and -Os, and possibly mark some functions as 'noinline'), reducing the use of libc (especially stdio and malloc) to the minimum.

    Even changes to the C source (eg careful use of local variables to avoid repeated memory accesses) can reduce the code size.