Arducam 16MP IMX519 autofocus stuck at 4 inches on Raspberry Pi Zero 2W Bullseye

Hi everyone, I’m trying to get autofocus working on an Arducam 16MP camera (B0371C, IMX519) connected to a Raspberry Pi Zero 2W. I’m running Raspberry Pi OS Bullseye, latest version, kernel 6.1.21-v7+. The live view comes up fine, but the focus is stuck at roughly 4 inches from the camera and never changes. Has anyone run into this?

Thanks for the details. Could you tell me how you set this up, which guide you followed, and what you’ve already tried? Also, can you share what’s currently in your /boot/config.txt?

I followed the Arducam quick start guide for the IMX519 autofocus camera. I pulled the install shell script, made it executable, and used it to install libcamera and libcamera_apps. Then I edited /boot/config.txt to add dtoverlay=imx519 and rebooted. Here’s what config.txt looks like now:

[all]
start_x=1
dtoverlay=vc4-fkms-vc3d,cma=128
dtoverlay=imx519

That overlay config looks okay for this camera. When you run the live view, which command are you using and does the preview come up correctly? Also, have you tried changing the autofocus mode or range to rule out it being locked at a near focus position?

I ran:

libcamera-still -t 0

The preview appears and the image is visible, but the focus stays stuck at about 4 inches. I also tried adjusting the libcamera autofocus modes and ranges, and nothing changed - it just stays at the same focus distance.

Autofocus stuck like that usually means the autofocus driver portion for the IMX519 isn’t actually loaded - the sensor works for live view, but the AF control isn’t there. Can you try installing the kernel driver package with:

./install_pivariety_pkgs.sh -p imx519_kernel_driver

and paste the output if it fails?

I tried that and it failed. I also tried the imx519 low speed driver option and it failed the exact same way. The output is shown in a screenshot. Basically the script errors out during the step where it fetches the driver package - the download part blows up before anything gets installed. I can paste more of the text if it helps, but the tail of it is an error while pulling the file.

Looking at that output, this looks like a network problem rather than a camera or driver problem. That step is supposed to fetch the autofocus-related driver for the IMX519, and if the download gets interrupted or corrupted on the way down, the script fails right there. The low speed driver fails the same way because it goes through the same fetch step.

Can you try this: delete the file that the install script partially downloaded (the leftover/corrupted one), then re-run the command:

./install_pivariety_pkgs.sh -p imx519_kernel_driver

A corrupt download left on disk will keep failing until it’s removed, so make sure you delete it before retrying. Let me know what happens on the retry.