CM4-NVME-NAS-BOX

From Waveshare Wiki
Jump to: navigation, search
CM4-NVME-NAS-BOX
CM4-NVME-NAS-BOX.jpg

ETH, USB 3.0, HDMI, PCIE
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

CM4-NVME-NAS-BOX is an all-in-one mini-computer, mainly designed but not limited to homes, small home offices, etc. Provides a simple and easy-to-use solution, no expert knowledge of networking and storage systems is required. On-board infrared, audio, and other modules.

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. 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.

User Guide

Click here to see how to install a NAS system

USB2.0

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

 dtoverlay=dwc2,dr_mode=host

After restarting
If you use the latest Raspberry Pi OS (image after October 30, 2021) USB2.0 is OTG mode by default, 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 (USB cannot be recognized without adding it).
CM4 Burn EMMC 12.png

Audio

Audio interface using USB audio, support for playback and recording, stereo codec, support for headphones with microphone, headset two-in-one.
Check the USB device: lsusb

pi@CM4-NVME-NAS-BASE:~ $ lsusb 
Bus 003 Device 002: ID 0c76:161f JMTek, LLC.

Note: If the audio is not recognized, it may be that the USB2.0 function is not enabled, you need to enable USB2.0 first and then it can be recognized.

Check the playback device: aplay -l

pi@CM4-NVME-NAS-BASE:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Device [USB PnP Audio Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Check the recording device: arecord -l

pi@CM4-NVME-NAS-BASE:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Audio Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Recorded test: sudo arecord -f S32_LE -Dplughw:1,0 | aplay -Dplughw:1,0

pi@CM4-NVME-NAS-BASE:~ $ sudo arecord  -f S32_LE  -Dplughw:1,0 | aplay -Dplughw:1,0
xcb_connection_has_error() returned true
xcb_connection_has_error() returned true
Recording WAVE 'stdin' : Signed 32 bit Little Endian, Rate 8000 Hz, Mono
Playing WAVE 'stdin' : Signed 32 bit Little Endian, Rate 8000 Hz, Mono

Note: The recording test command is not unique, users need to modify the command according to the actual device number, where the first "-Dplughw:1,0" means to record sound card 1 device 0 (arecord -l can see the corresponding sound card and device), and the second "aplay -Dplughw:1,0" means to play sound card 1 device 0 (aplay -l can see the corresponding sound card and device). (you can see the corresponding sound card and device in aplay -l).

Adjust the volume: sudo alsamixer.
CM4-NVME-NAS-BOX09.png
F6: Select sound card
Reserved pads (no soldering)
Separately (from top to bottom):

Volume +
Volume -
Playback pause

CM4-NVME-NAS-BOX11.png

PCIE

CM4-NVME-NAS-BOX12.jpg
Check the device:

pi@CM4-NVME-NAS-BASE:~ $ lspci
00:00.0 PCI bridge: Broadcom Limited Device 2711 (rev 20)
01:00.0 PCI bridge: ASMedia Technology Inc. ASM1184e PCIe Switch Port
02:01.0 PCI bridge: ASMedia Technology Inc. ASM1184e PCIe Switch Port
02:03.0 PCI bridge: ASMedia Technology Inc. ASM1184e PCIe Switch Port
02:05.0 PCI bridge: ASMedia Technology Inc. ASM1184e PCIe Switch Port
02:07.0 PCI bridge: ASMedia Technology Inc. ASM1184e PCIe Switch Port
03:00.0 USB controller: VIA Technologies, Inc. VL805 USB 3.0 Host Controller (rev 01)
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)

The above is not connected to any NVME devices, if connected to NVME devices will output more corresponding devices.

Extended Gigabit Ethernet port

Two Gigabit NICs on board with ETH0 as the native NIC and ETH1 as the expansion NIC.

  • The new version of the Raspberry Pi system kernel integrated RTL8111H driver, if you can not find the network card can try to upgrade the package.
sudo apt update
sudo apt upgrade
  • If you are using a different version of the system, please install the driver.
wget https://files.waveshare.com/upload/e/ee/CM4-DUAL-ETH-MINI-Example.zip
unzip CM4-DUAL-ETH-MINI-Example.zip -d ./CM4-DUAL-ETH-MINI-Example
cd CM4-DUAL-ETH-MINI-Example/Driver/
tar vjxf r8168-8.050.03.tar.bz2
cd r8168-8.050.03
sudo ./autorun.sh
  • (Optional) If you compile your kernel, you can choose the following options to load the driver.
Device Drivers
 > Network device support
   > Ethernet driver support
     > Realtek devices
       > Realtek 8169/8168/8101/8125 ethernet support

RTC

RTC (PCF85063a) on i2c-10, address is 0x51 (7-bit address).

RTC battery holder model CR1220 (NOT Included by default).

sudo nano /boot/config.txt
 #Add at the end
 dtparam=i2c_vc=on
 dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
 #Add # before dtparam=audio=on
 #dtparam=audio=on
 #Save and exit, restart
 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 disable the network to check the time, otherwise, it will be changed back.

Set the hardware clock time:

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

View hardware clock:

sudo hwclock -r

Display version information:

sudo hwclock --verbose

4G

The interface is the MINI PCIE interface on the back of the box, connect it to SIM7600G-H-PCIE.

sudo apt-get install minicom
sudo minicom -D /dev/ttyUSB2
#Enter the following commands:
AT+CUSBPIDSWITCH=9011,1,1
#Return OK 
#And wait for rebooting the network card 
#This command only needs to be set once, the next power-up will be in this mode by default.
#If you can't get the USB0 card to execute
sudo dhclient -v usb0

If the connected module lsusb is identified as ID 1e0e:9018

Bus 001 Device 004: ID 1e0e:9018 Qualcomm / Option

But there is no /dev/ttyUSB2, execute the following commands:

sudo modprobe option
sudo sh -c 'echo "1e0e 9018" > /sys/bus/usb-serial/drivers/option1/new_id'

Please click here to refer to RNDIS dial-up Internet Access.
The USB0 network card will be recognized after normal execution of the above (if you don't have another USB network card connected).
If you are using an IoT card, such as a mobile IoT card, and successfully register the network; however, dial-up internet fails to ping through, you can try to select the optimal frequency band with one of the following AT commands:

AT+CNBP=0x0002000000400183,0x000001E000000000,0x0000000000000021
AT+CNBP=0x0002000000400180,0x480000000000000000000000000000000000000000000042000001E200000095,0x0000000000000021

AT Command

If the network is not connected, you can check the status via AT commands:

sudo apt-get install minicom
sudo minicom -D /dev/ttyUSB2

Common AT Commands

The following AT commands are general for 4G/5G modules.

Command Description Return Value
AT AT Test Command OK
ATE ATE1 sets echo
ATE0 turns off echo
OK
AT+CGMI Query module manufacturer OK
AT+CGMM Query module model OK
AT+CGSN Check Product Serial Number OK
AT+CSUB Query Module Version and Chip OK
AT+CGMR Check Firmware Version Serial Number OK
AT+IPREX Setting the module hardware serial port baud rate +IPREX:
OK
AT+CRESET Reset the module OK
AT+CSQ Network signal quality query, return signal value +CSQ: 17,99
OK
AT+CPIN? Queries the SIM card status and returns READY, indicating that the SIM card can be recognized normally +CPIN: READY
AT+COPS? Query the current operator, after normal networking, will return the operator information +COPS:
OK
AT+CREG? Check Web Registration Status +CREG:
OK
AT+CPSI? Query UE system information
AT+CNMP Network mode selection command:
2: Automatic
13: GSM only
38: LTE only
48: Any modes but LTE
... ....
OK

For more AT commands refer to: AT_Command_V2.00
For more documentation refer to: SIMCom
For more detailed use refer to: SIM7600X 4G

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://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/
  #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
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 HDMI ports 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.

IR Test

Infrared receiver tube model: LFN LF0038K

Connect the GPOI18 pin
Reference Demo

Resource

Demo

Document

Schematic Diagram

Software

FAQ

 Answer:

Turn on when power is applied.
By default, a short pressing of the power button has no effect. Long press to force power off, after power off, it will power off, and then press it to power on.

{{{5}}}


 Answer:

You could use GPIO19 pin to control it.

{{{5}}}


 Answer:

The button battery type is CR1220.

{{{5}}}



Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)