Template: CM4-DUAL-CAMERA-BASE Guide

From Waveshare Wiki
Jump to: navigation, search

Writing Image

USB2.0

To reduce consumption, USB interfaces are disabled in CM4 by default. If you need to use USB ports, please add the following line to config.txt file.

dtoverlay=dwc2,dr_mode=host

Then reboot the CM4. If you use the newest Bullseye image, the USB2.0 is set to OTG mode by default, and it occurs the error in CM4:

config failed, hub doesn't have any ports! (err -19)

To remove the errors, you can remove the line otg_mode=1 from config.txt file and add the line:

dtoverlay=dwc2,dr_mode=host

CSI

CSI and DSI are disabled by default. When using the camera and DSI, it will occupy three I2C devices: I2C-10, I2C-11, and I2C-0.

  • Open a terminal and run the following commands:
wget https://files.waveshare.com/upload/7/75/CM4_dt_blob_Source.zip
unzip -o  CM4_dt_blob_Source.zip -d ./CM4_dt_blob_Source
sudo chmod 777 -R CM4_dt_blob_Source
cd CM4_dt_blob_Source/
sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
# HDMI1 has no image output when using any CSI
#If you need to restore, delete the corresponding dt-blob.bin: sudo rm -rf /boot/dt-blob.bin 
#Execution is complete. Power off and restart CM4.

Recording test

And then connect the cameras and DSI display.
1: Please power off the IO Board first before your connection.
2: Connect the power adapter after connecting the cameras and DSI display
3: Wait a few seconds before the screen boot up.
4: If the DSI LCD cannot display, please check if you have added /boot/dt-blob.bin. If there already has the dt-blob.bin, just try to reboot.
5: The camera needs to be enabled by raspi-config, enter sudo raspi-config on the terminal, choose Interfacing Options -> Camera -> Yes -> Finish -> Yes and reboot the system.

Old Version (Buster)

  • Test the Cameras:

Test camera0:

sudo raspivid -t 0 -cs 0

Test camera1:

sudo raspivid -t 0 -cs 1

New Version (Bullseye)

If you are using the latest Raspberry Pi OS (Bullseye):

#New system uses dual cameras
#Remove camera_auto_detect=1 in config.txt
#camera_auto_detect=1

#Add
dtoverlay=imx219,cam1
dtoverlay=imx219,cam0

#imx219 is the camera sensor model, there are other sensors supported
dtoverlay=ov5647,cam0
dtoverlay=imx219,cam0
dtoverlay=ov9281,cam0
dtoverlay=imx477,cam0
dtoverlay=imx519,cam0

#and then reboot
reboot

#Open the camera
libcamera-hello -t 0
or
libcamera-hello


#Other partial commands:
#Check if the camera is detected
libcamera-hello --list-cameras

#Turn on the corresponding camera, preview for 5 seconds
libcamera-hello  --camera 1
libcamera-hello  --camera 0

#Take a photo
libcamera-jpeg -o test.jpg

#Shooting video
libcamera-vid -t 10000 -o test.h264

#you can add --camera to specify a camera
#-t <duration> allows the user to select how long the window is displayed, in milliseconds

More instructions click me

  • HDMI1 is disabled if you use DSI interfaces for displaying, even if you just compile the corresponding files without connecting to the DSI screen, please note it
  • Any connection of two HDMI ports can output images, not limited to which HDMI port, if two HDMI screens are connected, only HDMI0 has image output
  • If you want to enable both HDMI, please delete the dt-blob.bin file with the following command:
sudo rm -rf /boot/dt-blob.bin
  • Then reboot

Reference Raspberry Pi Manual