Run NI FPGA Compile Worker on CentOS as a Systemd Service

Updated Oct 30, 2023

Environment

Software

  • LabVIEW FPGA Compilation Tool
  • LabVIEW FPGA Compilation Tool for Vivado 2017.2

Operating System

  • Linux

Other

  • CentOS 7.x
  • SUSE Enterprise Linux 15.x
  • RHEL 7.x

The NI FPGA Compile Worker processes FPGA compile tasks distributed by a NI FPGA Compile Server and provides the link between LabVIEW code and a bitfile to configure the FPGA during application deployment. The NI FPGA compilation tool chain is based on either the Xilinx Vivado or ISE FPGA toolkits. 

On Linux, the NI FPGA Compile Worker is executed by the mono .NET runtime environment. As of now, the Compile Worker is not automatically started when the system is booted.

This article will describe how to setup a systemd service to launch the NI FPGA Compile Worker unattendedly at system startup. While the example covers CentOS 7.8, the same procedure should apply to other supported Linux distributions that are based on the systemd init system.

Procedure Summary

  • Install the required packages mono-core and Xvfb
  • Prepare a shell script file that sets the environment variables and runs CompileWorker.exe using mono.
  • Setup the nifpgaworker.service for systemd, enable and register the service for automatic startup
  • Configure the NI FPGA Compile Worker to connect to a CompileServer running on the network
  • Compile an FPGA bitfile via the server and the Linux CompileWorker from a LabVIEW client.

Preparatory Steps

First, ensure that you have NI-FPGA including either the Xilinx Vivado or ISE toolkits installed. To do this, follow the instructions for Setting up a Linux-Based FPGA Compile Worker.
Next, make sure that the ‘Xvfb’ X virtual frame buffer utility and mono runtime environment are installed with sudo yum install Xvfb mono-core

Setting up the systemd service

Next, setup the Compile Worker caller script and systemd service as described below. The files mentioned in the how-to are given below. Ensure that you have root privileges when following the procedure.

  1. Create /etc/systemd/system/service/nifpgaworker.service with the contents below and mark it readable / writeable with chmod 664 /etc/systemd/system/nipfgaworker.service
  2. Create /usr/local/natinst/nifpgacompileworker/start_nifpgacompileworker.sh with the contents below and mark it executable via chmod 774 /usr/local/natinst/nifpgacompileworker/start_nifpgacompileworker.sh
  3. Setup the CompileServer by changing into the Compile workerdirectory cd /usr/local/natinst/nifpgacompileworker (adjust the path if it located in a different folder) and executing sh cw_wrapper.sh mono CompileWorker.exe. This needs to be done only during the first-time setup or when the Compile Server or its login credentials have changed.
    1. Enter the IP address of the Compile Server
    2. User is typically admin and password is empty per default
    3. Confirm the next dialogs with OK
    4. Kill the CompileServer process, i.e. with kill -9 <pid>. You can find the pid with pgrep -f CompileWorker
  4. Next, register the compile worker service with the following commands:
    1. systemctl daemon-reload
    2. systemctl enable nifpgaworker.service
    3. systemctl start nifpgaworker.service
 

SHELL SCRIPT file to call CompileWorker by the service

Should be placed as /usr/local/natinst/nifpgacompileworker/start_nifpgacompileworker.sh

#!/bin/bash
CW_PATH=/usr/local/natinst/nifpgacompileworker
export LD_LIBRARY_PATH=$DIR:/usr/local/natinst/mono/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/natinst/mono/bin/:$PATH
# This line is a workaround for Mono 4.0.4. Mono 4.2.1 has fixed the issue. See CAR #550029.
export MONO_XMLSERIALIZER_THS=no
# set screen to virtual framebuffer
# no worries, this will only apply to the contents of the shell file
if which Xvfb
then
               Xvfb :1 -screen 0 1024x768x16 &
               export DISPLAY=:1
fi
cd $CW_PATH
mono $CW_PATH/CompileWorker.exe

SYSTEMD service defintion file contents

Should be created as /etc/systemd/system/nifpgaworker.service

[Unit]
Description=NI FPGA Compile Worker Wrapper
[Service]
ExecStart=/usr/local/natinst/nifpgacompileworker/start_nifpgacompileworker.sh
ExecStop=
StandardOutput=syslog
StandardError=syslog
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=default.target

The NI FPGA Compile Worker should now start as a systemd service at boot. This can be particularly beneficial if the system is used as an unattended standalone compilation server. The service should also restart automatically after an unexpected crash and will output log data to the system journal. The above procedure was tested on CentOS 7.3, CentOS 7.8, CentOS 7.9 using NI FPGA 2018, 2019 and 2020 with the Xilinx Vivado 2017.2 compilation toolkit as well as the Xilinx Vivado 2019.1 compilation toolkit. The described steps should work similarly on Red Hat Enterprise Linux (RHEL) of the same versions.
 

Compile Worker Troubleshooting:

  1.     Check the service status with systemctl status nifpgaworker.service (if that is the service name you used during creation above).
  2.     If the status is stopped and an error is shown: Make sure that Xvfb is installed (see above) and you have run the configuration using cw_wrapper.sh at least once (see above).
  3.     Attempt to restart the service with systemctl start nifpgaworker.service
  4.     Check the service status again or look through the full log for error messages via journalctl -u nifpgaworker.service (if that is the service name you used during creation above).
Compile Server Troubleshooting:
  1. Make sure the CompileWorker registered properly with the Compile Server. It should show up on the Worker list at http://<compileserver_IP_adress>:3582/WIF.html#/NationalInstruments.WIF.FpgaCompileFarmWifExtension;component/FpgaCompileFarmWifExtensionPage.dyn.xaml (edit the link to point to your server's proper IP adress. you will need Microsoft SilverLight to see the page)
  2. Screenshot of a properly registered CompileWorker.