younseok
Posts: 4
Joined: Thu Feb 28, 2019 12:45 am

'v4l2' does not work normally.

Mon May 13, 2019 5:30 am

I am developing a project using a picam.

This system uses opencv and v4l2.

When the system boots, the program that was developed automatically runs and the camera runs.

On most system boot programs run normally and the camera runs normally. Almost all cases.

However, if the system boots 200 times, one error occurs. And the camera does not work.


This is the boot log recorded in the / var / log / syslog file.

Code: Select all

May 13 03:23:38 raspberrypi rc.local[376]: VIDIOC_STREAMON: Invalid argument
May 13 03:23:38 raspberrypi kernel: [   10.391778] mmal_vchiq: timed out waiting for sync completion
May 13 03:23:38 raspberrypi kernel: [   10.391794] bcm2835-v4l2: Failed enabling camera, ret -62
May 13 03:23:38 raspberrypi kernel: [   10.391800] bcm2835-v4l2: Failed to enable camera
May 13 03:23:38 raspberrypi kernel: [   10.391807] ------------[ cut here ]------------
May 13 03:23:38 raspberrypi kernel: [   10.391849] WARNING: CPU: 1 PID: 406 at drivers/media/v4l2-core/videobuf2-core.c:1347 vb2_start_streaming+0xe4/0x160 [videobuf2_core]
May 13 03:23:38 raspberrypi kernel: [   10.391854] Modules linked in: cfg80211 rfkill vc4 drm_kms_helper drm snd_soc_core snd_compress snd_pcm_dmaengine snd_bcm2835(C) syscopyarea sysfillrect snd_pcm sysimgblt fb_sys_fops snd_timer snd i2c_bcm2835 fixed uio_pdrv_genirq uio bcm2835_v4l2(C) v4l2_common videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_core videodev media cuse fuse i2c_dev ip_tables x_tables ipv6
May 13 03:23:38 raspberrypi kernel: [   10.392015] CPU: 1 PID: 406 Comm: veinvu-100 Tainted: G         C      4.14.79-v7+ #1159
May 13 03:23:38 raspberrypi kernel: [   10.392020] Hardware name: BCM2835
May 13 03:23:38 raspberrypi kernel: [   10.392051] [<8010ff30>] (unwind_backtrace) from [<8010c174>] (show_stack+0x20/0x24)
May 13 03:23:38 raspberrypi kernel: [   10.392070] [<8010c174>] (show_stack) from [<80788fa4>] (dump_stack+0xd4/0x118)
May 13 03:23:38 raspberrypi kernel: [   10.392087] [<80788fa4>] (dump_stack) from [<8011dd50>] (__warn+0xf8/0x110)
May 13 03:23:38 raspberrypi kernel: [   10.392102] [<8011dd50>] (__warn) from [<8011de38>] (warn_slowpath_null+0x30/0x38)
May 13 03:23:38 raspberrypi kernel: [   10.392136] [<8011de38>] (warn_slowpath_null) from [<7f125614>] (vb2_start_streaming+0xe4/0x160 [videobuf2_core])
May 13 03:23:38 raspberrypi kernel: [   10.392195] [<7f125614>] (vb2_start_streaming [videobuf2_core]) from [<7f126c08>] (vb2_core_streamon+0x130/0x178 [videobuf2_core])
May 13 03:23:38 raspberrypi kernel: [   10.392244] [<7f126c08>] (vb2_core_streamon [videobuf2_core]) from [<7f1351dc>] (vb2_streamon+0x40/0x60 [videobuf2_v4l2])
May 13 03:23:38 raspberrypi kernel: [   10.392287] [<7f1351dc>] (vb2_streamon [videobuf2_v4l2]) from [<7f13524c>] (vb2_ioctl_streamon+0x50/0x54 [videobuf2_v4l2])
May 13 03:23:38 raspberrypi kernel: [   10.392415] [<7f13524c>] (vb2_ioctl_streamon [videobuf2_v4l2]) from [<7f0e5e40>] (v4l_streamon+0x28/0x2c [videodev])
May 13 03:23:38 raspberrypi kernel: [   10.392606] [<7f0e5e40>] (v4l_streamon [videodev]) from [<7f0e8974>] (__video_do_ioctl+0x2a0/0x314 [videodev])
May 13 03:23:38 raspberrypi kernel: [   10.392796] [<7f0e8974>] (__video_do_ioctl [videodev]) from [<7f0e8318>] (video_usercopy+0x224/0x5bc [videodev])
May 13 03:23:38 raspberrypi kernel: [   10.392988] [<7f0e8318>] (video_usercopy [videodev]) from [<7f0e86d0>] (video_ioctl2+0x20/0x24 [videodev])
May 13 03:23:38 raspberrypi kernel: [   10.393178] [<7f0e86d0>] (video_ioctl2 [videodev]) from [<7f0e4720>] (v4l2_ioctl+0xd4/0xe8 [videodev])
May 13 03:23:38 raspberrypi kernel: [   10.393283] [<7f0e4720>] (v4l2_ioctl [videodev]) from [<8029ea5c>] (do_vfs_ioctl+0xac/0x7c4)
May 13 03:23:38 raspberrypi kernel: [   10.393299] [<8029ea5c>] (do_vfs_ioctl) from [<8029f1b8>] (SyS_ioctl+0x44/0x6c)
May 13 03:23:38 raspberrypi kernel: [   10.393316] [<8029f1b8>] (SyS_ioctl) from [<80108000>] (ret_fast_syscall+0x0/0x28)
May 13 03:23:38 raspberrypi kernel: [   10.393324] ---[ end trace a585056f891c4a28 ]---


Please help us to resolve this.

UberEclectic
Posts: 2
Joined: Thu May 09, 2019 11:50 pm

Re: 'v4l2' does not work normally.

Thu May 23, 2019 11:39 pm

I have a similar stack, which used to work.
I made the mistake of doing a "sudo apt update; sudo apt dist-upgrade" and now I'm dead in the water.
My camera has a custom V4L2 kernel extension, and it has a dependency on videobuf2-core, which is now no longer present on the system.
Unfortunately, I am dependent on a 3rd-party to update their kernel extension.

Did you ever find a solution to your original problem?
Meanwhile, I am writing perhaps as a warning to not update your kernel when running your particular stack. :S
I am currently searching for any solution, such as some sort of kernel extension "alias" to point the now missing videobuf2-core to its replacement, but so far, no joy. :-(

For posterity:

Code: Select all

modprobe: WARNING: Module videobuf2-core not found in directory /lib/modules/4.19.42-v7+
....
$ find /lib/modules -iname '*video*'
/lib/modules/4.19.42+/kernel/drivers/video
/lib/modules/4.19.42+/kernel/drivers/media/v4l2-core/videodev.ko
/lib/modules/4.19.42+/kernel/drivers/media/v4l2-core/videobuf-vmalloc.ko
/lib/modules/4.19.42+/kernel/drivers/media/v4l2-core/videobuf-core.ko
/lib/modules/4.19.42+/kernel/drivers/media/usb/uvc/uvcvideo.ko
/lib/modules/4.19.42+/kernel/drivers/media/common/videobuf2
/lib/modules/4.19.42+/kernel/drivers/media/common/videobuf2/videobuf2-dma-contig.ko
/lib/modules/4.19.42+/kernel/drivers/media/common/videobuf2/videobuf2-memops.ko
/lib/modules/4.19.42+/kernel/drivers/media/common/videobuf2/videobuf2-vmalloc.ko
/lib/modules/4.19.42+/kernel/drivers/media/common/videobuf2/videobuf2-v4l2.ko
/lib/modules/4.19.42+/kernel/drivers/media/common/videobuf2/videobuf2-common.ko
/lib/modules/4.19.42-v7+/kernel/drivers/video
/lib/modules/4.19.42-v7+/kernel/drivers/media/v4l2-core/videodev.ko
/lib/modules/4.19.42-v7+/kernel/drivers/media/v4l2-core/videobuf-vmalloc.ko
/lib/modules/4.19.42-v7+/kernel/drivers/media/v4l2-core/videobuf-core.ko
/lib/modules/4.19.42-v7+/kernel/drivers/media/usb/uvc/uvcvideo.ko
/lib/modules/4.19.42-v7+/kernel/drivers/media/common/videobuf2
/lib/modules/4.19.42-v7+/kernel/drivers/media/common/videobuf2/videobuf2-dma-contig.ko
/lib/modules/4.19.42-v7+/kernel/drivers/media/common/videobuf2/videobuf2-memops.ko
/lib/modules/4.19.42-v7+/kernel/drivers/media/common/videobuf2/videobuf2-vmalloc.ko
/lib/modules/4.19.42-v7+/kernel/drivers/media/common/videobuf2/videobuf2-v4l2.ko
/lib/modules/4.19.42-v7+/kernel/drivers/media/common/videobuf2/videobuf2-common.ko
And on a completely different system I was did a similar find and the videobuf2-core was there, but after the "sudo apt dist-upgrade" it was removed, so, yeah, the removal was definitely deliberate, but I sure wish I had known that would happen before I did it on the system where it matters with the V4L2 camera + OpenCV.

younseok
Posts: 4
Joined: Thu Feb 28, 2019 12:45 am

Re: 'v4l2' does not work normally.

Mon May 27, 2019 9:30 am

firstly, thanks to your reply
now, my system is perfect work. and i am free for the error.

My system receives input from the camera. Then, it performs image processing using opencv, and then outputs it using an output device

At this time, my output device is connected with dpi24. So I allocate memory space and use "/ dev / fb0" to output.

My guess is that during the initialization of "/ dev / fb0" and "/ dev / video0" during the boot process, there is a conflict between each other and an error occurs because the camera framebuffer can not be accessed.

But this is entirely my own idea and there may have been problems in other areas.

I may be wrong, but I am currently working perfectly and if I have the same problem in the same situation as myself, please leave a reply and provide my solution.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6628
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: 'v4l2' does not work normally.

Fri May 31, 2019 12:29 pm

Why post this in the C/C++ forum when there is a forum specifically for the camera board?

UberEclectic you're conflating issues.
In the shift from 4.14 to 4.19 kernels various things within V4L2 have moved. Mainly putting videobuf2 in a separate directory rather than sharing v4l2-core. It sounds like your driver is somehow now incorrectly configured and is looking for modules that are now built differently.
Sorry, that is the issue with relying on out-of-tree drivers - they can break should the internal kernel APIs get updated. However any kernel driver should be licenced under GPLv2, therefore there is an obligation on the supplier to release the source code.
The changes shouldn't be significant, but without information as to what the device is it is near impossible to give advice.

@younseok.
The camera stack is quite involved, with most of it running on the GPU. It's hard to say from the kernel logs exactly what went wrong, but I'd guess at a failure on the I2C to the camera. Error handling within V4L2 is a bit of a pain, and the driver could probably do with a going over to ensure that error cases are handled cleanly.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “C/C++”