An example of (NIOS) EPCS Remote Update through UART

An example of (NIOS) EPCS Remote Update through UART

 

Here is presented a method, that explains how to configure EPCS remotely using UART. An example was taken from my existing project and not designed to specially for description how to do.

At first place there need to create default project that works as default Image and gives possibility to load second image to EPCS flash device. Created remote configuration project for Quartus you can download here remote_update.

Acctually there need several thinks that need to do, to make it work. First create NIOS processor and add remote update controller and several other components that make NIOS processor Fig. 1.

 

Nios_cpu

 Fig. 1. An example of NIOS processor of remote update project

Next step is to set NIOS cpu reset vector to EPCS device and inclusion of swap custom instruction (Fig. 2). This custom instruction revers bits of received data before writing to EPCS (MSB bit first).

Nios
swap

Fig.2 An example of configuration of reset vector for NIOS cpu (Top) and swap custom instruction (Bottom)

 

Second step is to Generate NIOS processor and go back to Quartus environment. There need to do several steps also. There need to set configuration device. Goto menu Assignments->Device.. find in Category list Device

dev
Fig. 3. An example of window Device and Pin Options

Find Configuration Tab and choose Configuration scheme Active Serial and Configuration mode Remote (Fig. 4). Here need to take into account that only default Image should have remote update configuration component. Other Image (or Images) that will be loaded to EPCS should have Standard configuration mode.

epcs_remote

Fig. 4. An example of Quartus project configuration to remote update controller

Compile Quartus project and now you have required remote update hardware image (*.sof). Next step is to create NIOS software to handle second Image configuration stream and write it to required EPCS address. I recommend to read remote update controller description. There is shown an example of C code which can be used as reconfiguration command after Image update or download to EPCS.

int CycloneIII_Reconfig( int remote_update_base, int flash_base, int reconfig_offset, int watchdog_timeout, int width_of_flash );                         (1)

I will not analyze here C code that is provided. If you need to make some changes you can do it by your self. The code has no warranty and presented as working example.

At this point you need Flash EPCS device though NIOS IDE environment using Menu Tool->Flash Programmer...

Next step is to create second Image that will be loaded into EPCS after default Image using UART. Tis image has no remote update, but I think you can add it if you want to use (1) function to switch between Images.
Writing to EPCS flash device takes some time. I have used *.ttf ASCII file and simple ASCII  handling routine to make remote configuration.  ASCII type configuration file can be acquired by selecting Tabular Text File (*.ttf)  in Programming Files Tab (Fig. 5). You can use *.rbf file to send raw data though UART but you will need to change C code that will handle this.

ttf

Fig. 5. Selection of *.ttf generation in Programming Files Tab.

I should mention that there are several ways how to put NIOS processor software to *.tff file. The simplest way is to use memory initialization option in SOPC Builder environment: choosing On-chip Memory component Tab Memory Initialization (Fig. 6).

memory_init

Fig. 6. An example that show how to put NIOS software to single configuration file *.ttf

This method helps to put NIOS software in to *.sof file too, but it requires regeneration of NIOS processor and later whole Quartus project. This is not comfortable if you have large project which takes a lot of time to recompile. There is other method that can help. The Nios software and hardware images can be combined using tcl command line in Quartus. Go to menu View find Utility Windows->Tcl Console (Fig. 7).

tcl

Fig. 7. Starting TCL console in Quartus

In main Quartus windows should appear console. Recompile your NIOS IDE project, in main Quartus project should be created onchip_memory.hex file. After that you need to TCL console enter commands:

quartus_cdb – -update_mif  YOUR_PROJECT_NAME

And after some time when update will succseed enter:

quartus_asm  YOUR_PROJECT_NAME

After that required files should be created.

So we have created default image project (remote_update do not forged to Flash it First using standard method)  and second project that will be loaded through UART using *.ttf file. To send data though UART from PC side I have used created by my self upload program. This program fist counts all rows that are available in *.ttf file and sends total number of rows though UART. Because NIOS processor gives command to PC send data, there need a number that represents total amount of rows available. In next step program sends one line of number form *.tff file (Fig. 8 ). The second line will be send if response is received (program responds on received letter ‘K‘). Program control sending routine and helps to program EPCS with new image at 0xC0000 address.

numbers

Fig. 8. An example of *.ttf file

This method helps using remote update controller download second Image to EPCS. If you need switching between Images you need to keep status of loaded second Images somewhere in EPCS memory or other external memory and using remote update controller activate (1) function with default Image address. There is other solution. According that default Image always check (read EPCS for status) is there any other Images or not. If it founds image (In this project I have used 0×1F0000 address to store status of loaded second Image) then it loads it. To go back form second Image to default Image you can erase cell at 0×1F0000 address and turn off-on power. Then default Image will check this address again and finds that there no any other Images to load and keeps working as default.

program

Fig. 9. AN example of program that can be used upload *.ttf Image to EPCS

The PC program is very simple, there are several buttons: OpenFile and Update is clear. Restore button is related to restore default Image options, by sending ‘D’+#13 though UART.

Download NIOS IDE software:  remote_update_soft.zip
Download Quartus project:      remote_update.qar

Download program for PC (XP/Vista/W7):  Program

If you find useful this information and if you want support further development please DONATE.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值