Libcamera & IMX519 FAQ

This post is used to explain some common problems with IMX519 and libcamera.

Question 1:
I get an error similar to the following when installing the kernel driver:

Cannot find the corresponding package, please send the following information to [email protected]
Hardware Revision: b03111
Kernel Version: 5.4.83-v7l+

Solution:
Need to install the latest Raspberry Pi system, and do not execute rpi-update
https://downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2021-11-08/
https://downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2022-01-28/

Question 2:
I get the following error when running libcamera:

....
[0:01:46.295273858] [631] INFO Camera camera.cpp:1028 configuring streams: (0) 4656x3496-YUV420 (1) 4656x3496-SRGGB10_CSI2P 
[0:01:46.296042453] [632] INFO RPI raspberrypi.cpp:751 Sensor: /base/soc/i2c0mux/[email protected]/[email protected] - Selected sensor format: 4656x3496-SRGGB10_1X10 - Selected unicam format: 4656x3496-pRAA
 [0:01:46.351230171] [632] ERROR V4L2 v4l2_videodevice.cpp:1179 /dev/video0[12:cap]: Unable to request 1 buffers: Cannot allocate memory 
ERROR: *** failed to allocate capture buffers ***

Solution:
Modify /boot/config.txt to add dtoverlay=vc4-kms-v3d,cma-<size>
1e2e4414-8f29-43f0-a603-382072320c40

Example:
333938a4-1166-47fe-b9a0-c7102bf2bd2c

Note: It is recommended to set to cma-128 or cma-96 on devices with smaller memory such as Pi Zero / Zero 2 W

Question 3:
I got an error similar to the following when I ran libcamera:

terminate called after throwing an instance of \'std::runtime_error\'
what(): failed to import fd 21
Aborted

Solution:
For Raspbian Buster users, please also:

  1. Open /boot/config.txt
  2. Add the following line under [all]:
    dtoverlay=vc4-fkms-v3d
  3. Save and reboot

For Raspbian Bullseye users running on Pi Zero ~ Pi 3:,

  1. Open a terminal
  2. Run sudo raspi-config
  3. Navigate to Advanced Options
  4. Enable Glamor graphic acceleration
  5. Reboot your Pi

For more details, please refer to the official forum guide on how to configure the camera module >>

Question 4:
I cannot install the corresponding package using a third-party system.

Solution:
Need to install the latest Raspberry Pi system, and do not execute rpi-update
https://downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2021-11-08/
https://downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2022-01-28/

About Octoprint:
Currently Octoprint’s mjpg-streamer plugin does not support libcamera, if you want to use a camera with a focus motor, you can try 5mp v1 camera, 8mp v2 camera, we are also trying to solve this problem (need to develop mjpg-streamer libcamera plugin), but Currently not supported.

Update:
A mjpg-streamer that works with libcamera:

Update2:
We have successfully run libcamera & imx519 on OctoPi Nightly build, please refer to:

Question 5:
How to use two camera ports on the CM4

Solution:
You need to install the latest Raspberry Pi system (after 2022/01/28), and do not execute rpi-update
https://downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2022-01-28/

Refer to this documentation to install drivers and applications:

After installing the system and drivers, add the following information to /boot/config.txt:

[cm4]
dtoverlay=imx519
dtoverlay=imx519,cam0

Note 1: For pivariety series, please modify imx519 to arducam.
Note 2: Need to reboot after modifying /boot/config.txt

Usage:

List all cameras:

libcamera-still --list-cameras

Specify camera:

libcamera-still -t 0 --camera 0
libcamera-still -t 0 --camera 1

A post was split to a new topic: Quad-HAT outputs the wrong image

Question 6: Which driver should I install?

The 16MP Quad-Camera Kit(B0388), 15-Meter Cable Extension Kit (U6248) and Arducam Mini 16MP IMX519(B0389, B0391) require the “low speed” version of the driver:

wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
chmod +x install_pivariety_pkgs.s
./install_pivariety_pkgs.sh -p imx519_kernel_driver_low_speed

In fact, if you are not sure which driver to install, please install imx519_kernel_driver_low_speed, the only difference between the “low speed” version of the driver and the normal version is that the maximum resolution frame rate of the “low speed” version is 1-2 frames slower than the normal version.

Question 7: Open I2C bus error

Some systems do not have i2c enabled by default, and you will encounter the following errors when running libcamera-apps:

Solution:

sudo raspi-config
     --> Interface Options
          --> I2C
1 Like

The I2C error is missing from your post and your website. Please could you put the error in - I may have the same problem.

Thanks

@Edward are there plans to update the arducam-libcamera libraries to handle the new Jpeg-sycc change? It breaks the ability to use picamera2 and autofocus controls at the same time without a new update

@geneius

The upgrade has now been done. Please update:

wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
chmod +x install_pivariety_pkgs.sh
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps

IMX519 installed and working fine on a rPi4 2MB.

However need to change the flicker setting to 50hz, looks like the default is 60Hz.

Is there a way to do this?

After investigation is seem the implementation for imx519 in libcamera does not support this, also exposure control is limited.

Shutter speed is fully exposed and so this may be the solution e.g. setting 20000us (50hz) or 16667 (60Hz) taking into consideration frame speed.

Any comments appreciated.