0

On a RasPi4, the HQ-Camera works well with the legacy camera stack, but not with the libcamera stack. I did an update from Buster to Bullseye.

$ uname -a
Linux raspberrypi 5.10.89-v7l+ #1506 SMP Fri Dec 31 14:40:15 GMT 2021 armv7l GNU/Linux
$ cat /etc/debian_version 
11.2

I have these lines in the sections pi4 and all of /boot/config.txt.

[pi4]
max_framebuffers=2

[all]
dtoverlay=vc4-kms-v3d
camera_auto_detect=1
gpu_mem=128

v4l2-ctl gives met his output.

$ v4l2-ctl --list-devices
bcm2835-codec-decode (platform:bcm2835-codec):
    /dev/video10
    /dev/video11
    /dev/video12
    /dev/video18
    /dev/media3

bcm2835-isp (platform:bcm2835-isp):
    /dev/video13
    /dev/video14
    /dev/video15
    /dev/video16
    /dev/video20
    /dev/video21
    /dev/video22
    /dev/video23
    /dev/media0
    /dev/media1

unicam (platform:fe801000.csi):
    /dev/video0
    /dev/video1
    /dev/media2

This is the list of v4l2 modules I have running:

$ lsmod | grep v4l2
v4l2_dv_timings        36864  1 bcm2835_unicam
v4l2_fwnode            24576  2 bcm2835_unicam,imx477
v4l2_mem2mem           36864  1 bcm2835_codec
bcm2835_v4l2           45056  0
bcm2835_mmal_vchiq     32768  3 bcm2835_isp,bcm2835_codec,bcm2835_v4l2
videobuf2_vmalloc      16384  1 bcm2835_v4l2
videobuf2_v4l2         32768  5 bcm2835_unicam,bcm2835_isp,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem
videobuf2_common       61440  6 bcm2835_unicam,bcm2835_isp,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
videodev              249856  9 bcm2835_unicam,bcm2835_isp,v4l2_fwnode,bcm2835_codec,videobuf2_common,imx477,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
mc                     45056  8 bcm2835_unicam,bcm2835_isp,bcm2835_codec,videobuf2_common,imx477,videodev,v4l2_mem2mem,videobuf2_v4l2

The libcamera-hello tool gives opens a window which stays black and returns this output.

$ libcamera-hello --verbose
Options:
    verbose: 1
    info_text:#%frame (%fps fps) exp %exp ag %ag dg %dg
    timeout: 5000
    width: 0
    height: 0
    output: 
    post_process_file: 
    rawfull: 0
    preview: default
    qt-preview: 0
    transform: identity
    roi: all
    metering: centre
    exposure: normal
    ev: 0
    awb: auto
    flush: false
    wrap: 0
    brightness: 0
    contrast: 1
    saturation: 1
    sharpness: 1
    framerate: 30
    denoise: auto
    viewfinder-width: 0
    viewfinder-height: 0
    tuning-file: (libcamera)
    lores-width: 0
    lores-height: 0
Opening camera...
[1:15:29.735694777] [4396]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3156-f4070274
[1:15:29.760121740] [4398]  WARN CameraSensorProperties camera_sensor_properties.cpp:141 No static properties available for 'imx477'
[1:15:29.760260201] [4398]  WARN CameraSensorProperties camera_sensor_properties.cpp:143 Please consider updating the camera sensor properties database
[1:15:29.795995652] [4398] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009e0901 but control is not exposed by device /dev/video0
[1:15:29.796142131] [4398] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x00980911 but control is not exposed by device /dev/video0
[1:15:29.796233296] [4398] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009e0903 but control is not exposed by device /dev/video0
Acquired camera /base/soc/i2c0mux/i2c@1/imx477@1a
Configuring viewfinder...
Viewfinder size chosen is 2028x1520
Final viewfinder size is 2028x1520
Stream configuration adjusted
[1:15:29.798509442] [4396]  INFO Camera camera.cpp:937 configuring streams: (0) 2028x1520-YUV420
[1:15:29.799375168] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt Y10  Score: 500 (best 500)
[1:15:29.799553646] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt Y12  Score: 500 (best 500)
[1:15:29.799666348] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt Y14  Score: 500 (best 500)
[1:15:29.799822752] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt BA10 Score: 1500 (best 500)
[1:15:29.799934213] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt GB10 Score: 1500 (best 500)
[1:15:29.800352669] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt BG10 Score: 1500 (best 500)
[1:15:29.800463408] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RG10 Score: 1500 (best 500)
[1:15:29.800589572] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt BA81 Score: 2500 (best 500)
[1:15:29.800681867] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt BA12 Score: 500 (best 500)
[1:15:29.800772884] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt GB12 Score: 500 (best 500)
[1:15:29.800896160] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt BG12 Score: 500 (best 500)
[1:15:29.800996084] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RG12 Score: 500 (best 500)
[1:15:29.801087712] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RGB3 Score: 500 (best 500)
[1:15:29.801186377] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt BGR3 Score: 500 (best 500)
[1:15:29.801361170] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt GB14 Score: 500 (best 500)
[1:15:29.801475557] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt BG14 Score: 500 (best 500)
[1:15:29.801578055] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RG14 Score: 500 (best 500)
[1:15:29.801816236] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt GR14 Score: 500 (best 500)
[1:15:29.801976363] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RGB4 Score: 500 (best 500)
[1:15:29.802136120] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pBAA Score: 1000 (best 500)
[1:15:29.802242507] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pGAA Score: 1000 (best 500)
[1:15:29.802335449] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pRAA Score: 1000 (best 500)
[1:15:29.802431781] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pgAA Score: 1000 (best 500)
[1:15:29.802537001] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RGGB Score: 2500 (best 500)
[1:15:29.802639426] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pBCC Score: 0 (best 0)
[1:15:29.802744127] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pGCC Score: 0 (best 0)
[1:15:29.802848033] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pRCC Score: 0 (best 0)
[1:15:29.802949698] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pgCC Score: 0 (best 0)
[1:15:29.803056918] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pBEE Score: 500 (best 0)
[1:15:29.803159454] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pGEE Score: 500 (best 0)
[1:15:29.803340154] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pREE Score: 500 (best 0)
[1:15:29.803442819] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt pgEE Score: 500 (best 0)
[1:15:29.803537280] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt GRBG Score: 2500 (best 0)
[1:15:29.803632390] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt GBRG Score: 2500 (best 0)
[1:15:29.803788091] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RGBO Score: 500 (best 0)
[1:15:29.803890404] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt Y10P Score: 500 (best 0)
[1:15:29.803987717] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt Y12P Score: 500 (best 0)
[1:15:29.804091900] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt Y14P Score: 500 (best 0)
[1:15:29.804241527] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RGBP Score: 500 (best 0)
[1:15:29.804388043] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RGBQ Score: 500 (best 0)
[1:15:29.804477208] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt RGBR Score: 500 (best 0)
[1:15:29.804566244] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt YVYU Score: 500 (best 0)
[1:15:29.804655242] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt YUYV Score: 500 (best 0)
[1:15:29.804743241] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt GREY Score: 2500 (best 0)
[1:15:29.804832128] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt VYUY Score: 500 (best 0)
[1:15:29.804920219] [4398]  INFO RPI raspberrypi.cpp:122 Mode: 2028x1520 fmt UYVY Score: 500 (best 0)
[1:15:29.805242158] [4398]  INFO RPI raspberrypi.cpp:620 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected mode: 2028x1520-pgCC
[1:15:29.810506752] [4398] ERROR IPARPI raspberrypi.cpp:539 Unable to find sensor control 0x009e0903
[1:15:29.810969743] [4398] ERROR IPARPI raspberrypi.cpp:351 Sensor control validation failed.
[1:15:29.811269479] [4398] ERROR RPI raspberrypi.cpp:1306 IPA configuration failed!
[1:15:29.811551030] [4398] ERROR RPI raspberrypi.cpp:757 Failed to configure the IPA: -32
Camera streams configured
Buffers allocated and mapped
Viewfinder setup complete
Requests created
[1:15:29.850236744] [4398] ERROR V4L2 v4l2_videodevice.cpp:1158 /dev/video1[17:cap]: Unable to request 4 buffers: Invalid argument
[1:15:29.850322613] [4398] ERROR RPI raspberrypi.cpp:817 Failed to allocate buffers
Closing Libcamera application(frames displayed 0, dropped 0)
Camera stopped!
Tearing down requests, buffers and configuration
Camera closed

I attached an image of the qv4l2 tool that also results in just a black window.

qv4l2 screenshot

Update 1

When I connect a webcam via USB, it works fine with the libcamera stack and tools like qv4l2.

Update 2

I increased the GPU memory in the file /boot/config.txt from 128 MB to 256 MB. Now, this error message is gone...

[1:15:29.850236744] [4398] ERROR V4L2 v4l2_videodevice.cpp:1158 /dev/video1[17:cap]: Unable to request 4 buffers: Invalid argument
[1:15:29.850322613] [4398] ERROR RPI raspberrypi.cpp:817 Failed to allocate buffers

But it still does not work.

$ libcamera-hello --verbose
...
[1:56:07.303203559] [2954]  INFO RPI raspberrypi.cpp:620 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected mode: 1640x1232-pgCC
[1:56:07.305500640] [2954] ERROR IPARPI raspberrypi.cpp:539 Unable to find sensor control 0x009e0903
[1:56:07.305605309] [2954] ERROR IPARPI raspberrypi.cpp:351 Sensor control validation failed.
[1:56:07.305632069] [2954] ERROR RPI raspberrypi.cpp:1306 IPA configuration failed!
[1:56:07.305680867] [2954] ERROR RPI raspberrypi.cpp:757 Failed to configure the IPA: -32
Closing Libcamera application(frames displayed 0, dropped 0)
Camera stopped!
Tearing down requests, buffers and configuration
Camera closed
ERROR: *** failed to configure streams ***

Update 3

When booting with the libcamera stack, dmesg shows me this warning when I try to execute libcamera-hello.

[   16.612743] ------------[ cut here ]------------
[   16.612775] WARNING: CPU: 2 PID: 884 at drivers/media/common/videobuf2/videobuf2-core.c:806 vb2_core_reqbufs+0x190/0x494 [videobuf2_common]
[   16.612781] Modules linked in: rfcomm cmac algif_hash aes_arm_bs crypto_simd cryptd algif_skcipher af_alg bnep hci_uart btbcm 8021q garp stp llc iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 imx477 iptable_mangle iptable_filter bluetooth ecdh_generic ecc snd_soc_hdmi_codec v3d gpu_sched bcm2835_v4l2(C) videobuf2_vmalloc brcmfmac bcm2835_isp(C) bcm2835_codec(C) i2c_mux_pinctrl brcmutil bcm2835_unicam bcm2835_mmal_vchiq(C) v4l2_dv_timings v4l2_mem2mem v4l2_fwnode videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_common i2c_mux raspberrypi_hwmon cfg80211 i2c_brcmstb vc_sm_cma(C) vc4 videodev rfkill mc i2c_bcm2835 cec drm_kms_helper snd_soc_core snd_compress snd_pcm_dmaengine snd_pcm snd_timer rpivid_mem snd syscopyarea sysfillrect sysimgblt fb_sys_fops nvmem_rmem uio_pdrv_genirq uio i2c_dev fuse drm drm_panel_orientation_quirks backlight ip_tables x_tables ipv6
[   16.613256] CPU: 2 PID: 884 Comm: libcamera-still Tainted: G         C        5.10.89-v7l+ #1506
[   16.613261] Hardware name: BCM2711
[   16.613265] Backtrace: 
[   16.613285] [<c0b873e0>] (dump_backtrace) from [<c0b87774>] (show_stack+0x20/0x24)
[   16.613291]  r7:ffffffff r6:00000000 r5:60000013 r4:c12e6fd8
[   16.613300] [<c0b87754>] (show_stack) from [<c0b8bb54>] (dump_stack+0xcc/0xf8)
[   16.613309] [<c0b8ba88>] (dump_stack) from [<c0220d2c>] (__warn+0xfc/0x114)
[   16.613316]  r10:bf563474 r9:00000009 r8:bf56e948 r7:00000326 r6:00000009 r5:bf56e948
[   16.613320]  r4:bf571f90 r3:c1205094
[   16.613327] [<c0220c30>] (__warn) from [<c0b87ed4>] (warn_slowpath_fmt+0x70/0xd8)
[   16.613332]  r7:00000326 r6:bf571f90 r5:c1205048 r4:00000000
[   16.613348] [<c0b87e68>] (warn_slowpath_fmt) from [<bf56e948>] (vb2_core_reqbufs+0x190/0x494 [videobuf2_common])
[   16.613354]  r9:bf2d9998 r8:c5d2de3c r7:c4418a84 r6:ffffffea r5:c1205048 r4:c4418a44
[   16.613374] [<bf56e7b8>] (vb2_core_reqbufs [videobuf2_common]) from [<bf5828d4>] (vb2_ioctl_reqbufs+0x80/0xa8 [videobuf2_v4l2])
[   16.613380]  r10:bf563474 r9:bf2d9998 r8:c4418ba4 r7:c5dd0c00 r6:c4418bb8 r5:00000000
[   16.613384]  r4:c5d2de3c
[   16.613429] [<bf582854>] (vb2_ioctl_reqbufs [videobuf2_v4l2]) from [<bf2d99e8>] (v4l_reqbufs+0x50/0x54 [videodev])
[   16.613434]  r7:bf563474 r6:c422d400 r5:c5dd0c00 r4:c5d2de3c
[   16.613496] [<bf2d9998>] (v4l_reqbufs [videodev]) from [<bf2da1b4>] (__video_do_ioctl+0x234/0x460 [videodev])
[   16.613501]  r7:00000003 r6:c1205048 r5:c0145608 r4:c4418bb8
[   16.613561] [<bf2d9f80>] (__video_do_ioctl [videodev]) from [<bf2dabd8>] (video_usercopy+0x138/0x5f0 [videodev])
[   16.613568]  r10:00000000 r9:c5d2de3c r8:00000000 r7:c1205048 r6:00000000 r5:c0145608
[   16.613572]  r4:c0145608
[   16.613631] [<bf2daaa0>] (video_usercopy [videodev]) from [<bf2db0b0>] (video_ioctl2+0x20/0x24 [videodev])
[   16.613637]  r10:0000000d r9:c5d2c000 r8:00000000 r7:c5dd0c00 r6:c5dd0c01 r5:c1205048
[   16.613641]  r4:bf2db090
[   16.613706] [<bf2db090>] (video_ioctl2 [videodev]) from [<bf2d31f4>] (v4l2_ioctl+0x4c/0x60 [videodev])
[   16.613743] [<bf2d31a8>] (v4l2_ioctl [videodev]) from [<c045540c>] (sys_ioctl+0x1d4/0x8ec)
[   16.613747]  r5:c1205048 r4:c0145608
[   16.613755] [<c0455238>] (sys_ioctl) from [<c0200040>] (ret_fast_syscall+0x0/0x28)
[   16.613760] Exception stack(0xc5d2dfa8 to 0xc5d2dff0)
[   16.613766] dfa0:                   b1014470 b1015e60 0000000d c0145608 b19f93a4 0000000d
[   16.613772] dfc0: b1014470 b1015e60 00000004 00000036 00000001 00000000 b101432c 00c1d2f8
[   16.613776] dfe0: b6e4dff4 b19f938c b6df1bf4 b6a9d1ac
[   16.613782]  r10:00000036 r9:c5d2c000 r8:c0200204 r7:00000036 r6:00000004 r5:b1015e60
[   16.613787]  r4:b1014470
[   16.613793] ---[ end trace 592759731a4618ff ]---
[   31.876600] cam-dummy-reg: disabling
[   31.876615] cam1-reg: disabling

Update 4

Modifying /boot/config.txt in a way that the cma-parameter is used, did not help. I tried this with different gpu_mem values.

[all]
camera_auto_detect=0
dtoverlay=imx477
gpu_mem=256
dtoverlay=vc4-kms-v3d,cma-512

2 Answers 2

0

The root cause and solution for this issue can be found here:

https://forums.raspberrypi.com/viewtopic.php?p=1958297

The latest kernel drivers use the media controller API, but the recent libcamera libraries are expecting the older non-media controller API.

Until a new version of the libcamera libraries is available, the kernel driver kan be told to use the old API by this setting in the /boot/config.txt.

dtoverlay=imx477,media-controller=0

With this all-section in the file /boot/config.txt, the camera works with the libcamera stack fine and the warning in dmesg is gone too:

[all]
camera_auto_detect=0
dtoverlay=imx477,media-controller=0
gpu_mem=256
dtoverlay=vc4-kms-v3d
0
  1. Open a terminal
  2. Run sudo raspi-config
  3. Navigate to Advanced Options
  4. Enable Glamor graphic acceleration
  5. Reboot your Pi

credit: https://www.arducam.com/docs/cameras-for-raspberry-pi/raspberry-pi-libcamera-guide/

1
  • Should be observed that Glamor is a 2D rendering library built on openGL for the Xorg server, meaning, it may improve performance of/solve problems with GUI desktop apps -- in this case the preview window. Although this does seem to be part of the OP's issue, the error reported is actually not the same as the one in the forum thread which Arducam's page strangely links as "the official forum guide on how to configure the camera module".
    – goldilocks
    May 9 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.