Difference between revisions of "Template:Cm4-disp-base-2.8a Guide"

From Waveshare Wiki
Jump to: navigation, search
 
(14 intermediate revisions by 3 users not shown)
Line 8: Line 8:
 
dtoverlay=dwc2,dr_mode=host
 
dtoverlay=dwc2,dr_mode=host
 
</pre>
 
</pre>
Then reboot the CM4 <br>
+
Then reboot the CM4.<br>
  
 
<font color="#ff00ff">
 
<font color="#ff00ff">
Line 15: Line 15:
 
config failed, hub doesn't have any ports! (err -19)
 
config failed, hub doesn't have any ports! (err -19)
 
</pre>
 
</pre>
However, USB can still workable. If you want to remove this error, please remove the ''line otg_mode=1'' in [cm4] of config.txt, and add ''dtoverlay=dwc2, dr_mode=host ''(USB cannot be recognized without adding it). <br>
+
However, USB can still be workable. If you want to remove this error, please remove the ''line 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>
 
[[FILE:CM4 Burn EMMC_12.png|800px]]<br>
 
</font>
 
</font>
  
 
<br>
 
<br>
 +
 
==Display==
 
==Display==
 
===For Raspberry Pi OS Bullseye batch===
 
===For Raspberry Pi OS Bullseye batch===
Line 30: Line 31:
 
dtoverlay=waveshare-28dpi-4b
 
dtoverlay=waveshare-28dpi-4b
 
</pre>
 
</pre>
*Download the [https://www.waveshare.com/w/upload/b/b5/28DPI-DTBO.zip 2.8inch DPI LCD DTO] file, unzip it and copyt the scripts to overlays directory (/boot/overlays)
+
*Download the [https://files.waveshare.com/upload/b/b5/28DPI-DTBO.zip 2.8inch DPI LCD DTO] file, unzip it, and copy the scripts to overlays directory (/boot/overlays).
 +
<pre>
 +
wget https://files.waveshare.com/upload/b/b5/28DPI-DTBO.zip
 +
unzip -o 28DPI-DTBO.zip -d ./28DPI-DTBO
 +
cd 28DPI-DTBO/28DPI-DTBO/
 +
sudo cp vc4-kms-DPI-28inch.dtbo /boot/overlays/
 +
sudo cp waveshare-28dpi-* /boot/overlays/
 +
</pre>
 +
 
 
===For Raspberry Pi OS Bluster batch or Ubuntu ===
 
===For Raspberry Pi OS Bluster batch or Ubuntu ===
*Remove the line: dtoverlay=vc4-fkms-V3D from the config.txt file
+
*Remove the line: <font color="#FF0000">dtoverlay=vc4-fkms-V3D</font> from the config.txt file.
*Add the following lines to the config.txt file
+
*Add the following lines to the config.txt file:
 
<pre>
 
<pre>
 
gpio=0-9=a2
 
gpio=0-9=a2
Line 50: Line 59:
 
dtoverlay=waveshare-28dpi-4b
 
dtoverlay=waveshare-28dpi-4b
 
</pre>
 
</pre>
*Restart your Raspberry Pi and test it
+
*Save and safely eject the TF card and insert it into the Raspberry Pi.
 +
*Power on the Raspberry Pi and wait normally for about thirty seconds for normal display.
 +
 
 
=== Orientation setting for Raspberry Pi OS===
 
=== Orientation setting for Raspberry Pi OS===
 
*Check if KMS or FKMS driver is enabled.
 
*Check if KMS or FKMS driver is enabled.
 
*:You can check if ''dtoverly=vc4-kms-v3d'' or ''dtoverlya=vc4-fkms-v3d'' are added to config.txt file
 
*:You can check if ''dtoverly=vc4-kms-v3d'' or ''dtoverlya=vc4-fkms-v3d'' are added to config.txt file
 
*If the KMS/FKMS driver is enabled. You can set the orientation by the following command:
 
*If the KMS/FKMS driver is enabled. You can set the orientation by the following command:
:<pre>
+
<pre>
 
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
 
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
#Add the following line to the autostart file to rotate display, reboot is required
+
#Add the following line to the autostart file to rotate the display, reboot is required
 
#0: 0 degree; 1:270 degree;2: 180 degree; 3: 90 degree
 
#0: 0 degree; 1:270 degree;2: 180 degree; 3: 90 degree
 
xrandr -o 1
 
xrandr -o 1
 
</pre>
 
</pre>
*If the KMS/FKMS driver is disabled, please use the following command to rotate display:
+
*If the KMS/FKMS driver is disabled, please use the following command to rotate the display:
:<pre>
+
<pre>
 
sudo nano /boot/config.txt
 
sudo nano /boot/config.txt
#Add the following line to config.txt file to rotate display, reboot is required
+
#Add the following line to the config.txt file to rotate the display, reboot is required
 
#0: 0 degree; 1:90 degree;2: 180 degree; 3: 270 degree
 
#0: 0 degree; 1:90 degree;2: 180 degree; 3: 270 degree
 
display_rotate=3
 
display_rotate=3
 
</pre>
 
</pre>
 +
 +
===Touch to Rotate===
 +
After rotating the display, the touch position is not correct because the touch does not change with the display angle. So touch needs to be modified.
 +
 +
1. Install libinput.
 +
sudo apt-get install xserver-xorg-input-libinput
 +
: If you installed Ubuntu system. The installation instructions are:
 +
sudo apt install xserver-xorg-input-synaptics
 +
2. Create the xorg.conf.d directory under /etc/X11/ (if the directory already exists, go directly to step 3).
 +
sudo mkdir /etc/X11/xorg.conf.d
 +
3. Copy the 40-libinput-conf file to the directory just created.
 +
sudo cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/
 +
4. Edit the file.
 +
sudo nano /etc/X11/xorg.conf.d/40-libinput.conf
 +
Find the touchscreen part, add the following statement in it, and save it.
 +
Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"
 +
Similar to the following picture:<br />
 +
[[File:Touch roate.jpg]]
 +
<br />
 +
5. Restart the Raspberry Pi.
 +
sudo reboot
 +
Complete the above steps to perform a 90-degree rotation.
 +
 +
'''Note: '''<br />
 +
90-degree rotation: Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"
 +
 +
180-degree rotation: Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1"
 +
 +
270-degree rotation: Option "CalibrationMatrix" "0 -1 1 1 0 0 0 0 1"
 +
 
==M.2==
 
==M.2==
The carrier board features M.2 KEY M interface for PCI-E devices like NVME SSD. SATA disk is not supported. <br />
+
The carrier board features the M.2 KEY M interface for PCI-E devices like NVME SSD. SATA disk is not supported. <br />
The device could support 2230, 2242 SSD, for some of the SSD, you may need to rebuild the kernel yourself.
+
The device could support 2230, and 2242 SSD, for some of the SSD, you may need to rebuild the kernel yourself.
:[[File:CM4-IO-BASE-B-1-1 (1).png|400px]]
+
:[[File:CM4-DISP-BASE-2.8A-M-2.png|400px]]
  
 
==Camera==
 
==Camera==
Line 78: Line 119:
 
===Download script===
 
===Download script===
 
<pre>
 
<pre>
wget https://www.waveshare.com/w/upload/a/a2/Dts-2.8A.zip
+
wget https://files.waveshare.com/upload/a/a2/Dts-2.8A.zip
 
  unzip -o  Dts-2.8A.zip -d ./Dts-2.8A
 
  unzip -o  Dts-2.8A.zip -d ./Dts-2.8A
 
  sudo chmod 777 -R Dts-2.8A
 
  sudo chmod 777 -R Dts-2.8A
Line 84: Line 125:
 
  sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-cm4-singlecam-dpi28.dts
 
  sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-cm4-singlecam-dpi28.dts
 
</pre>
 
</pre>
 
 
=== Old Version (Buster) ===
 
=== Old Version (Buster) ===
 
Note: On December 2, 2021, the Raspberry Pi OS for Raspberry Pi split into two branches, the Buster branch, and the Bullseye branch.
 
Note: On December 2, 2021, the Raspberry Pi OS for Raspberry Pi split into two branches, the Buster branch, and the Bullseye branch.
Line 93: Line 133:
 
View the first connected camera screen:
 
View the first connected camera screen:
 
  sudo raspivid -t 0 -cs 0
 
  sudo raspivid -t 0 -cs 0
 
<br><br>
 
 
 
=== New Version (Bullseye) ===
 
=== New Version (Bullseye) ===
If you are using the Bullseye branch of the system, refer to the following
+
If you are using the Bullseye branch of the system, refer to the following:
 
 
 
====Camera====
 
====Camera====
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
Line 111: Line 147:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
More instructions [https://www.raspberrypi.com/documentation/accessories/camera.html#libcamera-hello click me]
+
More instructions [https://www.raspberrypi.com/documentation/accessories/camera.html#libcamera-hello click me].
 
<br>
 
<br>
Reference [https://www.raspberrypi.com/documentation/computers/compute-module.html Raspberry Pi Manual]
+
Reference [https://www.raspberrypi.com/documentation/computers/compute-module.html Raspberry Pi Manual].

Latest revision as of 08:10, 30 March 2024

Writing Image

USB2.0

The USB port is disabled by default on the CM4 for saving power. If you need to use it, you need to add the following to the config.txt file:

dtoverlay=dwc2,dr_mode=host

Then reboot the CM4.

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 workable. If you want to remove this error, please remove the line 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


Display

For Raspberry Pi OS Bullseye batch

  • Modify the config.txt file and append the following lines to the file:
dtoverlay=vc4-kms-v3d
dtoverlay=vc4-kms-DPI-28inch
dtoverlay=waveshare-28dpi-3b-4b   
dtoverlay=waveshare-28dpi-3b
dtoverlay=waveshare-28dpi-4b
  • Download the 2.8inch DPI LCD DTO file, unzip it, and copy the scripts to overlays directory (/boot/overlays).
wget https://files.waveshare.com/upload/b/b5/28DPI-DTBO.zip
unzip -o 28DPI-DTBO.zip -d ./28DPI-DTBO
cd 28DPI-DTBO/28DPI-DTBO/
sudo cp vc4-kms-DPI-28inch.dtbo /boot/overlays/
sudo cp waveshare-28dpi-* /boot/overlays/

For Raspberry Pi OS Bluster batch or Ubuntu

  • Remove the line: dtoverlay=vc4-fkms-V3D from the config.txt file.
  • Add the following lines to the config.txt file:
gpio=0-9=a2
gpio=12-17=a2
gpio=20-25=a2
dtoverlay=dpi24
enable_dpi_lcd=1
display_default_lcd=1
extra_transpose_buffer=2
dpi_group=2
dpi_mode=87
dpi_output_format=0x7F016
hdmi_timings=480 0 26 16 10 640 0 25 10 15 0 0 0 60 0 32000000 1
dtoverlay=waveshare-28dpi-3b-4b
dtoverlay=waveshare-28dpi-3b
dtoverlay=waveshare-28dpi-4b
  • Save and safely eject the TF card and insert it into the Raspberry Pi.
  • Power on the Raspberry Pi and wait normally for about thirty seconds for normal display.

Orientation setting for Raspberry Pi OS

  • Check if KMS or FKMS driver is enabled.
    You can check if dtoverly=vc4-kms-v3d or dtoverlya=vc4-fkms-v3d are added to config.txt file
  • If the KMS/FKMS driver is enabled. You can set the orientation by the following command:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
#Add the following line to the autostart file to rotate the display, reboot is required
#0: 0 degree; 1:270 degree;2: 180 degree; 3: 90 degree
xrandr -o 1
  • If the KMS/FKMS driver is disabled, please use the following command to rotate the display:
sudo nano /boot/config.txt
#Add the following line to the config.txt file to rotate the display, reboot is required
#0: 0 degree; 1:90 degree;2: 180 degree; 3: 270 degree
display_rotate=3

Touch to Rotate

After rotating the display, the touch position is not correct because the touch does not change with the display angle. So touch needs to be modified.

1. Install libinput.

sudo apt-get install xserver-xorg-input-libinput
If you installed Ubuntu system. The installation instructions are:
sudo apt install xserver-xorg-input-synaptics

2. Create the xorg.conf.d directory under /etc/X11/ (if the directory already exists, go directly to step 3).

sudo mkdir /etc/X11/xorg.conf.d

3. Copy the 40-libinput-conf file to the directory just created.

sudo cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/

4. Edit the file.

sudo nano /etc/X11/xorg.conf.d/40-libinput.conf

Find the touchscreen part, add the following statement in it, and save it.

Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"

Similar to the following picture:
Touch roate.jpg
5. Restart the Raspberry Pi.

sudo reboot

Complete the above steps to perform a 90-degree rotation.

Note:
90-degree rotation: Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"

180-degree rotation: Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1"

270-degree rotation: Option "CalibrationMatrix" "0 -1 1 1 0 0 0 0 1"

M.2

The carrier board features the M.2 KEY M interface for PCI-E devices like NVME SSD. SATA disk is not supported.
The device could support 2230, and 2242 SSD, for some of the SSD, you may need to rebuild the kernel yourself.

CM4-DISP-BASE-2.8A-M-2.png

Camera

If you use the buster system, you just need to add the configuration file and reboot.
If you use the new version (bullseye) system, additional modifications are required

Download script

wget https://files.waveshare.com/upload/a/a2/Dts-2.8A.zip
 unzip -o  Dts-2.8A.zip -d ./Dts-2.8A
 sudo chmod 777 -R Dts-2.8A
 cd Dts-2.8A/
 sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-cm4-singlecam-dpi28.dts

Old Version (Buster)

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

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

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

sudo raspivid -t 0 -cs 0

New Version (Bullseye)

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

Camera

#Detect camera
libcamera-hello --list-cameras

#Preview
libcamera-hello  --camera 0

#Capture picture
libcamera-jpeg -o test.jpg

More instructions click me.
Reference Raspberry Pi Manual.