Altera Quartus II and NIOS II command line tutorial

12 October 2014 08:06 | Molnár Péter

Other languages: Magyar Français

This is a simple introductory tutorial or quick howto into the command line management of Altera Quartus II development environment. My working method is configuring projects with graphical tools and then use command line for compiling, programming.

Quartus II

First, you need to launch the nios2 command shell, because it sets the environment variables:

$ <altera_home>/nios2eds/nios2_command_shell.sh

Creating a project

$ quartus_sh --tcl_eval project_new <project_name>

Synthetising, placing, routing

Open a new tcl script file (for example compile.tcl) and copy the following into the new file:

package require ::quartus::flow
project_open <project_name>
execute_flow -compile
project_close

Then execute:

$ quartus_sh -t compile.tcl

Cleaning the project:

$ quartus_sh --clean <project_name>

Launching Qsys with existing .qsys design file:

$ qsys-edit <system design>.qsys

Creating test bench template for simulation:

$ quartus_eda --read_settings_files=on --write_settings_files=off <project_name> -c <project_name> --gen_testbench

Starting NativeLink simulation:

$ quartus_sh -t "<altera_home>/quartus/common/tcl/internal/nativelink/qnativesim.tcl" --rtl_sim "<project_name>"  "<project_name>"

Programming over USB Blaster:

$ jtagconfig # need only for first time
1) USB-Blaster [2-2]
...
$ quartus_pgm -c "USB-Blaster [2-2]" -m jtag -o 'P;output_files/<project_name>.sof'
# or in one line:
$ quartus_pgm -c "`jtagconfig --enum  | head -n 1 | sed 's/1) //'`" -m jtag -o 'P;output_files/<project_name>.sof'

NIOS II command shell

First, you need to launch the nios2 command shell:

$ <altera_home>/nios2eds/nios2_command_shell.sh

Launching BSP (Board Support Package) graphical interface:

$ nios2-bsp-editor --settings ../<N2swproject>_bsp/settings.bsp

Generating BSP (Board Support Package) from existing configuration:

$ cd <project_name>/software/<N2swproject>
$ nios2-bsp-generate-files --settings ../<N2swproject>_bsp/settings.bsp --bsp-dir ../<N2swproject>_bsp

Compiling and downloading to NIOS II soft-processor:

$ make all
$ nios2-download -r -g <N2swproject>.elf

Launching NIOS II jtag terminal:

$ nios2-terminal