Skip to main content

QSPI 双屏 ST77916 LCD 异显

本示例适配的 QSPI 屏为 W180TE010I-18Z,使用 QSPI 四数据线模式驱动。

两块 QSPI 屏幕

SPI2 所接屏幕使用 PD1—PD6,引脚配置如下:

V861TFT 模块
PD1QSPI-CS
PD2QSPI-CLK
PD3QSPI-D0
PD4QSPI-D1
PD5QSPI-D3
PD6QSPI-D2
PL6RESET
3V3VCC
GNDGND

SPI1 所接屏幕使用 PD14—PD19,引脚配置如下:

V861TFT 模块
PD14QSPI-CS
PD15QSPI-CLK
PD16QSPI-D0
PD17QSPI-D1
PD18QSPI-D3
PD19QSPI-D2
PL7RESET
3V3VCC
GNDGND

下方设备树将 SPI1 所接屏幕映射为 fb0,将 SPI2 所接屏幕映射为 fb1。

勾选驱动​

Allwinner BSP --->
Device Drivers --->
Video Drivers --->
SPI LCD Panel Drivers --->
<*> LCD FB Driver Support (SPI LCD)
LCD FB Panels select --->
[*] LCD support ST77916 QSPI panel

image-20250417103054875

配置设备树​

note

本例中的 150 MHz SPI 时钟是当前开发板与屏幕组合的已验证配置。其他平台请根据 SPI 控制器、板级走线和屏幕规格实测确定可用频率,不要直接照搬该数值。

&pio {
spi1_pins_default: spi1@0 {
pins = "PD14", "PD15", "PD16", "PD17", "PD18", "PD19"; /* CS, SCK, D0, D1, D3, D2 */
function = "spi1";
allwinner,drive = <3>;
};

spi1_pins_sleep: spi1@1 {
pins = "PD14", "PD15", "PD16", "PD17", "PD18", "PD19";
function = "io_disabled";
};

spi2_pins_default: spi2@0 {
pins = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6"; /* CS, SCK, D0, D1, D3, D2 */
function = "spi2";
allwinner,drive = <3>;
};

spi2_pins_sleep: spi2@3 {
pins = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6";
function = "io_disabled";
};
};

&lcd_fb {
status = "okay";
port {
#address-cells = <1>;
#size-cells = <0>;
spi_panel0: endpoint@0 {
reg = <0>;
remote-endpoint = <&panel_st77916_spi1>;
};
spi_panel1: endpoint@1 {
reg = <1>;
remote-endpoint = <&panel_st77916_spi2>;
};
};
};

&spi1 {
pinctrl-0 = <&spi1_pins_default>;
pinctrl-1 = <&spi1_pins_sleep>;
pinctrl-names = "default", "sleep";
clock-frequency = <150000000>;
sunxi,spi-bus-mode = <SUNXI_SPI_BUS_MASTER>;
sunxi,spi-cs-mode = <SUNXI_SPI_CS_SOFT>;
status = "okay";

panel_st77916_spi1: slave@0 {
device_type = "spi-panel";
compatible = "allwinner,spi-panel";
reg = <0x0>;
spi-max-frequency = <150000000>;
spi-rx-bus-width = <4>;
spi-tx-bus-width = <4>;
lcd_used = <1>;
lcd_driver_name = "st77916_qspi";
lcd_if = <2>;
lcd_qspi_if = <2>;
lcd_data_speed_hz = <118153846>;
lcd_x = <360>;
lcd_y = <360>;
lcd_pixel_fmt = <10>;
lcd_dbi_fmt = <2>;
lcd_rgb_order = <0>;
lcd_width = <60>;
lcd_height = <60>;
lcd_pwm_used = <0>;
lcd_pwm_ch = <6>;
lcd_pwm_freq = <5000>;
lcd_pwm_pol = <1>;
lcd_frm = <1>;
lcd_gamma_en = <1>;
fb_buffer_num = <2>;
lcd_backlight = <100>;
lcd_fps = <60>;
lcd_dbi_te = <0>;
lcd_dbi_clk_mode = <0>;
lcd_gpio_0 = <&rtc_pio PL 7 GPIO_ACTIVE_LOW>;
status = "okay";
};
};

&spi2 {
pinctrl-0 = <&spi2_pins_default>;
pinctrl-1 = <&spi2_pins_sleep>;
pinctrl-names = "default", "sleep";
clock-frequency = <150000000>;
sunxi,spi-bus-mode = <SUNXI_SPI_BUS_MASTER>;
sunxi,spi-cs-mode = <SUNXI_SPI_CS_SOFT>;
status = "okay";

panel_st77916_spi2: slave@0 {
device_type = "spi-panel";
compatible = "allwinner,spi-panel";
reg = <0x0>;
spi-max-frequency = <150000000>;
spi-rx-bus-width = <4>;
spi-tx-bus-width = <4>;
lcd_used = <1>;
lcd_driver_name = "st77916_qspi";
lcd_if = <2>;
lcd_qspi_if = <2>;
lcd_data_speed_hz = <118153846>;
lcd_x = <360>;
lcd_y = <360>;
lcd_pixel_fmt = <10>;
lcd_dbi_fmt = <2>;
lcd_rgb_order = <0>;
lcd_width = <60>;
lcd_height = <60>;
lcd_pwm_used = <0>;
lcd_pwm_ch = <6>;
lcd_pwm_freq = <5000>;
lcd_pwm_pol = <1>;
lcd_frm = <1>;
lcd_gamma_en = <1>;
fb_buffer_num = <2>;
lcd_backlight = <100>;
lcd_fps = <60>;
lcd_dbi_te = <0>;
lcd_dbi_clk_mode = <0>;
lcd_gpio_0 = <&rtc_pio PL 6 GPIO_ACTIVE_LOW>;
status = "okay";
};
};

功能测试​

启动后可以执行 ls /dev 查看 framebuffer 节点。

image-20250417114946962

修改 LVGL​

在 platform/thirdparty/gui/lvgl-8/lv_examples/src/lv_conf.h 中将 LVGL 色深配置为 RGB565,并启用 RGB565 字节交换:

/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#define LV_COLOR_DEPTH 16

/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/
#define LV_COLOR_16_SWAP 1

image-20250417114845701

执行 make menuconfig,选择 Gui -> Littlevgl -> <*> lv_examples。

LVGL 示例需要编译两个版本,分别输出到 fb0 和 fb1:

mmo 是 Tina Linux SDK 中用于单独编译 OpenWrt 软件包的命令,-B 表示清理后重新编译。执行前需要在 SDK 根目录完成 source build/envsetup.sh 和 lunch。

  1. 保持 platform/thirdparty/gui/lvgl-8/lv_examples/src/lv_drv_conf.h 中 framebuffer 设备路径为默认的 /dev/fb0,执行 mmo lv_examples -B。编译完成后,立即将 out/.../openwrt/build_dir/target/lv_examples/src/lv_examples 复制到 SDK 输出目录之外,备份为 lv_examples_fb0;其中 ... 随板级配置而变化,可以通过 find out -path '*/build_dir/target/lv_examples/src/lv_examples' 查找实际路径。
  2. 在 lv_drv_conf.h 中将 /dev/fb0 修改为 /dev/fb1,再次执行 mmo lv_examples -B。将第二次生成的可执行文件备份为 lv_examples_fb1。
  3. 打包固件前,将 lv_examples_fb0 以 lv_examples 为文件名、将 lv_examples_fb1 以原文件名放入目标根文件系统的 /usr/bin,确保两个版本均被打包。不要直接连续执行两次 mmo,否则第二次编译会覆盖第一次的同名产物。

image-20250417114741300

执行 make 重新编译完整固件并烧录,确认固件中包含两个可执行文件。以下命令中的参数 1 表示运行 lv_demo_music。启动后,在目标板终端分别执行:

lv_examples 1
lv_examples_fb1 1

两块屏幕均正常显示且帧率符合预期,即为测试通过。