2025年6月20日 星期五

Orange Pi One 連接 ST7796 界面電阻觸控 LCD

參考連結

動機與背景

因為貪便宜,也為了改 3D印表機不要花太高的成本,在網路上買了好幾片 Orange Pi One 的單板電腦。

可能因為用的晶片太舊,新的 Kernel 在支援上會有問題。例如目前的 kernel 是 6.12.30,同樣的程式,在 Orange Pi Zero 3 上,可以正常執行,但在 Orange Pi One 就是怪怪的,使用 tinydrm 的 module,完全無法啟動 X window。經反覆測試,確認在較舊的 kernel  6.6.75 上,才能正常執行。另外,armbian/build 的 32位元的 sunxi 的 kernel,沒有把 gpio-backlight 編成 module,dts 中,無法控制背光。

使用 panel-mipi-dbi-spi,在 Orange Pi Zero3 下,可以正常運作,也可以執行 KlipperScreen。但在 Orange Pi One,相同的設定檔,會出現下面的錯誤訊息。後來確認,背光控制要有 gpio_backlight 的 kernel module。

$ dmesg | less
[   18.163593] panel-mipi-dbi-spi spi0.0: supply power not found, using dummy regulator
[   18.163853] panel-mipi-dbi-spi spi0.0: supply io not found, using dummy regulator
[   18.164817] spi spi0.0: deferred probe pending: panel-mipi-dbi-spi: Failed to get backlight

$ sudo modprobe gpio_backlight
[sudo] password for klipper: 
modprobe: FATAL: Module gpio_backlight not found in directory /lib/modules/6.12.23-current-sunxi

另外,Orange Pi Zero3 的 image 裡,有 fb_st7796s 的模組,在 Orange Pi One 則沒有。

使用 6.12.30-current-sunxi,雖然 console 是正常的,但啟動 X window,就會出現 Bus error。

$ X

X.Org X Server 1.21.1.7
X Protocol Version 11, Revision 0
Current Operating System: Linux orangepione 6.12.30-current-sunxi #2 SMP Thu May 22 20:29:54 CST 2025 armv7l
Kernel command line: root=UUID=4c8b2287-edb5-431a-904c-a21f8f213ef8 rootwait rootfstype=ext4 splash=verbose console=ttyS0,115200 console=tty1 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 consoleblank=0 loglevel=1 ubootpart=d0be82e5-01 ubootsource=mmc usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u   sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16 cgroup_enable=memory
xorg-server 2:21.1.7-3+deb12u9 (https://www.debian.org/support) 
Current version of pixman: 0.42.2
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Mon Jun 23 14:36:07 2025
(==) Using config directory: "/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(EE) 
(EE) Backtrace:
(EE) 
(EE) Bus error at address 0xb6185000
(EE) 
Fatal server error:
(EE) Caught signal 7 (Bus error). Server aborting
(EE) 
(EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE) 
(EE) Server terminated with error (1). Closing log file.
Aborted

另外,使用 6.12.30-current-sunxi,自行編譯的 fb_st7796s 或 fb_ili9488 模組,也不能正常運作,會變得一片白屏。

經過反覆的測試,確認 Orange Pi One 的 32位元的系統,要使用 6.6.75 的 kernel 才能正常運作。

自行 build image

後來自行照著 armbian 的 build 說明,自行 build image,終於可以正常安裝執行 KlipperScreen。

複製 armbian/build 的程式。

$ git clone https://github.com/armbian/build

然後修改 build/config/kernel/linux-sunxi-legacy.config,增加 build gpio_backlight 和 fb_st7796s 的 kernel module。

.......
CONFIG_BACKLIGHT_QCOM_WLED=m
CONFIG_BACKLIGHT_RT4831=m
CONFIG_BACKLIGHT_GPIO=m
CONFIG_BACKLIGHT_LED=m
........
CONFIG_FB_TFT_ST7735R=m
CONFIG_FB_TFT_ST7789V=m
CONFIG_FB_TFT_ST7796S=m
CONFIG_FB_TFT_TINYLCD=m
........

執行 compile.sh。

$ ./compile.sh \
BOARD=orangepione \
BRANCH=legacy RELEASE=bookworm \
BUILD_MINIMAL=yes BUILD_DESKTOP=no  \
NETWORKING_STACK="network-manager" \
KERNEL_CONFIGURE=no \
INSTALL_HEADERS=yes \
KERNEL_BTF=yes

編譯完成,產生的 image。

$ ls build/output/images/
Armbian-unofficial_25.08.0-trunk_Orangepione_bookworm_legacy_6.6.75_minimal.img
Armbian-unofficial_25.08.0-trunk_Orangepione_bookworm_legacy_6.6.75_minimal.img.sha
Armbian-unofficial_25.08.0-trunk_Orangepione_bookworm_legacy_6.6.75_minimal.img.txt

成果

放張照片,當作紀念。

真是太棒了。





沒有留言:

張貼留言

網誌存檔