Hi everyone, I’m stuck getting the autofocus working on my IMX519 16MP AF camera from Arducam. The camera captures images, but it never actually focuses - autofocus just doesn’t kick in at all. This is part of a work prototype we’re planning to take to production, so I need it sorted fairly urgently. Has anyone else hit this? Where should I even start?
Sorry you’re having trouble. To help narrow this down, could you share the details of your setup? Board, OS version, kernel, how the camera is connected, and anything you see when you try to use autofocus would be really useful. Logs and exact commands help a lot too.
Sure, here’s everything I have. The camera is the 16MP Arducam AutoFocus camera with the IMX519 sensor, bought directly from Arducam during the Kickstarter. It’s on a Raspberry Pi CM4 running Debian bullseye, the latest 64-bit release from Raspberry Pi, kernel 6.1.21-v8+. Hardware revision d03140, arch aarch64. It’s a fresh install with no other packages downloaded. In config.txt I have dtoverlay=imx519.
I followed the quick start and libcamera guides:
One thing I noticed: back in July '22 Edward said CM3/CM4 weren’t supported yet in this post: Install_pivariety_pkgs.sh update and FAQ - not sure if that’s still relevant.
When I run:
./install_pivariety_pkgs.sh -p libcamera_dev
I get downgrade / held broken package errors:
Hardware Revision: d03140
Kernel Version: 6.1.21-v8+
OS Codename: bullseye
ARCH: aarch64
kernel:6.1.21-v8+
Note, selecting 'libcamera0' instead of './libcamera0_0_git20230512+8689dd6b-1_arm64.deb'
The following packages will be REMOVED:
libcamera-apps python3-libcamera python3-picamera2
The following packages will be DOWNGRADED:
libcamera0
0 upgraded, 0 newly installed, 1 downgraded, 3 to remove and 0 not upgraded.
E: Packages were downgraded and -y was used without --allow-downgrades.
Note, selecting 'libcamera-dev' instead of './libcamera-dev_0_git20230512+8689dd6b-1_arm64.deb'
The following packages have unmet dependencies:
libcamera-dev : Depends: libcamera0 (= 0~git20230512+8689dd6b-1) but 0~git20230707+2783c8d8-1 is to be installed
E: Unable to correct problems, you have held broken packages.
python3-libcamera is already the newest version (0~git20230707+2783c8d8-1).
python3-picamera2 is already the newest version (0.3.12-1).
dpkg -l | grep libcamera0 shows:
ii libcamera0:arm64 0~git20230707+2783c8d8-1 arm64 complex camera support library
When I run:
libcamera-still -t 0 --autofocus-mode continuous
it starts up but logs these warnings about no AF algorithm:
Made X/EGL preview window
[5:27:17.222306935] [9814] INFO Camera camera_manager.cpp:297 libcamera v0.0.5+82-2783c8d8
[5:27:17.296683104] [9815] INFO RPI vc4.cpp:437 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media3 and ISP device /dev/media0
[5:27:17.296947526] [9815] INFO RPI pipeline_base.cpp:1101 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
[5:27:17.298223252] [9814] INFO Camera camera.cpp:1033 configuring streams: (0) 2328x1748-YUV420
[5:27:17.299267683] [9815] INFO RPI vc4.cpp:565 Sensor: /base/soc/i2c0mux/i2c@1/imx519@1a - Selected sensor format: 2328x1748-SRGGB10_1X10 - Selected unicam format: 2328x1748-pRAA
[5:27:17.341895942] [9819] WARN IPARPI ipa_base.cpp:665 Could not set AF_MODE - no AF algorithm
[5:27:17.342035644] [9819] WARN IPARPI ipa_base.cpp:1014 Could not set AF_SPEED - no focus algorithm
[5:27:17.342180439] [9819] WARN IPARPI ipa_base.cpp:996 Could not set AF_RANGE - no focus algorithm
Things I’ve already tried:
- I edited the .sh file to allow downgrades. The errors went away, but then libcamera stopped working completely, so I reverted it.
- I found this GitHub page (GitHub - ArduCAM/IMX519_AK7375 · GitHub) that says the motor driver and device tree need updating, but I really don’t want to modify the kernel.
- I don’t need CDAF/PDAF - I just need plain autofocus working again ASAP.
Thanks for the detailed logs. We’ve updated the libcamera installation script since that older guide was written, and the previous script had some package version issues that cause exactly the downgrade errors you’re seeing. Please try reinstalling with the updated script by running these in order:
./install_pivariety_pkgs.sh -l
./install_pivariety_pkgs.sh -p libcamera0
./install_pivariety_pkgs.sh -p libcamera_apps
That should pull the correct versions and get autofocus working. Let me know how it goes.
Good news - after rerunning the updated script, autofocus is working now. The camera focuses properly.
But I still have a couple of leftovers. Running ./install_pivariety_pkgs.sh -p libcamera_apps still throws a package downgrade error:
Hardware Revision: d03140
Kernel Version: 6.1.21-v8+
OS Codename: bullseye
ARCH: aarch64
kernel:6.1.21-v8+
--2023-07-20 22:31:21-- https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/libcamera_apps_links_new.txt
Saving to: 'libcamera_apps_links.txt'
2023-07-20 22:31:22 (752 KB/s) - 'libcamera_apps_links.txt' saved [2115/2115]
--2023-07-20 22:31:22-- https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/libcamera-apps-v0.0.5/libcamera-apps_1.2.1-1_arm64.deb
2023-07-20 22:31:23 (3.94 MB/s) - 'libcamera-apps_1.2.1-1_arm64.deb' saved [331032/331032]
Note, selecting 'libcamera-apps' instead of './libcamera-apps_1.2.1-1_arm64.deb'
The following packages will be DOWNGRADED:
libcamera-apps
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
E: Packages were downgraded and -y was used without --allow-downgrades.
And libcamera-still -t 0 --autofocus-mode continuous still prints a warning about rpi.focus:
Made X/EGL preview window
[0:03:11.375023437] [2404] INFO Camera camera_manager.cpp:297 libcamera v0.0.0+4365-d2ae87e6
[0:03:11.449390057] [2405] WARN RPiController controller.cpp:136 No algorithm found for "rpi.focus"
[0:03:11.451074216] [2405] INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media3 and ISP device /dev/media0
[0:03:11.451193422] [2405] INFO RPI pipeline_base.cpp:1101 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
[0:03:11.452440067] [2404] INFO Camera camera.cpp:1033 configuring streams: (0) 2328x1748-YUV420
[0:03:11.453132621] [2405] INFO RPI vc4.cpp:572 Sensor: /base/soc/i2c0mux/i2c@1/imx519@1a - Selected sensor format: 2328x1748-SRGGB10_1X10 - Selected unicam format: 2328x1748-pRAA
Autofocus works despite these, but I wanted to flag it in case it matters.
Glad autofocus is working. I haven’t personally run into that downgrade error during the libcamera_apps install step, so I’m looking into it. Quick question: does the libcamera_apps install error actually affect autofocus in practice, or is it just the warning that shows up? The ‘No algorithm found for rpi.focus’ warning usually means the running libcamera build doesn’t include the focus algorithm, but since you’re saying autofocus is functional, I want to confirm whether anything is actually broken by the leftover error, or if it’s just cosmetic from the package version mismatch.
Thanks for following up. From what I can tell autofocus appears to be working just fine now, so I’ll treat the remaining messages as cosmetic for the time being. Appreciate the help!
Great, thanks for confirming. To sum up: the autofocus issue was resolved by reinstalling with the updated script, and the remaining libcamera_apps downgrade error plus the ‘No algorithm found for rpi.focus’ warning appear to be cosmetic and don’t affect autofocus in practice. If you rebuild or reinstall later, keep using the updated script and avoid forcing the downgrade. Marking this as resolved, but feel free to post back if anything changes.