01signal.com

Quartus / Linux: 使用命令行对 FPGA 进行编程

命令行?

是的,它比 GUI programmer方便得多。用 bitstream file 加载 FPGA 是一项重复性任务。连接到同一台计算机的同一块板上的同一 FPGA 始终是相同的文件。不知何故, GUI tools 把它变成了一个令人生畏的仪式(有时甚至是一个测验,当它无法准确判断连接了哪个设备时,所以我应该知道确切的那个)。

使用命令行,它实际上是从 bash history中选择命令,然后按 Enter。令人惊讶的是,命令行工具不会像 GUI 工具那样提出愚蠢的问题。

首先,一些玩弄

设置 environment:

$ /path/to/quartus/15.1/nios2eds/nios2_command_shell.sh

列出找到的所有设备(自动检测 cable ):

$ quartus_pgm --auto
Info: *******************************************************************
Info: Running Quartus Prime Programmer
    Info: Version 15.1.0 Build 185 10/21/2015 SJ Lite Edition
    Info: Copyright (C) 1991-2015 Altera Corporation. All rights reserved.
[ ... ]
    Info: agreement for further details.
    Info: Processing started: Sun May 27 15:06:22 2018
Info: Command: quartus_pgm --auto
Info (213045): Using programming cable "USB-BlasterII [2-5.1]"
1) USB-BlasterII [2-5.1]
  02B040DD   5CGTFD9(A5|C5|D5|E5)/..
  020A40DD   5M2210Z/EPM2210

[ ... ]

请注意,加载 bitstream不需要如上所示列出设备。告诉 FPGA 在 JTAG chain中的位置可能很有用,也许。真的是做一次探索板的事情。

jtagd

重要的是要注意这个 daemon,它听 TCP/IP port 1309。它负责通过 USB bus与 JTAG 适配器通信,所以 GUI programmer 和命令行工具都依赖它。如果没有 daemon 运行,这两个都启动它。

但是,如果您使用多个版本的 Quartus,这可能会造成混淆,特别是如果您第一次尝试使用旧版本加载 FPGA ,然后再尝试新版本。这是因为新版本的 Quartus 将继续使用旧版本的 jtagd。而且这个较旧的 jtagd 可能不支持较新版本的 Quartus 支持的 FPGAs 。所以结论是,如果发生奇怪的事情,这可能会解决它,并且无论如何都不会受到伤害:

$ killall jtagd

加载 FPGA

quartus_pgm 以绿色文本显示其大部分输出。一般来说,如果没有红色的文字,一切都很好。

$ quartus_pgm -m jtag -o "p;path/to/file.sof"

或者,在 JTAG chain 中明确添加 JTAG 的位置(特别是如果它不是第一个设备)。在这种情况下,它是 @1,这意味着它是 JTAG chain中的第一个设备。如果是第二台设备,请选择 @2 等。

$ quartus_pgm -m jtag -o "p;path/to/file.sof@1"
Info: *******************************************************************
Info: Running Quartus Prime Programmer
    Info: Version 15.1.0 Build 185 10/21/2015 SJ Lite Edition
    Info: Copyright (C) 1991-2015 Altera Corporation. All rights reserved.
    Info: Your use of Altera Corporation's design tools, logic functions
    Info: and other software and tools, and its AMPP partner logic
    Info: functions, and any output files from any of the foregoing
    Info: (including device programming or simulation files), and any
    Info: associated documentation or information are expressly subject
    Info: to the terms and conditions of the Altera Program License
    Info: Subscription Agreement, the Altera Quartus Prime License Agreement,
    Info: the Altera MegaCore Function License Agreement, or other
    Info: applicable license agreement, including, without limitation,
    Info: that your use is for the sole purpose of programming logic
    Info: devices manufactured by Altera and sold by Altera or its
    Info: authorized distributors.  Please refer to the applicable
    Info: agreement for further details.
    Info: Processing started: Sun May 27 15:35:02 2018
Info: Command: quartus_pgm -m jtag -o p;path/to/file.sof@1
Info (213045): Using programming cable "USB-BlasterII [2-5.1]"
Info (213011): Using programming file p;path/to/file.sof@1 with checksum 0x061958E1 for device 5CGTFD9E5F35@1
Info (209060): Started Programmer operation at Sun May 27 15:35:05 2018
Info (209016): Configuring device index 1
Info (209017): Device 1 contains JTAG ID code 0x02B040DD
Info (209007): Configuration succeeded -- 1 device(s) configured
Info (209011): Successfully performed operation(s)
Info (209061): Ended Programmer operation at Sun May 27 15:35:09 2018
Info: Quartus Prime Programmer was successful. 0 errors, 0 warnings
    Info: Peak virtual memory: 432 megabytes
    Info: Processing ended: Sun May 27 15:35:09 2018
    Info: Elapsed time: 00:00:07
    Info: Total CPU time (on all processors): 00:00:03

如果出现任何问题 - 设备不匹配、未能扫描 JTAG chain 或其他任何问题,您将很难错过,因为错误是用红色写的。命令行界面的好处是每次尝试都从头开始,所以只需打开电路板并重试。

Cyclone 10 GX FPGA development kit

这块板给我带来了一些额外的麻烦,所以说几句。当此板连接到计算机时,它显示为 09fb:6810,但是在尝试加载 FPGA (注意末尾的“@2”)后:

$ quartus_pgm -m jtag -o "p;thecode.sof@2"
Error (213019): Can't scan JTAG chain. Error code 86.

设备的 ID 更改为 09fb:6010。所以显然有一些 firmware 的 reprogramming ( system log 显示与新的 ID断开和重新连接)。该板被 Quartus的 GUI Programming Tool检测为 GX0000406 ,但是点击“Auto Detect”却是“Unable to scan device chain. Hardware is not connected”。

好的,那么试试 scan怎么样?

$ quartus_pgm --auto
[ ... ]
Info (213045): Using programming cable "10CGX0000406 [1-5.1.2]"
1) 10CGX0000406 [1-5.1.2]
  Unable to read device chain - Hardware not attached

我的问题显然是正在运行的 jtagd 是由旧版本的 Quartus启动的,它无法识别 Cyclone 10 设备。所以按照上面的建议,杀了它。之后,使用上面的命令进行编程与 Quartus Pro 17.1一起工作:

$ quartus_pgm --auto
[...]
Info (213045): Using programming cable "USB-BlasterII [1-5.1.2]"
1) USB-BlasterII [1-5.1.2]
  031820DD   10M08SA(.|ES)/10M08SC
  02E120DD   10CX220Y
此页面由英文自动翻译。 如果有不清楚的地方,请参考原始页面
Copyright © 2021-2024. All rights reserved. (6f913017)