使用树莓派RP2040控制器配置FPGA
整理并分享与RP2040配置FPGA相关的例程,利用RP2040的可编程IO,以及USB1.1的接口功能,可以使用非常低的成本完成对FPGA的配置。
标签
FPGA
RP2040
ilovefpga
更新2021-11-20
2831

在研究如何使用RP2040对FPGA进行编程,好处:

  • RP2040有USB1.1端口
  • RP2040有非常灵活的可编程IO,通过汇编编程,可以实现几乎任何一种端口逻辑
  • RP2040一般会搭配比较大的串行Flash,SPI接口,这个可以同时用于存储FPGA的配置文件
  • RP2040的MicroPython版本是将RP2040当成大容量存储器来使用,对于所有的操作系统都是免驱动
  • 关键RP2040比较便宜,只要1美元的价格,即便搭配Flash也是一种成本非常低廉的解决方案。

先汇总一下目前网上有人尝试的结果:

PCB combining Raspberry Pi Pico and iCE40 FPGA

FsUOtF8iFLLWhLMn-Iz6tNeMzO64

使用PICO模块对ICE40 HX芯片进行配置

FgAGb3N2t5sUtWPApEDhSFuf1u-E

演示程序为ICE40 HX驱动DVI显示器

使用的Python插件:

#!/usr/bin/env python3

# picoprog.py
#
# Copyright (C) 2021 Dan Rodrigues <danrr.gh.oss@gmail.com>
#
# SPDX-License-Identifier: MIT

import sys

import usb.core
import usb.util

# Expecting 1 argument with bitstream to load
if len(sys.argv) != 2:
    print("Usage: picoprog.py <bistream>")
    sys.exit(0)

# Find Pico programmer device
dev = usb.core.find(idVendor=0x2E8A, idProduct=0x0004)
if dev is None:
    raise RuntimeError("Device not found")

cfg = dev.get_active_configuration()
intf = cfg[(2, 0)]

outep = usb.util.find_descriptor(
    intf,
    # First OUT endpoint
    custom_match= \
        lambda e: \
            usb.util.endpoint_direction(e.bEndpointAddress) == \
            usb.util.ENDPOINT_OUT)

inep = usb.util.find_descriptor(
    intf,
    # First IN endpoint
    custom_match= \
        lambda e: \
            usb.util.endpoint_direction(e.bEndpointAddress) == \
            usb.util.ENDPOINT_IN)

assert inep is not None
assert outep is not None

# Load bitstream to send

bitstream_path = sys.argv[1]
bitstream_file = open(bitstream_path, 'rb')
if bitstream_file is None:
    raise ValueError("Failed to open bitstream file: {:s}".format(bitstream_path))

bitstream = bitstream_file.read()
bitstream_file.close()

# Send bitstream over USB

ctrl_request_type = 0x40

ctrl_request_prepare = 0x01
ctrl_request_finalize = 0x02

dev.ctrl_transfer(ctrl_request_type, ctrl_request_prepare, 0, 0)
outep.write(bitstream)
dev.ctrl_transfer(ctrl_request_type, ctrl_request_finalize, 0, 0)

第二篇文章:

Raspberry Pico powered Xilinx Virtual Cable - Xilinx JTAG Cable!

Pinout image

 

下一步尝试在Lattice的FPGA芯片ICE40UP5K和CrossLink-NX上实现一下。

 

团队介绍
评论
0 / 100
查看更多
目录
硬禾服务号
关注最新动态
0512-67862536
info@eetree.cn
江苏省苏州市苏州工业园区新平街388号腾飞创新园A2幢815室
苏州硬禾信息科技有限公司
Copyright © 2024 苏州硬禾信息科技有限公司 All Rights Reserved 苏ICP备19040198号