ArduCam IMX519 autofocus on Pi 3B OctoPrint: no focus slider, camera list hangs

Hi everyone, hoping someone can help. I’m using an Arducam 16 MP autofocus camera (IMX519, product B0371) on my Raspberry Pi 3B running OctoPrint, and I can’t get it to focus. The image also looks like it’s stuck zoomed in — I attached a photo taken from the camera’s position so the zoom can be compared.

In the OctoPrint Camera Settings plugin I can’t find any “Focus Absolute” slider at all, so I have no way to focus, and the other sliders act in a very strange way. I found two ArduCam plugins in the OctoPrint repository that should allow focusing, but all of the controlling sliders were greyed-out — I assumed they must be for older models.

On top of that, when I run libcamera-still --list-cameras it never finishes and only prints the empty ‘Available cameras’ header:

===========================
Available cameras
-----------------
===========================

I’m also confused by all the ERRORs that libcamera-still emits. Any ideas what’s going on?

Thanks for the detailed report. A few things jump out right away.

First, can you confirm whether the kernel has been updated on your system? That’s usually the first thing to check with the IMX519. If you’re not sure, paste the output of uname -a and uname -r and I’ll take a look.

Second, the fact that libcamera-still --list-cameras only prints the header and nothing else is strange — that almost always points to something not being configured correctly, so we’ll dig into that.

About the sliders: the plugins you found are NOT for older cameras. Everything in the link you mention is supported by the imx519, so that’s not why they’re greyed out. Also worth knowing — over SSH there’s no preview available, so you can only use the no-preview command and check the effect by saving images.

Can you share your environment? Camera model, board, OS, and the relevant lines from /boot/config.txt would help a lot.

Sure, here’s the environment:

  • Camera: ArduCam 16 MPx autofocus (IMX519), product B0371
  • Board: Raspberry Pi 3B (non-plus), running OctoPrint
  • OS: Raspbian GNU/Linux 11 (bullseye), VERSION_ID=11, VERSION_CODENAME=bullseye
  • uname -a: Linux octopi 5.15.32-v7+ #1538 SMP Thu Mar 31 19:38:48 BST 2022 armv7l GNU/Linux

I connected via SSH, so there’s no graphical environment and windows can’t be created. meminfo shows MemTotal: 892508 kB, MemFree: 550624 kB, MemAvailable: 716252 kB, SwapTotal: 102396 kB, CmaTotal: 262144 kB, CmaFree: 250528 kB.

Relevant lines from /boot/config.txt:

dtparam=audio=on
start_x=1
display_auto_detect=1
dtoverlay=vc4-kms-v3d
max_framebuffers=2
disable_overscan=1
gpu_mem=128
dtoverlay=imx519
dtoverlay=imx519,cam0
dtoverlay-vc4-kms-v3d,cma-128

I followed the ArduCam guide for the autofocus solution on OctoPi.

Thanks, that helps. Based on this, the kernel likely needed updating and the driver probably needs reinstalling.

To reinstall the imx519 kernel driver, run:

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 imx519_kernel_driver_low_speed

Then check the camera listing:

libcamera-still --list-cameras

And since you’re on SSH, use the no-preview command and detect the effect by saving images:

libcamera-still -t 5000 -n -o test.jpg

Can you also send me the logs from a run so we can see what the driver is actually reporting? The behavior of --list-cameras in particular is a useful clue.

For context on what I already tried: I downloaded the image mentioned in the HOW-TO, and after everything was installed and the camera was working, I updated the system and OctoPrint. I installed the OctoPrint Camera Settings plugin from the URL in the HOW-TO, then searched the OctoPrint repository and found the two ArduCam plugins (all sliders greyed-out).

Here’s the log for libcamera-still -t 10 --autofocus:

pi@octopi:~ $ libcamera-still -t 10 --autofocus
Preview window unavailable
[0:32:34.286205646] [2290]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3730-67300b62
[0:32:34.290128820] [2292] ERROR V4L2 v4l2_device.cpp:349 'imx519 10-001a': Unable to set controls: Device or resource busy
[0:32:34.292040172] [2292]  WARN CameraSensorProperties camera_sensor_properties.cpp:174 No static properties available for 'imx519'
[0:32:34.292443817] [2292]  WARN CameraSensorProperties camera_sensor_properties.cpp:176 Please consider updating the camera sensor properties database
[0:32:34.340640128] [2292]  WARN RPI raspberrypi.cpp:1274 Mismatch between Unicam and CamHelper for embedded data usage!
[0:32:34.341447523] [2292] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009a090a but control is not exposed by device /dev/v4l-subdev0
[0:32:34.341748408] [2292]  INFO RPI raspberrypi.cpp:1398 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media3 and ISP device /dev/media0

And libcamera-still --list-cameras (it never finishes, just prints this):

===========================
Available cameras
-----------------
===========================

And dmesg | grep imx519:

pi@octopi:~ $ dmesg | grep imx519
[   11.268538] imx519 10-001a: Device found is imx519
[   11.269214] imx519 10-001a: Consider updating driver imx519 to match on endpoints

Good, this confirms what I suspected on two fronts.

  1. The kernel likely needed updating and the imx519 driver needs to be reinstalled — the “Consider updating driver imx519 to match on endpoints” line in dmesg is a hint there.

  2. The missing output from libcamera-still --list-cameras is a strong signal that something isn’t configured correctly. That empty listing is not normal.

Also, to be clear about the plugins: the referenced slider plugins are all supported by imx519 — they are not older-camera plugins, so don’t chase that theory.

So please do the following:

  • Confirm the kernel has been updated (if you’re not sure, paste the updated uname -r output).
  • Reinstall 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.sh
./install_pivariety_pkgs.sh -p imx519_kernel_driver_low_speed
  • Then re-run libcamera-still --list-cameras and, on SSH, verify with a no-preview capture:
libcamera-still -t 5000 -n -o test.jpg

If you still have questions after that, take a screenshot and post it here so we can see exactly what you’re looking at.

The focus problem is resolved now — thanks for that.

But I have a new problem: I need a bigger field of view. The camera is about 16 cm from the object I’m showing, and the nearest object at the bottom of the view is 13 cm from the camera. Nothing closer to the camera is visible. I’m not sure whether that can be adjusted or whether it’s just a feature of the camera lens.

Here’s a video with commentary demonstrating the issue: https://www.youtube.com/watch?v=SiDpouYjEn4

For context, uname -r gives 5.15.32-v7+, and I assume the kernel was also updated at some point.

Glad the focus is working now. On the field of view — I’ve forwarded that to our marketing colleagues so they can take a look, since it’s more of a product/lens question than a driver one. I’ll let you know if we hear back.

Meanwhile, let me explain why libcamera-still --list-cameras was producing no output. The principle is that the camera actually has to be started in order to retrieve the resolution. On OctoPrint the camera is occupied by default — the OctoPrint camera service is holding it — so any libcamera-related commands from the command line will fail to get the camera until that service is stopped.

So the fix for that part: shut down the camera service on OctoPrint first, then run your libcamera commands from the command line, e.g. libcamera-still --list-cameras. Once the service releases the camera, the listing should come up properly.

That did it — after stopping the OctoPrint camera service, libcamera-still --list-cameras actually lists the camera now instead of hanging on the empty header. Makes total sense that OctoPrint was holding the camera.

Thanks also for passing the field-of-view question along. I’ll keep an eye out for anything from the marketing team.

Great to hear. To wrap up the current state:

  • The focus issue is resolved after reinstalling the imx519 kernel driver.
  • The reason libcamera-still --list-cameras gave no output is that the camera must be started to retrieve the resolution, and on OctoPrint the camera is occupied by default by the OctoPrint camera service. Stopping that service before running libcamera commands from the command line is the workaround — after that, libcamera-still --list-cameras works as expected.
  • For SSH use, remember there’s no preview, so stick with no-preview captures like libcamera-still -t 5000 -n -o test.jpg and check the saved images.
  • The field-of-view question has been forwarded to our marketing colleagues; it’s not something we can adjust from the driver side at this point.

If anything else comes up, post back here and we’ll pick it up.