Template: Cm4-disp-base-7a-box Guide

From Waveshare Wiki
Revision as of 02:41, 9 March 2022 by Eng20 (talk | contribs) (→‎RTC FAN)
Jump to: navigation, search

Writing Image


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


RS485/RS232

It is closed by default. If you need to open it, you need to add content in config.txt:
sudo nano /boot/config.txt

 dtoverlay=uart3
 dtoverlay=uart5
 reboot
 ls /dev/ttyAMA*


RS232 occupies GPIO5/GPIO4 (BCM code 4/5), device number ttyAMA1
RS485 occupies GPIO13/GPIO12 (BCM code 13/12), device number ttyAMA2

RS485 can be switched to GPIO15/14, device number ttyS0
Refer to 27 in the onboard resources, and change the corresponding resistance to the corresponding position

Test

 sudo apt-get install minicom
 # RS232
 sudo minicom -D /dev/ttyAMA1
 #RS485
 sudo minicom -D /dev/ttyAMA2


GPIO

The GPIO input/output interface only supports a single mode and does not support switching. The following are the corresponding pins of the interface.
OUT CH1 GPIO17
OUT CH2 GPIO27
IN CH1 GPIO22
IN CH2 GPIO23

The module only supports 3.3V and 5V and does not support other voltages, which can be switched by jumper caps.

RTC FAN

Screen and camera turned on

Use the old version (buster) system to load the configuration file and restart to identify, the new version (bullseye) system needs to add additional modification files

Load Configuration File

When using the camera and DSI, it will occupy three I2C devices: I2C-10, I2C-11, I2C-0
The camera needs to run raspi-config, select Interfacing Options->Camera->Yes->Finish-Yes, reboot the system, open the enable camera, and then restart to save the changes.
Execute 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/
 sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
 # After execution, turn off the power and restart the CM4

Old Version (Buster)

Note: On December 2, 2021, the Raspberry Pi OS for Raspberry Pi split into two branches, the Buster branch and the Bullseye branch.

The Buster branch is a continuation of the old system and is more stable. The Bullseye branch adds some new features, uses open source libraries and new interfaces.

If you use the Buster branch system, the image can be used normally without any modification. View the first connected camera screen:

sudo raspivid -t 0 -cs 0



New Version (Bullseye)

If you are using the Bullseye branch of the system, refer to the following

Show

Comment the following statements in the config.txt file (the config file is located in the root directory of the TF card, namely /boot):

#camera_auto_detect=1
#dtoverlay=vc4-kms-v3d

Add the following statement below [all]:

dtoverlay=vc4-fkms-v3d


After saving, restart the Raspberry Pi

sudo reboot

Camera

libcamera-hello -t 0
or
libcamera-hello

#The default camera model is ov5647, if you need to change it to other cameras, you can check the camera model by yourself
#Add to
dtoverlay=ov5647,cam1
dtoverlay=ov5647,cam0

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

#then restart
reboot

#Other part of the command:
#Check if the camera is detected
libcamera-hello --list-cameras

#open camera
libcamera-hello --camera 0

#Taking Pictures
libcamera-jpeg -o test.jpg
#You can add --camera to specify the camera

More instructions click me
Reference Raspberry Pi Manual

Pinput

Compute-Module-4-1-21.png

No. PIN Description
1 PI BOOT The pin is low when booting. This pin is connected to USB SLAVE interface.
2 EEPROM WP Set it to LOW to avoid writing EEPROM
3 IP1/0 MXL7704 AN1/0 Pin of CM4 board
4 VADC COMP Video output
5 ETH IN ETH synchronize signal
6 PI_EN Synchronize with PI_RUN signal
7 PI_GLOBAL_EN MXL7704 power enable pin of CM4, Low to disable.
8 PI_RUN CM4 status pin, high for On. Pull-down it to foruce reset the CM4
9 WIFI_EN WIFI enable pin, Low to disbale, and NC to enable.
11 BT_EN Bluetooth enable pin, Low to disable and NC to enable.