Forum Discussion
Altera_Forum
Honored Contributor
19 years agoWowha! How did I miss all of those GNU tools?! Bonus! Thanks a bunch,
Kevin --- Quote Start --- originally posted by fischer@Aug 10 2006, 03:43 PM two possibilities done with script files (not from ide)
nios2 .flash files are srec files
1.
a) use elf2flash to generate flash-file from elf-file
http://forum.niosforum.com/work2/style_emoticons/<#emo_dir#>/cool.gif use nios2-elf-objcopy to change address of srec file
2.
a) use elf2flash to generate flash-file from elf-file
http://forum.niosforum.com/work2/style_emoticons/<#emo_dir#>/cool.gif use nios2-elf-objcopy to generate binary file from flash-file
c) use bin2flash to generate again flash-file at new offset
sample script for 1.
srcname=hello_world_0
flash_offset=0x100000 # where program is stored in flash
src_file=./src/$srcname.elf
dst_file=./flash_files/$srcname.flash
dst_file_off="./flash_files/"$srcname"_"$flash_offset".flash"
echo ----------------------------------------------------------------------------
echo "start elf2flash"
flashbase=0x000000 # baseaddress of flash
flashend=0x7fffff
resetaddress=0x000000
flash_id=u1
bootloader=boot_loader_cfi.srec # bootloader
echo "elf file : "$src_file
echo "flash file : "$dst_file
echo "bootloader : "$bootloader
echo "flash id : "$flash_id
echo "flash base add : "$flashbase
echo "flash end add : "$flashend
echo "reset add : "$resetaddress
elf2flash --input=$src_file --output=$dst_file --base=$flashbase --end=$flashend --boot=$bootloader --reset=$resetaddress --flash=$flash_id --verbose
echo ----------------------------------------------------------------------------
echo "start objcopy"
echo "input flash file : "$dst_file
echo "output flash file : "$dst_file_off
echo "offset in flash : "$flash_offset
nios2-elf-objcopy -v -i srec -o srec --srec-forces3 --srec-len 32 --change-addresses $flash_offset $dst_file $dst_file_off
echo ----------------------------------------------------------------------------
echo "start quartus_programmer"
board_conf_file=b12dal03_fpga.sof # path to flash programmer board file
jtag_device=2 # no of device in jtag_chain
echo "board_conf_file: "$board_conf_file
echo "jtag-device : "$jtag_device
quartus_pgm --cable="usb-blaster [usb-0]" --mode=jtag --operation="p;$board_conf_file@$jtag_device"
echo ----------------------------------------------------------------------------
flash_file=$dst_file_off
baseflash=0x00000000 # baseaddress of flash
echo "start nios2-flash-programmer"
echo "flash file : "$flash_file
echo "jtag-device : "$jtag_device
echo "flash base add : "$baseflash
nios2-flash-programmer --debug --device=$jtag_device --accept-bad-sysid --base=$baseflash $flash_file
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=17515)
--- quote end ---
--- Quote End ---