Hi, I’m trying to run the Arducam ToF camera demo on my Raspberry Pi 4B (4GB) running Debian 11 bullseye with the arducam-tof-sdk-dev 0.1.0 arm64 package installed. The build with ./compile.sh seems to complete fine, but then the demo crashes right at the end of the compiling phase. I’m seeing a v4l2 warning about video0, a couple of VIDIOC_S_CTRL ‘Bad file descriptor’ errors, and then a segmentation fault. Anyone know what’s going on here?
Can you paste the full output of ./compile.sh here? The VIDIOC_S_CTRL errors usually mean the app is trying to talk to a video device that isn’t the ToF camera, but the full log will give us a clearer picture.
Sure, here’s the complete output:
nl-frank@raspberrypi:~/Arducam_tof_camera $ ./compile.sh
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr (found version "4.5.1")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nl-frank/Arducam_tof_camera/example/build
Scanning dependencies of target test_c
[ 10%] Building C object c/CMakeFiles/test_c.dir/test.c.o
[ 20%] Linking C executable test_c
[ 20%] Built target test_c
Scanning dependencies of target preview_usb
[ 30%] Building CXX object cpp/CMakeFiles/preview_usb.dir/preview_by_usb.cpp.o
[ 40%] Linking CXX executable preview_usb
[ 40%] Built target preview_usb
Scanning dependencies of target capture_raw
[ 50%] Building CXX object cpp/CMakeFiles/capture_raw.dir/capture_raw.cpp.o
[ 60%] Linking CXX executable capture_raw
[ 60%] Built target capture_raw
Scanning dependencies of target select_video_preview
[ 70%] Building CXX object cpp/CMakeFiles/select_video_preview.dir/select_video_preview.cpp.o
[ 80%] Linking CXX executable select_video_preview
[ 80%] Built target select_video_preview
Scanning dependencies of target preview_depth
[ 90%] Building CXX object cpp/CMakeFiles/preview_depth.dir/preview_depth.cpp.o
[100%] Linking CXX executable preview_depth
[100%] Built target preview_depth
v4l2_device_open_v4l2_subdev ***WARNING*** Link '../../devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/video4linux/video0' does not contain '/v4l-subdev'
VIDIOC_S_CTRL: Bad file descriptor
VIDIOC_S_CTRL: Bad file descriptor
Segmentation fault
Thanks. A couple of things to check. How many cameras are currently plugged into the Pi? Also can you run the following and paste the results:
ls /dev/video*
dpkg -l | grep arducam-tof-sdk-dev
pip3 list | grep ArduCamDepthCamera
and cat /etc/os-release so we can see the full environment?
Here’s what I get:
pip3 list | grep ArduCamDepthCamera returns nothing.
dpkg -l | grep arducam-tof-sdk-dev shows:
ii arducam-tof-sdk-dev 0.1.0 arm64 Driver development kit for arducam tof camera
ls /dev/video*:
/dev/video0 /dev/video12 /dev/video16 /dev/video20 /dev/video31
/dev/video1 /dev/video13 /dev/video18 /dev/video21
/dev/video10 /dev/video14 /dev/video19 /dev/video22
/dev/video11 /dev/video15 /dev/video2 /dev/video23
And the OS version:
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
That explains it. You have two cameras connected to the Raspberry Pi, so the demo code is probably defaulting to the wrong video device node (/dev/video0), which is why it tries to set controls on a device that doesn’t support them and then segfaults. You need to tell the demo explicitly which video device is the ToF camera.
For C/C++ you can do:
int video = 1; //if camera is /dev/video1
tof.open(Connection::CSI,video)
For Python:
camIdx = 1 # If the path of the camera is /dev/video1
cam.open(ac.TOFConnect.CSI,camIdx )
The quickest way to confirm this is the issue is to remove the other camera so only the ToF camera is connected, then run the demo again. Once it works standalone, you can reattach the second camera and figure out which /dev/videoN index belongs to the ToF camera.
Thanks, that sorted it on the Pi 4. I’ve moved to a Raspberry Pi 5 running Bookworm now though, and I’m hitting a different failure. It says:
open WARNING Could not open device node /dev/video0. Please check for permissions.
initialization failed
I’ve been cross checking everything and I’m starting to suspect Bookworm itself is the problem. I have 3 ToF cameras waiting to be integrated on this Pi 5.
Thanks for the details. That’s the issue right now — the ToF camera isn’t compatible with the Raspberry Pi 5 / Bookworm yet. Arducam just received a single Raspberry Pi 5 for testing, and there are a lot of camera modules that still need driver updates for the new platform. So the “Could not open device node /dev/video0” error on the Pi 5 isn’t something you can fix on your side yet. There are no user-executable steps for this one. Arducam expects to make the ToF camera compatible with Raspberry Pi 5 by the end of this month, so for now the best option is to wait for the compatibility update and keep an eye out for news from Arducam.