User guide
© March 2014 Altera Corporation Nios II Flash Programmer User Guide
3. Using the Flash Programmer from the
Command Line
The Nios II development tools provide command-line utilities which give you
complete control of the Nios II Flash Programmer features. You can create a custom
script file to automate a flash programming task.
Alternatively, you can use the flash programmer GUI. Chapter 2, Using the Flash
Programmer GUI describes the flash programmer GUI.
1 The Nios II Flash Programmer GUI programs flash memory by creating a script based
on the command-line utilities. The script is well-formed, customized to your project,
and human-readable. You can use it as a reference for flash programmer
command-line syntax. The GUI-generated script is particularly helpful if you need to
use the --instance parameter listed in Table 3–2.
After you successfully program flash memory using the Nios II Flash Programmer
GUI, you can find the flash programmer script in the directory you specified in the
Staging Directories dialog box, available on the Options menu. The flash
programmer script is a file named flash_programmer.sh.
Table 3–1 lists the Nios II Flash Programmer command-line utilities.
The main utility for programming flash memory from the command line is
nios2-flash-programmer. It requires industry-standard S-record input files. These
utilities ensure that the input is compatible with the Nios II Flash Programmer. Input
file names for all utilities must include an explicit extension, such as .elf or .flash.
On Windows computers, when you launch the Nios II Command Shell, the flash
programmer utilities are available in your default search path.
f For more information about the Nios II Command Shell, refer to the Getting Started
from the Command Line chapter of the Nios II Software Developer's Handbook.
The following sections list the utilities and their functions.
Table 3–1. Flash Programmer Command-Line Utilities
nios2-flash-programmer Programs an S-record file into flash memory. Can also read back data,
verify data, provide debug information about the flash chip, and more.
sof2flash Converts an SRAM Object File (.sof) to an S-record file.
elf2flash Converts a Nios II Executable and Linking Format File (.elf) to an S-record
file.
bin2flash Converts an arbitrary data file to an S-record file.