Raspbian Buster: SainSmart 1,8" TFT LCD Modul ansteuern mit Kernel 5.4 und Device Tree
Damit das SainSmart 1,8" TFT LCD Modul, welches einen ST7735R Chip verwendet, unter Raspbian Buster mit dem Kernel 5.4 verwendet werden kann, muss der Device Tree genutzt werden. Der Device Tree ist eine Datenstruktur zur Beschreibung von Hardware, die beim Booten an das Betriebssystem übergeben wird. In dieser Anleitung soll ein Device Tree Blob für den ST7735R Chip erzeugt werden, über welchen die benötigten Kernelmodule und Einstellungen geladen werden, um so das SainSmart 1,8" TFT LCD Modul anzusteuern.
Als Grundlage für die folgende Anleitung wurde das Raspbian Buster Image vom 20.08.2020 verwendet.
Display mit dem Raspberry Pi verbinden
Wie Sie das SainSmart 1.8" TFT LCD Modul mit Ihrem Raspberry Pi verbinden müssen, können Sie in der Anleitung Raspberry Pi: SainSmart 1,8" TFT LCD Modul anschließen nachlesen
Device Tree Overlay erstellen
Erstellen Sie mit einem Editor eine neue Device Tree Konfigurationsdatei mit dem Namen st7735r.dts.
pi@raspberrypi:~ $ nano st7735r.dts
Fügen Sie in diese Datei die folgenden Zeilen ein. Durch die einzelnen Parameter werden die benötigten Einstellungen für die Ansteuerung des SainSmart 1,8" TFT LCD Moduls festgelegt.
/* Device tree overlay for ST7735R */
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@2 {
target = <&gpio>;
__overlay__ {
st7735r_display_pins: st7735r_display_pins {
brcm,pins = <24 25>;
brcm,function = <1 1>;
brcm,pull = <0 0>;
};
};
};
fragment@3 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
st7735rdisplay: st7735r-display@0{
compatible = "jianda,jd-t18003-t01", "sitronix,st7735r";
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&st7735r_display_pins>;
spi-max-frequency = <32000000>;
rotation = <0>;
fps = <20>;
height = <160>;
width = <128>;
buswidth = <8>;
reset-gpios = <&gpio 25 0>;
dc-gpios = <&gpio 24 0>;
debug = <0>;
};
};
};
__overrides__ {
speed = <&st7735rdisplay>,"spi-max-frequency:0";
rotate = <&st7735rdisplay>,"rotation:0";
fps = <&st7735rdisplay>,"fps:0";
debug = <&st7735rdisplay>,"debug:0";
};
};
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@2 {
target = <&gpio>;
__overlay__ {
st7735r_display_pins: st7735r_display_pins {
brcm,pins = <24 25>;
brcm,function = <1 1>;
brcm,pull = <0 0>;
};
};
};
fragment@3 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
st7735rdisplay: st7735r-display@0{
compatible = "jianda,jd-t18003-t01", "sitronix,st7735r";
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&st7735r_display_pins>;
spi-max-frequency = <32000000>;
rotation = <0>;
fps = <20>;
height = <160>;
width = <128>;
buswidth = <8>;
reset-gpios = <&gpio 25 0>;
dc-gpios = <&gpio 24 0>;
debug = <0>;
};
};
};
__overrides__ {
speed = <&st7735rdisplay>,"spi-max-frequency:0";
rotate = <&st7735rdisplay>,"rotation:0";
fps = <&st7735rdisplay>,"fps:0";
debug = <&st7735rdisplay>,"debug:0";
};
};
Device Tree Blob erzeugen
Mit dem Device Tree Compiler wird jetzt die binäre Device Tree Blob Datei erzeugt und direkt im Verzeichnis /boot/overlays abgelegt.
pi@raspberrypi:~ $ sudo dtc -@ -I dts -O dtb -o /boot/overlays/st7735r.dtbo st7735r.dts
Device Tree Blob einbinden
Den soeben erstellten Device Tree Blob können Sie jetzt in der Konfigurationsdatei /boot/config.txt einbinden.
pi@raspberrypi:~ $ sudo nano /boot/config.txt
Fügen Sie am Ende der Datei die folgende Zeile ein.
dtoverlay=st7735r
Nachdem Sie die config.txt erweitert haben, müssen Sie einen Neustart des Systems durchführen.
pi@raspberrypi:~ $ sudo shutdown -r now
Mit dem Befehl lsmod können Sie nach dem Neustart überprüfen ob alle Kernelmodule geladen wurden. Es sollten unter anderen die Kernelmodule spi_bcm2835, syscopyarea, sysfillrect, sysimgblt, fb_sys_fops und st7735r angezeigt werden.
pi@raspberrypi:~ $ lsmod
Module Size Used by
sha256_generic 16384 0
libsha256 20480 1 sha256_generic
cfg80211 671744 0
rfkill 28672 2 cfg80211
8021q 32768 0
garp 16384 1 8021q
stp 16384 1 garp
llc 16384 2 garp,stp
st7735r 16384 0
drm_mipi_dbi 28672 1 st7735r
drm_kms_helper 184320 3 st7735r,drm_mipi_dbi
drm 442368 4 st7735r,drm_mipi_dbi,drm_kms_helper
drm_panel_orientation_quirks 16384 1 drm
syscopyarea 16384 1 drm_kms_helper
sysfillrect 16384 1 drm_kms_helper
sysimgblt 16384 1 drm_kms_helper
fb_sys_fops 16384 1 drm_kms_helper
backlight 20480 1 st7735r
spidev 20480 0
raspberrypi_hwmon 16384 0
bcm2835_codec 36864 0
bcm2835_isp 28672 0
bcm2835_v4l2 45056 0
v4l2_mem2mem 32768 1 bcm2835_codec
bcm2835_mmal_vchiq 28672 3 bcm2835_isp,bcm2835_codec,bcm2835_v4l2
videobuf2_vmalloc 16384 1 bcm2835_v4l2
videobuf2_dma_contig 20480 2 bcm2835_isp,bcm2835_codec
videobuf2_memops 16384 2 videobuf2_dma_contig,videobuf2_vmalloc
videobuf2_v4l2 28672 4 bcm2835_isp,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem
spi_bcm2835 20480 0
snd_bcm2835 28672 1
videobuf2_common 53248 5 bcm2835_isp,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
snd_pcm 98304 1 snd_bcm2835
videodev 229376 6 bcm2835_isp,bcm2835_codec,videobuf2_common,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
snd_timer 32768 1 snd_pcm
snd 73728 5 snd_timer,snd_bcm2835,snd_pcm
mc 45056 6 bcm2835_isp,bcm2835_codec,videobuf2_common,videodev,v4l2_mem2mem,videobuf2_v4l2
vc_sm_cma 32768 2 bcm2835_isp,bcm2835_mmal_vchiq
uio_pdrv_genirq 16384 0
uio 20480 1 uio_pdrv_genirq
fixed 16384 0
ip_tables 28672 0
x_tables 32768 1 ip_tables
ipv6 450560 18
Module Size Used by
sha256_generic 16384 0
libsha256 20480 1 sha256_generic
cfg80211 671744 0
rfkill 28672 2 cfg80211
8021q 32768 0
garp 16384 1 8021q
stp 16384 1 garp
llc 16384 2 garp,stp
st7735r 16384 0
drm_mipi_dbi 28672 1 st7735r
drm_kms_helper 184320 3 st7735r,drm_mipi_dbi
drm 442368 4 st7735r,drm_mipi_dbi,drm_kms_helper
drm_panel_orientation_quirks 16384 1 drm
syscopyarea 16384 1 drm_kms_helper
sysfillrect 16384 1 drm_kms_helper
sysimgblt 16384 1 drm_kms_helper
fb_sys_fops 16384 1 drm_kms_helper
backlight 20480 1 st7735r
spidev 20480 0
raspberrypi_hwmon 16384 0
bcm2835_codec 36864 0
bcm2835_isp 28672 0
bcm2835_v4l2 45056 0
v4l2_mem2mem 32768 1 bcm2835_codec
bcm2835_mmal_vchiq 28672 3 bcm2835_isp,bcm2835_codec,bcm2835_v4l2
videobuf2_vmalloc 16384 1 bcm2835_v4l2
videobuf2_dma_contig 20480 2 bcm2835_isp,bcm2835_codec
videobuf2_memops 16384 2 videobuf2_dma_contig,videobuf2_vmalloc
videobuf2_v4l2 28672 4 bcm2835_isp,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem
spi_bcm2835 20480 0
snd_bcm2835 28672 1
videobuf2_common 53248 5 bcm2835_isp,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
snd_pcm 98304 1 snd_bcm2835
videodev 229376 6 bcm2835_isp,bcm2835_codec,videobuf2_common,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
snd_timer 32768 1 snd_pcm
snd 73728 5 snd_timer,snd_bcm2835,snd_pcm
mc 45056 6 bcm2835_isp,bcm2835_codec,videobuf2_common,videodev,v4l2_mem2mem,videobuf2_v4l2
vc_sm_cma 32768 2 bcm2835_isp,bcm2835_mmal_vchiq
uio_pdrv_genirq 16384 0
uio 20480 1 uio_pdrv_genirq
fixed 16384 0
ip_tables 28672 0
x_tables 32768 1 ip_tables
ipv6 450560 18
Weiterführende Tutorials
Raspbian Buster: Datum und Uhrzeit auf dem SainSmart 1,8" TFT LCD Modul ausgeben
Dieser Eintrag wurde am 27.12.2020 erstellt.
Direkter Link zu dieser Seite: http://www.gtkdb.de/index_36_3100.html
[ Zur Startseite ] [ Zur Kategorie ]
© 2004-2021 by Georg Kainzbauer