Forum Discussion
15 Replies
- Altera_Forum
Honored Contributor
Hi,
You can write a myscript.sh file : a shell file with same purpose than DOS batch (*.bat) file. Have a look at *.sh in nios directories. You can launch .sh file by (NOT TESTED, it is just an example): enter the command : sh (or bash) myscript.sh in the good directory or make it executable by chmod +x myscript.sh and launch it : ./myscript.sh in the good directory. - Altera_Forum
Honored Contributor
In this design example zip file under /software you will find a shell script that you can take a look at. If you just want to run a series of shell command then your script should be fairly short. If you edit it on Windows before running it make sure to run dos2unix on the file to make sure it has the correct new line formatting.
http://www.altera.com/support/examples/nios2/exm-modular-scatter-gather-dma.html - Altera_Forum
Honored Contributor
I am not quite understanding the process here. I have made a *.sh file and can execute it from the NIOS II Command Shell, thanks for the help there.
How can I run *.sh from windows or a *.bat file? - Altera_Forum
Honored Contributor
I did a quick test and this seemed to work. I wrote a one line batch file with this in it:
C:\altera\10.1\nios2eds\"Nios II Command Shell.bat" nios2-terminal So the Nios II command shell opens and the command "nios2-terminal" is run. So instead of running the terminal you would call your script. So maybe something like this: C:\altera\10.1\nios2eds\"Nios II Command Shell.bat" sh <path to my_script.sh>/<my_script.sh> - Altera_Forum
Honored Contributor
I just tried the following and it just opens the command shell, but doesn't run the script
C:\>"C:\altera\91\nios2eds\Nios II Command Shell.bat " sh "C:\altera\91\nios2eds\test.sh" ------------------------------------------------ Welcome To Altera SOPC Builder Version 9.1, Built Wed Mar 24 22:13:17 PDT 2010 ------------------------------------------------ ------------------------------------------------ Welcome to the Nios II Embedded Design Suite Version 9.1, Built Thu Mar 25 01:25:52 PDT 2010 Example designs can be found in /cygdrive/c/altera/91/nios2eds/examples ------------------------------------------------ (You may add a startup script: c:/altera/91/nios2eds/user.bashrc) ~ [NiosII EDS]$ - Altera_Forum
Honored Contributor
You'll need to use a different drive mapping than you are accustom to on windows. Something like this might work better:
sh /cygdrive/c/altera/91/nios2eds/test.sh I would start with something simple like putting your script in the default location that the Nios II command shell opens at and then work in the path later once you have that working first. When you add the paths I recommend not putting the script in the ACDS installation directory since it's a good idea to keep your custom stuff separate. - Altera_Forum
Honored Contributor
I have tried that too, here is the line straight from the bat file.
"C:\altera\91\nios2eds\Nios II Command Shell.bat" sh /cygdrive/c/altera/91/nios2eds/test.sh It does not run the script when it opens, but if I type sh /cygdrive/c/altera/91/nios2eds/test.sh after the command shell starts, it will run the script. I am able to run a startup script by copying my script to: "C:\altera\91\nios2eds\user.bashrc" However I would hate to implement it that way. - Altera_Forum
Honored Contributor
Here is my solution/workaround for now anyways.
creatNiosApps.bat --------------------------------------------------------------- copy "C:\Development\Ethernet_ES\NIOS\test.sh" "C:\altera\91\nios2eds\user.bashrc" "C:\altera\91\nios2eds\Nios II Command Shell.bat" --------------------------------------------------------------- test.sh --------------------------------------------------------------- NIOS_DIR="C:/Development/Ethernet_ES/NIOS" mkdir $NIOS_DIR"/Hex_Files" make -C $NIOS_DIR"\software\output_app" clean make -C $NIOS_DIR"\software\output_app" all $SOPC_KIT_NIOS2/bin/elf2hex --base=0x41060000 --end=0x41067fff --width=8 --input=$NIOS_DIR"/software/output_app/output_app.elf" --output=$NIOS_DIR"/Hex_Files/output_app.hex" rm -rf "C:\altera\91\nios2eds\user.bashrc" exit -------------------------------------------------------------------- Thanks for all the help - Altera_Forum
Honored Contributor
"sh -c <command> [args]" might work a bit better.
Most "bourne-like" shells behave this way. Since the Nios II shell environment is based on Bash ("Bourne Again SHell"), this should work. Cheers, slacker - Altera_Forum
Honored Contributor
--- Quote Start --- Here is my solution/workaround for now anyways. creatNiosApps.bat --------------------------------------------------------------- copy "C:\Development\Ethernet_ES\NIOS\test.sh" "C:\altera\91\nios2eds\user.bashrc" "C:\altera\91\nios2eds\Nios II Command Shell.bat" --------------------------------------------------------------- test.sh --------------------------------------------------------------- NIOS_DIR="C:/Development/Ethernet_ES/NIOS" mkdir $NIOS_DIR"/Hex_Files" make -C $NIOS_DIR"\software\output_app" clean make -C $NIOS_DIR"\software\output_app" all $SOPC_KIT_NIOS2/bin/elf2hex --base=0x41060000 --end=0x41067fff --width=8 --input=$NIOS_DIR"/software/output_app/output_app.elf" --output=$NIOS_DIR"/Hex_Files/output_app.hex" rm -rf "C:\altera\91\nios2eds\user.bashrc" exit -------------------------------------------------------------------- Thanks for all the help --- Quote End --- Your quoting is all wrong.... You probably want to include the shell variable substitutions in "" (eg "$NIOS_DIR") not the literal text. This will ensure that any spaces or shell wildcard characters don't generate multiple parameters. You need to always use forward slashes /, in a shell script \ is a single character escape.