Run NI FPGA Compile Worker on CentOS as a Systemd Service

Updated Dec 8, 2020

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 running cw_wrapper.sh mono CompileWorker.exe (typically located at /usr/local/natinst/nifpgacompileworker folder) with an attached screen/remote X-session. This has to be done only once.
    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 and CentOS 7.8 using NI FPGA 2018 and 2019 with the Xilinx Vivado 2017.2 compilation toolkit.