FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
5892 Discussions

DE0 Nano - Problem using the provided examples

Altera_Forum
Honored Contributor II
2,447 Views

Hi, 

 

i just received my DE0 Nano board and I've been trying the examples in the system CD. 

I've downloaded and installed Quartus 11.0sp1 + Nios II/Nios II GCC4 Toolchain. 

 

Every example works fine, except the myfirst_niosii example. 

When I execute the batch file, it programs the .sof file into the FPGA, but it is unable to to start the test_bashrc. 

Excerpt of test.bat: 

" "%QUARTUS_ROOTDIR%\bin\cygwin\bin\bash.exe" --rcfile ".\test_bashrc" " 

 

After the .sof file is programmed, it gives an error saying that it is unable to find the nios2-terminal and the nios2-download commands. 

 

From what I can understand these commands are called so that the hello_world_0.elf file is downloaded and run. 

 

Anybody can help me shed some light on this? 

 

Thanks in advance
0 Kudos
11 Replies
Altera_Forum
Honored Contributor II
745 Views

Check your enviroment variables and add quartus bin to it

0 Kudos
Altera_Forum
Honored Contributor II
745 Views

I am having the same problem - even with Quartus bin directory added (and confirmed) to the path. 

 

Its very frustrating for the demos to not work. 

Any help would be appreciated. 

 

Host is Win7 32 bit 

added path using controlpanel->system->advanced->environmental variable->edited path by adding ;C:\altera\11.0sp1\quartus\bin\ 

run cmd to open window 

confirmed path environmental var now points to quartus bin 

cd to DE0_Nano_SOPC_DEMO\demo_batch 

run test.bat 

ends with errors of nios2-download and nios2-terminal not found 

dumped to [NiosII EDS]$ prompt
0 Kudos
Altera_Forum
Honored Contributor II
745 Views

 

--- Quote Start ---  

 

run cmd to open window 

 

--- Quote End ---  

 

 

Perhaps this is the issue. Rather than using a windows console, try using the Cygwin bash shell that comes with the NIOS tools (it'll be called something like NIOS II command shell). 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
745 Views

Is the console not the best location to run a distributed demonstration batch file? Such as... 

DE0-nano-1.0.5\Demonstration\DE0_Nano_SOPC_DEMO\demo_batch\test.bat 

 

 

i found nios2-download and nios2-terminal in c:\altera\11.0sp1\nios2eds\bin and added it to path environmental variable. It now gets further along, but with different error messages.... 

 

cygdrive/c/altera/11.0sp1/nios2eds/bin/nios2-download: line 596: nios2-elf-objcopy: command not found 

DE0_Nano.elf.srec: Unable to open input file 

rm: cannot remove 'DE0_Nano.elf.srec': No such file or directory 

nios2-terminal: connected to hardware target using JTAG UART on cable 

nios2-terminal: "USB-Blaster [USB-0]", device 1, instance 0 

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

 

 

Searched and found nios2-elf-objcopy.exe 

added c:\altera\11.0sp1\nios2eds\bin\gnu\h-i686-mingw32\bin 

to path, re-opened cmd console, confirmed path, and ran test.bat 

 

Now it seems like it is working. 

 

At some point I will learn more about Nios terminal, for now just want to make sure all the demos are running as a stable base to start with. 

 

Sure wish at least the demos would work straight out of the box. 

 

 

 

 

 

test_bashrc contains the following: 

# file: nios2_sdk_shell_bashrc# # 2004.03.15 dvb# # +------------------------------------------------# | This is the Nios II Kit SDK Shell rc file# |# | It calls the standard SOPC Builder rc file, first, and# | then patches a few things up to do with replicated# | scripts and revisions, so that the ones provided# | with Nios II take precedence.# | 

# |# | call the SOPC Builder standard script# | 

 

. "$QUARTUS_ROOTDIR/sopc_builder/bin/nios_bash" 

# |# | Alias things we like very much# | 

 

alias nb=nios2-build 

alias nios-build=nios2-build 

alias nr=nios2-run 

alias nios-run=nios2-run 

alias nd=nios2-debug 

alias nios-debug=nios2-debug 

alias nc=nios2-console 

alias nios-console=nios2-console 

 

 

nios2-download de0_nano.elf -c usb-blaster[usb-0] -r -g 

nios2-terminal -c usb-blaster[usb-0]  

# remove exit 

# End of file 

 

 

 

test.bat contains the following (and calls above): 

%QUARTUS_ROOTDIR%\\bin\\quartus_pgm.exe -m jtag -c USB-Blaster[USB-0] -o "p;DE0_Nano.sof" 

@ set SOPC_BUILDER_PATH_71=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_71% 

@ set SOPC_BUILDER_PATH_72=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_72% 

@ set SOPC_BUILDER_PATH_80=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_80% 

@ set SOPC_BUILDER_PATH_81=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_81% 

@ set SOPC_BUILDER_PATH_90=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_90% 

@ set SOPC_BUILDER_PATH_91=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_91% 

@ set SOPC_BUILDER_PATH_92=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_92% 

@ set SOPC_BUILDER_PATH_100=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_100% 

@ set SOPC_BUILDER_PATH_101=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_101% 

@ set SOPC_BUILDER_PATH_102=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_102% 

@ set SOPC_BUILDER_PATH_110=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_110% 

@ set SOPC_BUILDER_PATH_111=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_111% 

@ set SOPC_BUILDER_PATH_112=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_112% 

@ set SOPC_BUILDER_PATH_120=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_120% 

@ "%QUARTUS_ROOTDIR%\bin\cygwin\bin\bash.exe" --rcfile ".\test_bashrc" 

pause 

 

 

 

 

 

 

0 Kudos
Altera_Forum
Honored Contributor II
745 Views

test_bashrc contains bash scripting syntax, while test.bat contains windows shell syntax. 

 

You commented that you started from a windows cmd shell, and got dumped to a [NiosII EDS]$ prompt - which is the Cygwin prompt - so I was suggesting to start from the Cygwin prompt and see if that helped. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
745 Views

Hi, 

 

I also defined every environment variable related to Quartus. That one included. 

But shouldn't all the variables be defined by the setup upon installation????? 

 

Anyway, the first time I installed the Eclipse allowed me to start a new Nios2 C project, BSP project, everything. After some uninstalling and installing of Quartus (always the same version) the options to start Nios2 related project do not appear. Something is very weird with this..... 

 

Anyway, I removed everything Quartus related from the environment variables and the registry. I'm now on my fourth attempt of installing everything. 

 

I just wanna make sure I can compile and execute .elf files for the Nios2 processor at this point. Every other demonstration works just fine. 

 

 

rogerjennings: 

"@ set SOPC_BUILDER_PATH_71=%SOPC_KIT_NIOS2%+%SOPC_BUILDE R_PATH_71%" 

Could the space in "...BUILDE R_PATH..." have anything to do with what we are experiencing? 

 

 

dwh@ovro.caltech.edu

"You commented that you started from a windows cmd shell, and got dumped to a [NiosII EDS]$ prompt - which is the Cygwin prompt - so I was suggesting to start from the Cygwin prompt and see if that helped." 

I started from the nios2 command shell and despite finding nios2-terminal and nios2-download, I was unable to see test_bashrc so I could execute it. 

 

UPDATE: 

Just finished a brand new instalation of Quartus 11.0 and Nios2 EDS. 

Had a problem finding nios2-download and nios2-terminal. 

Added to the PATH environment variable: 

C:\altera\11.0sp1\nios2eds\bin and C:\altera\11.0sp1\nios2eds\bin\gnu\H-i686-mingw32\bin 

 

after executing the batch file, the following error happened. 

"bash 5532 c:\altera\11.0sp1\quartus\bin\cygwin\bin\bash.exe: *** fatal error - internal error reading the windows environment - too many environment variables?" 

 

Bit strange isn't it? 

 

NEW UPDATE: 

SUCCESS!!! I changed the order by which the paths (mentioned above) appear on the PATH environment variable. I had them at the end, now their at the beginning. Why? Because I read somewhere on this forum that cygwin has a limited amount of memory for environment variables. 

 

"Hello from Nios II!" :D 

 

Tell me if it work for you. 

 

Cheers, 

LDS
0 Kudos
Altera_Forum
Honored Contributor II
745 Views

I know it's an old topic, but the problem still exists in 13.0sp1. 

 

I've followed your solution, adding the appropriate files to the environmental path. The nios2-download command is now found, but new errors return: 

 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 2: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 4: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 15: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 17: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 23: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 25: $'\r': syntax error near unexpected token '$'{\R'''cygdrive/c/altera/13.0sp1/sp1/nios2eds/bin/nios2-download: line 25: '{ 

nois2-terminal: connected to hardware target using JTAG UART on cable 

nois2-terminal: "USB-Blaster [USB-0]", device 1, instance 0 

nois2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

 

Now what :( this is so frustrating. I spend literally 12 hours not to get a demo working that was provided by altera. Shouldn't this be an out-of-the-box example?
0 Kudos
Altera_Forum
Honored Contributor II
745 Views

 

--- Quote Start ---  

I know it's an old topic, but the problem still exists in 13.0sp1. 

 

I've followed your solution, adding the appropriate files to the environmental path. The nios2-download command is now found, but new errors return: 

 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 2: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 4: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 15: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 17: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 23: $'\r': command not found. 

/cygdrive/c/altera/13.0sp1/nios2eds/bin/nios2-download: line 25: $'\r': syntax error near unexpected token '$'{\R'''cygdrive/c/altera/13.0sp1/sp1/nios2eds/bin/nios2-download: line 25: '{ 

nois2-terminal: connected to hardware target using JTAG UART on cable 

nois2-terminal: "USB-Blaster [USB-0]", device 1, instance 0 

nois2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

 

Now what :( this is so frustrating. I spend literally 12 hours not to get a demo working that was provided by altera. Shouldn't this be an out-of-the-box example? 

--- Quote End ---  

 

 

EDIT: ok, I finally solved the above problem by opening each file in sublime and changing the encoding.
0 Kudos
Altera_Forum
Honored Contributor II
745 Views

 

--- Quote Start ---  

 

$'\r': command not found. 

 

--- Quote End ---  

 

This message is related to the file using Windows encoding instead of Unix. The Cygwin command dos2unix can be used to correct the encoding. 

 

I agree that it is pretty lame that the demos do not work "out of the box". Personally, I just start with the schematic of the board and write my own demos. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
745 Views

This is my - now working - version of the test_bashrc (Quartus 14.0 Webedition, win7 64bit): 

 

As mentioned above the file has to be saved with unix style line endings. dos2unix does the job of converting line endings if your editor saves windows style only. 

Maybe nios2-download also has to be converted using dos2unix. 

 

Change /cygdrive/c/altera/14.0 to your correct location. 

 

-- snip --# file: nios2_sdk_shell_bashrc# # 2004.03.15 dvb# # +------------------------------------------------# | This is the Nios II Kit SDK Shell rc file# |# | It calls the standard SOPC Builder rc file, first, and# | then patches a few things up to do with replicated# | scripts and revisions, so that the ones provided# | with Nios II take precedence.# | 

 

# |# | call the SOPC Builder standard script# | 

 

 

. "$QUARTUS_ROOTDIR/sopc_builder/bin/nios_bash" 

 

# |# | Alias things we like very much# | 

 

 

alias nb=nios2-build 

alias nios-build=nios2-build 

alias nr=nios2-run 

alias nios-run=nios2-run 

alias nd=nios2-debug 

alias nios-debug=nios2-debug 

alias nc=nios2-console 

alias nios-console=nios2-console 

 

 

path=$path:/cygdrive/c/altera/14.0/nios2eds/bin:/cygdrive/c/altera/14.0/nios2eds/bin/gnu/h-x86_64-mingw32/bin:/cygdrive/c/altera/14.0/quartus/bin32:/cygdrive/c/altera/14.0/quartus/bin32 

 

 

nios2-download DE0_Nano.elf -c USB-Blaster[USB-0] -r -g 

nios2-terminal -c USB-Blaster[USB-0] # remove exit 

 

# End of file
0 Kudos
Altera_Forum
Honored Contributor II
745 Views

Bumping an old thread, but this is the top result when I googled my problem and I figured someone might want this fix in future. The SOPC demo wasn't working, the problem can be fixed on windows by creating a DE0_Nano.sh file in the demo_batch directory with the following: 

 

# file: nios2_sdk_shell_bashrc 

 

"$SOPC_KIT_NIOS2/nios2_command_shell.sh" nios2-download DE0_NANO.elf -c 1 -r -g 

"$SOPC_KIT_NIOS2/nios2_command_shell.sh" nios2-terminal -c 1 

 

# End of file
0 Kudos
Reply