Q's ToyBox

「よQ」のおもちゃ箱

MENU

ST7789 CS無し LCDにコンソールを

ST7789 LCD 240x240 1.3インチのちっちゃいところにRaspberry Piのコンソールを表示したい。

同じことを考えている人はいる様ですが、CS(ChipSelect)がない!カーネルバージョンがBusterから5.xに上がってしまった!との声が。

でもやりたいね。

いろいろ読み進めると、以下の2点がキーであることがわかりました。

・Pimoroni Pirate Audio Headphone Amp for Raspberry Pi

・ST7789のCS無しはSPI MODE3で動かす

 

経緯から

Webで見つけたあっきぃさんのページ

akkiesoft.hatenablog.jp

でも、僕のLCDモジュールにはCSがないのです。

あっきぃさんの通りにやってもダメでした。

forums.pimoroni.com

Pimoroniの"DeviceTreeを使う"これは基本的に正解(でした)。

ここからCS無しを対応しましょう。

1. Install “buster-lite” and run “sudo apt update” but DO NOT run “sudo apt upgrade”

2. run “sudo raspi-config” and enable “SSH”, “SPI”, and “I2C” within “Interfacing Options” then reboot.

3. login as the pi user.

4. run “wget
https://gist.githubusercontent.com/hgroll/2731ae6d05350df663b123615f765bf5/raw/f8fe3829136296c20ba670dcd572e8a5c60da995/pidi-overlay.dts

5. run “dtc -@ -I dts -O dtb -o pidi.dtbo pidi-overlay.dts”

6. run “sudo cp pidi.dtbo /boot/overlays/”

7. edit “/boot/config.txt” and add the line “dtoverlay=pidi”

8. edit “/boot/cmdline.txt” and append " fbcon=map:10 fbcon=font:VGA8x16" (with the beginning space) to the 1st line after the word “rootwait”

9. run “sudo dpkg-reconfigure console-setup” then select “UTF8”, “Guess optimal…”, “Let the system select…”, “8x16”, “Ok”

10. run “sudo reboot”

違うのは4.でgetしたdtsファイルの編集です。

修正前
reg = <0>;
pinctrl-names = "default";

led-gpios = <&gpio 13 1>;

このregとpinctrl-namesの間に「MODE3で動いてね」を挿入し、

Backlight LEDの値も1から0へ変更します。

編集後
reg = <0>;
spi-cpol = <1>;
spi-cpha = <1>;
pinctrl-names = "default";

led-gpios = <&gpio 13 0>;

この2行だけ付け加えて5.から先を進めましょう。

raspi-configでSPIを有効にするのを忘れずに。

f:id:yoque8107:20211112010625p:plain

配線 Raspberry Pi                                               LCDモジュール
1pin(3.3V)    ----------------------------- VCC
9pin(GND)   ----------------------------- GND
17pin(3.3V)  ----------------------------- RES
19pin(MOSI) ----------------------------- SDA
21pin(DC)     ----------------------------- DC
23pin(SCLK) ----------------------------- SCL
26pin(CS)     ----------(open)
33pin(BackLight) ------------------------ BLK

以上