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

NIOS memory usage

Altera_Forum
Honored Contributor II
3,380 Views

Does Nios IDE offer a tool for reporting memory usage of my project? 

Basically I'd like to display the amount of space used for every memory section. 

Better if I could have also a complete mapping with all names defined in the project. 

I tried to use objdump with the elf file but this is not very easy to use and to find the information I need. 

(moreover I had to use objdump from another processor toolchain because the one provided with Nios IDE stops with a dll function not found error) 

 

Cris
0 Kudos
11 Replies
Altera_Forum
Honored Contributor II
2,063 Views

Look at getting the linker to produce a map file ('-Map map_file' or similar). 

Otherwise objdump -p and objdump -h usually give enough info. 

(Any version of objdump for any architecure should work there!)
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

1. Assuming you are on Windows, you have to use nios2-elf-xxx tools from Nios2 command shell. All Nios2 tools are compiled with plain cygwin rather than MinGW so they wouldn't work from normal Windows command prompt. 

2. Use 'nios2-elf-size -A'. Or simple 'size -A'.
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

 

--- Quote Start ---  

Look at getting the linker to produce a map file ('-Map map_file' or similar). 

Otherwise objdump -p and objdump -h usually give enough info. 

(Any version of objdump for any architecure should work there!) 

--- Quote End ---  

 

 

Ok with using objdump; I can get the required info. 

I tried with the -Map switch to automate the file generation into build process but I get the error: 

Linking test_2010.elf... nios2-elf-g++: dumpmap: No such file or directory nios2-elf-g++: unrecognized option `-Map' make: *** Error 1 

I looked at nios-elf-ld help and I found the -Map command is correct. Does this nios2-elf-g++ called from the IDE indirectly calls this linker or it uses its own set of command switches? I tried to add other linker options (i.e. --verbose , --stats) but these are working correctly. 

 

Regards 

Cris
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

for nios2-elf-gcc you should add: 

-Wl,-Map -Wl,"mymap.map" 

nios2-elf-g++ is probably the same 

 

BTW, AFAIR Nios2 EDS build tools generate map by default. 

What set of tools are you working with. Legacy Nios2 IDE? Better stop right now, for anything above toy size it's painful.
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

 

--- Quote Start ---  

for nios2-elf-gcc you should add: 

-Wl,-Map -Wl,"mymap.map" 

nios2-elf-g++ is probably the same 

 

--- Quote End ---  

 

I found the problem. I inserted a space between Wl, and -Map and I eventually discovered this is not allowed.  

 

 

--- Quote Start ---  

 

BTW, AFAIR Nios2 EDS build tools generate map by default. 

What set of tools are you working with. Legacy Nios2 IDE? Better stop right now, for anything above toy size it's painful. 

--- Quote End ---  

 

I couldn't find any default generated map (that's why I wanted the -Map option).  

However, AFAIK I'm using Nios2 EDS (9.0 sp2), although inside the tools every reference is Nios2 IDE. I have a reference to Nios2 EDS only in the start menu. Is this correct? What's the difference between EDS and IDE? 

I apologize for the very silly question, but so far I used Nios tools only at a very basic level. 

 

Cris
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

Using the 9.0 IDE I had to generate my own linker script (which it really doesn't want you to do) in order to get the code and data assigned to correct memory areas. 

However since I'm loading code through a external interface (custom vhdl generating avalon writes - will be a PCIe slave) I don't need the jtag debug (it actually gets in the way) and am now building using versions of gcc and binutils compiled from the tarball downloaded from Altera's web site - without using any of their IDEs (etc). 

My Nios code/data blocks get converted into ppc object file data blocks and then linked into a ppc program which is also linked with the nios symbol table! This saves worrying (too much) about binary compatibility between the fpga code and the program that drives it - everying is compiled and linked on the same system by one makefile. 

 

I am going to have to sort out the 9.1 IDE to do some tests of custom instructions on a standard (cyclone III) eval board - without having to get our hardware guys to rebuld the main fpga image for me.
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

Hi everybody! 

I would like to extend this question: 

Are there any simple and easy to use tools for windows xp to figure out how many bytes are used in NIOS2 memory? 

I got the number of used bytes by "nios2-elf-size" from nios2 command shell. But using this linux tools under windows xp really isn't nice. You always have to start the nios2 command shell first and then you have to enter the path to the elf-file in linux-style (no copy and paste of the windows-path is possible). 

All i want to have is quick and simple possiblity to get the number of used bytes in NIOS2 memory (one plain number, no adding of bytes by myself). A windows command-line tool would be nice. Does anything like this exist? 

I would even write my tool to parse the *.map file but i couldn't figure out what lines hold the memory information. Could anybody perhaps post a short example how to interpret the *.map file? 

 

FredFlintstone
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

Welcome to windows :-) 

Cygwin (which is what Altera use) will process a 'windows' path provided you enclose the pathname in single quotes - which stops the shell treating \ as a 'quote next character' request. 

 

Or do what many of us do and use cygwin yourself in order to make it possible to do anything vaguely sane on under windows. 

 

If you write a program, I'd suggest parsing the elf program file and extracting the 'program headers'. These are relatively sane.
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

 

--- Quote Start ---  

Hi everybody! 

I would like to extend this question: 

Are there any simple and easy to use tools for windows xp to figure out how many bytes are used in NIOS2 memory? 

I got the number of used bytes by "nios2-elf-size" from nios2 command shell. But using this linux tools under windows xp really isn't nice. You always have to start the nios2 command shell first and then you have to enter the path to the elf-file in linux-style (no copy and paste of the windows-path is possible). 

All i want to have is quick and simple possiblity to get the number of used bytes in NIOS2 memory (one plain number, no adding of bytes by myself). A windows command-line tool would be nice. Does anything like this exist? 

I would even write my tool to parse the *.map file but i couldn't figure out what lines hold the memory information. Could anybody perhaps post a short example how to interpret the *.map file? 

 

FredFlintstone 

--- Quote End ---  

 

 

One day you would hopefully realize that using "Linux" (in fact, cygwin) tools under WinXp (and Win7, less so under Vista) is pretty convenient. Yes, you have to start nios2 command shell first, but there is no need to ever close it. As DSL told you, copy&paste of Windows path works just fine as long as you don't forget to enclose the path in single or double quotes. Assuming you are not on Vista, drag&drop from Windows Explorer works too. 

And if it's still to much work for you, nobody prevents you from creating desktop shortcut that will open nios2 command shell in the directory of your choice. 

 

But before you are enlighten, you can download MinGW. The 'size' utility that comes with MinGW works very well with nios2 elf images and does so from "normal" Windows cmd.exe prompt.
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

Thanks for your quick replies! 

 

> don't forget to enclose the path in single or double quotes 

Ok, if you know the trick... 

 

> But before you are enlighten, you can download MinGW. The 'size' 

> utility that comes with MinGW works very well with nios2 elf images and 

> does so from "normal" Windows cmd.exe prompt. 

This sounds really great. I will give this a try and hope that i can stick to my windows cmd.exe prompt. 

 

Best regards 

Fred
0 Kudos
Altera_Forum
Honored Contributor II
2,063 Views

Regarding the annoying task of setting Nios command shell path, I recently found this interesting shortcut: 

http://www.alteraforum.com/forum/showthread.php?t=23777 

Regards 

Cris
0 Kudos
Reply