Cannot open /dev/video0 with Arducam ToF camera on Raspberry Pi 4B

Hi everyone. I’m trying to get the ArduCAM ToF camera working on a Raspberry Pi 4B. I ran ./Install_dependencies.sh and it completed fine, but then ./compile.sh fails. I’m on Bookworm (also tried Bullseye). The compile errors are a bunch of missing/undefined ArduCAM API members:

  • FrameType::CONFIDENCE_FRAME
  • CameraInfo::device_type
  • DeviceType::DEVICE_VGA
  • CameraCtrl::FMT_WIDTH
  • CameraCtrl::FMT_HEIGHT
  • CameraCtrl::MODE
  • CameraCtrl::FRAME_RATE
  • TofWorkMode::DOUBLE_FREQ
  • TofWorkMode::SINGLE_FREQ
  • to_int

Anyone seen this before?

Those errors happen because the example code on the default Arducam_tof_camera branch doesn’t match the SDK headers the current build is using. Those members aren’t defined in the SDK headers anymore.

Try this:

That branch’s example code should line up with the SDK headers.

Thanks, I switched to v1.0.3 and it compiles now, but I’ve hit a runtime error. Running the compiled binary gives:

open WARNING Could not open device node /dev/video0. Please check for permissions.
initialization failed

Environment:

  • Raspberry Pi 4B
  • Fresh install of Bookworm Raspberry Pi OS
  • OpenCV 4.6.0
  • GNU C/C++ compilers 12.2.0
  • Repo path: /home/pi/Arducam_tof_camera

What I ran:

CMake build succeeded — test_c, preview_depth, select_video_preview, capture_raw, preview_usb all built. It found OpenCV 4.6.0 at /usr. But the device node won’t open. I’ve tried both Bookworm and Bullseye Raspberry Pi OS.

Now that it compiles, the /dev/video0 failure points to the camera overlay not being configured. Without it, the device node won’t be created or accessible.

Add this line to /boot/firmware/config.txt:

dtoverlay=arducam-pivariety,media-controller=0

Then reboot the Pi. That overlay is required for the ToF camera’s /dev/video0 node to show up.

I added the overlay line and rebooted, but the same /dev/video0 error is still there. I checked /boot/firmware/config.txt and the line ‘dtoverlay=arducam-pivariety,media-controller=0’ was actually already present. I added it once more anyway and rebooted — no change. I also double-checked the camera connection and the contacts on both ends, everything looks fine.

Since the overlay is already present and the error persists, I need a bit more to diagnose this. I’ve sent you a private message with the diagnostic tool and where to send the output. In short:

  • Reboot the device first
  • Run the bug report tool I sent over PM
  • It generates an arducam-bug-report.txt file

Please also send pictures of the hardware connection — both the Raspberry Pi end and the camera end — through the private message. I’ll look at those together with the report.

I’ve sent the hardware photos (Pi end and camera end) and the arducam-bug-report.txt through private message. Let me know what you find.

Thanks for those. Looking at the report, this points to the ToF camera needing a firmware update. Do you happen to have a Raspberry Pi 5 available? The firmware update procedure is documented under the Pi 5 preparation section here:

https://docs.arducam.com/Raspberry-Pi-Camera/Tof-camera/Getting-Started/#preparation-on-pi5

My board is a Raspberry Pi 4B, and I don’t have a Pi 5 available. Can the camera be made to work on the Pi 4B?

Sorry for the confusion — I only mentioned the Pi 5 because the firmware update procedure happens to be documented in the Pi 5 preparation section of the docs. The camera itself needs a firmware update, and that’s the root cause of the /dev/video0 failure. The Pi 5 is just where the instructions are written.

Got it. So what can I actually do with only a Raspberry Pi 4?

The same firmware update steps documented under ‘preparation on Pi 5’ apply to the Pi 4 as well. Follow those steps here:

https://docs.arducam.com/Raspberry-Pi-Camera/Tof-camera/Getting-Started/#preparation-on-pi5

Run through the firmware update on your Pi 4B, then try the v1.0.3 branch again.

It worked! After updating the firmware using those Pi 5 prep steps on my Pi 4, I used the v1.0.3 branch and the camera is working now. Thanks for the help.

Great to hear. So to sum it up for anyone else hitting this: the ToF camera needed a firmware update, combined with using the v1.0.3 branch of Arducam_tof_camera. That resolved both the original compile errors and the ‘Could not open device node /dev/video0’ failure.