GAMEPI20に純なLinux(RaspberryPi OS)を入れる
https://github.com/darrenliew96/gamepi20_drivers
RasPi ImagerでカードにOSを焼く
Updateする
sudo apt update sudo apt full-upgrade audo apt dist-update
$ uname -a Linux raspberrypi 5.10.63+ #1459 Wed Oct 6 16:40:27 BST 2021 armv6l GNU/Linux
$ nano gamepi20.dts
/dts-v1/; /plugin/; / { compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709"; fragment@0 { target = <&spi0>; __overlay__ { status = "okay"; spidev@0{ status = "disabled"; }; spidev@1{ status = "disabled"; }; }; }; fragment@1 { target = <&gpio>; __overlay__ { gamepi20_pins: gamepi20 { brcm,pins = <25 27 >; brcm,function = <1 1>; /* out */ brcm,pull = <0>; /* none */ }; }; }; fragment@2 { target = <&spi0>; __overlay__ { /* needed to avoid dtc warning */ #address-cells = <1>; #size-cells = <0>; gamepi20: gamepi20@0{ compatible = "sitronix,st7789v"; reg = <0>; pinctrl-names = "default"; pinctrl-0 = <&gamepi20_pins>; spi-max-frequency = <96000000>; rotate = <90>; width = <240>; height = <320>; fps = <60>; buswidth = <8>; spi-cpol; spi-cpha; custom = <1>; bgr; reset-gpios = <&gpio 27 1>; dc-gpios = <&gpio 25 0>; led-gpios = <&gpio 24 1>; /*cs-gpios = <&gpio 8 0>;*/ debug = <0>; init = <0x1000011 0x20000ff 0x1000036 0xA0 0x100003a 0x05 0x1000021 0x100002a 0x00 0x01 0x00 0x3f 0x100002b 0x00 0x00 0x00 0xef 0x10000b2 0x0c 0x0c 0x00 0x33 0x33 0x10000b7 0x35 0x10000bb 0x1f 0x10000c0 0x0c 0x10000c2 0x01 0x10000c3 0x12 0x10000c4 0x20 0x10000c6 0x0f 0x10000d0 0xa4 0xa1 0x10000e0 0xd0 0x08 0x11 0x08 0x0C 0x15 0x39 0x33 0x50 0x36 0x13 0x14 0x29 0x2d 0x10000e1 0xd0 0x08 0x10 0x08 0x06 0x06 0x39 0x44 0x51 0x0b 0x16 0x14 0x2f 0x31 0x1000029>; }; }; }; __overrides__ { speed = <&gamepi20>,"spi-max-frequency:0"; rotate = <&gamepi20>,"rotate:0"; width = <&gamepi20>,"width:0"; height = <&gamepi20>,"height:0"; fps = <&gamepi20>,"fps:0"; debug = <&gamepi20>,"debug:0"; }; };
元ネタの https://github.com/darrenliew96/gamepi20_drivers にあるファイルから一部修正してある。
具体的には、
修正前 led-gpios = <&gpio 24 0>; 修正後 led-gpios = <&gpio 24 1>;
$ sudo dtc -@ -I dts -O dtb -o /boot/overlays/gamepi20.dtbo gamepi20.dts
# Uncomment some or all of these to enable the optional hardware interfaces dtparam=i2c_arm=on dtparam=i2s=on dtparam=spi=on #dtoverlay=i2c-dev=spi_bcm2835 # Automatically load overlays for detected cameras camera_auto_detect=0 #無効にしておく # Automatically load overlays for detected DSI displays display_auto_detect=0 #無効にしておく # Enable DRM VC4 V3D driver #dtoverlay=vc4-kms-v3d #max_framebuffers=2 #無効にしておく # Disable compensation for displays with overscan disable_overscan=1 [cm4] # Enable host mode on the 2711 built-in XHCI USB controller. # This line should be removed if the legacy DWC2 controller is required # (e.g. for USB device mode) or if USB support is not required. #otg_mode=1 #無効にしておく [all] #dtoverlay=pi3-disable-bt #dtoverlay=pi3-miniuart-bt #enable_uart=1 #GAMEPI20のディスプレイドライバ指定 dtoverlay=gamepi20 #画面解像度を適当に小さくしておく(HDMIはVGAの60fps GAMEPI20は320x240) hdmi_force_hotplug=1 hdmi_cvt=640 480 60 1 0 0 0 hdmi_group=2 hdmi_mode=1 hdmi_mode=87 audio_pwm_mode=2 dtoverlay=audremap,pins_18_19
sudo apt-get install cmake git cd ~ git clone https://github.com/tasanakorn/rpi-fbcp cd rpi-fbcp/ mkdir build cd build/ cmake .. make sudo install fbcp /usr/local/bin/fbcp
フレームバッファー間のコピーを行うコマンド。
プライマリディスプレイのフレームバッファの内容をセカンダリディスプレイのフレームバッファにコピーする。
つまり、ミラーリング。
sudo nano /etc/modulesに追記 i2c-dev spi-bcm2835 flexfb fbtft_device
sudo nano /etc/modprobe.d/fbtft.conf options fbtft_device name=flexfb gpios=reset:27,dc:25,cs:8,led:24 speed=96000000 bgr=1 fps=60 custom=1 height=240 width=320 options flexfb setaddrwin=0 width=320 height=240 init=-1,0x11,-2,120,-1,0x36,0xA0,-1,0x3A,0x05,-1,0x21,-1,0x2A,0x00,0x01,0x00,0x3F,-1,0x2B,0x00,0x00,0x00,0xEF,-1,0xB2,0x0C,0x0C,0x00,0x33,0x33,-1,0xB7,0x35,-1,0xBB,0x1F,-1,0xC0,0x2C,-1,0xC2,0x01,-1,0xC3,0x12,-1,0xC4,0x20,-1,0xC6,0x0F,-1,0xD0,0xA4,0xA1,-1,0xE0,0xD0,0x08,0x11,0x08,0x0C,0x15,0x39,0x33,0x50,0x36,0x13,0x14,0x29,0x2D,-1,0xE1,0xD0,0x08,0x10,0x08,0x06,0x06,0x39,0x44,0x51,0x0B,0x16,0x14,0x2F,0x31,-1,0x29,-3
fbcp & exit 0
キー | BCM No. | GPIO No. | 物理ピン |
↑ | 12 | 26 | 32 |
→ | 21 | 29 | 40 |
← | 13 | 23 | 35 |
↓ | 20 | 28 | 38 |
SELECT | 16 | 27 | 36 |
START | 26 | 25 | 37 |
Y | 17 | 0 | 11 |
X | 22 | 3 | 15 |
A | 23 | 4 | 16 |
B | 4 | 7 | 7 |
L | 5 | 21 | 29 |
R | 6 | 22 | 31 |
L R ┌────┐ ↑ │ │ Y ← → │ │ B X ↓ │ │ A └────┘ SELECT START