Segmentation fault with autofocus on 16mp

  1. Where did you get the camera module(s)?
    Roboshop in NL
  2. Model number of the product(s)?
    16mp Autofocus imx519 - UC-873 Rev C.
  3. What hardware/platform were you working on?
    Pi 4 Model B Rev 1.2 4MB
  4. Instructions you have followed. (link/manual/etc.)
    How To Use Arducam 16MP Camera On Raspberry Pi - Arducam
  • Running BullsEye
  • Lib camera version (apps/dev) 0.0.10

Using --autofocus in the command crashes libcamera(-vid/still/etc) function with a segmentation fault.

Created logging with LIBCAMERA_LOG_LEVELS=*:DEBUG
I tried several libcamera functions and they all crash when the --autofocus option is added.
This is only the 2nd day that I worked with the camera and to my knowledge nothing changed. The 1st day I didn’t have this problem and it seemed to start of of nowhere…
There is an image when the autofocus is skipped but the image is not in focus. Manual focus option don’t seem to work…
Not sure the camera itself may be broken??

[I seem to be unable to attach the full log]

LIBCAMERA_LOG_LEVELS=*:DEBUG libcamera-vid -t 0 --width 1920 --height 1080 --codec h264 -n -l -o tcp://0.0.0.0:5001 --autofocus

.......

0:13:12.919639723] [1721] DEBUG RPiAgc agc.cpp:729 after AWB, target dg 1 gain 119.811 target_Y 0.20001
[0:13:12.919670297] [1721] DEBUG RPiAgc agc.cpp:744 Digital gain 1 desaturate? 0
[0:13:12.919695946] [1721] DEBUG RPiAgc agc.cpp:746 Target totalExposureNoDG 263043.64us
[0:13:12.919725075] [1721] DEBUG RPiAgc agc.cpp:793 After filtering, totalExposure 263043.64us no dg 263043.64us
[0:13:12.919758983] [1721] DEBUG RPiAgc agc.cpp:833 Divided up shutter and gain are 32880.45us and 8
[0:13:12.919791261] [1721] DEBUG RPiAgc agc.cpp:872 Output written, total exposure requested is 263043.64us
[0:13:12.919820687] [1721] DEBUG RPiAgc agc.cpp:874 Camera exposure update: shutter time 32880.45us analogue gain 8
[0:13:12.919852206] [1721] DEBUG RPiAlsc alsc.cpp:403 frame_phase 1
[0:13:12.919874465] [1721] DEBUG RPiAlsc alsc.cpp:331 Starting ALSC calculation
[0:13:12.919897243] [1721] DEBUG RPiAlsc alsc.cpp:308 AWB results found, using 4000
[0:13:12.919956132] [1716] DEBUG RPiAlsc alsc.cpp:452 ct is 4000, interpolating between 3000 and 6000
[0:13:12.919997206] [1716] DEBUG RPiAlsc alsc.cpp:452 ct is 4000, interpolating between 3000 and 6000
[0:13:12.920084799] [1716] DEBUG RPiAlsc alsc.cpp:727 Stop after 1 iterations
[0:13:12.920124577] [1716] DEBUG RPiAlsc alsc.cpp:727 Stop after 1 iterations
[0:13:12.920184189] [1721] DEBUG RPiContrast contrast.cpp:111 Move histogram point 5.15967 to 983.04
[0:13:12.920215800] [1721] DEBUG RPiContrast contrast.cpp:115 Final values 983.04 -> 983.04
[0:13:12.920244726] [1721] DEBUG RPiContrast contrast.cpp:132 Move histogram point 490.203 to 62259.2
[0:13:12.920273115] [1721] DEBUG RPiContrast contrast.cpp:136 Final values 60259.2 -> 62259.2
[0:13:12.920328356] [1721] DEBUG IPARPI raspberrypi.cpp:1278 Applying AGC Exposure: 32880.45us (Shutter lines: 2328, AGC requested 32880.45us) Gain: 8 (Gain Code: 896)
Segmentation fault

Last bit of DMESG

6.175705] [drm] Initialized vc4 0.0.0 20140616 for gpu on minor 1
[    6.176104] vc4-drm gpu: [drm] Cannot find any crtc or sizes
[    6.285478] brcmfmac: F1 signature read @0x18000000=0x15264345
[    6.301720] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43455-sdio for chip BCM4345/6
[    6.423640] usbcore: registered new interface driver brcmfmac
[    6.586893] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43455-sdio for chip BCM4345/6
[    6.603757] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM4345/6 wl0: Nov  1 2021 00:37:25 version 7.45.241 (1a2f2fa CY) FWID 01-703fd60
[    6.662040] rtc-ds1307: probe of 1-0068 failed with error -121
[    7.215949] imx519 10-001a: Device found is imx519
[    7.216544] imx519 10-001a: Consider updating driver imx519 to match on endpoints
[    7.848274] uart-pl011 fe201000.serial: no DMA platform data
[    7.968169] 8021q: 802.1Q VLAN Support v1.8
[    8.039289] Adding 102396k swap on /var/swap.  Priority:-2 extents:1 across:102396k SSFS
[    8.419328] brcmfmac: brcmf_cfg80211_set_power_mgmt: power save enabled
[    8.878428] bcmgenet fd580000.ethernet: configuring instance for external RGMII (RX delay)
[    8.879806] bcmgenet fd580000.ethernet eth0: Link is Down
[   13.115472] hdmi-audio-codec hdmi-audio-codec.0.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.115531]  MAI: soc_pcm_open() failed (-19)
[   13.116192] hdmi-audio-codec hdmi-audio-codec.0.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.116230]  MAI: soc_pcm_open() failed (-19)
[   13.116761] hdmi-audio-codec hdmi-audio-codec.0.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.116793]  MAI: soc_pcm_open() failed (-19)
[   13.126616] hdmi-audio-codec hdmi-audio-codec.0.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.126695]  MAI: soc_pcm_open() failed (-19)
[   13.127960] hdmi-audio-codec hdmi-audio-codec.0.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.128010]  MAI: soc_pcm_open() failed (-19)
[   13.128495] hdmi-audio-codec hdmi-audio-codec.0.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.128530]  MAI: soc_pcm_open() failed (-19)
[   13.306900] hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.306964]  MAI: soc_pcm_open() failed (-19)
[   13.307556] hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.307594]  MAI: soc_pcm_open() failed (-19)
[   13.308120] hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.308152]  MAI: soc_pcm_open() failed (-19)
[   13.316098] hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.316185]  MAI: soc_pcm_open() failed (-19)
[   13.316590] hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.316632]  MAI: soc_pcm_open() failed (-19)
[   13.316908] hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
[   13.316939]  MAI: soc_pcm_open() failed (-19)
[   13.982089] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   15.912586] ICMPv6: process `dhcpcd' is using deprecated sysctl (syscall) net.ipv6.neigh.wlan0.retrans_time - use net.ipv6.neigh.wlan0.retrans_time_ms instead
[   15.987448] Bluetooth: Core ver 2.22
[   15.987618] NET: Registered PF_BLUETOOTH protocol family
[   15.987627] Bluetooth: HCI device and connection manager initialized
[   15.987643] Bluetooth: HCI socket layer initialized
[   15.987652] Bluetooth: L2CAP socket layer initialized
[   15.987669] Bluetooth: SCO socket layer initialized
[   16.001772] Bluetooth: HCI UART driver ver 2.3
[   16.001797] Bluetooth: HCI UART protocol H4 registered
[   16.001871] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   16.002235] Bluetooth: HCI UART protocol Broadcom registered
[   16.252741] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   16.252764] Bluetooth: BNEP filters: protocol multicast
[   16.252780] Bluetooth: BNEP socket layer initialized
[   16.272501] NET: Registered PF_ALG protocol family
[   16.351036] vc4-drm gpu: [drm] Cannot find any crtc or sizes
[   16.391049] Bluetooth: RFCOMM TTY layer initialized
[   16.391081] Bluetooth: RFCOMM socket layer initialized
[   16.391105] Bluetooth: RFCOMM ver 1.11
[   31.710902] cam-dummy-reg: disabling
[ 4817.808456] ieee80211 phy0: brcmf_run_escan: error (-52)
[ 4817.808493] ieee80211 phy0: brcmf_cfg80211_scan: scan error (-52)
[ 5117.815225] ieee80211 phy0: brcmf_run_escan: error (-52)
[ 5117.815261] ieee80211 phy0: brcmf_cfg80211_scan: scan error (-52)
[ 5417.822809] ieee80211 phy0: brcmf_run_escan: error (-52)
[ 5417.822846] ieee80211 phy0: brcmf_cfg80211_scan: scan error (-52)
[ 5717.830445] ieee80211 phy0: brcmf_run_escan: error (-52)
[ 5717.830482] ieee80211 phy0: brcmf_cfg80211_scan: scan error (-52)
[ 6017.836687] ieee80211 phy0: brcmf_run_escan: error (-52)
[ 6017.836725] ieee80211 phy0: brcmf_cfg80211_scan: scan error (-52)

@SupportTeam Any idea?

Hi,
You can refer to the two commands below:

  • Auto focus: libcamera-still -t 0 --afmode auto --autofocus

  • Continous auto focus: libcamera-still -t 0 --afmode continuous --autofcous

@Dion I am not sure I understand your comment??

I know those are the options: the segmentation happens when --autofocus is present in the command.
I received an email (from support) with the question for more specific log information but I do not have access to that pi at the moment. This may take a few days, unfortunately.

Hi,
We have modified the autofocus mode in Libcamera version 10. Hence, the libcamera functions would crash when you added --autofocus. It is not correct if your libcamera version is 0.0.10.
If you want to use the autofocus mode, please refer to my last reply.

Hello @Dion, I’m facing the same problem as RayMan…

pi@krvkweather:~ $ libcamera-still -n -r --afmode auto --autofocus -o test.jpg
[0:10:18.357922671] [1058]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3897-c3c878a9
[0:10:18.365177501] [1060]  WARN CameraSensorProperties camera_sensor_properties.cpp:174 No static properties available for 'imx519'
[0:10:18.365269741] [1060]  WARN CameraSensorProperties camera_sensor_properties.cpp:176 Please consider updating the camera sensor properties database
[0:10:18.421259308] [1060]  WARN RPI raspberrypi.cpp:1280 Mismatch between Unicam and CamHelper for embedded data usage!
[0:10:18.422663482] [1060] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009a090a but control is not exposed by device /dev/v4l-subdev0
[0:10:18.423007182] [1060]  INFO RPI raspberrypi.cpp:1404 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media2 and ISP device /dev/media0
[0:10:18.424113594] [1058]  INFO Camera camera.cpp:1035 configuring streams: (0) 2328x1748-YUV420
[0:10:18.424942296] [1060]  INFO RPI raspberrypi.cpp:765 Sensor: /base/soc/i2c0mux/i2c@1/imx519@1a - Selected sensor format: 2328x1748-SRGGB10_1X10 - Selected unicam format: 2328x1748-pRAA
Segmentation fault
pi@krvkweather:~ $ libcamera-still -n -r --afmode continuous --autofocus -o test.jpg
[0:10:52.730654071] [1082]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3897-c3c878a9
[0:10:52.736870287] [1084]  WARN CameraSensorProperties camera_sensor_properties.cpp:174 No static properties available for 'imx519'
[0:10:52.736962266] [1084]  WARN CameraSensorProperties camera_sensor_properties.cpp:176 Please consider updating the camera sensor properties database
[0:10:52.777180297] [1084]  WARN RPI raspberrypi.cpp:1280 Mismatch between Unicam and CamHelper for embedded data usage!
[0:10:52.778588269] [1084] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009a090a but control is not exposed by device /dev/v4l-subdev0
[0:10:52.778928791] [1084]  INFO RPI raspberrypi.cpp:1404 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media2 and ISP device /dev/media0
[0:10:52.780078378] [1082]  INFO Camera camera.cpp:1035 configuring streams: (0) 2328x1748-YUV420
[0:10:52.780917026] [1084]  INFO RPI raspberrypi.cpp:765 Sensor: /base/soc/i2c0mux/i2c@1/imx519@1a - Selected sensor format: 2328x1748-SRGGB10_1X10 - Selected unicam format: 2328x1748-pRAA
Segmentation fault

I’ve tried your possible solutions but nothing. I’m using v0.0.10:

pi@krvkweather:~ $ dpkg -l | grep libcamera
ii  libcamera-apps                       0.0.10                           armhf        libcamera-apps
ii  libcamera-dev                        0.0.10                           armhf        libcamera

Everything else works perfect, but I really need that - - autofocus parameter because if not, the photo is blurry as hell.

Thanks.

Hello @Dion, hello everyone.

I have the same problem, when I use --autofocus don´t take the photo and it throws me an error of segment foult.
I try with the command --afmode auto and continuos but the camera does not focus.

weeks ago it worked perfectly.

Thanks.

Hi There
Facing the same, Autofocus issues with Adrucam 16MP imx519.
Looks like an update on the libcamera app making that trouble.
Pierrick

Hi,
Can you access the camera without autofocus?

Hi,
We are checking the problem and will tell you guys when we have the result.

yes, when I remove –autofocus it’s work well.

Thank you for your help!

Update: I reinstalled everything (still version 0.0.10) on a Pi3 (my report was on a Pi4) with the same camera unit.
Now all works fine. The command as I reported in my first post, the commands that @Dion provided and I even tried the commands as @javinair used. All is fine again.

I haven’t had the opportunity to test again on the original Pi4 as that is in use with an original Pi camera at the moment. As far as I can see the versions are the same: libcamera v0.0.0+3897-c3c878a9

And to emphasis my original report: when the --autofocus was NOT present the camera worked, but as others mentioned: the image is blurry/unusable.
So in short: in seems to work for me at this time but it did before and seemed to stop working without any particular reason (as per my original post). So it may happen again… my experience was similar to that of @gattostein

At least I know the camera is fine :slight_smile:

As soon as my Pi4 comes available I will retry and update if anything useful pops up.

hi,
I think it is a problem with the last update. I have another raspi 3 working with arducam 16 MP from 3 months ago without updating since then… the function I use is “libcamera-still --hflip --vflip -t 1000 -o /home/pi/Desktop/photo/ $ DATE.jpg -n --autofocus”
it works perfectly on these raspi3, but i copied exactly the same program, configuration, operating system (bullseye) to a new raspi3 and it doesn’t work with “–autofocus”.
For this reason I deduce that it may be something in the last update. I hope to help with these details.

greetings and thanks!

hi everyone, i’m facing the same exact issue here, 16mpix+RPi4 , libs 0.0.1, --autofocus produces seg fault, pictures without parameters came blurry, --afmode parameters do nothing.

Help!

Same issue here.

Auto focus: libcamera-still -t 0 --afmode auto --autofocus

Continous auto focus: libcamera-still -t 0 --afmode continuous --autofocus

both yield a segmentation fault.

Hi guys,
I have tested Pi 4 + 16mp camera today. I burned the brand new image(5.15.61-v7l+) to the RSP. And It works on my side. The easiest but rather clumsy way to check the problem is to re-burn the image and reinstall everything (camera driver, libcamera dev&apps 0.0.10 ) Because we have not met the problem you are facing. It is difficult for us to debug :sweat: Hope you can try this way and give me feedback.
As you can see in the screenshot below, my libcamera version is 0.0.10. @gattostein @codybravoteam @Pikasso @javinair @Steve_79
My RSP’info:


Dmesg log:
image

*Command: libcamera-still -t 0 --afmod auto --autofocus

Tx
Dion

Thanks Dion.
I’m going to reinstall everything again. OS and libraries and perform tests. I will be commenting!!

Dion, if you want to track down the bug, i can dump my OS image and share it, so you can throw it into your rig and test out, let me know

Hi,
That’s great! I will test it within the next few days.

same segmentation fault here after sudo apt upgrade.
If you reinstall OS, you jump before the update! (so autofocus works).
please test libcamera-still --afmode manual --manualfocus 50 after an upgrade of the OS to catch the error.