My application can’t see a fresh new /dev/tty* device on host.
The device in question is /dev/ttyXRUSB0, that is an Exar USB device driver, needed by an USB to RJ45 adapter for RS-485 communication.
I had to build a kernel module for that, inspiring on https://github.com/balena-io-projects/kernel-module-build.
In order to see the /dev/ttyXRUSB0 device, I have to load the xr_usb_serial_common.ko module.
On previous version of resinOS/balenaOS I was able to see the new device within my container, but now, on my Raspberry Pi 3 B running balenaOS 2.29.2+rev1 and Supervisor 9.0.1, I see the device only on the host, not within the container!
To see the device within the container I have to reboot/restart the container.
Note also that rebooting the device would lead to the same problem.
Is there a way I can refresh the list of /dev/tty* devices from the host within my container?
Hi @daghemo, Can you tell me what baseimage your Dockerfile starts FROM, it sounds like you don’t have udev running in the container, which is responsible for picking up the addition of dynamic devices in /dev.
#!/bin/bash
hostname "$HOSTNAME" &> /dev/null
if [[ $? == 0 ]]; then
PRIVILEGED=true
else
PRIVILEGED=false
fi
function mount_dev()
{
mkdir -p /tmp
mount -t devtmpfs none /tmp
mkdir -p /tmp/shm
mount --move /dev/shm /tmp/shm
mkdir -p /tmp/mqueue
mount --move /dev/mqueue /tmp/mqueue
mkdir -p /tmp/pts
mount --move /dev/pts /tmp/pts
touch /tmp/console
mount --move /dev/console /tmp/console
umount /dev || true
mount --move /tmp /dev
# Since the devpts is mounted with -o newinstance by Docker, we need to make
# /dev/ptmx point to its ptmx.
# ref: https://www.kernel.org/doc/Documentation/filesystems/devpts.txt
ln -sf /dev/pts/ptmx /dev/ptmx
mount -t debugfs nodev /sys/kernel/debug
}
function start_udev()
{
if [ "$UDEV" == "on" ]; then
if $PRIVILEGED; then
mount_dev
if command -v udevd &>/dev/null; then
unshare --net udevd --daemon &> /dev/null
else
unshare --net /lib/systemd/systemd-udevd --daemon &> /dev/null
fi
udevadm trigger &> /dev/null
else
echo "Unable to start udev, container must be run in privileged mode to start udev!"
fi
fi
}
function init()
{
# echo error message, when executable file doesn't exist.
if CMD=$(command -v "$1" 2>/dev/null); then
shift
exec "$CMD" "$@"
else
echo "Command not found: $1"
exit 1
fi
}
UDEV=$(echo "$UDEV" | awk '{print tolower($0)}')
case "$UDEV" in
'1' | 'true')
UDEV='on'
;;
esac
start_udev
init "$@"
It seems that you’re using the example code from here to build the module - that’s great !
I’ve noticed that there is an accompanying script there to nudge the module to be loaded - see run.sh in the said repo. Could you try explicitly invoking insmod from within the container to see if this helps - this is what the said run.sh does.