Intel Acceleration Stack快速入门指南: Intel FPGA Programmable Acceleration Card D5005

ID 683394
日期 9/09/2020
Public
文档目录

6.2. 运行Hello FPGA示例

hello_fpga示例主机应用程序使用OPAE库在本机环回(NLB)配置中测试硬件。使用nlb_mode_0 AFU映像加载FPGA以运行此示例。
  1. 运行以下命令以加载hello_fpga示例主机应用程序:
    sudo fpgasupdate $OPAE_PLATFORM_ROOT/hw/samples/nlb_mode_0/bin/\
    nlb_mode_0_unsigned.gbs
    注: fpgasupdate工具接受PCIE B:D.F (例如:04:00.0)作为一个参数。
  2. 配置系统大页面以分配此实用程序所需的20个2 MB大页面。此命令需要根特权:
    sudo sh -c "echo 20 > /sys/kernel/mm/hugepages/\
    hugepages-2048kB/nr_hugepages"
    注: 上面的配置用于单卡系统。对于多卡系统,请将2 MB大页面的数量设置为20*<number_of_cards>
  3. 对位于$OPAE_PLATFORM_ROOT/sw/opae*/samples/hello_fpga.chello_fpga更改到源代码目录:
    cd $OPAE_PLATFORM_ROOT/sw
    1. 提取tar文件:
      tar xf opae-*.tar.gz
    2. 更改为OPAE目录。
      cd opae*
  4. 编译示例:
    gcc -o hello_fpga -std=gnu99 -rdynamic \
    -ljson-c -luuid -lpthread -lopae-c -lm -Wl,-rpath \
    -lopae-c $OPAE_PLATFORM_ROOT/sw/opae*/samples/hello_fpga.c
    
  5. 输入以下命令运行此示例:
    sudo ./hello_fpga

    样例输出:

    Running Test
    Running on Bus 0x3b
    Done Running Test
Acceleration Stack 2.0.1 Release将以下工作AFU映像包含在$OPAE_PLATFORM_ROOT/hw/samples目录中:
  • dma_afu/bin/dma_afu_unsigned.gbs
  • streaming_dma_afu/bin/streaming_dma_afu_unsigned.gbs
  • hello_afu/bin/hello_afu_unsigned.gbs
  • hello_intr_afu/bin/hello_intr_afu_unsigned.gbs
  • hello_mem_afu/bin/hello_mem_afu_unsigned.gbs
  • nlb_mode_0/bin/nlb_mode_0_unsigned.gbs
  • nlb_mode_3/bin/nlb_mode_3_unsigned.gbs
  • nlb_mode_0_stp/bin/nlb_mode_0_stp_unsigned.gbs
  • hssi_prbs/bin/hssi_prbs_unsigned.gbs
  • byte_enable/bin/byte_enable_afu_unsigned.gbs
注: 为了使fpgasupdate能够成功地对比特流进行编程,在AFU开发过程中构建的所有AFU比特流必须通过PACSign进行处理(无论是否通过签署秘钥来添加相应的标头)。样本AFU ($OPAE_PLATFORM_ROOT/hw/<sample afu>/bin/*_unsigned.gbs)中提供的比特流由PACSign进行处理来添加相应的标头,但不使用任何秘钥进行签署。
下面的代码显示了一个示例AFU主机代码的编译和执行。
sudo fpgasupdate $OPAE_PLATFORM_ROOT/hw/samples/<afu>/bin/*_unsigned.gbs
cd $OPAE_PLATFORM_ROOT/hw/samples/<afu>/sw
make
sudo ./<executable>
对于样本AFU nlb_mode_0nlb_mode_3,预编译的可执行文件被复制到位置/usr/bin

请输入以下命令来执行AFU sample nlb_mode_0

sudo fpgasupdate \ 
$OPAE_PLATFORM_ROOT/hw/samples/nlb_mode_0/bin/*_unsigned.gbs
sudo sh -c "echo 20 > /sys/kernel/mm/hugepages/\
hugepages-2048kB/nr_hugepages"
sudo nlb0

请输入以下命令来执行sample nlb_mode_3

sudo fpgasupdate \ 
$OPAE_PLATFORM_ROOT/hw/samples/nlb_mode_3/bin/*_unsigned.gbs
sudo sh -c "echo 20 > /sys/kernel/mm/hugepages/\
hugepages-2048kB/nr_hugepages" 
sudo nlb3

请参考每个<example AFU>目录下的README文件以获取更多信息。