Error building v4l2loopback

Hello! I’m trying to create a duplicate of my USB video capture device so that I can stream and record it at the same time. Recording works fine with streamer, and streaming works find with mplayer. I have seen people using v4l2loopback to create additional nodes for their video devices. When I try installing with

sudo apt-get install v4l2loopback-dkms

it produces the following output:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libgconf2-4
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
  dkms
Suggested packages:
  v4l2loopback-utils
The following NEW packages will be installed:
  dkms v4l2loopback-dkms
0 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.
Need to get 89.4 kB of archives.
After this operation, 469 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://ports.ubuntu.com/ubuntu-ports/ trusty-updates/main dkms all 2.2.0.3-1.1ubuntu5.14.04.9 [65.7 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports/ trusty/universe v4l2loopback-dkms all 0.8.0-1 [23.6 kB]
Fetched 89.4 kB in 1min 4s (1,392 B/s)
Selecting previously unselected package dkms.
(Reading database ... 149251 files and directories currently installed.)
Preparing to unpack .../dkms_2.2.0.3-1.1ubuntu5.14.04.9_all.deb ...
Unpacking dkms (2.2.0.3-1.1ubuntu5.14.04.9) ...
Selecting previously unselected package v4l2loopback-dkms.
Preparing to unpack .../v4l2loopback-dkms_0.8.0-1_all.deb ...
Unpacking v4l2loopback-dkms (0.8.0-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up dkms (2.2.0.3-1.1ubuntu5.14.04.9) ...
Setting up v4l2loopback-dkms (0.8.0-1) ...
Loading new v4l2loopback-0.8.0 DKMS files...
First Installation: checking all kernels...
dpkg: warning: version '*-*' has bad syntax: version number does not start with digit
It is likely that 3.10.67-g458d45c belongs to a chroot's host
Building initial module for 3.10.67-g458d45c
ERROR (dkms apport): kernel package linux-headers-3.10.67-g458d45c is not supported
Error! Bad return status for module build on kernel: 3.10.67-g458d45c (aarch64)
Consult /var/lib/dkms/v4l2loopback/0.8.0/build/make.log for more information.

What should I do? Kernel headers are beyond the scope of my linux experience…

What do you get from “head -n 1 /etc/nv_tegra_release”?

# R23 (release), REVISION: 2.0, GCID: 6630372, BOARD: t210ref, EABI: hard, DATE: Tue Feb  9 01:49:02 UTC 2016

This is a fairly old release from back when user space was 32-bit (kernel space was still 64-bit). I’m thinking perhaps the module has some incompatibility with this. Is there a possibility you could flash to a newer release?

My device is installed in a remote location and I can’t access it directly. If it’s possible to flash by downloading an image over wifi then maybe, although I imagine I would have to set up all my services again from scratch :(

The only way to upgrade remotely would be through a series of dd tricks…which in turn would mean the system would have to be booted to alternate media, e.g., SD card or NFS. NFS would be a bad idea.

Very likely the packages are divided into kernel modules and user space components. The mismatched version seems to be a kernel issue. This is not at all surprising since the modules from the repository likely were not built against the Jetson’s kernel. It probably would not be too difficult to build the module on your local PC by cross compiling, and then copying the module to the Jetson over the network. There are some articles and information out there on cross compile. Since this is an old kernel you may find this of use (the kernel edits wouldn’t be needed since the edits are about R24 and you are looking at R23.2, but environment variable setting and such would be correct…also browse elinux.org and the R23.2 docs):
[url]https://devtalk.nvidia.com/default/topic/936880/jetson-tx1/jetson-tx1-24-1-release-need-help-with-complier-directions-can-not-complie/post/4885136/#4885136[/url]

Thanks for the lead - can you suggest any alternative ways to duplicate /dev/video0 without having to compile this module? Cloning a device seems like it should be pretty standard.

Cloning requires either having the device physically present in recovery mode, or else using dd while it is booted to alternative media.

Having a module (assuming module format is supported), or else adding the feature to the kernel image itself as an integrated feature is mandatory to getting a device special file…these files are in fact part of the driver and not really part of the file system. The process itself is considered more or less an ordinary task under Linux, but cross-compiling is a complication. Most any Linux user who wants to develop anything at all needs to be able to configure and build a kernel…no programming knowledge is required since the modules already exist.

Does anyone have advice on cross-compiling on R23.2 for the module to produce “/dev/video0”? If your host is Ubuntu then the cross-compile tools are just a package addition…in other cases you may need to download Linaro tool chains, or else use the tools available from the Documentation download of R23.2 ([url]https://developer.nvidia.com/embedded/linux-tegra-r232[/url]). The “baggage” subdirectory of the unpacked documents has some tools in it…and of course some documentation on kernel customization.

Hi,
For r24.2.1, please refer to
[url]https://devtalk.nvidia.com/default/topic/994012/jetson-tx1/passing-gst-launch-from-nvcamerasrc-to-v4l2sink/post/5090232/#5090232[/url]

For r28.1, v4l2loopback should work fine.

Please update your system via Jetpack or from https://developer.nvidia.com/embedded/linux-tegra first.

That makes a really good point…all of the effort to cross compile a module would be unnecessary if you flashed, and if you don’t flash expect any bug fixes to be missing.

FYI, I would consider it difficult, but it may be possible to remotely create an entry in extlinux.conf which mounts the file system read-only. Since you have no serial console you would have to make that the default entry and then reboot…you could then use dd to clone. However, there is a serious flaw… if the default entry mounts read-only, and you have no serial console access, then you can never put the Jetson back in read-write mode without physical access. Not a very good plan :P

If there were an SD card in the slot with a rescue image (basically just a clone of the existing system or a standard sample rootfs), then you could edit extlinux.conf and reboot without being in read-only mode. This would allow cloning via dd (which in turn might be done via the internet). The extlinux.conf could then be edited again from the alternate boot image on SD card, and rebooted to go back to the upgraded eMMC root file system. This would be rather dangerous though if physical access is difficult since there is a lot which could go wrong and once more require direct access.

“For r28.1, v4l2loopback should work fine.”
For r28.2 how to get v4l2loopback?

KERNELCONF=/usr/src/linux/.config                                           
 │ make[2]: Entering directory '/usr/src/modules/v4l2loopback'                 
 │ Building v4l2-loopback driver...                                            
 │ /usr/bin/make -C /usr/src/linux M=/usr/src/modules/v4l2loopback modules     
 │ make[3]: Entering directory '/usr/src/linux-headers-4.4.38-tegra'           
 │   CC [M]  /usr/src/modules/v4l2loopback/v4l2loopback.o                      
 │ scripts/basic/fixdep: 1: scripts/basic/fixdep: Syntax error: "("            
 │ unexpected                                                                  
 │ scripts/Makefile.build:267: recipe for target                               
 │ '/usr/src/modules/v4l2loopback/v4l2loopback.o' failed                       
 │ make[4]: *** [/usr/src/modules/v4l2loopback/v4l2loopback.o] Error 2         
 │ Makefile:1414: recipe for target '_module_/usr/src/modules/v4l2loopback'    
 │ failed                                                                      
 │ make[3]: *** [_module_/usr/src/modules/v4l2loopback] Error 2                
 │ make[3]: Leaving directory '/usr/src/linux-headers-4.4.38-tegra'            
 │

Please follow the steps to build v4l2loopback

$ sudo su
$ apt-get install v4l2loopback-utils
$ cd /usr/src/linux-headers-4.4.38-tegra
$ make modules_prepare
$ mkdir v4l2loopback
$ cd v4l2loopback
$ git clone https://github.com/umlaeute/v4l2loopback.git
$ cd v4l2loopback
$ make
$ make install
$ modprobe v4l2loopback

And then do https://devtalk.nvidia.com/default/topic/994012/jetson-tx1/passing-gst-launch-from-nvcamerasrc-to-v4l2sink/post/5090232/#5090232

1 Like

Shall I re-flash OS ?

sudo su
[sudo] password for nvidia: 
root@tegra-ubuntu:/home/nvidia# apt-get install v4l2loopback-utils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
v4l2loopback-utils is already the newest version (0.9.1-4).
0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.
root@tegra-ubuntu:/home/nvidia# cd /usr/src/linux-headers-4.4.38-tegra
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra# make modules_prepare
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/bin2c
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --silentoldconfig Kconfig
#
# configuration written to .config
#
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  Generating include/generated/mach-types.h
  CC      kernel/bounds.s
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CC      arch/arm64/kernel/asm-offsets.s
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
grep: scripts/../arch/x86/entry/syscalls/syscall_32.tbl: No such file or directory
  HOSTCC  scripts/dtc/dtc.o
  HOSTCC  scripts/dtc/flattree.o
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/dtc/util.o
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTLD  scripts/dtc/dtc
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/modpost.o
  CC      scripts/mod/devicetable-offsets.s
  GEN     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/pnmtologo
  HOSTCC  scripts/conmakehash
  HOSTCC  scripts/sortextable
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra# make modules_prepare
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
grep: scripts/../arch/x86/entry/syscalls/syscall_32.tbl: No such file or directory
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra# mkdir v4l2loopback
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra# cd v4l2loopback
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra/v4l2loopback# make
make: *** No targets specified and no makefile found.  Stop.
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra/v4l2loopback# $ git clone https://github.com/umlaeute/v4l2loopback.git
bash: $: command not found
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra/v4l2loopback# git clone https://github.com/umlaeute/v4l2loopback.git
Cloning into 'v4l2loopback'...
remote: Counting objects: 1575, done.
remote: Total 1575 (delta 0), reused 0 (delta 0), pack-reused 1575
Receiving objects: 100% (1575/1575), 733.63 KiB | 486.00 KiB/s, done.
Resolving deltas: 100% (875/875), done.
Checking connectivity... done.
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra/v4l2loopback# cd v4l2loopback
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback# make
Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback modules
make[1]: Entering directory '/usr/src/linux-headers-4.4.38-tegra'
  CC [M]  /usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback/v4l2loopback.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback/v4l2loopback.mod.o
  LD [M]  /usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback/v4l2loopback.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.4.38-tegra'
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback# make install
make -C /lib/modules/`uname -r`/build M=/usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback modules_install
make[1]: Entering directory '/usr/src/linux-headers-4.4.38-tegra'
  INSTALL /usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback/v4l2loopback.ko
  DEPMOD  4.4.38-tegra
make[1]: Leaving directory '/usr/src/linux-headers-4.4.38-tegra'
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback# modprobe v4l2loopback
modprobe: ERROR: could not insert 'v4l2loopback': Bad address
root@tegra-ubuntu:/usr/src/linux-headers-4.4.38-tegra/v4l2loopback/v4l2loopback#

I’ll try insmod with the .ko output

insmod ./v4l2loopback.ko devices=1 video_nr=2 exclusive_caps=1

Hi Andrey1984,
If you have installed v4l2loopback-dkms, please remove it and try again.

works finally with insmod;
thank you
works with modprobe v4l2loopback devices=1 video_nr=2 exclusive_caps=1;

Will there be a step-by step guide on that for Xavier?

Hi Andrey,
Any error you have met when executing these steps? The steps are HW-independent and should work fine.

Hi DaneLLL:
The list of errors include but not limited to the listed below:
[url]https://devtalk.nvidia.com/default/topic/1042839/jetson-agx-xavier/how-to-get-modules_prepare-to-function-/post/5289753/#5289753[/url]
[url]https://devtalk.nvidia.com/default/topic/1042839/jetson-agx-xavier/how-to-get-modules_prepare-to-function-/post/5291416/#5291416[/url]

In one place I saw you had a “permission denied” error. If at any point you compiled as user root, then leftover intermediate results would interfere with non-root builds. If the directory being modified by a command is root owned and you do not use sudo, then this too would deny.

Within the typical Linux install the headers would be located at “/usr/src/linux-headers-<uname -r>”. Using this directory might mean using “make modules_prepare” (this is if you don’t use the full source and do out of tree build of a module), which in turn modifies that directory and it requires “sudo make modules_prepare”.

For the case of using your own separately downloaded full source make sure the owning directory is not root, or instead use the “O=/some/where” option to not touch the original source. I very highly recommend your original source be pristine (e.g., via “sudo make mrproper”), and only build with an alternate output destination (the “O=/some/where” option).

Because the kernel source tree is not the only tree involved (“source_sync.sh” or more recent source downloads include both a “kernel/kernel-4.4/” directory and a “hardware/nvidia/” directory) cleaning a previous config may not work as expected. In this case you should completely erase your temporary output destination named in the “O=/some/where” and recreate that directory before starting build again. Do not use “sudo” with the “O=/some/where” option.

https://devtalk.nvidia.com/default/topic/1042839/jetson-agx-xavier/how-to-get-modules_prepare-to-function-/post/5291416/#5291416
Hi Andrey,
Xavier release is on K4.9. Looks like v4l2loopback-utils is not supported on this kernel version.

Building initial module for 4.9.108-tegra
ERROR (dkms apport): kernel package linux-headers-4.9.108-tegra is not supported
Error! Bad return status for module build on kernel: 4.9.108-tegra (aarch64)
Consult /var/lib/dkms/v4l2loopback/0.10.0/build/make.log for more information.