Intel Acceleration Stack Quick Start Guide: Intel FPGA Programmable Acceleration Card D5005

ID 683394
Date 7/09/2021
Document Table of Contents

6.2. Running the Hello FPGA Example

The hello_fpga sample host application uses the OPAE library to test the hardware in a native loopback (NLB) configuration. Load the FPGA with the nlb_mode_0 AFU image to run this example.
  1. Run the following command to load the hello_fpga sample host application:
    sudo fpgasupdate $OPAE_PLATFORM_ROOT/hw/samples/nlb_mode_0/bin/\
    Note: The fpgasupdate tool accepts PCIE B:D.F (for example: 04:00.0) as an argument
  2. Configure the system hugepages to allocate 20, 2 MB hugepages that this utility requires. This command requires root privileges:
    sudo sh -c "echo 20 > /sys/kernel/mm/hugepages/\
    Note: The above configuration is for a single card system. For multiple cards, set the number of 2 MB hugepages to 20*<number_of_cards>.
  3. Change to the source code directory for hello_fpga located at $OPAE_PLATFORM_ROOT/sw/opae*/samples/hello_fpga.c:
    1. Extract the tar file:
      tar xf opae-*.tar.gz
    2. Change to the OPAE directory:
      cd opae*
  4. Compile the example:
    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. To run the example, type the following command:
    sudo ./hello_fpga

    Sample output:

    Running Test
    Running on Bus 0x3b
    Done Running Test
The Acceleration Stack 2.0.1 Release includes the following working AFU images in the $OPAE_PLATFORM_ROOT/hw/samples directory:
  • 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
Note: For fpgasupdate to successfully program the bitstreams, all AFU bitstreams built through the AFU development process must be processed by PACSign with or without signing keys to add appropriate headers. The bitstreams provided within the sample AFUs ($OPAE_PLATFORM_ROOT/hw/<sample afu>/bin/*_unsigned.gbs) are processed with PACSign to add an appropriate header but they are not signed with any key.
The code below shows an example AFU host code compilation and execution.
sudo fpgasupdate $OPAE_PLATFORM_ROOT/hw/samples/<afu>/bin/*_unsigned.gbs
cd $OPAE_PLATFORM_ROOT/hw/samples/<afu>/sw
sudo ./<executable>
For sample AFU nlb_mode_0 and nlb_mode_3, the pre-compiled executables are copied to location /usr/bin.

To execute AFU sample nlb_mode_0, type the following commands:

sudo fpgasupdate \ 
sudo sh -c "echo 20 > /sys/kernel/mm/hugepages/\
sudo nlb0

To execute sample nlb_mode_3, type the following commands:

sudo fpgasupdate \ 
sudo sh -c "echo 20 > /sys/kernel/mm/hugepages/\
sudo nlb3

Refer to the README file available under each <example AFU> directory for additional information.