• sales

    +86-0755-88291180

Raspberry pi CM4-NAS-Double-Deck User Guide

Introduction

The CM4-NAS-Double-Deck is an all-in-one mini computer designed primarily for home environments or small home offices, but not limited to these scenarios. Out of the box, no expert knowledge of networking and storage systems is required.

Notes

  1. Do not unplug any device except the USB when it is charged.
  2. The Type C port can be used as a power supply or as a USB SLAVE interface to program images.
  3. In order to ensure the normal power supply of CM4, please do not connect other devices when using the Type C interface to program the image.
  4. When CM4 is in normal use, it needs to provide a 5V 2A or higher power supply for CM4. Otherwise, problems such as automatic shutdown and frequency reduction may occur.
  5. The module does not have any protection, please do not short-circuit the power supply.
  6. USB2.0 is closed by default, if you want to open it, you need to add dtoverlay=dwc2,dr_mode=host in config.txt.

Assembly Guide

NAS Usage And Installation Guide

Demo Usage

  • Enter the following commands to run the program:
sudo apt-get install unzip -y
wget https://www.waveshare.com/w/upload/7/73/CM4-NAS-Double-Deck_Demo.zip
unzip CM4-NAS-Double-Deck_Demo.zip
sudo chmod 777 -R CM4-NAS-Double-Deck_Demo
cd CM4-NAS-Double-Deck_Demo/RaspberryPi/example/
python main.py
  • Enter the following commands in the terminal to set self-starting.
sudo nano /etc/rc.local
#Add the following statement directly in fi and exit0, be sure to add &, if you don't add it, it won't start automatically
cd /home/pi/RaspberryPi/example
sudo python main.py &
  • Operation introduction
PWR:
*Short press in shutdown state: power on
*Short press in the power-on state: turn on/off the 2-inch screen display
*Long press in the power-on state: Forced shutdown
USER:
*Short press in the power-on state: switch to another interface (in the case of running the example, otherwise invalid)
*Long/short press in shutdown state: invalid

USB 2.0

The USB port is disabled by default on the CM4 to save power. If it needs to be enabled, you need to add the following to the config.txt file:

dtoverlay=dwc2,dr_mode=host

Then reboot it.
If you use the latest Raspberry Pi OS (image after October 30, 2021), USB2.0 is the default OTG mode, and CM4 will report an error:

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

However, USB can still be used. If you want to remove this error, remove otg_mode=1 in [cm4] of config.txt, and add dtoverlay=dwc2, dr_mode=host (if you don't add it, USB can not be recognized).

RTC

RTC (PCF85063a) on i2c-1, the address is 0 x 51 (7-bit address).

sudo nano /boot/config.txt
 #add in the end
 dtparam=i2c_vc=on
 dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
 #Add # before dtparam=audio=on 
 #dtparam=audio=on
 #Save, exit, and reboot  
 sudo reboot

Hwclock

Synchronize system clock -> hardware clock.

sudo hwclock -w

Synchronize hardware clock -> system clock.

sudo hwclock -s
  #Need to close the network or close the network time, otherwise, it will be changed back.

Set the hardware clock time:

sudo hwclock --set --date="9/8/2021 16:45:05"

View the hardware clock.

sudo hwclock -r

Show version information.

sudo hwclock --verbose

CSI DSI

Configure Files

CSI and DSI are disabled by default. When using the camera and DSI, three I2C devices, I2C-10, I2C-11, and I2C-0, will be occupied.
Booting is performed as follows:

wget https://www.waveshare.com/w/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/
  #If you want to use two cameras and DSI0, you can execute:
  sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
  #If you want to use two cameras and DSI1, you can execute:
  sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
  #When using any DSI, HDMI1 has no image output, even if you are not connected to the DSI screen, as long as you compile the corresponding file, then HDMI1 will have no output
  #If you need to restore, delete the corresponding dt-blob.bin: sudo rm -rf /boot/dt-blob.bin
  #Execution is complete, turn off the power and restart CM4

Record Test

Connect to the camera and the DSI display:
1. Please make sure it is connected under powering off.
2. Connect to the power.
3. The display will be booted after waiting for a few seconds.
4. If it fails to boot, check whether /boot/dt-blob.bin exists, and reboot it if it exists.

Old Version (Buster)

The camera needs to run raspi-config, select Interfacing Options->Camera->Yes->Finish-Yes, reboot the system, open enable camera, and then restart to save the changes.
Test the Raspberry Pi camera.
Check the screen of the first connected camera:

sudo raspivid -t 0 -cs 0

Check the screen of the second connected camera:

sudo raspivid -t 0 -cs 1

New Version (Bullseye)

If you use the latest Raspberry Pi OS (Bullseye):

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

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

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

#Then reboot
reboot

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


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

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

#Taking photos
libcamera-jpeg -o test.jpg

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

#You can add --camera to specify the camera
#-t <duration> option allows the user to choose how long the window is displayed in milliseconds

For more commands, you can click here.

  • Note: If using a DSI interface display there will be an HDMI disabled, even if just compiling the corresponding file without connecting a DSI screen.
  • Any connection between two HDMIs can output images, not limited to that HDMI. If two HDMI screens are connected, only HDMI0 has an image output.
  • If you want to enable both HDMI, delete the dt-blob.bin file with the following command:
sudo rm -rf /boot/dt-blob.bin
  • And then reboot it.

Please refer to Raspberry Pi manual.


Connect to the camera again:
1: Make sure to connect in the power off state.
2: Connect the power supply.
3: Wait a few seconds for the screen to boot.
4: If it cannot be started, check whether /boot/dt-blob.bin exists and if it exists, restart it again.
5: The camera needs to run raspi-config, select Interfacing Options->Camera->Yes->Finish-Yes, reboot the system, open enable camera, and then restart to save the changes.
Test photo:

raspistill -o image.jpg

Test video:

raspivid -o video.h264 -t 10000

Among them, -t 10000 means recording for 10 seconds, and users can adjust it according to their own needs.
Please refer to CSI camera.