IMX519 autofocus control fails with "AfMode not advertised" on Raspberry Pi libcamera

Hi everyone, hoping someone can point me in the right direction. I’ve got a set of IMX519 16MP autofocus cameras on a Raspberry Pi, and my app keeps dying as soon as it tries to set up autofocus. The error is:

RuntimeError: Control AfMode is not advertised by libcamera

It’s thrown from this line in /home/pi/BABU/NEW_UI/auto.py (line 52):

self.picam2.set_controls({“AfMode”: controls.AfModeEnum.Auto, “AfTrigger”: controls.AfTriggerEnum.Start})

I already went through Arducam support’s startup and libcamera install instructions (the Libcamera User Guide ‘getting started’ page) and even ran their bug report tool earlier, but the problem is still there. Not really sure what to check next.

Can you share a bit more info? Specifically:

  • the libcamera version banner from your app startup
  • the camera startup logs (especially any ERROR lines)
  • output of dpkg -l | grep libcamera

That ‘not advertised’ error usually means libcamera didn’t bring up the autofocus/lens driver, so the AfMode control never gets registered. The startup logs should show exactly where it fails.

Sure, here’s what I have.

Environment:
libcamera v0.0.5+83-bde9b04f
Sensor: imx519 10-001a
Lens controller: ak7375 10-000c
Pipeline config: /usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml
Script: /home/pi/BABU/NEW_UI/auto.py
picamera2: /usr/lib/python3/dist-packages/picamera2

Startup logs:
[0:07:57.380360899] [1552] INFO Camera camera_manager.cpp:297 libcamera v0.0.5+83-bde9b04f
[0:07:57.423093362] [1573] ERROR V4L2 v4l2_device.cpp:93 ‘ak7375 10-000c’: Failed to open V4L2 device ‘/dev/v4l-subdev1’: Invalid argument
[0:07:57.423199102] [1573] ERROR CameraSensor camera_sensor.cpp:527 ‘imx519 10-001a’: Lens initialisation failed, lens disabled
[0:07:57.449205462] [1573] INFO RPI vc4.cpp:437 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media1 and ISP device /dev/media3
[0:07:57.449313405] [1573] INFO RPI pipeline_base.cpp:1101 Using configuration file ‘/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml’
[0:07:57.467523237] [1552] INFO Camera camera.cpp:1033 configuring streams: (0) 3000x2456-XBGR8888 (1) 4656x3496-SRGGB10_CSI2P
[0:07:57.470597582] [1573] INFO RPI vc4.cpp:565 Sensor: /base/soc/i2c0mux/i2c@1/imx519@1a - Selected sensor format: 4656x3496-SRGGB10_1X10 - Selected unicam format: 4656x3496-pRAA

I haven’t run the dpkg command yet, will do that next.

Thanks, those two ERROR lines are the key part:

‘ak7375 10-000c’: Failed to open V4L2 device ‘/dev/v4l-subdev1’: Invalid argument
‘imx519 10-001a’: Lens initialisation failed, lens disabled

The imx519 sensor itself is fine - it registers and the streams configure normally. But the ak7375 lens controller fails to open its V4L2 subdev, so libcamera disables the lens. When the lens is disabled, the AfMode/AfTrigger controls are never advertised, which is exactly why picamera2 throws that RuntimeError.

Can you paste the full traceback and the output of dpkg -l | grep libcamera? The package list will tell us whether the right libcamera build is actually installed.

Here’s the full traceback:

Traceback (most recent call last):
File “/home/pi/BABU/NEW_UI/auto.py”, line 403, in
window = Auto()
File “/home/pi/BABU/NEW_UI/auto.py”, line 52, in init
self.picam2.set_controls({“AfMode”: controls.AfModeEnum.Auto, “AfTrigger”: controls.AfTriggerEnum.Start})
File “/usr/lib/python3/dist-packages/picamera2/picamera2.py”, line 1093, in set_controls
self.controls.set_controls(controls)
File “/usr/lib/python3/dist-packages/picamera2/controls.py”, line 58, in set_controls
self.setattr(k, v)
File “/usr/lib/python3/dist-packages/picamera2/controls.py”, line 33, in setattr
raise RuntimeError(f"Control {name} is not advertised by libcamera")
RuntimeError: Control AfMode is not advertised by libcamera

I’ll run the dpkg command now and post the output.

The traceback confirms the chain: picamera2 set_controls → controls.set_controls → setattr → RuntimeError, all because libcamera never advertised the control.

So far the picture is:

  • imx519@1a registers on the camera stack and streams configure correctly.
  • ak7375 10-000c fails to open /dev/v4l-subdev1 (Invalid argument).
  • Lens init is disabled, so AfMode/AfTrigger are not advertised.

That’s why the app crashes even though the camera itself is detected.

Please run:

dpkg -l | grep libcamera

and paste the output. If a stock Raspberry Pi OS libcamera is present instead of the Arducam build, the lens driver behavior can differ, so I want to rule that out first.

Also double-check you installed libcamera from the Arducam guide:
https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/Libcamera-User-Guide/#getting-started

Once that’s confirmed, I’d like a bug report to see the full system state. I’ve sent you the bug report tool via private message. The steps are: reboot the device, then download the tool from there, set it executable (chmod +x), and run it. It writes arducam-bug-report.txt in the current directory - send that file back to me privately so I can dig into the lens device issue.

Understood. I’ll run dpkg -l | grep libcamera and post the result, and I’ll generate the bug report file and send it over. The libcamera install I did was from that Arducam getting-started page. One thing I’m wondering - the sensor side configures fine, only the lens fails. Is that more likely a libcamera/kernel mismatch, or could the ak7375 controller itself be faulty?

Good question. The logs show libcamera tried to open the ak7375 subdev and got ‘Invalid argument’, so the failure happens before autofocus can be enabled. Since the imx519 sensor configures correctly and only the lens init fails, the likely candidates are a libcamera package/build mismatch, a kernel overlay or driver issue for the ak7375, or a problem with the lens controller on that unit. The dpkg output and the bug report will help narrow it down.

To summarize where we are:

  • Sensor: imx519@1a detected and registered; streams configured at 4656x3496-SRGGB10.
  • Lens: ak7375 10-000c fails to open /dev/v4l-subdev1 (Invalid argument), so lens initialization is disabled.
  • Result: AfMode/AfTrigger are not advertised by libcamera, which is why picamera2 raises ‘Control AfMode is not advertised’.

Send over the dpkg -l | grep libcamera output and the arducam-bug-report.txt and we’ll go from there.