测底稳定NIOS开发之一:将nios产生的编程文件转换成jic (连载)

将nios产生的编程文件转换成jic

前言:

      基于某种原因,自从开始fpga开发和nios项目开发中,均为正常使用EDS IDE自带的flash programmer 进行成功的下载固化epcs程序。好在通过研究,发现了可以使用命令行直接合成数据。通过jic转换工具,直接生成jic文件,直接使用jtag下载,由此省了不少事。

使用软件:Quartus II 12.0(基于某种原因不再考虑之前的版本,13.1测试也没问题)

FPGA:EP4CE10E22C8

开发板:FPGA_VIP_V101 核心板 EP4_V202

操作系统:xp 32bit

 

 

将sof和elf文件合成一个jic文件,其步骤是:

1.生成bat文件

1)将下面的命令copy到文本文档里,

@ set SOPC_BUILDER_PATH_72=%SOPC_KIT_NIOS2%+%SOPC_BUILDER_PATH_72%

@ "%QUARTUS_ROOTDIR%\bin\cygwin\bin\bash.exe" --rcfile "%SOPC_KIT_NIOS2%\nios2_sdk_shell_bashrc"

2)保存并重命名文档为:Nios II Command Shell.bat

2.将要合并的sof和elf文件以及上一步中生成的bat文件拷贝到相同目录下。并重命名sof文件和elf文件。

sof文件重命名为:“quartus.sof”;

elf文件重命名为:“nios.elf”。

3.运行Nios II Command Shell.bat,并按照以下步骤键入相关命令

1) 将SOF文件转换为Flash文件

sof2flash --epcs --input= quartus.sof --output=hw.flash --quiet
2) 将ELF文件转换为Flash文件

elf2flash --epcs --after=hw.flash --input=nios.elf --output=sw.flash
3) 将两个文件合成为一个文件

cp hw.flash hw_sw.flash

cat sw.flash >> hw_sw.flash
4) 产生HEX文件

nios2-elf-objcopy --input-target srec --output-target ihex hw_sw.flash output.hex

3.将hex转换为jic文件

1)打开 Quartus -> File -> Convert Programming File ...    
2)选择 output: *.jic , select your epsc, outputfilename,
3)选择器件所对应的flash-loader

4)移除条目:sof
5)添加上述步骤所产生的output.hex文件
6)Generate ...

完成。

由于上述方法中第2步在实现过程中比较繁琐(命令无法进行复制且较长),可考虑通过批处理方式实现。

建立一个文本文件,将第2步中的命令输入到文件中保存并重命名为“test”(注:此文件与上述的sof、elf和bat文件在相同的目录下)。

Test文件中内容如下:

sof2flash --epcs --input=quartus.sof --output=hw.flash --quiet
elf2flash --epcs --after=hw.flash --input=nios.elf --output=sw.flash
cp hw.flash hw_sw.flash

cat sw.flash >> hw_sw.flash
nios2-elf-objcopy --input-target srec --output-target ihex hw_sw.flash output.hex

 

运行Nios II Command Shell.bat,然后输入命令sh test 就可以得到HEX文件(output.hex)。

产生JIC的方法同上。

若直接打开不了Nios II Command Shell

使用ide打开

 

 

2015-3-24

由网友:奇迹再现 整理

链接:http://pan.baidu.com/s/1c0CRkuW 密码:euxt

http://ccjt.taobao.com/

posted on 2015-03-24 13:56  层层惊涛  阅读(1755)  评论(0编辑  收藏  举报