Arducam 16MP autofocus stuck after reboot on Pi Zero 2 and Pi4 Bullseye

Having a weird issue with my Arducam 16MP Autofocus camera (IMX519). It was working fine this morning on a Pi Zero 2 - the autofocus was visibly shifting focus and I used it with libcamera-hello for both stills and video. After rebooting this evening, the autofocus no longer moves at all and the lens is stuck at a single focus position.

I’ve reproduced it on both a Raspberry Pi Zero 2 and a Pi 4 B (2GB), both on Bullseye with the latest Pi OS build. I already tried the autofocus options like --autofocus-range and --lens-position, but no luck. I was following the guide at https://www.arducam.com/raspberry-pi-camera/autofocus/

Sounds like the autofocus driver/module might have stopped driving the lens motor, but let’s capture what the AF controller is actually doing. Can you enable RPiAf debug logging and run the camera for about 10 seconds? Set it like this:

export LIBCAMERA_LOG_LEVELS=RPiAf:0

Setting RPiAf to level 0 should reveal the autofocus algorithm state and any lens movement activity. Post whatever shows up in the terminal.

I tried that but nothing extra came up. I ran:

export LIBCAMERA_LOG_LEVELS=RPiAf:0

and then ran libcamera-hello, but I didn’t see any additional RPiAf output. Here’s the full terminal:

|09:28:28|pi@PiZero2:[~]> libcamera-hello
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
|09:28:49|pi@PiZero2:[~]> export LIBCAMERA_LOG_LEVELS=RPiAf:0
|09:28:51|pi@PiZero2:[~]>

The preview opens but the lens doesn’t physically move. libcamera v0.0.0+4186-d1dc0373 on Bullseye. I’ve also tried the other Pi 4 and it does the same thing.

Ah, the export probably didn’t get picked up because libcamera-hello was launched in a separate context after the export. Try it inline with a timeout so it runs and exits cleanly:

LIBCAMERA_LOG_LEVELS=RPiAf:0 libcamera-hello -t 10000

The -t 10000 makes it run for 10 seconds. Post the output.

Okay, that worked - I can see RPiAf debug lines now. Here’s the output:

|10:06:06|pi@PiZero2:[~]> LIBCAMERA_LOG_LEVELS=RPiAf:0 libcamera-hello -t 10000
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

Still no lens movement though.

Thanks, that’s a useful clue. What I see is switchMode and a single weight recomputation, but after that there are no focus-sweep or lens-movement entries at all. That’s consistent with the autofocus controller not actually commanding the lens to move.

Next, can you generate a full camera bug report so we can look at the whole system? Reboot the Pi first, then run:

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 produces an arducam-bug-report.txt in the current directory. Send that file over.

Done. I rebooted and ran the tool, and it generated arducam-bug-report.txt. I’ve sent the file to you in a private message since it’s got a bunch of system info in it.

Got it, thanks. I’ve had a look at the report but I still need to check a few things live on your setup, so I’ve sent you the remote support details and scheduling info via private message. Please check your messages - and note it needs to be set up on the Pi 4, not the Pi Zero.

To recap where we’re at: the RPiAf debug log showed switchMode and weight recomputation but no lens movement activity, which points at the autofocus controller not commanding the lens motor. The autofocus is still stuck at a single focus position, and we don’t have a fix yet - I’ll keep investigating.