Starting the Nios II Command Shell brings up a console window in a UNIX-like environment.
The Windows directories are attached to the /cygdrive
directory. The C directory, for example, is linked to
/cygdrive/c
.
The root directory is mapped to a Quartus directory. On my
system it is C:\altera\72sp1\quartus\bin\cygwin
.
[SOPC Builder]$ echo $PATH /cygdrive/c/altera/72/nios2eds/bin:/cygdrive/c/altera/72/nios2eds/bin/nios2-gnut ools/H-i686-pc-cygwin/bin:/cygdrive/c/altera/72/nios2eds/sdk2/bin:/cygdrive/c/al tera/72/nios2eds/bin/fs2/bin:/bin:/usr/bin:/cygdrive/c/altera/72sp1/quartus/win ... output truncated ...
The usual Windows path is included in the colon-delimited list. The first few directories in the list are:
/cygdrive/c/altera/72/nios2eds/bin: /cygdrive/c/altera/72/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin: /cygdrive/c/altera/72/nios2eds/sdk2/bin: /bin: /usr/bin: /cygdrive/c/altera/72sp1/quartus/win:
Below is a screen image of the Nios II Console:
You can mark and copy a portion of the console window by pressing the right mouse button with the mouse cursor in the title bar (not the client window). Select Edit - Mark, drag the mouse to select a region, then press the enter key. You can then paste the selection into another document.
The advantage of copying text from the console window is that the resulting content is generally more readable and avoids the black background of a screen capture, as shown below.
------------------------------------------------ Welcome To Altera SOPC Builder Version 7.2, Built Tue Nov 20 21:50:25 PST 2007 ------------------------------------------------ ------------------------------------------------ Welcome to the Nios II Embedded Design Suite Version 7.2, Built Tue Nov 20 23:27:29 PST 2007 Example designs can be found in /cygdrive/c/altera/72/nios2eds/examples ------------------------------------------------ (You may add a startup script: c:/altera/72/nios2eds/user.bashrc) /cygdrive/c/altera/72/nios2eds/examples [SOPC Builder]$ |
The Nios II Console is “unix-style”. Directory paths are separated by a forward slash (/). The following example changes the directory to the c-drive and then uses pwd to “print the working directory”.
[SOPC Builder]$ cd /cygdrive/c /cygdrive/c [SOPC Builder]$ pwd /cygdrive/c /cygdrive/c [SOPC Builder]$ |
From here, change directory to one where a Nios II executable file (.elf) is stored. For example:
cd nios2lab1/software/hello_world_small_0/release.
Most Nios II tools are designed to run from the console. For example, to obtain the size of an executable program:
[SOPC Builder]$ nios2-elf-size hello_world_small_0.elf text data bss dec hex filename 652 16 0 668 29c hello_world_small_0.elf |
[SOPC Builder]$ nios2-elf-readelf -h hello_world_small_0.elf ELF Header: Magic: 7f 45 4c 46 01 01 01 ff 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: Standalone App ABI Version: 0 Type: EXEC (Executable file) Machine: Altera Nios II Version: 0x1 Entry point address: 0x8020 Start of program headers: 52 (bytes into file) Start of section headers: 14180 (bytes into file) Flags: 0x0 Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 2 Size of section headers: 40 (bytes) Number of section headers: 20 Section header string table index: 17 |
You can redirect output to a file, which can then be edited, and inserted into a document. For example, to generate a disassembly listing:
[SOPC Builder]$ nios2-elf-objdump -d hello_world_small_0.elf > hello.da.txt |
The output file, hello.da.txt was edited to the following excerpt (main program):
0000806c <main>: 806c: deffff04 addi sp,sp,-4 8070: 01000074 movhi r4,1 8074: 21209d04 addi r4,r4,-32140 8078: dfc00015 stw ra,0(sp) 807c: 00081780 call 8178 <alt_putstr> 8080: 003fff06 br 8080 <main+0x14>
Collections of useful operations can be collected into a “shell script” that can be run from the console. For example, type (or download demo.zip) the following script into a file called demo.sh:
#!/bin/sh inp="hello_world_small_0" oup="hi_world" nios2-elf-size ${inp}.elf > ${oup}.size.txt nios2-elf-readelf -h ${inp}.elf > ${oup}.program.txt nios2-elf-objdump -dS ${inp}.elf > ${oup}.da.txt echo done
To run the script, enter
./demo.sh
Maintained by John Loomis, last updated 15 September 2008