V4l2loopback troubleshooting

Hi, I’m trying to install v4l2loopback devices, but when modprobing no /dev/videoX device is created, and modprobe also doesnt give any error.

Here’s a full log from the terminal:

drakorg@dev-jp43:~$ sudo apt list -i | grep -i v4l2loopback

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

drakorg@dev-jp43:~$ sudo apt install v4l2loopback-dkms
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libavdevice57 libtext-charwidth-perl libtext-wrapi18n-perl module-assistant v4l-utils
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  v4l2loopback-utils
The following NEW packages will be installed:
  v4l2loopback-dkms
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 23,1 kB of archives.
After this operation, 112 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 v4l2loopback-dkms all 0.10.0-1ubuntu1 [23,1 kB]
Fetched 23,1 kB in 1s (34,3 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package v4l2loopback-dkms.
(Reading database ... 171277 files and directories currently installed.)
Preparing to unpack .../v4l2loopback-dkms_0.10.0-1ubuntu1_all.deb ...
Unpacking v4l2loopback-dkms (0.10.0-1ubuntu1) ...
Setting up v4l2loopback-dkms (0.10.0-1ubuntu1) ...
Loading new v4l2loopback-0.10.0 DKMS files...
It is likely that 4.9.140-tegra belongs to a chroot's host
Building for 4.15.0-20-generic and 4.9.140-tegra
Building initial module for 4.15.0-20-generic
Done.

v4l2loopback:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.15.0-20-generic/updates/dkms/

depmod...

DKMS: install completed.
Building initial module for 4.9.140-tegra
Done.

v4l2loopback:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.9.140-tegra/updates/dkms/

depmod...

DKMS: install completed.
drakorg@dev-jp43:~$ sudo modprobe v4l2loopback devices=8
drakorg@dev-jp43:~$ ls -la /dev/video*
ls: cannot access '/dev/video*': No such file or directory
drakorg@dev-jp43:~$


As you can see modprobe doesnt create the devices … and I have no clue on where to start digging.
For the record, /dev/video0 had been created successfully before, and I could use it with no problem, until a moment where it started to give an error (ioctl write error something), so I sudo apt removed it, hoping I would be able to recreate them, but it didn’t work.

I also see on the logs that it refers to two versions, 4.9 and 4.15 and that it says something about one of them probably belonging to a chroot environment, but I’ve no clue what that means, or if it’s normal.

If anyone has any pointer on where to start looking I’d really appreciate it.
The workaround if I don’t manage to make it work again, reinstall from scratch, but if I can avoid that, great.
Thank you.
Regards.
Eduardo

One thing I’ve noticed, is that the modprobe autocomplete does not suggest the v4l2loopback module as it would on previous occasions, it now just autocomplets to v4l2-tpg … as if the v4l2loopback is not being recognized or something.

Hi,
There are discussions in the topics:
Jetpack 4.2.1 : building v4l2loopback fails
Get two video streams of different resolutions from a single camera with NVIDIA Gstreamer - #7 by Honey_Patouceul

Please check and give it a try.

you may also try some options from the list below

sudo su
cd /usr/src/linux-headers-4.9.140-tegra-ubuntu18.04_aarch64/kernel-4.9
## dropped in latter release##make modules_prepare
mkdir v4l2loopback
git clone https://github.com/umlaeute/v4l2loopback.git v4l2loopback
cd v4l2loopback && git checkout -b v0.10.0
make
## if the sequence above fails - adopt the line: make -C /lib/modules/4.9.140-tegra/build M=`$pwd` modules
## make -C /lib/modules/`uname -r`-tegra/build M=/usr/src/v4l2loopback modules_install

make install
apt-get install -y v4l2loopback-dkms v4l2loopback-utils
modprobe v4l2loopback devices=1 video_nr=2 exclusive_caps=1
echo options v4l2loopback devices=1 video_nr=2 exclusive_caps=1 > /etc/modprobe.d/v4l2loopback.conf
echo v4l2loopback > /etc/modules
update-initramfs -u

Ok, I think I finally nailed it. It may have had something to do with the fact that a /dev/video0 was always there and I didn’t recall configuring anything to make v4l2loopback autostart, so I took that /dev/video0 as a device that just shouldn’t be there. Because of that and since it didn’t go away with modprobe -r v4l2loopback, i tried to manually delete it, which I did, but it would still come back after a reboot. In the meantime I uninstalled and installed every possible combination of v4l2loopback and tried everything to get rid of that /dev/video0 that was stuck there, just to realize that it wasn’t created by v4l2loopback, but it was the representation of a cam I had connected.

After realizing that /dev/video0 was fine, I made peace with it and focused on making v4l2loopack work on the rest of the devices. The solution was to do a final modprobe -r v4l2loopback. After that it was like the module started to work as expected, and all video1 to video8 appeared after a final modprobe v4l2loopback devices=8.

I then automated with the steps you mentioned in your script (beware that you used a > to /etc/modules where that would trash whatever modules you may have had) … a >> would have been better.

In any case I finally got it working, so thanks to everyone.
Best regards,
Eduardo