FPGA通过CPU远程升级方案

方案介绍

本文介绍Xilinx提供的一种远程更新FPGA程序的方案,该方案是将FPGA外挂的FLASH芯片分为top、bottom两个部分,bottom存储golden程序,top存储update程序,golden区域通过JTAG配置原始的FPGA程序,其中包含升级的逻辑和上电跳转到update区域地址信息,CPU向FPGA发送升级程序通过升级逻辑将程序写入FLASH芯片的top区域。这样,FPGA每次上电通过跳转地址信息跳转到top区域加载update区域的程序,从而实现FPGA升级的功能。

升级流程图

在这里插入图片描述
这里跳转地址选择0xF50000。跳转地址是按照相关文档的例程的例子参考。

功能框图

在这里插入图片描述

例程实现

由于Ultrascale系列FPGA的DQ0~DQ3规划到了FPGA的专用BANK0上面,而在使用BPI加载模式时, FPGA配置完成之后,BPI配置接口通常保持未使用状态,通过使用STARTUPE3原语,就可以使用这些专用引脚,所以可以将CPU写来的数据存储到flash芯片top部分,通过CPU设置FPGA从top部分加载程序,实现FPGA在线升级的功能。

AXI Quad SPI IP核的生成和配置

Dual/Quad SPI Mode

Dual SPI mode is selected when the Mode option in the Vivado IDE is set to Dual. The relevant parameters in this mode are:
• Mode
• Slave Device
• Enable STARTUPEn Primitive
Note: The STARTUPE2 primitive is applicable for 7 series devices. The STARTUPE3 primitive is applicable for UltraScale™ devices.
• Transaction Width
• No. of Slaves
• FIFO Depth
The properties associated with the FIFO are:
• The depth of the FIFO is based on the FIFO Depth option which has valid values of 16 or 256.
• The width of the FIFO is 8-bits because the page size of the SPI slave memories is always 8-bits.
• The quad SPI mode is selected when the Mode option is set to Quad. The behavior of the ports in quad SPI mode is:
• For standard mode SPI instructions, the IO0 and IO1 pins are unidirectional and function the same as in standard SPI mode.
• For dual mode SPI instructions, the IO0 and IO1 pins are unidirectional or bidirectional depending on the type of instruction and memory selected by setting the control register bits. The IO2 and IO3-bits are 3-state.
• For quad mode SPI instructions, the IO0, IO1, IO2, and IO3 pins are unidirectional or bidirectional depending on the type of memory used while transmitting the command, address, and data.

Legacy Mode

Legacy mode is selected when the Enable Performance Mode option in the Vivado Integrated Design Environment (IDE) is disabled. Legacy mode uses the AXI4-Lite interface and is fully backward compatible(向后兼容) with all the older versions of the AXI Quad SPI core in terms of functionality, register bit placement, and register access.
The AXI Quad SPI core, when configured in Dual/Quad SPI mode, this core supports additional pins for interfacing with external memory. These additional pins are used while transmitting the command, address, and data based on the control register settings and command used.

Register Space (Legacy and Enhanced Non-XIPMode)

Note: The AXI4-Lite write access register is updated by the 32-bit AXI Write Data (_wdata) signal. For a Write, both the AXI Write Address Valid (_awvalid) and AXI Write Data Valid (*_wvalid) signals should be asserted together.
在这里插入图片描述
在这里插入图片描述
Notes:

  1. The power-on reset data in the SPI DRR is unknown or all zeros. This register should not be considered for power-on reset conditions.
  2. Exists only when FIFO Depth is set to 16 or 256.
  3. TOW = Toggle on write. Writing a 1 to a bit position within the register causes the corresponding bit position in the register to toggle.
    This table shows the set of registers applicable whether or not Enable Performance Mode is selected and Enable XIP Mode is not selected. Some AXI Quad SPI core registers should be accessed individually. These registers are configurable and accessible through either the AXI4-Lite interface or the AXI4 interface (enhanced mode). All registers are accessed as 32-bit.

Example Programming Sequence

The following steps briefly describe the erase, write and read command sequence for SPI flash.
Note: [1] The WRITE ENABLE command must be issued before every write transaction (erase/write data to the flash/register write of flash) command to the flash.
Note: [2] The following programming sequence is based on the 24-bit addressing mode of flash and assumes there is only one slave connected to the AXI QUAD SPI core.

Write Enable Command Sequence

  1. Disable the master transaction by asserting the master inhibit bit of SPICR (60h), and reset the RX and TX FIFOs through SPICR.
  2. Issue the write enable command by writing 0x06 into SPIDTR.
  3. Issue chip select by writing 0x00 to SPISSR(70h).
  4. Enable master transaction by deasserting the SPICR master inhibit bit.
  5. Deassert chip select by writing 0x01 to SPISSR.
  6. Disable master transaction by asserting the SPICR master inhibit bit.

Erase Command Sequence

  1. Reset RX and TX FIFOs through SPICR.
  2. Issue sector erase command into SPIDTR to erase any specific sector followed by the flash sector address or issue the bulk erase command to erase the entire flash followed by the flash base address.
  3. Issue chip select by writing 0x00 to SPISSR.
  4. Enable master transaction by deasserting the SPICR master inhibit bit.
  5. Deassert chip select by writing 0x01 to SPISSR.
  6. Disable master transaction by asserting the SPICR master inhibit bit.

Write Data Command Sequence

  1. Reset RX and TX FIFOs through SPICR.
  2. Issue the write data command into SPIDTR, to write data into any specific sector
    followed by the flash sector address.
  3. Fill SPIDTR with the data to be written to flash; the maximum data size depends upon the configured QSPI FIFO size.
  4. Issue chip select by writing 0x00 to SPISSR.
  5. Enable master transaction by deasserting the SPICR master inhibit bit.
  6. Deassert chip select by writing 0x01 to SPISSR.
  7. Disable master transaction by asserting the SPICR master inhibit bit.

Read Data Command Sequence

  1. Reset RX and TX FIFOs through SPICR.
  2. Issue the read data command into SPIDTR to read data from any specific sector followed by the flash sector address.
  3. Fill SPIDTR with the dummy data to read required data from the flash.
  4. Issue chip select by writing 0x00 to SPISSR(70h).
  5. Enable master transaction by deasserting the SPICR master inhibit bit.
  6. Deassert chip select by writing 0x01 to SPISSR.
  7. Disable master transaction by asserting SPICR master inhibit bit.
  8. Read SPIDRR, to get the Read data that is received from the SPI bus.
  9. Refer to the respective SPI slave (flash) data sheet to know which commands to issue.
  10. Write/Read commands vary with respect to the mode (Standard/Dual/Quad) used.

约束文件xdc设置

在xdc文件中添加如下设置:

set_property BITSTREAM.CONFIG.CONFIGRATE 33 [current_design]
set_property BITSTREAM.CONFIG.SPI_32BIT_ADDR YES [current_design]
set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
set_property BITSTREAM.CONFIG.SPI_FALL_EDGE YES [current_design]
set_property CONFIG_MODE SPIx4 [current_design]
set_property BITSTREAM.GENERAL.COMPRESS TRUE [current_design]
set_property BITSTREAM.CONFIG.TIMER_CFG 0x8000000 [current_design]

Golden镜像设置

set_property BITSTREAM.CONFIG.NEXT_CONFIG_ADDR 0x00F50000 [current_design]
set_property BITSTREAM.CONFIG.NEXT_CONFIG_REBOOT ENABLE [current_design]

Update镜像设置

set_property BITSTREAM.CONFIG.CONFIGFALLBACK ENABLE [current_design]
其中set_property BITSTREAM.CONFIG.TIMER_CFG这一项设置是使能FPGA在上电配置过程中的看门狗计时器,具体的数值没有找到相关参考文档,还希望能够私信探讨。

参考文档:

Xapp1257、pg153、ug908、ug570.
目前方案已经经过平台验证,刚开始写博文,如有问题欢迎私信指正。

  • 7
    点赞
  • 68
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
Intel FPGA远程升级是指通过网络将新的FPGA固件加载到远程设备中的过程。这种方法可以实现远程设备的升级,而不需要直接访问该设备。这样可以大大简化设备维护和升级的流程。 要实现Intel FPGA远程升级,首先需要确保目标设备具备网络连接能力。其次,需要将待升级的新的FPGA固件上传到升级服务器上。然后,通过升级服务器与目标设备进行通信,将新的FPGA固件传输到目标设备中。一旦传输完成,目标设备便可以使用新的FPGA固件,从而获得新的功能或性能提升。 远程升级过程中,需要注意以下几个关键问题。首先是数据传输的安全性。由于升级过程需要通过网络传输大量的敏感数据,确保数据传输的安全非常重要。其次是兼容性问题。新的FPGA固件必须与目标设备兼容,否则可能会导致设备异常或不可用。最后是升级过程的稳定性。由于远程升级过程中涉及到网络通信,偶发的通信故障可能导致升级失败,因此需要采取相应措施来确保升级过程的稳定性和可靠性。 总的来说,Intel FPGA远程升级为设备的维护和升级提供了方便快捷的方式。它允许在不直接访问设备的情况下进行远程升级,从而节省了时间和资源,提高了设备的可用性和安全性。同时,在使用远程升级功能时,需要注意数据的安全性、兼容性和稳定性等关键问题,以确保升级过程的成功和可靠性。
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值