Arducam 21MP IMX230 autofocus capture segfaults on Raspberry Pi

Hi, I have an Arducam 21MP IMX230 (SKU: B0324) and it keeps failing whenever I try to capture with autofocus. Plain still captures work, but any autofocus capture crashes. My setup:

  • Raspberry Pi: Linux raspberrypi 5.15.84-v8+ #1613 SMP PREEMPT Thu Jan 5 12:03:08 GMT 2023 aarch64 GNU/Linux
  • Debian version: 11.6
  • libcamera-apps: 0.0.12 arm64
  • libcamera-dev: 0.0.12 arm64
  • Camera: arducam-pivariety [5344x4016] (/base/soc/i2c0mux/i2c@1/arducam_pivariety@c)
  • dmesg shows: firmware version: 0x10001 and ‘Consider updating driver arducam-pivariety to match on endpoints’

Any idea what’s going on?

Thanks for the details. Can you post the exact command you’re running for the autofocus capture, plus the output you get when it fails? It would also help to know whether a basic still capture without autofocus works on the same camera.

Sure. This is the command that crashes:

libcamera-still -n --autofocus-mode=auto --autofocus-on-capture=1 -o test.jpg

And yes, a still capture without autofocus works fine with this Python code:

#!/usr/bin/python3
from picamera2 import Picamera2
import time
picam2 = Picamera2()
camera_config = picam2.create_still_configuration()
picam2.configure(camera_config)
picam2.start()
time.sleep(1)
picam2.capture_file(“test.jpg”)
picam2.close()

Thanks, that’s helpful - it means the sensor itself is capturing fine without AF. Could you run the autofocus command again and paste the full terminal output? Also run libcamera-hello --list-cameras and share the supported modes.

Here’s the output from the failing command:

[1:01:04.752286095] [6015] INFO Camera camera_manager.cpp:299 libcamera v0.0.0+4186-d1dc0373
[1:01:04.769499268] [6017] WARN CameraSensorProperties camera_sensor_properties.cpp:205 No static properties available for ‘arducam-pivariety’
[1:01:04.769551897] [6017] WARN CameraSensorProperties camera_sensor_properties.cpp:207 Please consider updating the camera sensor properties database
[1:01:04.778519432] [6017] ERROR IPAProxy ipa_proxy.cpp:149 Configuration file ‘arducam-pivariety.json’ not found for IPA module ‘raspberrypi’
[1:01:05.115295136] [6017] INFO RPI raspberrypi.cpp:1425 Registered camera /base/soc/i2c0mux/i2c@1/arducam_pivariety@c to Unicam device /dev/media4 and ISP device /dev/media2
[1:01:05.116091422] [6015] INFO Camera camera.cpp:1028 configuring streams: (0) 2672x2008-YUV420
[1:01:05.166640305] [6017] INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/arducam_pivariety@c - Selected sensor format: 2656x2004-SRGGB10_1X10 - Selected unicam format: 2656x2004-pRAA
[1:01:05.206947223] [6021] WARN IPARPI raspberrypi.cpp:810 Could not set AF_MODE - no AF algorithm
Segmentation fault

And the camera modes:

‘SRGGB10_CSI2P’:
640x480 [120.08 fps - (0, 0)/0x4016 crop]
1280x720 [120.02 fps - (0, 0)/5344x4016 crop]
1280x960 [120.08 fps - (0, 0)/5344x4016 crop]
1920x1080 [30.01 fps - (0, 0)/5344x4016 crop]
2592x1944 [15.00 fps - (0, 0)/5344x4016 crop]
2656x2004 [30.01 fps - (0, 0)/5344x4016 crop]
3840x2160 [10.00 fps - (0, 0)/5344x4016 crop]
5344x4012 [9.00 fps - (0, 0)/5344x4016 crop]

Thanks for all that. The key line is ‘Could not set AF_MODE - no AF algorithm’ right before the segfault - the AF algorithm isn’t loading for this sensor. We haven’t fully pinned down the root cause yet, but first please check the steps in the Arducam libcamera guide for the 16MP/64MP autofocus cameras:

https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/Libcamera-User-Guide/#for-arducam-16mp64mp-autofocus-camera

Can you also run ‘dmesg | grep arducam’ and paste the result? Those firmware/endpoint lines are useful context.

I went through all the commands in that guide, but every single one still ends in Segmentation fault. The full commands and outputs are too long to paste here - I’ve saved them all into a text file (arducam_seg_fault.txt) along with the raspinfo output. The result is always the same though.

Here’s the dmesg output you asked for:

dmesg | grep arducam
[ 6.964179] arducam-pivariety 10-000c: firmware version: 0x10001
[ 7.399902] arducam-pivariety 10-000c: Consider updating driver arducam-pivariety to match on endpoints

Thanks. Based on all of this, the segfault on this IMX230 is a firmware issue - the camera firmware needs updating to fix the autofocus crash.

Here’s the procedure:

  1. Power the Pi off, and use a jumper wire to short the camera board. I’ve sent you a picture via private message showing exactly where.
  2. Power the Pi back on. Once it’s restarting, you can remove the jumper wire from the camera board.
  3. Decompress the firmware package I’ve sent you via private message, and pick the file matching your kernel version (32-bit or 64-bit).
  4. Go into the imx230_lanes2_firmware folder and run the updater command.

If you see ‘Firmware update successful, please reboot’, the update worked and you should reboot the Pi to apply it. If you see the red error hint instead, the update didn’t take - replug the camera and start from scratch.

Good news - after the firmware update the Segmentation fault is gone. The --lens-position parameter now works and gives different pictures depending on the value. My app is headless so it’s hard to test autofocus visually before I wire up the parameters in the Python app, but the crash is definitely fixed.

One thing though: dmesg still shows firmware version 0x10001 after the upgrade. Would a new IMX230 unit show something different, or is that expected? I initially suspected a 32-bit OS problem, not running X, or driver/Picamera2 issues. Might be worth adding this to the troubleshooting wiki:

https://docs.arducam.com/Raspberry-Pi-Camera/Pivariety-Camera/Troubleshooting/

Great, that matches what we see here - the firmware update resolves the segfault. You mentioned the manual focus command - is it still not working? We tested it on our side and it works fine after the firmware update. If you’re still getting an error, can you post the terminal output?

For reference, the manual focus command is documented here:

https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/Libcamera-User-Guide/#manual-focus

Sorry, my earlier note was just an example - I hadn’t actually tested the other commands yet. The manual focus command does work. I’m running the Pi headless with no screen, so it’s hard to see autofocus in a preview, but after more testing everything works, including autofocus from Python using the Picamera2 library.

Glad it’s sorted. To summarize: the firmware update fixed the Segmentation fault, and the autofocus / manual focus commands now work. The fact that dmesg still reports firmware version 0x10001 after the update is expected on these units - it doesn’t mean the update failed. I’ll add this troubleshooting info to the wiki so others hitting the same segfault can find it:

https://docs.arducam.com/Raspberry-Pi-Camera/Pivariety-Camera/Troubleshooting/