Autofocus lens stuck after reboot with libcamera on Raspberry Pi Arducam IMX519

Hi everyone,

I’m having a weird issue with my Arducam 16MP Autofocus camera (IMX519). Autofocus just stopped working after a reboot. The lens doesn’t physically move at all anymore, it’s stuck at one focus position. Before this it was working fine on my Pi Zero 2 with libcamera-hello, libcamera-still and libcamera-vid. Focus would shift back and forth before capture, but now nothing moves.

I’ve reproduced the same thing on a Pi 4 as well, so I don’t think it’s the Zero 2.

Thanks for the report. We’re still investigating the root cause for this one. Can you turn on RPiAf autofocus debug logging and run a 10 second capture so we can see what the AF algorithm is doing?

Run:
export LIBCAMERA_LOG_LEVELS=RPiAf:0

Then:
libcamera-hello -t 10000

Let it run for about 10 seconds and paste the terminal output here.

Here’s some more environment info and what I’ve tried so far.

Environment:

  • Pi Zero 2 and Pi 4 B 2GB, Bullseye (latest Pi OS)
  • Arducam 16MP Autofocus camera (IMX519)
  • libcamera v0.0.0+4186-d1dc0373

Things I’ve tried:

  • –autofocus-range, --lens-position, and other AF params
  • Same camera on a Pi 4
  • export LIBCAMERA_LOG_LEVELS=RPiAf:0

This is the output from a normal run:

Made X/EGL preview window
[0:04:02.777669829] [1192] INFO Camera camera_manager.cpp:299 libcamera v0.0.0+4186-d1dc0373
[0:04:02.840905693] [1194] WARN RPI raspberrypi.cpp:1308 Mismatch between Unicam and CamHelper for embedded data usage!
[0:04:02.843884584] [1194] INFO RPI raspberrypi.cpp:1425 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media2 and ISP device /dev/media0
[0:04:02.845510877] [1192] INFO Camera camera.cpp:1028 configuring streams: (0) 2048x1536-YUV420
[0:04:02.846962328] [1194] INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx519@1a - Selected sensor format: 2328x1748-SRGGB10_1X10 - Selected unicam format: 2328x1748-pRAA

Thanks. That run doesn’t actually show any RPiAf debug lines, which usually means the log level didn’t get applied to that process. Can you try setting it inline for the 10 second run like this:

LIBCAMERA_LOG_LEVELS=RPiAf:0 libcamera-hello -t 10000

That should print the RPiAf debug output while it runs.

Okay, I ran it inline this time. The lens still doesn’t move, but here’s the output:

Made X/EGL preview window
[0:41:48.431226438] [1537] INFO Camera camera_manager.cpp:299 libcamera v0.0.0+4186-d1dc0373
[0:41:48.488876939] [1539] WARN RPI raspberrypi.cpp:1308 Mismatch between Unicam and CamHelper for embedded data usage!
[0:41:48.491283125] [1539] INFO RPI raspberrypi.cpp:1425 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media2 and ISP device /dev/media0
[0:41:48.492852961] [1537] INFO Camera camera.cpp:1028 configuring streams: (0) 2048x1536-YUV420
[0:41:48.493763842] [1539] INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx519@1a - Selected sensor format: 2328x1748-SRGGB10_1X10 - Selected unicam format: 2328x1748-pRAA
[0:41:48.583832571] [1543] DEBUG RPiAf af.cpp:226 switchMode: statsRegion: 0,0,4656,3496
[0:41:48.583992205] [1543] DEBUG RPiAf af.cpp:308 Recomputed weights:
[0:41:48.584075903] [1543] DEBUG RPiAf af.cpp:317 0 0 0 0
[0:41:48.584126111] [1543] DEBUG RPiAf af.cpp:317 0 384 384 0
[0:41:48.584174444] [1543] DEBUG RPiAf af.cpp:317 0 0 0 0

I don’t see any errors, but nothing moves physically.

Thanks, that’s useful. The RPiAf side does initialize, I can see switchMode with the stats region and the recomputed weights, but it stops there, so we need more of the system state. Can you generate the full camera bug report after a fresh reboot?

wget -O arducam-camera-bug-report https://github.com/ketai-dhr/arducam-camera-bug-report/releases/download/tools/arducam-camera-bug-report
chmod +x ./arducam-camera-bug-report
./arducam-camera-bug-report

That writes arducam-bug-report.txt in the current directory. Please attach it to your reply.

Done. I rebooted and ran the script. I’ve attached arducam-bug-report.txt. Let me know if you need anything else from it.

Thanks, I’ve gone through the bug report. At this point we can confirm the camera sensor and stream are up, the IMX519 registers and streams fine, and RPiAf initializes with the expected stats region and weights, but the lens actuator still never moves. We’re still digging into the root cause, so I don’t have a fix to share yet.

To take this further I’ve sent you details privately for setting up a remote session so we can look at the live system. Please check your messages and we’ll continue from there.