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

From Waveshare Wiki
Jump to: navigation, search
(Created page with " ==Writing Image== 1、 If your Compute Module 4 (CM4 hereafter) is the LITE version, you just need to write the image to Micro SD card like Raspberry Pi boards.<br> 2、 If y...")
 
Tag: Replaced
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
+
==Note==
 +
<font color="red">Do not plug or unplug any device while the base board is powered on.</font>
 
==Writing Image==
 
==Writing Image==
1、 If your Compute Module 4 (CM4 hereafter) is the LITE version, you just need to write the image to Micro SD card like Raspberry Pi boards.<br>
+
*[[Write Image for Compute Module Boards eMMC version]]
2、 If your use the eMMC version, you need to connect the CM4 to PC by Micro USB cable, Download the [https://raw.githubusercontent.com/raspberrypi/usbboot/master/win32/rpiboot_setup.exe  rpiboot tools] and install it as administrator<br>
+
*[[Wrote Image for Compute Module Boards Lite version |Write Image for Compute Module Boards Lite version]]
3、 Download newest Raspberry Pi OS image from [https://www.raspberrypi.org/downloads/raspberry-pi-os/  Raspberry Pi Website].<br>
+
==RTC FAN==
[[FILE:Compute_Module_4_IO_Board_3.png|600px]]<br>
+
{{CM-RTC-FAN}}
If you use the eMMC version, you need to connect the CM4 to the IO board. Connect the <font color="#ff0000">BOOT </font> pin of IO board to the <font color="#ff0000">GND  </font> . Connect USB SLAVE Interface of IO board to PC. Connect 12V power adapter to IO Board. A device named BCMxxx is recognized, and you need to run the rpiboot software, to regonzied eMMC of CM4 as an portable drive.<br>
 
[[FILE:Compute-Module-4-1-1.png|600px]]<br>
 
4、 Format SD card: You need to format the MicroSD card or the eMMC by SDFormatter.exe software.<br>
 
[[FILE:PI4-03.JPG]]<br>
 
5、 Write image: You need to write the image to Micro SD card or the eMMC by Win32DiskImager.exe software. Select the image file and click “Write”. Please DO NOT format it after formatting.<br>
 
[[FILE:PI4-04.JPG]]<br>
 
6、 Booting: Insert the Micro SD card into the card slot and connect the 12V power adapter. Power indicator turn solid red and the ACT is green and blink while booting.<br>
 
If you use the eMMC version, don't forget to disconnect the nRPI_BOOT J2 jumpers when powering off and reboot.<br>
 
<font color="#ff00ff">If you failed to write the eMMC, please try with the following steps:
 
*User Windows PC instead of Windows 7 or Linux. It seems that Windows 7 or Linux PC is not stable for eMMC writing.
 
*Check your CM4, make sure that it is the eMMC version which has one more eMMC chip compare to the LITE version..
 
[[File:Compute-Module-4-5.png|800px]]
 
*Note that you need to connect 12 power adapter to the Power port.
 
*Please change a USB cable for a try and make sure that the cable is data accessible.
 
*Change the USB port of the PC and try it again.
 
*Try to restart your PC.
 
*Re-connect the CM4 for a  try.
 
*Try with other PCs.
 
</font>
 
  
==RTC  FAN==
 
To enable the I2C for Cooling fan and the RTC, you need to add the line "dtparam=i2c_vc=on" to config file<br>
 
RTC is connected to i2c-10 with address  0x51(7bits)<br>
 
FAN is connected to i2c-10 上 with address 0x2f(7bits)<br>
 
<pre>
 
sudo nano /boot/config.txt
 
#Add the following line to the end
 
dtparam=i2c_vc=on
 
#comment the line dtparam=audio=on
 
#dtparam=audio=on
 
#Save and reboot
 
sudo reboot
 
</pre>
 
 
==CSI  DSI==
 
==CSI  DSI==
CSI  and  DSI are disabled by default. I2C-10、I2C-11、I2C-0 should be used for Camera and DSI displays.<br>
+
{{CM4-CSI-DSI2}}
Open a terminal and run the following commands:<br>
 
<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/
 
#If you want to use both cameras and DSI0
 
sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
 
#If you want to ue both cameras and DSI1
 
sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
 
#HDMI1 is disabled if you use DSI interfaces for displayin. HDMI1 cannot work even thought you just built the file without connecting DSI display, please note it.
 
#If you want to enable the HDMI1, please remove the dt-blob.bin file with the command: '''sudo rm -rf /boot/dt-blob.bin'''
 
#Turn off IO Board and re-power the CM4
 
</pre>
 
Connect Cameras and DSI display<br>
 
1: Please first disconnect power off the IP Board when connecting.<br>
 
2: Use [https://www.waveshare.com/CM-DSI-ADAPTER.htm  CM-DSI-ADAPTER ] to connect Compute Module 4 PoE Board and DSI displays<br>
 
3: Use[https://www.waveshare.com/RPi-Zero-v1.3-Camera-Cable.htm CSI adapter cable] to connect Compute Module 4 PoE Board and CSI cameras.<br>
 
3: Connect the power adapter<br>
 
4: Wait for booting.<br>
 
5: If the DSI display cannot work, please check if you have added /boot/dt-blob.bin and reboot.<br>
 
6: Please enable camera by raspi-config, choose Interfacing Options->Camera->Yes->Finish-Yesand reboot<br>
 
 
 
Reference:
 
 
 
Test RPi Camera:<br />
 
Test video0:
 
sudo raspivid -t 0 -cs 0
 
Test video1:
 
sudo raspivid -t 0 -cs 1
 
 
 
 
 
==Pinput==
 
[[FILE:Compute-Module-4-1-21.png]]<br>
 
 
 
{|border=2; style="width:800px;"
 
|-style="background:#efffff; color:blue;" align="center"
 
|style="width:58px"| No. ||PIN||Description
 
|-style="background:#00eecc; color:blue;" align="center"
 
|-align="center"
 
|1||PI BOOT||The pin is low when booting. This pin is connected to USB SLAVE interface.
 
|-align="center"
 
|style="width:66px"|2||EEPROM WP||Set it to LOW to avoid writing EEPROM
 
|-align="center"
 
|3||IP1/0||MXL7704 AN1/0 Pin of CM4 board
 
|-align="center"
 
|4||VADC COMP||Video output
 
|-align="center"
 
|5||ETH IN||ETH synchronize signal
 
|-align="center"
 
|6||PI_EN|| Synchronize with PI_RUN signal
 
|-align="center"
 
|7||PI_GLOBAL_EN||MXL7704 power enable pin of CM4, Low to disable.
 
|-align="center"
 
|8||PI_RUN||CM4 status pin, high for On. Pull-down it to foruce reset the CM4
 
|-align="center"
 
|9||WIFI_EN||WIFI enable pin, Low to disbale, and NC to enable.
 
|-align="center"
 
|11||BT_EN||Bluetooth enable pin, Low to disable and NC to enable.
 
|-align="center"
 
|}
 

Latest revision as of 02:12, 25 May 2023

Note

Do not plug or unplug any device while the base board is powered on.

Writing Image

RTC FAN

  • Note: Please connect the fan before turning on the power of the baseboard and then complete the test. Please do not connect the fan after the baseboard is powered on, because the fan control chip has been powered on, otherwise, the chip will be burned!
  • Note: Before connecting, please confirm whether the rated voltage of the fan is consistent with the voltage connected to the fan.

Please note that DSI and CSI are prohibited when using RTC.
I2C-10 is used by default.

RTC (PCF85063a) on i2c-10, address is 0 x 51 (7-bit address)
FAN ( EMC2301 ) on i2c-10, address is 0 x 2f (7-bit address)

If you need to add it to your program instead of the kernel, you can refer to the C and Python demo reference click here

RTC

sudo nano /boot/config.txt
 #Add the following lines at the end
 dtparam=i2c_vc=on
 dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
 #Add # in front of dtparam=audio=on
 #dtparam=audio=on
 #Save and exit, restart
 sudo reboot

How to use Hwclock

Synchronize system clock to hardware clock:

sudo hwclock -w

Synchronize hardware clock to system clock:

sudo hwclock -s
 #The network or the NTP needs to be closed, 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

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 no official configuration method for the fan currently, there is a third-party configuration method: https://github.com/neg2led/cm4io-fan
This method is published by a third party, and we are not responsible for any problems!

sudo apt-get install dkms 
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

#If an error message appears: Your kernel headers for kernel 5.XX.XX-v7l+ cannot be found at
#After rebooting the device, you can execute it:

#The following is the description of config.txt
#############################
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)
#############################

Or directly refer to the following:

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

The fan will start to accelerate when temperature is higher than 45 degrees Celsius, and will up to the highest speed when higher than 50 degrees Celsius.

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
    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. If it is not an official camera, set the "dtoverlay" statement without the "cam" suffix.
    • CM4-NANO - only CAM0 is used, so you only need to add "dtoverlay=imx219,cam0".
    4. Press Ctrl+o to save the file and then press Enter.
    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.