Loading

树莓派4b 64bit无法使用 Pi Camera V2 的解决办法

昨天晚上在捣鼓树莓派的时候,发现Pi Camera V2插上去无法工作:

vcgencmd get_camera

#返回以下信息
supported=0 detected=0

运行libcamera-hello后,返回以下信息

libcamera-hello

libEGL warning: DRI2: failed to authenticate
[0:01:09.134776795] [1082] INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3156-f4070274
[0:01:09.223517004] [1082] INFO Camera camera.cpp:937 configuring streams: (0) 1640x1232-YUV420
[0:01:09.223789018] [1096] INFO RPI raspberrypi.cpp:122 Mode: 3280x2464 fmt RG10 Score: 2218 (best 2218)
[0:01:09.223941873] [1096] INFO RPI raspberrypi.cpp:122 Mode: 1920x1080 fmt RG10 Score: 2041.48 (best 2041.48)
[0:01:09.224046189] [1096] INFO RPI raspberrypi.cpp:122 Mode: 1640x1232 fmt RG10 Score: 1500 (best 1500)
[0:01:09.224142537] [1096] INFO RPI raspberrypi.cpp:122 Mode: 640x480 fmt RG10 Score: 5004.81 (best 1500)
[0:01:09.224241489] [1096] INFO RPI raspberrypi.cpp:122 Mode: 3280x2464 fmt pRAA Score: 1718 (best 1500)
[0:01:09.224337889] [1096] INFO RPI raspberrypi.cpp:122 Mode: 1920x1080 fmt pRAA Score: 1541.48 (best 1500)
[0:01:09.224436633] [1096] INFO RPI raspberrypi.cpp:122 Mode: 1640x1232 fmt pRAA Score: 1000 (best 1000)
[0:01:09.224531835] [1096] INFO RPI raspberrypi.cpp:122 Mode: 640x480 fmt pRAA Score: 4504.81 (best 1000)
[0:01:09.224632245] [1096] INFO RPI raspberrypi.cpp:122 Mode: 3280x2464 fmt RGGB Score: 3218 (best 1000)
[0:01:09.224728020] [1096] INFO RPI raspberrypi.cpp:122 Mode: 1920x1080 fmt RGGB Score: 3041.48 (best 1000)
[0:01:09.224824420] [1096] INFO RPI raspberrypi.cpp:122 Mode: 1640x1232 fmt RGGB Score: 2500 (best 1000)
[0:01:09.224918268] [1096] INFO RPI raspberrypi.cpp:122 Mode: 640x480 fmt RGGB Score: 6004.81 (best 1000)
[0:01:09.225191636] [1096] INFO RPI raspberrypi.cpp:620 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected mode: 1640x1232-pRAA
[0:01:09.277446418] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: Saturation = 1.000000
[0:01:09.277623803] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: Contrast = 1.000000
[0:01:09.277684841] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: Brightness = 0.000000
[0:01:09.277736869] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: AwbMode = 0
[0:01:09.277788896] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: Sharpness = 1.000000
[0:01:09.277843945] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: ExposureValue = 0.000000
[0:01:09.277898785] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: AeExposureMode = 0
[0:01:09.277947168] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: FrameDurationLimits = [ 33333, 33333 ]
[0:01:09.278008205] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: AeMeteringMode = 0
[0:01:09.278055234] [1100] INFO IPARPI raspberrypi.cpp:626 Request ctrl: NoiseReductionMode = 3
[0:01:09.279092094] [1096] INFO RPISTREAM rpi_stream.cpp:122 No buffers available for ISP Output0
[0:01:09.279279114] [1096] INFO RPISTREAM rpi_stream.cpp:122 No buffers available for ISP Output0
[0:01:09.279357494] [1096] INFO RPISTREAM rpi_stream.cpp:122 No buffers available for ISP Output0
[0:01:09.369502717] [1096] INFO RPI raspberrypi.cpp:1636 Dropping frame at the request of the IPA (6 left)
[0:01:09.407055783] [1096] INFO RPI raspberrypi.cpp:1636 Dropping frame at the request of the IPA (5 left)
[0:01:09.441079179] [1096] INFO RPI raspberrypi.cpp:1636 Dropping frame at the request of the IPA (4 left)
[0:01:09.471882313] [1096] INFO RPI raspberrypi.cpp:1636 Dropping frame at the request of the IPA (3 left)
[0:01:09.506164964] [1096] INFO RPI raspberrypi.cpp:1636 Dropping frame at the request of the IPA (2 left)
[0:01:09.538106201] [1096] INFO RPI raspberrypi.cpp:1636 Dropping frame at the request of the IPA (1 left)
[0:01:09.570362367] [1096] INFO RPI raspberrypi.cpp:1636 Dropping frame at the request of the IPA (0 left)
terminate called after throwing an instance of 'std::runtime_error'
what(): failed to import fd 19
Aborted

在确认raspi-config里Camera Enabled之后,还是无法解决。
经过搜索,貌似是因为64bit下MMAL问题,导致无法正常使用摄像头,
且树莓派官方在 2021-10-30 Release Note 中提到,删除了原来的驱动支持:

  • New default camera subsystem based on libcamera
  • New camera demo applications (libcamera-still and libcamera-vid) have replaced raspistill and raspivid
  • Legacy camera subsystem removed from 64-bit RPi OS (still available on 32-bit)

以下是解决办法:

1.修改/boot/config.txt

root@raspberrypi:~ # sudo nano /boot/config.txt

...
#注释掉原来的摄像头自动检测语句,并添加"start_x=1"和"gpu_mem=128"

#camera_auto_detect=1
gpu_mem=128
start_x=1
...

该操作会让树莓派重新加载老版本的V4L2驱动

2.修改/etc/modules

root@raspberrypi:~ # sudo nano /etc/modules

...
#在最后面添加
bcm2835-v4l2
...

3.重启树莓派


此时再次运行

vcgencmd get_camera
#应该会返回
supported=1 detected=1

此时摄像头可通过ffplay、fswebcam等正常使用

fswebcam /dev/video0 -r 640x480 ~/test.jpg
#or
ffplay -f v4l2 -framerate 60 -video_size hd720 /dev/video0

image

需要注意,目前无法通过libcamera访问,会提示no camera available


参考链接:

1.qaza2008:树莓派4B 入门指导-- raspberry pi OS version : 2021/10/30 , Based on Debian version 11 (bullseye)
2.ourkix:树莓派4B ubuntu20.04 驱动pi camera模块
3.slimhazard:Re: STICKY: Raspberry Pi OS (64 bit) beta test version feedback

posted @ 2021-12-02 13:42  DouSTN  阅读(7526)  评论(0编辑  收藏  举报