Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12589 Discussions

Outsource a funktion to a flash device

Altera_Forum
Honored Contributor II
1,038 Views

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
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
221 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
221 Views

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?
0 Kudos
Altera_Forum
Honored Contributor II
221 Views

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.
0 Kudos
Reply