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++
12748 Discussions

Newbie Q - physical memory required for program

Altera_Forum
Honored Contributor II
1,513 Views

Hi, 

 

I built the first software package "Hello World" using the templates in the NIOS2 Eclipse IDE and was able to run it on the target.  

 

My question is how to find the size of the physical memory required to run this program on the NIOS2 system. 

 

I tried the command line utility "nios2-elf-size" utility and it showed me the various sections. But I am confused how to interpret the information that this utility provides (text data bss dec hex filename). Do I use the value reported for 'data' as the size of the physical memory required in bytes? 

 

The requirement I have for my project is the software should run on the "On Chip RAM" without using any external memory. 

 

Thanks in advance. 

 

-Ram
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
544 Views

'text' is code, 'bss' is data that is initialed to zeros, the other partts are rather obvious - 'dec' and 'hex' are the totals. 

 

The total size is probably just over 60k. 

 

To run in internal memory you need to remove all the calls to libc functions. So the printf() has to go! The code that calls your main() also calls intio libc - so you need to get rid of that as well. (I cheated and renamed main()). 

 

If you need to load data into a tightly coupled data block you will have to write your own linker script as well. 

 

The JTAG loader seems to run code from the jtag block - so it is the nios cpu that writes into memory and you need vaddr == paddr for the elf sections. If you are loading via external access to the Avalon bus, then you'll need to use the external address of data sections.
0 Kudos
Altera_Forum
Honored Contributor II
544 Views

If the program is still too large, I find using optimization levels -O2 or -O3, in the C/C++ build settings for the system library, really cut down on the amount of on-chip memory used.

0 Kudos
Altera_Forum
Honored Contributor II
544 Views

Thanks for the good info you have provided. 

 

I also saw one template - hello_world_small that is less than 400 bytes when built. Ofcourse the BSP is really bare bone. 

 

Thanks. 

 

-Ram.
0 Kudos
Reply