FPGA通过CPU远程升级方案

news/2024/11/29 4:32:58/

FPGA通过CPU远程升级方案

  • 方案介绍
    • 升级流程图
    • 功能框图
  • 例程实现
    • AXI Quad SPI IP核的生成和配置
      • Dual/Quad SPI Mode
      • Legacy Mode
    • Register Space (Legacy and Enhanced Non-XIPMode)
    • Example Programming Sequence
      • Write Enable Command Sequence
      • Erase Command Sequence
      • Write Data Command Sequence
      • Read Data Command Sequence
    • 约束文件xdc设置
      • 在xdc文件中添加如下设置:
      • Golden镜像设置
      • Update镜像设置
      • 参考文档:

方案介绍

本文介绍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.
目前方案已经经过平台验证,刚开始写博文,如有问题欢迎私信指正。


http://www.ppmy.cn/news/459475.html

相关文章

阿里云服务器如何升级配置(实例规格、cpu和内存、带宽)

很多用户在购买了阿里云服务器之后,后期随着业务的增加,原来购买的阿里云服务器可能就无法满足使用需求了,这就涉及到需要升级云服务器的实例规格、cpu和内存、带宽配置,该如何升级这些配置呢?以下是阿里云服务器如何升…

matlab吃cpu还是显卡_老电脑该升级CPU、硬盘还是内存、显卡?大白话告诉你该怎么做...

一台电脑的使用寿命还是很长的,只是到了一定时间,性能会越来越跟不上时代,连最基本的网页浏览都会变得卡卡的,尤其是超过5年的老电脑。 可是该怎办?扔了可惜,想继续用需要升级哪些部件呢?下面我们就来聊聊,老电脑该如何升级。 一、电脑的几个主要部件 (一)CPU:俗称中央…

联想g510升级换什么cpu好_老775平台还有升级CPU的必要吗?实测来告诉你

老775平台还有升级CPU的必要吗?实测来告诉你 2019-05-09 11:58:24 12点赞 11收藏 14评论 你是AMD Yes党?还是intel和NVIDIA的忠实簇拥呢?最新一届#装机大师赛#开始啦!本次装机阵营赛分为3A红组、intel NVIDIA蓝绿组、混搭组还有ITX组,实体or虚拟装机都能参与,可使用值得买…

cpu计算机兼容,电脑升级之CPU篇:给CPU升级主要是兼容性问题,其他方法也用不上...

大家都知道,要给老电脑升级,首要选择的是升级硬盘和内存,然后再考虑到显卡。而CPU的升级是一个比较复杂的问题,毕竟成本太高,有时并不在考虑升级的硬件范围。 但升级CPU对很多用户来说,并不是必须的升级内容…

2023.04.20

今天我没干啥。写了工厂模式的demo,也算是了解更深一点了,突然想到,既然自己现在用的框架是ruiyi为啥不去官网读一下呢

2023.4.1

额,熬夜了还是,其实不应该熬夜的。题也没写多少个哪。 睡觉睡觉,刷了刷抖音,看到了好几个抽象的up猪,好好笑 真是两个有趣的灵魂,哈哈哈。

2023.04.19

作业&#xff1a;请简述字节序的概念&#xff08;概念、大小端&#xff09;&#xff0c;用共用体的方式求本机的大小端。 #include<string.h> #include<stdio.h> #include<stdlib.h>//共用体 int check() {union {char a;int b;}fun;fun.b1;return fun.a;} …