Recently I was trying to make FPGA tools running inside a LinuX Container (LXC). Getting the software tools running is basically about coping with Xilinx’s horrible bash scripts. Making the container see the FPGA hardware seems more challenging and there are very few references on the Internet.
The major trick is to pass the correct devices to the LXC. FPGAs (at least those our lab is using) are treated as character devices under /dev/
. By default, only very few devices are passed to LXC and apparently FPGAs are not among them. To do this manually, we have to add a hook for FPGA devices first:
lxc.hook.autodev = /var/lib/lxc/fpga-dev-hook
where the hook contains something like
#!/bin/sh cp -dpR /dev/xcldma* ${LXC_ROOTFS_MOUNT}/dev
Note that you need to give the LXC proper access to the devices. A lazy man’s solution is to add
lxc.cgroup.devices.allow = a *:* rwm
to allow any device. A better solution is to use something like
lxc.cgroup.devices.allow = c 243:3 rw
to allow specific devices. c
means character devices. Other options possible in this place are b
for block devices and a
for “all”. 243
is the major number of the device. 3
is the minor number. Be alert that the major and minor numbers can be different on different machines for the same device. rw
at the end of the line means read & write, obviously. Another option possible here is m
for mknod
. Please RTFM for details about device whitelist controller.
Last but not least, make sure to install the device driver correctly on the host.
References