Difference between revisions of "Template:Compute Module 4 PoE 4G Board manual"

From Waveshare Wiki
Jump to: navigation, search
 
(46 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
==Precautions==
 +
<font color="#ff0000">Do not plug or unplug any devices while it is powered on.</font><br>
 +
All of the following are tested on Raspberry Pi OS, no other systems are supported.<br>
 +
 
==Writing Image==
 
==Writing Image==
 
*[[Write Image for Compute Module Boards eMMC version]]
 
*[[Write Image for Compute Module Boards eMMC version]]
Line 8: Line 12:
 
dtoverlay=dwc2,dr_mode=host
 
dtoverlay=dwc2,dr_mode=host
 
</pre>
 
</pre>
 +
It will take effect after restart<br>
 +
 +
<font color="#ff00ff">
 +
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: <br>
 +
  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). <br>
 +
[[FILE:CM4 Burn EMMC_12.png|800px]]<br>
 +
</font>
 +
==Preparation before use==
 +
===Demo Download===
 +
Open the Raspberry Pi terminal and execute the following commands:
 +
<pre>
 +
sudo wget https://files.waveshare.com/upload/b/ba/Compute_Module_4_PoE_4G_Board_Code.zip
 +
unzip -o  Compute_Module_4_PoE_4G_Board_Code.zip -d ./Compute_Module_4_PoE_4G_Board_Code
 +
sudo chmod 777 -R Compute_Module_4_PoE_4G_Board_Code
 +
cd Compute_Module_4_PoE_4G_Board_Code
 +
</pre>
 +
 +
===Installing Libraries===
 +
<font color="#ff0000"> All libraries are installed according to your needs, just install the one you need to use, you don't have to install all of them.</font><br/>
 +
If you just test the function, you can directly use the C program without installing any library. Our C program does not need to install any library by default.<br/>
 +
With the update of each version, there may be some software incompatibilities, or running an error, if this problem occurs, you can feedback to us<br/>
 +
*Install BCM2835, open the Raspberry Pi terminal, and run the following command (<font color="#ff0000">not recommended</font>)
 +
<pre>
 +
#If you have any questions, please visit http://www.airspayce.com/mikem/bcm2835/
 +
#Any other problems can be reported in the link above, please do not contact the author directly
 +
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz
 +
tar zxvf bcm2835-1.68.tar.gz
 +
cd bcm2835-1.68/
 +
sudo ./configure
 +
sudo make
 +
sudo make check
 +
sudo make install
 +
</pre>
 +
* install wiringpi
 +
<pre>
 +
#WiringPi does not officially support CM4, but you can install the unofficial version because this version is not the official version
 +
#This version is only for CM4
 +
#Any other problems can be reported on GitHub, please do not contact the author directly
 +
git clone https://github.com/WiringPi/WiringPi.git
 +
cd WiringPi/
 +
./build
 +
#Execute gpio -v and the version number is 2.6.
 +
</pre>
 +
* Install the Python function library
 +
<pre>
 +
#python2
 +
sudo apt-get update
 +
sudo apt-get install python-pip
 +
sudo apt-get install python-pil
 +
sudo apt-get install python-numpy
 +
sudo pip install RPi.GPIO
 +
sudo pip install spidev
 +
sudo pip2 install python-can
 +
#python3
 +
sudo apt-get update
 +
sudo apt-get install python3-pip
 +
sudo apt-get install python3-pil
 +
sudo apt-get install python3-numpy
 +
sudo pip3 install RPi.GPIO
 +
sudo pip3 install spidev
 +
sudo pip3 install python-can
 +
</pre>
 +
 +
===Open I2C interface===
 +
*Execute in terminal:
 +
<pre>
 +
sudo raspi-config
 +
#Select Interfacing Options -> I2C ->yes to start the i2C kernel driver
 +
</pre>
 +
[[File:2591RaspberryPi.png|900px]] <br />
 +
*then restart the raspberry pi
 +
<pre>
 +
sudo reboot
 +
</pre>
 +
<br/><br/>
 +
 
==USB TO UART==
 
==USB TO UART==
The USB to UART port is connected to GPIO14(BCM) and GPIO15(BCM) pins of CM4 with a converter.<br />
+
The UART is connected to CM4 by default, and is connected to the GPIO14 (BCM) and GPIO15 (BCM) pins of CM4<br>
You can connect the USB to the UART port for login CM4 via serial.<br />
+
When starting serial debugging, you can directly connect to the computer through this interface to log in to the CM4<br>
The USB to UART port can also be used for power, in this case, you need to solder a 0ohm resistor to the pad for enabling the powering function.<br />
+
[[File:Compute Module 4 PoE 4G Board 6.png|300px]]<br>
[[File:Compute Module 4 PoE 4G Board 6.png|300px]]
+
You can also supply power through this interface, but the default is not able to supply power. If you need to supply power through this interface, please connect the resistor (0R) on the interface.
 +
 
 
==Buzzer/LED==
 
==Buzzer/LED==
 
===Buzzer===
 
===Buzzer===
The buzzer is connected to GPIO22(BCM), low active.<br />
+
The buzzer is connected to GPIO22(BCM 22), low active.<br />
 
:[[File:Compute Module 4 PoE 4G Board 4.png|350px]]
 
:[[File:Compute Module 4 PoE 4G Board 4.png|350px]]
 +
 
===LED===
 
===LED===
Two LEDs are integrated for users, the green one is connected to GPIO20(BCM)and the red one is connected to GPIO21(BCM), low active. <br />
+
Two LEDs are integrated for users, the green one is connected to GPIO20(BCM)and the red one is connected to GPIO21(BCM), <font color=red>low active.</font><br />
 
:[[File:Compute Module 4 PoE 4G Board 5.png|250px]]
 
:[[File:Compute Module 4 PoE 4G Board 5.png|250px]]
 +
 +
===【expected results】===
 +
Two user LEDs flash alternately.<br>
 +
LED changes once, the buzzer sounds once.
 +
 +
===【Python examples】===
 +
<pre>
 +
cd LED_BUZZER/python/
 +
sudo python main.py
 +
</pre>
 +
===【C examples】===
 +
<pre>
 +
cd LED_BUZZER/c/
 +
make clean
 +
sudo make
 +
sudo ./main
 +
</pre>
 +
 
==4G/5G==
 
==4G/5G==
To work with 4G/5G, you need to connect a wireless module to the M.2 B KEY for featuring corresponding functions. M.2 B KEY only extends USB2.0 interfaces, it doesn't support PCIe devices.<br>
+
To work with 4G/5G, you need to connect a wireless module to the M.2 B KEY for featuring corresponding functions. M.2 B KEY only extends USB2.0 interfaces, it doesn't support PCIE devices.<br>
[[FILE:Compute Module 4 PoE 4G Board_3.png | 400px]]<br>
+
[[File: 屏幕截图 2023-06-06 151006.png| 400px]]<br>
 
SIM card is required to work with the 4G/5G module<br>
 
SIM card is required to work with the 4G/5G module<br>
 
This carrier board supports the 4G module by default, if you use it with 5G modules, some of the 5G functions are not supported.<br>
 
This carrier board supports the 4G module by default, if you use it with 5G modules, some of the 5G functions are not supported.<br>
If you use a 5G module, please check the [[https://www.waveshare.com/wiki/SIM8200EA-M2_5G_HAT SIM8200EA-M2_5G HAT wiki]] about how to set up 5G.
+
If you use a 5G module, please check the [https://www.waveshare.com/wiki/SIM8200EA-M2_5G_HAT SIM8200EA-M2_5G HAT wiki] about how to set up 5G.<br>
 +
It takes a certain amount of time (about 30 seconds) to close or open the mold<br>
 +
In the downloaded routine there is an M_2_PWR script that can be executed<br>
 +
<pre>
 +
sudo ./M_2_PWR 0
 +
#Open the mod
 +
sudo ./M_2_PWR 1
 +
#Close the mod
 +
</pre>
 +
Open the mod<br>
 +
The 5G module is not controlled by the enable pin
  
If you need to toggle the working status of the 4G module, you can control the GPIO6(BCM), set the GPIO6 to High for disabling the 4G module and set it to Low for enabling.<br>
 
To toggle the working status of the 4G module, please add delay time for waiting for the operation to work.<br>
 
If you use the 5G module, the GPIOs cannot work for it.<br />
 
 
===SIM7600 M.2 module===
 
===SIM7600 M.2 module===
 
Status of M.2 indicators:
 
Status of M.2 indicators:
{|class="wikitable"
+
{| class="wikitable"
!M.2_NET !! M.2_STA !!
 
|-
 
|Red LED || Green LED|| Status
 
 
|-
 
|-
|Solid || OFF ||Power OFF
+
! <font color="#ff0000"> STA </font>||<font color="#008000"> NET </font>||Status
 
|-
 
|-
|Solid || OFF ||Starting
+
! <font color="#ff0000"> On </font>|| <font color="#008000"> Off</font>||<font color="#ff0000"> Off or starting</font >
 
|-
 
|-
|Solid || Solid || SIM card is an invalid or weak signal
+
! <font color="#ff0000"> Long light</font>|| <font color="#008000"> Long light</font>||<font color="#ff0000"> Looking for network</font >
 
|-
 
|-
|Solid || Blink || Working
+
! <font color="#ff0000"> Steady on</font> || <font color="#008000"> Blinking</font>||<font color="#008000"> Connected and working fine</font>
 
|-
 
|-
|OFF ||Blink/Solid||Shutdowning
+
! <font color="#ff0000"> Off </font> ||<font color="#008000"> Blinking/Solid </font> || Shutting down
 
|}
 
|}
  
Line 52: Line 157:
 
sudo apt-get install minicom
 
sudo apt-get install minicom
 
sudo minicom -D /dev/ttyUSB2
 
sudo minicom -D /dev/ttyUSB2
</pre>
+
# Enter the following commands:
Type the following command on the minicom<br />
 
<pre>
 
 
AT+CUSBPIDSWITCH=9011,1,1
 
AT+CUSBPIDSWITCH=9011,1,1
</pre>
+
#return OK
Close the minicom and configure usb0<br />
+
#Then wait for the network card to restart
<pre>
+
#This command only needs to be set once, the next time it is powered on, it will be in this mode by default
 +
#If the USB0 network card cannot be obtained, execute:
 
sudo dhclient -v usb0
 
sudo dhclient -v usb0
 
</pre>
 
</pre>
 
+
About RNIDS networking, please refer to [https://www.waveshare.com/wiki/Raspberry_Pi_networked_via_RNDIS Raspberry Pi networked via RNDIS RNIDS Networking method]<br />
About RNIDS networking, please refer to [Raspberry Pi networked via RNDIS RNIDS Networking method]<br />
+
With the operations above, a USB0 port will be recognized.(if you don't have other USB network card connected)<br />
With the operations above, a USB0 port will be recognized.<br />
+
<font color="#ff00ff">If you use an IoT card, such as a mobile IoT card, to successfully register the network; but the dial-up Internet connection fails and cannot be pinged, you can try to use one of the following AT commands to select the optimal frequency band:</font>
If the network cannot work, please try to switch frequency with the following AT commands:
 
 
<pre>
 
<pre>
 
  AT+CNBP=0x0002000000400183,0x000001E000000000,0x0000000000000021
 
  AT+CNBP=0x0002000000400183,0x000001E000000000,0x0000000000000021
 
  AT+CNBP=0x0002000000400180,0x480000000000000000000000000000000000000000000042000001E200000095,0x0000000000000021
 
  AT+CNBP=0x0002000000400180,0x480000000000000000000000000000000000000000000042000001E200000095,0x0000000000000021
 
</pre>
 
</pre>
 +
 
===<font color="Bf0000">'''AT Commands'''</font>===
 
===<font color="Bf0000">'''AT Commands'''</font>===
 
If the network cannot work, plaese check module with AT commands
 
If the network cannot work, plaese check module with AT commands
Line 112: Line 216:
 
|}
 
|}
 
<font color="red">
 
<font color="red">
For more AT commands, please refer to: [https://www.waveshare.com/w/upload/6/68/SIM7500_SIM7600_Series_AT_Command_Manual_V2.00.pdf AT_Command_V2.00]<br />
+
For more AT commands, please refer to: [https://files.waveshare.com/upload/6/68/SIM7500_SIM7600_Series_AT_Command_Manual_V2.00.pdf AT_Command_V2.00]<br />
 
You can also refer to:[https://cn.simcom.com/product/SIM7600X-H.html SIMCom]
 
You can also refer to:[https://cn.simcom.com/product/SIM7600X-H.html SIMCom]
 
</font><br />
 
</font><br />
 +
 
==PCIE==
 
==PCIE==
 
The PCIe interface is PCIe 2.0 X1, the maximum speed is 500Mb/s <br />
 
The PCIe interface is PCIe 2.0 X1, the maximum speed is 500Mb/s <br />
Most of the PCIEx1 device is not supported by Raspberry Pi without a driver. <br />
+
Support most PCIE x1 cards, many PCIEx1 device cards on the market, the default Raspberry Pi system is not supported, because the Raspberry Pi Linux does not add drivers. <br />
 
Please check your PCIe device before you used [https://pipci.jeffgeerling.com/ Supported device testing] <br />
 
Please check your PCIe device before you used [https://pipci.jeffgeerling.com/ Supported device testing] <br />
 
Raspberry [https://github.com/geerlingguy/raspberry-pi-pcie-devices/tree/master/extras/cross-compile Kernel compiling]
 
Raspberry [https://github.com/geerlingguy/raspberry-pi-pcie-devices/tree/master/extras/cross-compile Kernel compiling]
Line 152: Line 257:
 
</pre>
 
</pre>
  
<br/><br/>
 
 
==Isolation ADC==
 
==Isolation ADC==
 
The isolation ADC is mounted in isolation I2C with 0x48 address<br />
 
The isolation ADC is mounted in isolation I2C with 0x48 address<br />
 
I2C is default disabled, please refer to [[#Enable I2C]] to enable the I2C interface.<br />
 
I2C is default disabled, please refer to [[#Enable I2C]] to enable the I2C interface.<br />
 
 
===C===
 
===C===
 
<pre>
 
<pre>
Line 171: Line 274:
 
<font color="#ff0000">  Output voltage vlaue </font><br/>
 
<font color="#ff0000">  Output voltage vlaue </font><br/>
 
<br/>
 
<br/>
Note: the ADC chip used is ADS1113, its reference voltage is 2.048V, the range of differential input.<br/>
+
Note: the ADC chip used is ADS1113, its reference voltage is 2.048V, the range of differential input, Input voltage range: ±2.048V<br/>
  
<br/><br/>
 
 
==CAN==
 
==CAN==
 
The CAN is diabled by default, you need to modify the config.txt file for enabling it.<br>
 
The CAN is diabled by default, you need to modify the config.txt file for enabling it.<br>
Line 189: Line 291:
 
  dmesg | grep spi0
 
  dmesg | grep spi0
 
</pre>
 
</pre>
[[file:Compute Module 4 PoE 4G Board_1.png | 600px]]
+
[[file:Compute Module 4 PoE 4G Board_1.png | 600px]]<br>
 
Run the following command:
 
Run the following command:
 
  sudo ip link set can0 up type can bitrate 1000000
 
  sudo ip link set can0 up type can bitrate 1000000
 
  sudo ifconfig can0 txqueuelen 65536
 
  sudo ifconfig can0 txqueuelen 65536
 
  ifconfig
 
  ifconfig
[[file:Compute Module 4 PoE 4G Board_2.png | 600px]]
+
[[file:Compute Module 4 PoE 4G Board_2.png | 600px]]<br>
出现can0 设备号说明驱动成功<br>
+
If the device can0 is recognized, it means that the driver was installed successfully<br>
 +
===Testing===
 +
Install can-utils:<br>
 +
<pre>
 +
sudo apt-get install can-utils
 +
</pre>
  
===测试===
+
Receive data
安装can-utils:<br>
+
<pre>
sudo apt-get install can-utils
 
接收数据
 
 
  candump can0
 
  candump can0
发送数据
+
</pre>
 +
Send data
 +
<pre>
 
  cansend can0 000#11.22.33.44
 
  cansend can0 000#11.22.33.44
  #其中11.22.33.44 是数据
+
  #11.22.33.44 is data sent
  #如果需要发送其他数据可以使用继续添加例如
+
  #If you need to transmit more dta, you can also extend the data just like this:
 
  # cansend can0 000#11.22.33.04.70
 
  # cansend can0 000#11.22.33.04.70
#不可以使用英文和中文,两位一码格式添加
+
</pre>
  
===例程===
+
===Examples===
====【Python例程】====
+
====【Python examples】====
*进入对应的目录:
+
*Go into the directorty of python example:
*接收端运行receive.py:
+
*Open a terminal as receiver and run the receive.py:
 
<pre>
 
<pre>
 
sudo python reveive.py
 
sudo python reveive.py
 
</pre>
 
</pre>
*发送端运行send.py:
+
*Open another terminal as sender and run the send.py:
 
<pre>
 
<pre>
 
sudo python send.py
 
sudo python send.py
 
</pre>
 
</pre>
  
本例程是基于python平台,确保以及安装了python-can库<br />
+
The examples provided is absed on python, please make sure that you have installed the python-can library.<br />
在发送之前要先创建一个can设备,因为前面只是启用MCP2515内核:
+
Create a CAN device before you send data,because the front only enables the MCP2515 core
 
<pre>
 
<pre>
 
os.system('sudo ip link set can0 type can bitrate 100000')
 
os.system('sudo ip link set can0 type can bitrate 100000')
 
os.system('sudo ifconfig can0 up')
 
os.system('sudo ifconfig can0 up')
 
</pre>
 
</pre>
*第一步:连接到CAN总线<br />
+
*Step 1: Connect to the CAN bus<br />
 
<pre>
 
<pre>
 
can0 = can.interface.Bus(channel = 'can0', bustyp = 'socketcan_ctypes')
 
can0 = can.interface.Bus(channel = 'can0', bustyp = 'socketcan_ctypes')
 
</pre>
 
</pre>
*第二步:创建信息<br />
+
*Step 2: Create information<br />
 
<pre>
 
<pre>
 
msg = can.Message(arbitration_id=0x123, data=[0, 1, 2, 3, 4, 5, 6, 7], extended_id=False)
 
msg = can.Message(arbitration_id=0x123, data=[0, 1, 2, 3, 4, 5, 6, 7], extended_id=False)
 
</pre>
 
</pre>
*第三步:发送信息
+
*Step 3: Send message
<pre>
 
 
can0.send(msg)
 
can0.send(msg)
 
</pre>
 
</pre>
*最后同样要关闭can设备
+
*Close the CAN device finally
 
<pre>
 
<pre>
 
os.system('sudo ifconfig can0 down')
 
os.system('sudo ifconfig can0 down')
 
</pre>
 
</pre>
*接收数据:
+
*Receive data:
 
<pre>
 
<pre>
 
msg = can0.recv(10.0)
 
msg = can0.recv(10.0)
 
</pre>
 
</pre>
recv()中定义超时接收时间。<br />
+
recv() defines the timeout<br />
'''更多请参考:https://python-can.readthedocs.io/en/stable/interfaces/socketcan.html<br />'''
+
'''for more details, please refer to https://python-can.readthedocs.io/en/stable/interfaces/socketcan.html<br />'''
 
<br />
 
<br />
  
====【C例程】====
+
====【C examples】====
*阻塞接收,树莓派打开终端,运行:
+
*Blocking receive, open the terminal of Raspberry Pi and run the following commands:
 
<pre>
 
<pre>
 
cd CAN/c/receive/
 
cd CAN/c/receive/
Line 259: Line 365:
 
sudo ./can_receive
 
sudo ./can_receive
 
</pre>
 
</pre>
*发送,树莓派打开终端,运行:
+
*Send data, open a terminal of Raspberry Pi and run the following commands:
 
<pre>
 
<pre>
 
cd CAN/c/receive/
 
cd CAN/c/receive/
Line 268: Line 374:
  
 
<br/><br/>
 
<br/><br/>
 +
 
==RS485/232==
 
==RS485/232==
默认关闭,如需打开需要在config.txt中添加内容:<br>
+
The interface is closed by default, you can modify the config.txt to enable it.<br>
sudo nano /boot/config.txt<br>
+
<pre>
 +
sudo nano /boot/config.txt
 +
</pre>
 +
Add the following lines to the config.txt file:
 +
<pre>
 
  dtoverlay=uart3
 
  dtoverlay=uart3
 
  dtoverlay=uart5
 
  dtoverlay=uart5
 +
</pre>
 +
Reboot the Raspbery Pi and check if the ports are recognized.
 +
<pre>
 
  reboot  
 
  reboot  
 
  ls /dev/ttyAMA*
 
  ls /dev/ttyAMA*
<br>
+
</pre>
RS232占用GPIO5/GPIO4(BCM编码4/5),设备号ttyAMA1<br>
+
RS232 interfaces use the GPIO5/GPIO4(BCM4/5), recognized as ttyAMA1<br>
RS485占用GPIO13/GPIO12(BCM编码13/12),设备号ttyAMA2<br>
+
RS485 interfaces use the GPIO13/GPIO12(BCM13/12),recognzied as ttyAMA2<br>
===测试===
+
===Test===
 +
Install minicom and test it with the minicom<br />
 +
<pre>
 
  sudo apt-get install minicom
 
  sudo apt-get install minicom
 
  # RS232
 
  # RS232
Line 284: Line 400:
 
  #RS485
 
  #RS485
 
  sudo minicom -D /dev/ttyAMA2
 
  sudo minicom -D /dev/ttyAMA2
 
+
</pre>
 
==RTC  FAN==
 
==RTC  FAN==
 
<font color="red">
 
<font color="red">
*注意事项:请在接通拓展板电源前接上风扇再完成测试,请不要在拓展板已通电即风扇控制芯片已经通电之后再接上风扇,否则会烧掉芯片!
+
*Note: Please first connect the FAN and then the power, otherwise you may damage the controller of the fan!
*注意事项:连接前请确认风扇电压和实际上连接的风扇供电
+
*Note: Please make sure the operation voltage of the cooling fan is the same as the carrier board.
 
</font>
 
</font>
使用树莓派系统(2021-05-07-raspios-buster-armhf-full )<br/>
+
<font color="#ff0000"> Note that if you want to use the RTC function, please first disable the DSI and CSI. </font><br/>
<font color="#ff0000"> 注意 使用RTC禁止使用DSI和CSI  </font><br/>
+
If you want to use them at the same time, please change the I2C to I2C1 (the right).<br/>
如果需要同时使用,将I2C切换到I2C1设备上(右边)<br/>
 
 
[[file:Compute Module 4 PoE 4G Board_11.png | 500px]]<br/>
 
[[file:Compute Module 4 PoE 4G Board_11.png | 500px]]<br/>
<font color="#ff0000"> 切换之后所有程序或者驱动全部需要修改 </font><br/>
+
<font color="#ff0000"> You need to modify the codes and driver after changing.</font><br/>
<font color="#ff0000"> 例程默认使用I2C10(左边) </font><br/>
+
<font color="#ff0000"> The demo codes use I2C10 by default (the left)</font><br/>
 
<br/>
 
<br/>
 
+
If you need simple use or need to add to your program instead of the kernel, see C and Python demos.[[https://www.waveshare.com/wiki/CM4_RTC_FAN CM4 RTC FAN]]
如果需要简单使用,或者需要添加到你程序中而不是内核中,参考C和Python例程参考 [[https://www.waveshare.net/wiki/CM4_RTC_FAN 点这里]]<br\>
 
 
 
 
===RTC===
 
===RTC===
sudo nano /boot/config.txt
+
Open the terminal and modify the config.txt file<br />
#在最后添加
+
<pre>
dtparam=i2c_vc=on
+
sudo nano /boot/config.txt
dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
+
</pre>
#在dtparam=audio=on前面添加#
+
Add the following lines to the file and modify the audio setting
#dtparam=audio=on
+
<pre>
#保存退出,重启
+
#Add the lines to the end of file
sudo reboot
+
dtparam=i2c_vc=on
 +
dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
 +
#remove the setting dtparam=audio=on by adding the # to the front of the line
 +
#dtparam=audio=on
 +
</pre>
 +
Save and reboot the Raspberry Pi.
 +
<pre>
 +
sudo reboot
 +
</pre>
 +
====Hwclock====
 +
Synchronize system clock -> hardware clock
 +
<pre>
 +
sudo hwclock -w
 +
</pre>
 +
Synchronize hardware clock -> system clock
 +
<pre>
 +
sudo hwclock  -s
 +
</pre>
  
====Hwclock简单使用====
+
Note that you need to disable the network synchronization function, otherwise, the time will be changed according to network time.<br />
同步系统时钟 -> 硬件时钟
 
sudo hwclock -w
 
  
同步硬件时钟 -> 系统时钟
+
Set hardware clock:
sudo hwclock -s
+
<pre>
#需要关闭网络,或者关闭网络对时,负责会被改回去
+
sudo hwclock --set --date="9/8/2021 16:45:05"
 +
</pre>
  
设置硬件时钟时间:
+
Check the hardware clock.<br />
sudo hwclock --set --date="9/8/2021 16:45:05"
+
<pre>
 +
sudo hwclock -r
 +
</pre>
 +
Check the version.<br />
 +
<pre>
 +
sudo hwclock --verbose
 +
</pre>
  
查看硬件时钟
+
===Cooling fan===
sudo hwclock -r
+
When powered on, the fan will spin for 1 second, then stop for 2 seconds, and then spin again, this is a normal phenomenon<br>
 
+
There is currently no official configuration method for fans, there is a third-party configuration method: https://github.com/neg2led/cm4io-fan<br>
显示版本信息
+
This method is released by a third party, not an official release, and we are not responsible for any problems! <br>
sudo hwclock --verbose
+
<pre>
 
 
<br\>
 
<br\>
 
 
 
===风扇===
 
在上电的时候 风扇会转1秒,然后停止2秒,再转,这是正常现象<br\>
 
风扇目前没有官方的配置方法,有一个第三方配置方法:https://github.com/neg2led/cm4io-fan<br\>
 
此方法为第三方发布,不是官方发布,出现任何问题,概不负责!<br\>
 
 
  mkdir -p ~/src
 
  mkdir -p ~/src
 
  cd ~/src
 
  cd ~/src
Line 340: Line 467:
 
  sudo chmod 777 install.sh
 
  sudo chmod 777 install.sh
 
  sudo  ./install.sh
 
  sudo  ./install.sh
#下面是对于config.txt的描述介绍
+
</pre>
 +
The device tree overlay has a few options, here's the equivalent of a /boot/overlays/README info section:<br />
 +
<pre>
 
  #############################
 
  #############################
 
  Name:  cm4io-fan
 
  Name:  cm4io-fan
Line 358: Line 487:
 
                             at which the fan begins to slow down (default 2000)
 
                             at which the fan begins to slow down (default 2000)
 
   #############################
 
   #############################
或者 直接参考如下:
+
</pre>
dtoverlay=cm4io-fan,minrpm=500,maxrpm=5000,midtemp=45000,midtemp_hyst=2000,maxtemp=50000,maxtemp_hyst=2000
+
For example, speed up the fan if the temperature is higher than 45°C and set it to maximum value if the temperate is higher than 50°C:<br />
温度高于45摄氏度开始加速,高于50摄氏度最高速
+
<pre>
 +
dtoverlay=cm4io-fan,minrpm=500,maxrpm=5000,midtemp=45000,midtemp_hyst=2000,maxtemp=50000,maxtemp_hyst=2000
 +
</pre>
  
 
==CSI  DSI==
 
==CSI  DSI==
CSI  和 DSI默认是关闭的,使用摄像头和DSI的时候会占用I2C-10、I2C-11、I2C-0 三个I2C设备<br>
+
{{CM4-CSI-DSI2}}
开机执行如下:<br>
+
<!--
sudo apt-get install p7zip-full
+
===Configuration file===
wget https://www.waveshare.net/w/upload/4/41/CM4_dt_blob.7z
+
CSI  and  DSI interfaces are closed by default, they will use the I2C-10, I2C-11 and I2C-0.<br>
7z x CM4_dt_blob.7z -O./CM4_dt_blob
+
Open a terminal and run the following commands:
sudo chmod 777 -R CM4_dt_blob
+
<syntaxhighlight lang="python">
cd CM4_dt_blob/
+
  wget https://www.waveshare.net/w/upload/7/75/CM4_dt_blob_Source.zip
#如果使用两个摄像头和DSI0 执行
+
  unzip -o CM4_dt_blob_Source.zip -d ./CM4_dt_blob_Source
sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
+
  sudo chmod 777 -R CM4_dt_blob_Source
#如果使用两个摄像头和DSI1 执行
+
  cd CM4_dt_blob_Source/
sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
+
  #If using two cameras and DSI0 execute
#在使用任意DSI时,HDMI1没有图像输出,哪怕你没有连接DSI屏幕只要编译的对应的文件,那HDMI1就没有输出了
+
  sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
#如果需要恢复,删除对应的dt-blob.bin 即可: sudo rm -rf /boot/dt-blob.bin  
+
  # if using two cameras and DSI1 execute
#执行完毕 关闭电源 重启CM4
+
  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 do not connect the DSI screen, as long as the corresponding file is compiled, then HDMI1 will not output
 +
  #If you need to restore, delete the corresponding dt-blob.bin: sudo rm -rf /boot/dt-blob.bin
 +
  # After execution, turn off the power and restart the CM4
 +
</syntaxhighlight>
 +
===Recording test===
 +
Then connect the Camera and DSI display:<br>
 +
1: Make sure the connection is in the power-off state<br>
 +
2: Connect Power<br>
 +
3: Wait a few seconds for the screen to start up<br>
 +
4: If it fails to start, check whether /boot/dt-blob.bin exists, and restart it if it exists.<br>
 +
5: 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.<br>
  
再连接摄像头和DSI屏幕:<br>
+
====Old version (Buster)====
1: 确保断电状态下连接<br>
 
2: 使用[https://www.waveshare.net/shop/CM-DSI-ADAPTER.htm  CM-DSI-ADAPTER ]转接板连接Compute Module 4 PoE Board和DSI屏幕<br>
 
3: 使用[https://www.waveshare.net/shop/RPi-Zero-v1.3-Camera-Cable.htm CSI转接线]转接板连接Compute Module 4 PoE Board和CSI摄像头<br>
 
3: 连接电源<br>
 
4: 等待几秒后屏幕启动<br>
 
5: 如果无法启动,检查/boot/dt-blob.bin 是否存在,如果存在再次重启即可<br>
 
6: 摄像头需要运行raspi-config,选择Interfacing Options->Camera->Yes->Finish-Yes,reboot系统,打开enable camera,然后重启即可保存修改。<br>
 
  
参考
+
Test the Raspberry Pi camera<br>
 
+
Check the first camera connected to the screen:<br />
测试树莓派摄像头
+
<pre>
查看接入的第一个摄像头画面:
 
 
  sudo raspivid -t 0 -cs 0
 
  sudo raspivid -t 0 -cs 0
查看接入的第二个摄像头画面:
+
</pre>
 +
Check the second camera connected to the screen:<br />
 +
<pre>
 
  sudo raspivid -t 0 -cs 1
 
  sudo raspivid -t 0 -cs 1
 +
</pre>
 +
====New version(Bullseye)====
 +
If using the latest Raspberry Pi OS (Bullseye):<br>
 +
<syntaxhighlight lang="python">
 +
libcamera-hello -t 0
 +
or
 +
libcamera-hello
  
 +
#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
  
参考[https://www.raspberrypi.org/documentation/hardware/computemodule/cmio-camera.md  CSI相机]  
+
#where imx219 is the camera sensor model, and there are other sensors
[https://www.raspberrypi.org/documentation/hardware/computemodule/cmio-display.md  DSI显示器]
+
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 the corresponding camera
 +
libcamera-hello --camera 1
 +
libcamera-hello --camera 0
 +
 
 +
#Taking Pictures
 +
libcamera-jpeg -o test.jpg
 +
#You can add --camera to specify the camera
 +
</syntaxhighlight>
 +
 
 +
More instructions [https://www.raspberrypi.com/documentation/accessories/camera.html#libcamera-hello click me]
 +
<br>
 +
*Note: If using the DSI interface display will have an HDMI disabled, even if just compile the corresponding file without connecting the DSI screen.
 +
*Any connection of two HDMIs can output images, not limited to that HDMI, if two HDMI screens are connected, only HDMI0 has 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
 +
*Then reboot <br>
  
 +
Reference [https://www.raspberrypi.com/documentation/computers/compute-module.html Raspberry Pi Manual]
 
-->
 
-->

Latest revision as of 03:21, 27 February 2024

Precautions

Do not plug or unplug any devices while it is powered on.
All of the following are tested on Raspberry Pi OS, no other systems are supported.

Writing Image

USB2.0

The USB interfaces are default disabled in CM4, you need to enable it by adding the following lines:the config.txt

dtoverlay=dwc2,dr_mode=host

It will take effect after restart

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

Preparation before use

Demo Download

Open the Raspberry Pi terminal and execute the following commands:

sudo wget https://files.waveshare.com/upload/b/ba/Compute_Module_4_PoE_4G_Board_Code.zip
unzip -o  Compute_Module_4_PoE_4G_Board_Code.zip -d ./Compute_Module_4_PoE_4G_Board_Code
sudo chmod 777 -R Compute_Module_4_PoE_4G_Board_Code
cd Compute_Module_4_PoE_4G_Board_Code

Installing Libraries

All libraries are installed according to your needs, just install the one you need to use, you don't have to install all of them.
If you just test the function, you can directly use the C program without installing any library. Our C program does not need to install any library by default.
With the update of each version, there may be some software incompatibilities, or running an error, if this problem occurs, you can feedback to us

  • Install BCM2835, open the Raspberry Pi terminal, and run the following command (not recommended)
#If you have any questions, please visit http://www.airspayce.com/mikem/bcm2835/
#Any other problems can be reported in the link above, please do not contact the author directly
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz
tar zxvf bcm2835-1.68.tar.gz
cd bcm2835-1.68/
sudo ./configure
sudo make
sudo make check
sudo make install
  • install wiringpi
#WiringPi does not officially support CM4, but you can install the unofficial version because this version is not the official version
#This version is only for CM4
#Any other problems can be reported on GitHub, please do not contact the author directly
git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi/
./build
#Execute gpio -v and the version number is 2.6.
  • Install the Python function library
#python2
sudo apt-get update
sudo apt-get install python-pip
sudo apt-get install python-pil
sudo apt-get install python-numpy
sudo pip install RPi.GPIO
sudo pip install spidev
sudo pip2 install python-can
#python3
sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-pil
sudo apt-get install python3-numpy
sudo pip3 install RPi.GPIO
sudo pip3 install spidev
sudo pip3 install python-can

Open I2C interface

  • Execute in terminal:
sudo raspi-config
#Select Interfacing Options -> I2C ->yes to start the i2C kernel driver

2591RaspberryPi.png

  • then restart the raspberry pi
sudo reboot



USB TO UART

The UART is connected to CM4 by default, and is connected to the GPIO14 (BCM) and GPIO15 (BCM) pins of CM4
When starting serial debugging, you can directly connect to the computer through this interface to log in to the CM4
Compute Module 4 PoE 4G Board 6.png
You can also supply power through this interface, but the default is not able to supply power. If you need to supply power through this interface, please connect the resistor (0R) on the interface.

Buzzer/LED

Buzzer

The buzzer is connected to GPIO22(BCM 22), low active.

Compute Module 4 PoE 4G Board 4.png

LED

Two LEDs are integrated for users, the green one is connected to GPIO20(BCM)and the red one is connected to GPIO21(BCM), low active.

Compute Module 4 PoE 4G Board 5.png

【expected results】

Two user LEDs flash alternately.
LED changes once, the buzzer sounds once.

【Python examples】

cd LED_BUZZER/python/
sudo python main.py

【C examples】

cd LED_BUZZER/c/
make clean
sudo make
sudo ./main

4G/5G

To work with 4G/5G, you need to connect a wireless module to the M.2 B KEY for featuring corresponding functions. M.2 B KEY only extends USB2.0 interfaces, it doesn't support PCIE devices.
屏幕截图 2023-06-06 151006.png
SIM card is required to work with the 4G/5G module
This carrier board supports the 4G module by default, if you use it with 5G modules, some of the 5G functions are not supported.
If you use a 5G module, please check the SIM8200EA-M2_5G HAT wiki about how to set up 5G.
It takes a certain amount of time (about 30 seconds) to close or open the mold
In the downloaded routine there is an M_2_PWR script that can be executed

sudo ./M_2_PWR 0
#Open the mod
sudo ./M_2_PWR 1
#Close the mod

Open the mod
The 5G module is not controlled by the enable pin

SIM7600 M.2 module

Status of M.2 indicators:

STA NET Status
On Off Off or starting
Long light Long light Looking for network
Steady on Blinking Connected and working fine
Off Blinking/Solid Shutting down

Before you configure the SIM7600 module, please make sure that the module is started normally.

sudo apt-get install minicom
sudo minicom -D /dev/ttyUSB2
# Enter the following commands:
AT+CUSBPIDSWITCH=9011,1,1
#return OK
#Then wait for the network card to restart
#This command only needs to be set once, the next time it is powered on, it will be in this mode by default
#If the USB0 network card cannot be obtained, execute:
sudo dhclient -v usb0

About RNIDS networking, please refer to Raspberry Pi networked via RNDIS RNIDS Networking method
With the operations above, a USB0 port will be recognized.(if you don't have other USB network card connected)
If you use an IoT card, such as a mobile IoT card, to successfully register the network; but the dial-up Internet connection fails and cannot be pinged, you can try to use one of the following AT commands to select the optimal frequency band:

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

AT Commands

If the network cannot work, plaese check module with AT commands

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

Common AT commands

Command Description Return
AT AT test OK
ATE ATE1 enable echo
ATE0 disable echo
OK
AT+CGMI Check manfacture OK
AT+CGMM Check module type OK
AT+CGSN Check SN OK
AT+CSUB Check module version OK
AT+CGMR Check firmware version OK
AT+IPREX Configure hardwara baud rate +IPREX:
OK
AT+CRESET Reset module OK
AT+CSQ Check signal quanlity +CSQ: 17,99
OK
AT+CPIN? Check SIM status +CPIN: READY
AT+COPS? CHeck the current supplier +COPS:
OK
AT+CREG? Check network status +CREG:
OK
AT+CPSI? Check UE information
AT+CNMP Configure network mode:
2:Automatic
13:GSM only
38:LTE only
48 : Any modes but LTE
... ....
OK

For more AT commands, please refer to: AT_Command_V2.00
You can also refer to:SIMCom

PCIE

The PCIe interface is PCIe 2.0 X1, the maximum speed is 500Mb/s
Support most PCIE x1 cards, many PCIEx1 device cards on the market, the default Raspberry Pi system is not supported, because the Raspberry Pi Linux does not add drivers.
Please check your PCIe device before you used Supported device testing
Raspberry Kernel compiling

Isolation GPIO/I2C

Isolation output pins are GPIO17 (BCM) and GPIO27(BCM)
Isolation input pins GPIO23 (BCM) and GPIO24(BCM)
Compute Module 4 PoE 4G Board 8.png

Configure the logic voltage of Isolation IO
Compute Module 4 PoE 4G Board 10.pngCompute Module 4 PoE 4G Board 9.png

Isolation I2C pins are GPIO2/3(BCM),I2C bus is I2C1,
Compute Module 4 PoE 4G Board 7.png


【Expected result】

The two OUT pins troggle in order
Read the values of two IN pins

【python example】

cd IO/python
sudo python main.py

【C example】

cd IO/c
make clean
sudo make
sudo ./main

Isolation ADC

The isolation ADC is mounted in isolation I2C with 0x48 address
I2C is default disabled, please refer to #Enable I2C to enable the I2C interface.

C

 cd ADC/c/
 sudo ./main 

python

 cd ADC/python/
 sudo python examples/main.py
  • Run the commands above to run the example

Expected result

Output voltage vlaue

Note: the ADC chip used is ADS1113, its reference voltage is 2.048V, the range of differential input, Input voltage range: ±2.048V

CAN

The CAN is diabled by default, you need to modify the config.txt file for enabling it.

 #Open and edit config.txt
 sudo nano /boot/config.txt
 #Add the following line to the file and save
 dtparam=spi=on
 dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
 #reboot Raspberry Pi
 reboot 

After rebooting, run the following command:

 dmesg | grep spi0

Compute Module 4 PoE 4G Board 1.png
Run the following command:

sudo ip link set can0 up type can bitrate 1000000
sudo ifconfig can0 txqueuelen 65536
ifconfig

Compute Module 4 PoE 4G Board 2.png
If the device can0 is recognized, it means that the driver was installed successfully

Testing

Install can-utils:

 sudo apt-get install can-utils

Receive data

 candump can0

Send data

 cansend can0 000#11.22.33.44
 #11.22.33.44 is data sent
 #If you need to transmit more dta, you can also extend the data just like this:
 # cansend can0 000#11.22.33.04.70

Examples

【Python examples】

  • Go into the directorty of python example:
  • Open a terminal as receiver and run the receive.py:
sudo python reveive.py
  • Open another terminal as sender and run the send.py:
sudo python send.py

The examples provided is absed on python, please make sure that you have installed the python-can library.
Create a CAN device before you send data,because the front only enables the MCP2515 core

os.system('sudo ip link set can0 type can bitrate 100000')
os.system('sudo ifconfig can0 up')
  • Step 1: Connect to the CAN bus
can0 = can.interface.Bus(channel = 'can0', bustyp = 'socketcan_ctypes')
  • Step 2: Create information
msg = can.Message(arbitration_id=0x123, data=[0, 1, 2, 3, 4, 5, 6, 7], extended_id=False)
  • Step 3: Send message

can0.send(msg)

  • Close the CAN device finally
os.system('sudo ifconfig can0 down')
  • Receive data:
msg = can0.recv(10.0)

recv() defines the timeout
for more details, please refer to https://python-can.readthedocs.io/en/stable/interfaces/socketcan.html

【C examples】

  • Blocking receive, open the terminal of Raspberry Pi and run the following commands:
cd CAN/c/receive/
make clean
sudo make
sudo ./can_receive
  • Send data, open a terminal of Raspberry Pi and run the following commands:
cd CAN/c/receive/
make clean
sudo make
sudo ./can_send



RS485/232

The interface is closed by default, you can modify the config.txt to enable it.

sudo nano /boot/config.txt

Add the following lines to the config.txt file:

 dtoverlay=uart3
 dtoverlay=uart5

Reboot the Raspbery Pi and check if the ports are recognized.

 reboot 
 ls /dev/ttyAMA*

RS232 interfaces use the GPIO5/GPIO4(BCM4/5), recognized as ttyAMA1
RS485 interfaces use the GPIO13/GPIO12(BCM13/12),recognzied as ttyAMA2

Test

Install minicom and test it with the minicom

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

RTC FAN

  • Note: Please first connect the FAN and then the power, otherwise you may damage the controller of the fan!
  • Note: Please make sure the operation voltage of the cooling fan is the same as the carrier board.

Note that if you want to use the RTC function, please first disable the DSI and CSI.
If you want to use them at the same time, please change the I2C to I2C1 (the right).
Compute Module 4 PoE 4G Board 11.png
You need to modify the codes and driver after changing.
The demo codes use I2C10 by default (the left)

If you need simple use or need to add to your program instead of the kernel, see C and Python demos.[CM4 RTC FAN]

RTC

Open the terminal and modify the config.txt file

sudo nano /boot/config.txt

Add the following lines to the file and modify the audio setting

#Add the lines to the end of file
dtparam=i2c_vc=on
dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
#remove the setting dtparam=audio=on by adding the # to the front of the line
#dtparam=audio=on

Save and reboot the Raspberry Pi.

sudo reboot

Hwclock

Synchronize system clock -> hardware clock

sudo hwclock -w

Synchronize hardware clock -> system clock

sudo hwclock  -s

Note that you need to disable the network synchronization function, otherwise, the time will be changed according to network time.

Set hardware clock:

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

Check the hardware clock.

sudo hwclock -r

Check the version.

sudo hwclock --verbose

Cooling fan

When powered on, the fan will spin for 1 second, then stop for 2 seconds, and then spin again, this is a normal phenomenon
There is currently no official configuration method for fans, there is a third-party configuration method: https://github.com/neg2led/cm4io-fan
This method is released by a third party, not an official release, and we are not responsible for any problems!

 mkdir -p ~/src
 cd ~/src
 git clone https://github.com/neg2led/cm4io-fan.git
 cd cm4io-fan
 sudo chmod 777 install.sh
 sudo  ./install.sh

The device tree overlay has a few options, here's the equivalent of a /boot/overlays/README info section:

 #############################
 Name:   cm4io-fan
 Info:   Raspberry Pi Compute Module 4 IO Board fan controller
 Load:   dtoverlay=cm4io-fan,<param>[=<val>]
 Params: minrpm             RPM target for the fan when the SoC is below 
                            mintemp (default 3500)
        maxrpm              RPM target for the fan when the SoC is above
                            maxtemp (default 5500)
        midtemp             Temperature (in millicelcius) at which the fan
                            begins to speed up (default 50000)
        midtemp_hyst        Temperature delta (in millicelcius) below mintemp
                            at which the fan will drop to minrpm (default 2000)
        maxtemp             Temperature (in millicelcius) at which the fan 
                            will be held at maxrpm (default 70000)
        maxtemp_hyst        Temperature delta (in millicelcius) below maxtemp
                            at which the fan begins to slow down (default 2000)
  #############################

For example, speed up the fan if the temperature is higher than 45°C and set it to maximum value if the temperate is higher than 50°C:

dtoverlay=cm4io-fan,minrpm=500,maxrpm=5000,midtemp=45000,midtemp_hyst=2000,maxtemp=50000,maxtemp_hyst=2000

CSI DSI

Configuration file

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:
sudo apt-get install p7zip-full -y
wget https://files.waveshare.com/upload/7/75/CM4_dt_blob_Source.zip
7z x CM4_dt_blob.7z -O./CM4_dt_blob
sudo chmod 777 -R CM4_dt_blob
cd CM4_dt_blob/
# If using two cameras and DSI1 execute
sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
# In the use of any DSI, HDMI1 no image output, even if you do not connect the DSI screen as long as the corresponding file compiled, that HDMI1 no output
# If you need to restore, delete the corresponding dt-blob.bin can be: sudo rm -rf /boot/dt-blob.bin 
#Execution is complete, power off and restart CM4


New Version (Bullseye)

Camera Config

  1. Execute the following commands to edit "/boot/config.txt" file.
    sudo nano /boot/config.txt
  2. Block or remove the automatic camera detection statement:
    CM4-NANO-B002.png
  3. Add the driver of the camera you are using, here I take IMX219 as an example and connect it to CAM0, and attach the adapter.
    CM4-NANO-B003.png
  4. Model CAM0 Set Sentence CAM1 Set Sentence
    OV9281 dtoverlay=ov9281,cam0 dtoverlay=ov9281,cam1
    IMX290/IMX327 dtoverlay=imx290,clock-frequency=37125000,cam0 dtoverlay=imx290,clock-frequency=37125000,cam1
    IMX378 dtoverlay=imx378,cam0 dtoverlay=imx378,cam1
    IMX219 dtoverlay=imx219,cam0 dtoverlay=imx219,cam1
    IMX477 dtoverlay=imx477,cam0 dtoverlay=imx477,cam1
    IMX708 dtoverlay=imx708,cam0 dtoverlay=imx708,cam1
    • If you are using the official Raspberry Pi camera and only one camera is connected, there is no need to set the config file.
    • CM4-NANO - only CAM0 is used, so you only need to add "dtoverlay=imx219,cam0".

    CM4-NANO-B004.png
    5. Ctrl+x to exit the editor.
    6. Reboot the Raspberry Pi.

    sudo reboot
    

Camera Test

  1. Enter the camera detection command, you can see that the camera is detected by now.
    libcamera-hello --list-cameras
    

    CM4-NANO-B005.png

  2. Display the camera screen on the desktop.
  3. libcamera-hello -t
    
  4. Taking photos.
    libcamera-jpeg -o test.jpg
    
  5. Record a video of 10s.
    libcamera-vid -t 10000 -o test.h264
    
  6. Other Commands
    Check whether the camera is detected:
    libcamera-hello --list-cameras

    Open the corresponding cameras:

    libcamera-hello  --camera 1
    libcamera-hello  --camera 0
    

    Take a photo:

    libcamera-jpeg -o test.jpg
    #Add --camera to specify a camera 
    

Old Version (Buster)

Camera Config

    1. Execute the following command to enter the Raspberry Pi configuration.
    sudo raspi-config

    2. Choose Interfacing Options and enter.
    Interface.png
    3. Choose Camera:
    Camera.png
    4. Choose to enable the camera interface.
    Camera2.png
    5. The system prompts as follows:
    Prompt.png
    6. Back to the main interface, select Finish.
    Finish.png
    7. Reboot the system.
    Finish2.png


    Camera Test

    raspistill -o image.jpg
    
    • Test the recording function:
    raspivid -o video.h264 -t 10000
    
      • Where -t 10000 means recording for 10 seconds, users can adjust according to their own needs.
      • Please refer to CSI.