- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is probably a simple solution to this, but I am having a hard time finding it in any of the documentation.
I have four applications that I need to build for a single board. I can build the projects and create the hex files from within the Nios II Command Shell using "make" and "elf2hex". I would like to automate this process. Is there a way to do this with a *.bat file? Thanks, JohnLink Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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>- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]$- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- "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 --- Quote End --- You don't need 'sh -c' here, that is usually only needed when you need a shell to do filename globbing or stdin/stdout redirection when a program is running something using one of the exec family of functions - eg execl().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dsl,
I'll admit my knowledge of shell files started yesterday, so I have taken your advice. slacker, I tried a few variations of "sh -c <command> [args]" and it does not work, I cannot get the "Nios II Command Shell.bat" to execute arguments when it is started. I am thinking this is a problem with 9.1. Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This isn't a problem only with 9.1, as I'm in 11.1sp1 and I can't do it either. Being able to auto-execute .sh scripts from my sim and build environments would help streamline things quite a bit, and reduce the amount of user interaction required.
If ANYONE knows how to automatically run a script at the NIOS shell, it would be greatly greatly appreciated!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The command shell will autorun the script file user.bashrc, so you can use this to make it work.
My batch file and script file are in a previous post. The batch file renames my script file to user.bashrc so it is autorun and starts the command shell. To prevent the script from running every time the command shell is opened, the last thing the script should do is delete itself. It would be nice if arguments worked, but this method has worked for me.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do the following:
I put all commands in a shell script, then I execute a wrapper bat file. alt_win.cmd
@echo off
mode con lines=32766
setlocal enabledelayedexpansion
SET myPwd=%CD%
:: 64-bit / 32-bit OS detection
SET binName=bin
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" SET binName=bin64
if "%QUARTUS_ROOTDIR%"=="" echo Env Var QUARTUS_ROOTDIR is missing. Is Quatrus installed? Is the path set correctly & exit /b 1
SET QUARTUS_BINDIR=%QUARTUS_ROOTDIR%\%binName%
SET PATH=%PATH%;%QUARTUS_BINDIR%
for /f "delims=" %%a in ('%SOPC_KIT_NIOS2%\bin\cygpath\cygpath.exe %myPwd%') do @set myCygPwd=%%a
::echo %myCygPwd%
%SOPC_KIT_NIOS2%\"Nios II Command Shell.bat" %myCygPwd%/%*
example.bat
@echo off
alt_win.cmd %~n0.sh %*
example.sh
# !/usr/bin/env bash
--SNIP--
cmd="quartus_pgm -c $uCable -m jtag -o ipv;$binDir/$flashFile"
echo " Running \"$cmd\""
$cmd || {
echo -e "\e quartus_pgm failed. \e[0m"
exitFunc 1
}
--SNIP
Using this methods allows you to have a unified interface to Windows and GNU/Linux. Windows users will double click on the example.bat file or even run it from cmd (with parameters and all) and GNU/Linux users will run the example.sh shell script as usual. Here is a working example : https://bitbucket.org/ftabunimeh/supportboard/src/default/scripts/
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page