一、将HW和SW合成一个JIC文件
需要的文件:sof,elf;
step1:先将硬件映像和软件映像转换成flash文件
打开nios II commandshell,输入:
sof2flash --input=hello_cy3.sof--output=hwimage.flash --epcs --verbose
elf2flash --input=hello_world_0.elf--output=swimage.flash --epcs --after=hwimage.flash –verbose
step2:把flash文件转化成hex文件
nios2-elf-objcopy-I srec -O ihex hwimage.flash hwimage.hex
nios2-elf-objcopy-I srec -O ihex swimage.flashs wimage.hex
step3:打开Quartus® IIConvert Programming File 工具,给Flash Loader添加器件类型,然后添加第2步转化出来的hex文件。添加hex文件时,选中“相对地址”选项。
点击Gererate,即生成了jic文件,再检查生成的.map 文件有hwimage.hex在起始地址0x0,swimage.hex文件在hwimage.hex结束地址后的起始地址1
hwsw_file.map显示了地址信息
BLOCK START ADDRESS END ADDRESS
hwimage.hex 0x00000000 0x00030FA5
swimage.hex 0x00030FA6 0x0003131D
Note: All the addresses in this file are byte addresses
注意:原SOF生成的hex文件从0地址开始编写,加入nios后的hex接在后面。
二、使用nios II command shell下载sof、elf文件
1、 先将sof、elf文件转化为flash文件
if !(test -e hwimage.flash)
then sof2flash --epcs --input=hwimage.sof --output=hwimage.flash
fi
then elf2flash --epcs --after=hwimage.flash --input=swimage.elf --output=swimage.flash
fi
2、 在下载flash文件之前需在FPGA加载hwimage.sof
nios2-configure-sof //未指定文件名,默认加载当前目录下的sof文件
3、 烧写flash文件
nios2-flash-programmer --epcs --base=0x00001000 hwimage.flash
nios2-flash-programmer --epcs --base=0x00001000 swimage.flash --go
注:--base :在niosII核在avalone总线上epcs核的基地址。
三、擦除整片epcs内容
nios2-flash-programmer --epcs--base=0x00001000 --erase-all