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

From Waveshare Wiki
Jump to: navigation, search
(3 intermediate revisions by the same user not shown)
Line 10: Line 10:
 
==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 USB to UART port is connected to GPIO14(BCM) and GPIO15(BCM) pins of CM4 with a converter.<br />
You can connect the USB to UART port for login CM4 via serial.<br />
+
You can connect the USB to the UART port for login CM4 via serial.<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 />
 
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]]
 
[[File:Compute Module 4 PoE 4G Board 6.png|300px]]
Line 22: Line 22:
 
==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 | 600px]]<br>
+
[[FILE:Compute Module 4 PoE 4G Board_3.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.
===4G===
+
 
 
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>
 
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>
 
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 />
M.2 status状态 红色LED 灯座 指示的就是4G 模组使能,红色灯亮起说明4G 模组已开机(5G模组不受使能管脚控制)
+
===SIM7600 M.2 module===
M.2 状态 绿色色LED 灯座 指示的就是4G 模组状态,绿色灯亮起说明4G 模组 开机完成,绿色闪烁说明模组已经成功联网
+
Status of M.2 indicators:
 +
{|class="wikitable"
 +
!M.2_NET !! M.2_STA !!
 +
|-
 +
|Red LED || Green LED|| Status
 +
|-
 +
|Solid || OFF ||Power OFF
 +
|-
 +
|Solid || OFF ||Starting
 +
|-
 +
|Solid || Solid || SIM card is an invalid or weak signal
 +
|-
 +
|Solid || Blink || Working
 +
|-
 +
|OFF ||Blink/Solid||Shutdowning
 +
|}
  
在配置前,请确认 4G 模块已经开机, 4G 模块对应了两个4G的LED已经亮起或者闪烁说明已经开机<br>
+
Before you configure the SIM7600 module, please make sure that the module is started normally.
关机状态下两个LED全部是熄灭的<br>
 
两个LED长亮是没有SIM卡<br>
 
 
<pre>
 
<pre>
 
sudo apt-get install minicom
 
sudo apt-get install minicom
 
sudo minicom -D /dev/ttyUSB2
 
sudo minicom -D /dev/ttyUSB2
#输入以下指令:
+
</pre>
 +
Type the following command on the minicom<br />
 +
<pre>
 
AT+CUSBPIDSWITCH=9011,1,1
 
AT+CUSBPIDSWITCH=9011,1,1
#返回OK 即可
+
</pre>
#然后重启
+
Close the minicom and configure usb0<br />
sudo reboot
+
<pre>
#如果无法获取USB0网卡执行:
 
 
sudo dhclient -v usb0
 
sudo dhclient -v usb0
 
</pre>
 
</pre>
RNDIS拨号上网请参考:
 
[https://www.waveshare.net/wiki/%E6%A0%91%E8%8E%93%E6%B4%BERNDIS%E6%8B%A8%E5%8F%B7%E4%B8%8A%E7%BD%91 RNDIS拨号上网]
 
  
正常执行上面之后会识别到USB0网卡(如果你没有连接其他USB网卡)<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.<br />
<font color="#ff00ff">如果你使用物联网卡,比如移动物联网卡,成功注册网络;但是拨号上网失败,无法ping通,可以尝试用以下AT指令的其中一条选择最优频段:</font>
+
If the network cannot work, please try to switch frequency with the following AT commands:
 +
<pre>
 
  AT+CNBP=0x0002000000400183,0x000001E000000000,0x0000000000000021
 
  AT+CNBP=0x0002000000400183,0x000001E000000000,0x0000000000000021
 
  AT+CNBP=0x0002000000400180,0x480000000000000000000000000000000000000000000042000001E200000095,0x0000000000000021
 
  AT+CNBP=0x0002000000400180,0x480000000000000000000000000000000000000000000042000001E200000095,0x0000000000000021
 
+
</pre>
===<font color="Bf0000">'''AT指令'''</font>===
+
===<font color="Bf0000">'''AT Commands'''</font>===
如果无法连接网络,可以通过指令AT检查状态
+
If the network cannot work, plaese check module with AT commands
 
<pre>
 
<pre>
 
sudo apt-get install minicom
 
sudo apt-get install minicom
Line 63: Line 76:
 
</pre>
 
</pre>
  
=== 常用AT指令 ===
+
=== Common AT commands  ===
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! 命令 !! 说明 !! 返回值
+
! Command !! Description !! Return
 
|-
 
|-
| AT || AT测试指令 || OK
+
| AT || AT test || OK
 
|-
 
|-
| ATE || ATE1设置回显<br /> ATE0关闭回显|| OK
+
| ATE || ATE1 enable echo <br /> ATE0 disable echo|| OK
 
|-
 
|-
| AT+CGMI || 查询模组制造商 || OK
+
| AT+CGMI || Check manfacture || OK
 
|-
 
|-
| AT+CGMM || 查询模组型号 || OK
+
| AT+CGMM || Check module type || OK
 
|-
 
|-
| AT+CGSN || 查询产品序列号 || OK
+
| AT+CGSN || Check SN || OK
 
|-
 
|-
| AT+CSUB || 查询模块版本以及芯片 || OK
+
| AT+CSUB || Check module version || OK
 
|-
 
|-
| AT+CGMR || 查询固件版本序列号 || OK
+
| AT+CGMR || Check firmware version || OK
 
|-
 
|-
| AT+IPREX  || 设置模块硬件串口波特率 || +IPREX:<br />OK
+
| AT+IPREX  || Configure hardwara baud rate || +IPREX:<br />OK
 
|-
 
|-
| AT+CRESET || 复位模块 || OK
+
| AT+CRESET || Reset module || OK
 
|-
 
|-
| AT+CSQ || 网络信号质量查询,返回信号值 || +CSQ: 17,99<br />OK
+
| AT+CSQ || Check signal quanlity || +CSQ: 17,99<br />OK
 
|-
 
|-
| AT+CPIN? || 查询SIM卡状态,返回READY,表示SIM卡能正常识别 || +CPIN: READY
+
| AT+CPIN? || Check SIM status || +CPIN: READY
 
|-
 
|-
| AT+COPS? || 查询当前运营商,正常联网后会返回运营商信息 || +COPS:<br />OK
+
| AT+COPS? || CHeck the current supplier || +COPS:<br />OK
 
|-
 
|-
| AT+CREG? || 查询网络注册状态 || +CREG:<br />OK
+
| AT+CREG? || Check network status || +CREG:<br />OK
 
|-
 
|-
| AT+CPSI? || 查询UE系统信息 ||  
+
| AT+CPSI? || Check UE information ||  
 
|-
 
|-
|AT+CNMP || 网络模式选择命令:<br />2:Automatic<br />13:GSM only<br />38:LTE only<br />48 : Any modes but LTE<br />... .... ||  OK
+
|AT+CNMP || Configure network mode:<br />2:Automatic<br />13:GSM only<br />38:LTE only<br />48 : Any modes but LTE<br />... .... ||  OK
 
|}
 
|}
 
<font color="red">
 
<font color="red">
更多AT指令参考: [https://www.waveshare.net/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://www.waveshare.com/w/upload/6/68/SIM7500_SIM7600_Series_AT_Command_Manual_V2.00.pdf AT_Command_V2.00]<br />
更多文档参考:[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==
 +
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 />
 +
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]
 +
 
 +
==Isolation GPIO/I2C==
 +
Isolation output pins are GPIO17 (BCM) and  GPIO27(BCM)<br />
 +
Isolation input pins GPIO23 (BCM) and  GPIO24(BCM)<br />
 +
[[FILE:Compute Module 4 PoE 4G Board_8.png | 400px]]<br /><br />
 +
 
 +
Configure the logic voltage of Isolation IO <br />
 +
[[FILE:Compute Module 4 PoE 4G Board_10.png | 400px]][[FILE:Compute Module 4 PoE 4G Board_9.png | 400px]]<br /><br />
 +
 
 +
Isolation I2C pins are GPIO2/3(BCM),I2C bus is I2C1,<br />
 +
[[FILE:Compute Module 4 PoE 4G Board_7.png | 500px]]<br />
 +
 
 +
 
 +
====【Expected result】====
 +
The two OUT pins troggle in order<br>
 +
Read the values of two IN pins<br>
 +
<br>
 +
 
 +
====【python example】====
 +
<pre>
 +
cd IO/python
 +
sudo python main.py
 +
</pre>
 +
 
 +
====【C example】====
 +
<pre>
 +
cd IO/c
 +
make clean
 +
sudo make
 +
sudo ./main
 +
</pre>
 +
 
 +
<br/><br/>
 +
==Isolation ADC==
 +
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 />
 +
 
 +
===C===
 +
<pre>
 +
cd ADC/c/
 +
sudo ./main
 +
</pre>
 +
===python===
 +
<pre>
 +
cd ADC/python/
 +
sudo python examples/main.py
 +
</pre>
 +
*Run the commands above to run the example
 +
===Expected result===
 +
<font color="#ff0000">  Output voltage vlaue </font><br/>
 +
<br/>
 +
Note: the ADC chip used is ADS1113, its reference voltage is 2.048V, the range of differential input.<br/>
 +
 
 +
<br/><br/>
 +
==CAN==
 +
The CAN is diabled by default, you need to modify the config.txt file for enabling it.<br>
 +
<pre>
 +
#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
 +
</pre>
 +
After rebooting, run the following command:<br>
 +
<pre>
 +
dmesg | grep spi0
 +
</pre>
 +
[[file:Compute Module 4 PoE 4G Board_1.png | 600px]]
 +
Run the following command:
 +
sudo ip link set can0 up type can bitrate 1000000
 +
sudo ifconfig can0 txqueuelen 65536
 +
ifconfig
 +
[[file:Compute Module 4 PoE 4G Board_2.png | 600px]]
 +
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
 +
<pre>
 +
candump can0
 +
</pre>
 +
Send data
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
===Examples===
 +
====【Python examples】====
 +
*Go into the directorty of python example:
 +
*Open a terminal as receiver and run the receive.py:
 +
<pre>
 +
sudo python reveive.py
 +
</pre>
 +
*Open another terminal as sender and run the send.py:
 +
<pre>
 +
sudo python send.py
 +
</pre>
 +
 
 +
The examples provided is absed on python, please make sure that you have installed the python-can library.<br />
 +
Create a CAN device before you send data.:
 +
<pre>
 +
os.system('sudo ip link set can0 type can bitrate 100000')
 +
os.system('sudo ifconfig can0 up')
 +
</pre>
 +
*Step 1: Connect to the CAN bus<br />
 +
<pre>
 +
can0 = can.interface.Bus(channel = 'can0', bustyp = 'socketcan_ctypes')
 +
</pre>
 +
*Step 2: Create information<br />
 +
<pre>
 +
msg = can.Message(arbitration_id=0x123, data=[0, 1, 2, 3, 4, 5, 6, 7], extended_id=False)
 +
</pre>
 +
*Step 3: Send message
 +
can0.send(msg)
 +
</pre>
 +
*Close the CAN device finally
 +
<pre>
 +
os.system('sudo ifconfig can0 down')
 +
</pre>
 +
*Receive data:
 +
<pre>
 +
msg = can0.recv(10.0)
 +
</pre>
 +
recv() defines the timeout<br />
 +
'''for more details, please refer to https://python-can.readthedocs.io/en/stable/interfaces/socketcan.html<br />'''
 +
<br />
 +
 
 +
====【C examples】====
 +
*Blocking receive, open the terminal of Raspberry Pi and run the following commands:
 +
<pre>
 +
cd CAN/c/receive/
 +
make clean
 +
sudo make
 +
sudo ./can_receive
 +
</pre>
 +
*Send data, open a terminal of Raspberry Pi and run the following commands:
 +
<pre>
 +
cd CAN/c/receive/
 +
make clean
 +
sudo make
 +
sudo ./can_send
 +
</pre>
 +
 
 +
<br/><br/>
 +
==RS485/232==
 +
The interface is closed by default, you can modify the config.txt to enable it.<br>
 +
<pre>
 +
sudo nano /boot/config.txt
 +
</pre>
 +
Add the following lines to the config.txt file:
 +
<pre>
 +
dtoverlay=uart3
 +
dtoverlay=uart5
 +
</pre>
 +
Reboot the Raspbery Pi and check if the ports are recognized.
 +
<pre>
 +
reboot
 +
ls /dev/ttyAMA*
 +
</pre>
 +
RS232 interfaces use the GPIO5/GPIO4(BCM4/5), recognized as ttyAMA1<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
 +
# RS232
 +
sudo minicom -D /dev/ttyAMA1
 +
#RS485
 +
sudo minicom -D /dev/ttyAMA2
 +
</pre>
 +
==RTC  FAN==
 +
<font color="red">
 +
*Note:Please fiest connect the FAN and then the power, otherwise you may damage the controller of fan!
 +
*Note: Please make sure the operation voltage of the cooling fan is the same as the carrier board.
 +
</font>
 +
<font color="#ff0000"> Note that if you want to use the RTC function, please first disable the DSI and CSI. </font><br/>
 +
If you want to use them at the same time, please change the I2C to I2C1 (the right)<br/>
 +
[[file:Compute Module 4 PoE 4G Board_11.png | 500px]]<br/>
 +
<font color="#ff0000"> You need to modify the codes and driver after changing.</font><br/>
 +
<font color="#ff0000"> The demo codes use I2C10 by default (the left)</font><br/>
 +
<br/>
 +
Please refer to the wiki of CM4_RTC_FAN about how to control the cooling fan and the RTC [[https://www.waveshare.com/wiki/CM4_RTC_FAN CM4 RTC FAN]]<br\>
 +
 
 +
===RTC===
 +
Open the terminal and modify the config.txt file<br />
 +
<pre>
 +
sudo nano /boot/config.txt
 +
</pre>
 +
Add the following lines to the file and modify the audio setting
 +
<pre>
 +
#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
 +
</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>
 +
 
 +
Note that you need to disable the network synchronization function, otherwise the time will be changed according to network time.<br />
 +
 
 +
Set hardware clock:
 +
<pre>
 +
sudo hwclock --set --date="9/8/2021 16:45:05"
 +
</pre>
 +
 
 +
Check the hardware clock<br />
 +
<pre>
 +
sudo hwclock -r
 +
</pre>
 +
Check the version.<br />
 +
<pre>
 +
sudo hwclock --verbose
 +
</pre>
 +
 
 +
===Cooling fan===
 +
The cooling fan will turn for a while when starting, it is normal.<br\>
 +
There is a third-party project for configuring cooling fan for reference:https://github.com/neg2led/cm4io-fan<br\>
 +
<pre>
 +
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
 +
</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
 +
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)
 +
  #############################
 +
</pre>
 +
For examples, speed up the fan if the temperature is higher than 45°C and set the it to maximum value if the temperate is higher than 50°C:<br />
 +
<pre>
 +
dtoverlay=cm4io-fan,minrpm=500,maxrpm=5000,midtemp=45000,midtemp_hyst=2000,maxtemp=50000,maxtemp_hyst=2000
 +
</pre>
 +
 
 +
==CSI  DSI==
 +
CSI  and  DSI interfaces are closed by default, they will use the I2C-10, I2C-11 and I2C-0.<br>
 +
Open a terminal and run the following commands:
 +
<pre>
 +
sudo apt-get install p7zip-full
 +
wget https://www.waveshare.com/w/upload/4/41/CM4_dt_blob.7z
 +
7z x CM4_dt_blob.7z -O./CM4_dt_blob
 +
sudo chmod 777 -R CM4_dt_blob
 +
cd CM4_dt_blob/
 +
</pre>
 +
Run the two camera and the DIS0 <br />
 +
<pre>
 +
sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
 +
</pre>
 +
Run the two camera and the DSI1 <br />
 +
<pre>
 +
sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
 +
</pre>
 +
Notices:<br />
 +
#The HDMI1 cannot work if you have compiled the file for DSI
 +
#To enable the HDMI1 again, please remove the dt-blob.bin file: sudo rm -rf /boot/dt-blob.bin
 +
#After running, restart the CM4
 +
 
 +
Connect the Camera and DSI display:<br>
 +
1: Please first turn off the power before connecting<br>
 +
2: Use [https://www.waveshare.com/CM-DSI-ADAPTER.htm  CM-DSI-ADAPTER ] to connect the Compute Module 4 PoE Board and DSI display.<br>
 +
3: Use [https://www.waveshare.com/RPi-Zero-v1.3-Camera-Cable.htm CSI cable] to connect the Compute Module 4 PoE Board and CSI camera.<br>
 +
3: Connect the power<br>
 +
4: The display will start after a few seconds.<br>
 +
5: If the display cannot work, please check if the file /boot/dt-blob.bin has been added to the directory and restart<br>
 +
6: To use the camera, you should enable the camera by raspi-config, choose Interfacing Options->Camera->Yes->Finish-Yes and then reboot.<br>
 +
 
 +
Testing
 +
 
 +
Test the first camera:<br />
 +
<pre>
 +
sudo raspivid -t 0 -cs 0
 +
</pre>
 +
Test the second camera:<br />
 +
<pre>
 +
sudo raspivid -t 0 -cs 1
 +
</pre>

Revision as of 09:52, 11 September 2021

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

USB TO UART

The USB to UART port is connected to GPIO14(BCM) and GPIO15(BCM) pins of CM4 with a converter.
You can connect the USB to the UART port for login CM4 via serial.
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.
Compute Module 4 PoE 4G Board 6.png

Buzzer/LED

Buzzer

The buzzer is connected to GPIO22(BCM), 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

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.
Compute Module 4 PoE 4G Board 3.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.

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.
To toggle the working status of the 4G module, please add delay time for waiting for the operation to work.
If you use the 5G module, the GPIOs cannot work for it.

SIM7600 M.2 module

Status of M.2 indicators:

M.2_NET M.2_STA
Red LED Green LED Status
Solid OFF Power OFF
Solid OFF Starting
Solid Solid SIM card is an invalid or weak signal
Solid Blink Working
OFF Blink/Solid Shutdowning

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

Type the following command on the minicom

AT+CUSBPIDSWITCH=9011,1,1

Close the minicom and configure usb0

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 the network cannot work, please try to switch frequency with the following AT commands:

 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
Most of the PCIEx1 device is not supported by Raspberry Pi without a driver.
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.



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

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 fiest connect the FAN and then the power, otherwise you may damage the controller of 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)

Please refer to the wiki of CM4_RTC_FAN about how to control the cooling fan and the RTC [CM4 RTC FAN]<br\>

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

The cooling fan will turn for a while when starting, it is normal.<br\> There is a third-party project for configuring cooling fan for reference:https://github.com/neg2led/cm4io-fan<br\>

 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 examples, speed up the fan if the temperature is higher than 45°C and set the 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

CSI and DSI interfaces are closed by default, they will use the I2C-10, I2C-11 and I2C-0.
Open a terminal and run the following commands:

 sudo apt-get install p7zip-full
 wget https://www.waveshare.com/w/upload/4/41/CM4_dt_blob.7z
 7z x CM4_dt_blob.7z -O./CM4_dt_blob
 sudo chmod 777 -R CM4_dt_blob
 cd CM4_dt_blob/

Run the two camera and the DIS0

 sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts

Run the two camera and the DSI1

 sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts

Notices:

  1. The HDMI1 cannot work if you have compiled the file for DSI
  2. To enable the HDMI1 again, please remove the dt-blob.bin file: sudo rm -rf /boot/dt-blob.bin
  3. After running, restart the CM4

Connect the Camera and DSI display:
1: Please first turn off the power before connecting
2: Use CM-DSI-ADAPTER to connect the Compute Module 4 PoE Board and DSI display.
3: Use CSI cable to connect the Compute Module 4 PoE Board and CSI camera.
3: Connect the power
4: The display will start after a few seconds.
5: If the display cannot work, please check if the file /boot/dt-blob.bin has been added to the directory and restart
6: To use the camera, you should enable the camera by raspi-config, choose Interfacing Options->Camera->Yes->Finish-Yes and then reboot.

Testing

Test the first camera:

 sudo raspivid -t 0 -cs 0

Test the second camera:

 sudo raspivid -t 0 -cs 1