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

ON-Chip Memory is too small for the source code

Altera_Forum
Honored Contributor II
985 Views

Hi, 

 

I´m a newbie in Altera and now I got a problem. I want lo load my source code to control my IP Core. I have a cyclon III DEV Board which has maximum 3888kbits of on chip memory but my code is much bigger. So how can I handle this problem?  

Thanks for youre advice! 

 

Regards
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
258 Views

Use external memory.

0 Kudos
Altera_Forum
Honored Contributor II
258 Views

Or try to use small C lib and see if it fits

0 Kudos
Altera_Forum
Honored Contributor II
258 Views

Thanks for your advice! 

But the point is that I already have a DDR2 SDRAM. My problem is now how to tell the core that the main function is not on the on-chip memory but in the SDRAM and also how can I load the Software on the SDRAM and not on the on-Chip memory. 

My idea was to load a small code on the on-chip mem which has the information that the main code is on the SDRAM. But I don´t know how to do this!
0 Kudos
Altera_Forum
Honored Contributor II
258 Views

Option 1 

If you want to move a whole memory section to ddr2 or to any another memory, select it in the BSP properties. 

e.g. : stack in onchip memory, code in ddr2, data in ddr2, ...  

 

Option 2 

If you want to move a single function to a specific memory, add 

__attribute__ ((section (".my_memory"))) 

after the function declaration, where 'my_memory' is the name you assigned to your memory in sopc builder or Qsys. 

e.g. int function_in_ddr2(int param) __attribute__ ((section (".ddr2_ext_mem"))); 

 

Option 3 

Use a custom linker scripts and map whatever you want wherever you need.
0 Kudos
Altera_Forum
Honored Contributor II
258 Views

Also, if you want to have code/data into multiple sections, you need to consider how the 'load' process will work. 

The JTAG loader uses the elf program headers to work out where to write each code/data area - so can load directly into the relevant area. 

The EPCS loader can only load one big chunk of data - so must load into external memory - code is added to alt_main() to copy the code/data to its correct physical address. 

The Altera linker scripts assume you are going to use (something like) the EPCS loader. This means they just don't work if you are trying to only use tightly coupled memory. 

 

You might also find that a lot of your code size it just bloat caused by using printf() and the malloc/free that happen in order to let you call printf().
0 Kudos
Reply