[转载]sof pof elf JTAG AS EPCS4

原文地址:sof pof elf JTAG AS EPCS4 作者:万里
    近来一直在研究新买的fpga开发板中的范例,verilog的范例大都验证过,没什么问题。在对工程进行编译时会生成sof和pof两种文件。其中  .sof(SRAM Object File)是用JTAG方式直接下载到FPGA里面的,因此断电后程序不会存在。.pof(Programmer Object File)是存放在配置器件如EPCS4里的,要通过AS方式下载。
    在nios范例中看到了定时器中断和数码管构成的时钟程序,以前一直是用JTAG方式于是想将之直接在线调试的,这次想对EPCS4进行配置,使程序一加电就自动执行。
    光盘里的视频有一个视频 A17_CFI_Flash_TEST 是讲如何将程序烧入flash的 ,他用了两个flash,分别是并行的cfi flash和串行的epcs4,最终将sof写入epcs4,而将C语言编译的文件.elf烧入cfi flash。注意在sopc的cpu设置中reset地址和exception地址都设置成了epcs_flash。
    在无双大大的博客中有一篇也是讲这个的:
    如何讓Nios II一Power On就執行?
    但是我以前看过的资料上说可以将sof和elf都配置到epcs中去,这样可以省去cfi flash了。经过两天的实验,终于搞定了。配置方法如下:
1. sopc中必须加入epcs_flash_cotrollor。将reset地址设为 epcs_flash,而将 exception地址设置成on chip memory。这样复位时epcs中的文件会被复制到on chip memory上运行。
2.程序是通过JTAG下载方式下载的。这一步我耽误了很长时间,因为一直认为epcs必须要用AS方式利用.pof配置,原来也可以通过JTAG方式配置,但必须利用nios flash programmer。
    3.当C程序编译好之后。先打开quartus programmer,将sof文件配置到FPGA。(这一步是否必须我还没有试过,感觉不是必须的)
4.打开nios flash programmer。如果连接没有问题,则新建flash编程文件,将.sof和.elf文件都加入。点击program flash 就行了。这样配置就完成了。
    为了证明.sof和.elf.文件都写入了epcs,可以找到工程文件夹下的script文件夹,里面有.sh文件。用记事本打开查看,显示一下内容:

#!/bin/sh
#
# This file was automatically generated.
#
# It can be overwritten by nios2-flash-programmer-generate or nios2-flash-programmer-gui.
#

#
# Converting SOF File: D:UsersAdministratorDocumentsalteranios_timer_firmware1timer_FW1.sof to: "..flash/timer_FW1_epcs_flash_controller.flash"
#
$SOPC_KIT_NIOS2/bin/sof2flash --input="D:/Users/Administrator/Documents/altera/nios_timer_firmware1/timer_FW1.sof" --output="../flash/timer_FW1_epcs_flash_controller.flash" --epcs --verbose 

#
# Programming File: "..flash/timer_FW1_epcs_flash_controller.flash" To Device: epcs_flash_controller
#
$SOPC_KIT_NIOS2/bin/nios2-flash-programmer "../flash/timer_FW1_epcs_flash_controller.flash" --base=0x0 --epcs --sidp=0x1840 --id=0x0 --timestamp=1334234277 --device=1 --instance=0 '--cable=USB-Blaster on localhost [USB-0]' --program --verbose 

#
# Converting ELF File: D:UsersAdministratorDocumentsalteranios_timer_firmware1softwaretimer_FW1timer_FW1.elf to: "..flash/timer_FW1_epcs_flash_controller_1_.flash"
#
$SOPC_KIT_NIOS2/bin/elf2flash --input="D:/Users/Administrator/Documents/altera/nios_timer_firmware1/software/timer_FW1/timer_FW1.elf" --output="../flash/timer_FW1_epcs_flash_controller_1_.flash" --epcs --after="../flash/timer_FW1_epcs_flash_controller.flash" --verbose 

#
# Programming File: "..flash/timer_FW1_epcs_flash_controller_1_.flash" To Device: epcs_flash_controller
#
$SOPC_KIT_NIOS2/bin/nios2-flash-programmer "../flash/timer_FW1_epcs_flash_controller_1_.flash" --base=0x0 --epcs --sidp=0x1840 --id=0x0 --timestamp=1334234277 --device=1 --instance=0 '--cable=USB-Blaster on localhost [USB-0]' --program --verbose 
    可以看到.sof和.elf文件都被转换为.flash文件写入到了epcs中,证明了我的做法是对的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值