Template:Compute Module 4 PoE 4G Board manual
- 1 Writing Image
- 2 USB2.0
- 3 USB TO UART
- 4 Buzzer/LED
- 5 4G/5G
- 6 PCIE
- 7 Isolation GPIO/I2C
- 8 Isolation ADC
- 9 CAN
- 10 RS485/232
- 11 RTC FAN
- 12 CSI DSI
- Write Image for Compute Module Boards eMMC version
- Wrote Image for Compute Module Boards Lite version
The USB interfaces are default disabled in CM4, you need to enable it by adding the following lines:the config.txt
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.
The buzzer is connected to GPIO22(BCM), low active.
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.
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.
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:
|Red LED||Green LED||Status|
|Solid||Solid||SIM card is an invalid or weak signal|
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
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:
If the network cannot work, plaese check module with AT commands
sudo apt-get install minicom sudo minicom -D /dev/ttyUSB2
Common AT commands
|ATE|| ATE1 enable echo
ATE0 disable echo
|AT+CGMM||Check module type||OK|
|AT+CSUB||Check module version||OK|
|AT+CGMR||Check firmware version||OK|
|AT+IPREX||Configure hardwara baud rate|| +IPREX:|
|AT+CSQ||Check signal quanlity|| +CSQ: 17,99|
|AT+CPIN?||Check SIM status||+CPIN: READY|
|AT+COPS?||CHeck the current supplier|| +COPS:|
|AT+CREG?||Check network status|| +CREG:|
|AT+CPSI?||Check UE information|
|AT+CNMP|| Configure network mode：
48 ： Any modes but LTE
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
The two OUT pins troggle in order
Read the values of two IN pins
cd IO/python sudo python main.py
cd IO/c make clean sudo make sudo ./main
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.
cd ADC/c/ sudo ./main
cd ADC/python/ sudo python examples/main.py
- Run the commands above to run the example
Output voltage vlaue
Note: the ADC chip used is ADS1113, its reference voltage is 2.048V, the range of differential input.
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
600px Run the following command：
sudo ip link set can0 up type can bitrate 1000000 sudo ifconfig can0 txqueuelen 65536 ifconfig
If the device can0 is recognized, it means that the driver was installed successfully
sudo apt-get install can-utils
cansend can0 000#220.127.116.11 #18.104.22.168 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
- 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
- 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
- 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
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:
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
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
- 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)
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\>
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
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
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:
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
- 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:
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.
Test the first camera:
sudo raspivid -t 0 -cs 0
Test the second camera：
sudo raspivid -t 0 -cs 1