Autofocus fails on one of dual IMX219 cameras after reboot on Raspberry Pi 5

Hi everyone, I’m running two Arducam 8MP IMX219 Motorized Focus Cameras on a Raspberry Pi 5 and having a weird autofocus problem. Both cameras autofocus fine when they’re running at the same time, but it’s not stable. After rebooting the Pi or power cycling, autofocus stops working on one of the cameras. It’s not always the same camera, and I can’t find any reliable way to get both working again. Sometimes physically disconnecting and reconnecting the cameras brings it back, but not every time. Has anyone run into this?

Thanks for the report. Can you share a bit more about your setup - the exact SKU, what Pi you’re on, and which documentation you’re following? Also curious if you already have a theory about what’s going on.

Sure. SKU is B0393 (8MP IMX219 Motorized Focus Camera), running on a Raspberry Pi 5, and I’ve been following the PiCamera2 Datasheet for this camera. It’s a dual camera setup.

My guess is the I2C communication between the two cameras isn’t getting configured correctly during boot, so the autofocus commands aren’t reliably reaching the camera. A few things I’m not sure about:

  • How do I check the camera configuration settings at runtime?
  • Does the Pi actually use the I2C pins for both cameras?
  • Do the I2C pins need to be configured separately?

Those are good questions. Yes, these cameras use I2C for the focus motor, and each camera’s I2C is mapped through the device tree. Normally you shouldn’t need to configure the I2C pins separately if the overlay and dtparam settings are correct. For runtime checking you can look at the loaded overlays and the I2C bus status. Before I go further, what have you already tried?

I’ve tried quite a few things:

  • Changing the order of the dtoverlay settings in config.txt
  • Enabling dtparam i2c_vc
  • Adding the autofocus algorithm to the imx219.json files
  • Reimaging the Pi completely
  • Calling back the AF state from PiCamera2 to print the focus positions that should be sent to the camera
  • Physically disconnecting/reconnecting the cameras (works sometimes, but not consistently)

Still fails randomly after a reboot.

Thanks, that’s really useful. The intermittent pattern - not always the same camera, and recovering when you physically reseat the cameras - points to an I2C/device tree configuration or focus-driver initialization problem during boot rather than a dead camera. We’re going to replicate your setup in the lab and check:

  1. The I2C communication behavior
  2. Behavior across multiple boot cycles
  3. Autofocus performance on both cameras running simultaneously

I’ll get back to you with specific results and recommendations, hopefully within about 24 hours.

Any update? Still seeing the same thing here.

Update - we reproduced the dual-camera autofocus problem in the lab and got it sorted. Root cause is the dtb (device tree blob) file needs to be replaced; the focus driver isn’t enabled/configured correctly with the current one.

Steps:

  1. Go to the IMX219 Motorized Focus Camera Quick Start Guide and open the ‘Enable the Focus Driver’ section: For 8MP IMX219 Motorized Focus Camera - Arducam Wiki
  2. Follow the steps there to replace the dtb file.
  3. Reboot the Raspberry Pi so it takes effect.

Let me know how it goes.

That did it. I replaced the dtb file, rebooted, and then power cycled and rebooted a few more times to test - both cameras keep autofocusing now. Thanks for the help!

Great, thanks for confirming. For anyone else who finds this thread: replacing the dtb file so the focus driver is enabled/configured correctly, then rebooting, resolves the intermittent autofocus failure on one camera in a dual-camera IMX219 Motorized Focus Camera setup. The telltale symptom is autofocus dropping on a random camera after a reboot/power cycle and coming back after physically reseating the cameras.