最近入手了一块微雪的幸狐RV1106微型Linux开发板,具体型号为Luckfox Pico Max,这是一款集成ARM Cortex-A7/RISC-V MCU/NPU/ISP等处理器。
根据微雪官网的wiki入门指导测试了一下,功能一切正常,感觉很nice,这款板子真的是麻雀虽小五脏俱全呀。
正好手头上有一块SPI接口的1.44寸tftlcd,分辨率是128*128的,驱动器IC是ST7735。微雪官方的指导文档里有一个控制器IC为ST7789的1.3寸LCD,所以我想应该可以参考这部分将我的1.44寸LCD驱动起来。
开发板及LCD如下图:
引脚连接如下:
LCD RV1106
VCC --- 39(VSYS)
GND --- 38(GND)
LED --- 17(GPIO2_B0_D)
CLK --- 14(GPIO1_C1_D)
SDI --- 15(GPIO1_C2_D)
RS --- 11(GPIO2_B1_D)
RST --- 16(GPIO1_C3_D)
CS --- 12(GPIO1_C0_D)
参考微雪的参考文档修改了设备树、配置文件开启了相关驱动支持。如下:
设备树:rv1106g-luckfox-pico-pro-max.dts
/ {model = "Luckfox Pico Max";compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1106";/*LCD_BL*/gpio2pb0:gpio2pb0 {compatible = "regulator-fixed";pinctrl-names = "default";pinctrl-0 = <&gpio2_pb0>;regulator-name = "gpio2_pb0";regulator-always-on;};/*LCD_DC*/gpio2pb1:gpio2pb1 {compatible = "regulator-fixed";pinctrl-names = "default";pinctrl-0 = <&gpio2_pb1>;regulator-name = "gpio2_pb1";regulator-always-on;};/*LCD_RES*/gpio1pc3:gpio1pc3 {compatible = "regulator-fixed";pinctrl-names = "default";pinctrl-0 = <&gpio1_pc3>;regulator-name = "gpio1_pc3";regulator-always-on;};
};/**********GPIO**********/
&pinctrl {/*LCD_BL*/gpio2-pb0 {gpio2_pb0:gpio2-pb0 {rockchip,pins = <2 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>;};};/*LCD_DC*/gpio2-pb1 {gpio2_pb1:gpio2-pb1 {rockchip,pins = <2 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>;};};/*LCD_RES*/gpio1-pc3 {gpio1_pc3:gpio1-pc3 {rockchip,pins = <1 RK_PC3 RK_FUNC_GPIO &pcfg_pull_none>;};};
};&spi0 {status = "okay";pinctrl-names = "default";pinctrl-0 = <&spi0m0_cs0 &spi0m0_pins>; st7735r@0{ status = "okay";compatible = "sitronix,st7735r"; reg = <0>; spi-max-frequency = <48000000>; fps = <30>;buswidth = <8>;debug = <0x7>;led-gpios = <&gpio2 RK_PB0 GPIO_ACTIVE_LOW>;//BLdc = <&gpio2 RK_PB1 GPIO_ACTIVE_HIGH>; //DCreset = <&gpio1 RK_PC3 GPIO_ACTIVE_LOW>; //RES};
};&pinctrl {spi0 {/omit-if-no-ref/spi0m0_pins: spi0m0-pins {rockchip,pins =/* spi0_clk_m0 */<1 RK_PC1 4 &pcfg_pull_none>,/* spie_miso_m0 */// <1 RK_PC3 6 &pcfg_pull_none>,/* spi_mosi_m0 */<1 RK_PC2 6 &pcfg_pull_none>;};};
};
配置文件:luckfox_rv1106_linux_defconfig
在末尾添加如下
CONFIG_FB_TFT_ST7735R=y
CONFIG_SPI_MASTER=y
CONFIG_FB=y
重新编译kernel后下载至开发板中,启动开发板后/dev里生成了fb0设备,如下:
这说明设备已经添加成功了。
通过cat /dev/urandom > /dev/fb0测试一下花屏功能,发现屏幕没有任何反应,仔细检查发现屏幕背光并没有点亮,万用表测量背光控制引脚电平为0v。这里我怀疑就是背光的问题,所以将LCD的背光控制引脚直接连接至3.3V引脚上,屏幕出现了花屏。又通过cat /dev/zero > /dev/fb0测试一下清屏功能也是正常,这就说明触摸屏的驱动应该是没有问题了,现在需要解决的是背光引脚控制电平的问题了。
想到之前使用其他linux板子驱动RGB触摸屏时都有一个backlight背光驱动的,我想应该也可以参考那个修改一下设备树来实现背光引脚的驱动。所以在kernel代码里全局搜索backlight,发现了好多相关的设备树配置方式,所以参考它们修改了一下rv1106g-luckfox-pico-pro-max.dts,如下:
/ {model = "Luckfox Pico Max";compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1106";/*LCD_BL*/// gpio2pb0:gpio2pb0 {// compatible = "regulator-fixed";// pinctrl-names = "default";// pinctrl-0 = <&gpio2_pb0>;// regulator-name = "gpio2_pb0";// regulator-always-on;// };backlight:backlight{ compatible = "gpio-backlight";pinctrl-names = "default";pinctrl-0 = <&gpio2_pb0>;gpios = <&gpio2 RK_PB0 GPIO_ACTIVE_HIGH>;default-on;};/*LCD_DC*/gpio2pb1:gpio2pb1 {compatible = "regulator-fixed";pinctrl-names = "default";pinctrl-0 = <&gpio2_pb1>;regulator-name = "gpio2_pb1";regulator-always-on;};/*LCD_RES*/gpio1pc3:gpio1pc3 {compatible = "regulator-fixed";pinctrl-names = "default";pinctrl-0 = <&gpio1_pc3>;regulator-name = "gpio1_pc3";regulator-always-on;};
};/**********GPIO**********/
&pinctrl {/*LCD_BL*/gpio2-pb0 {gpio2_pb0:gpio2-pb0 {rockchip,pins = <2 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>;};};/*LCD_DC*/gpio2-pb1 {gpio2_pb1:gpio2-pb1 {rockchip,pins = <2 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>;};};/*LCD_RES*/gpio1-pc3 {gpio1_pc3:gpio1-pc3 {rockchip,pins = <1 RK_PC3 RK_FUNC_GPIO &pcfg_pull_none>;};};
};&spi0 {status = "okay";pinctrl-names = "default";pinctrl-0 = <&spi0m0_cs0 &spi0m0_pins>; st7735r@0{ status = "okay";compatible = "sitronix,st7735r"; reg = <0>; spi-max-frequency = <48000000>; fps = <30>;buswidth = <8>;debug = <0x7>;led-gpios ; // = <&gpio2 RK_PB0 GPIO_ACTIVE_HIGH>;//BLdc = <&gpio2 RK_PB1 GPIO_ACTIVE_HIGH>; //DCreset = <&gpio1 RK_PC3 GPIO_ACTIVE_LOW>; //RESbacklight = &backlight;};
};&pinctrl {spi0 {/omit-if-no-ref/spi0m0_pins: spi0m0-pins {rockchip,pins =/* spi0_clk_m0 */<1 RK_PC1 4 &pcfg_pull_none>,/* spie_miso_m0 */// <1 RK_PC3 6 &pcfg_pull_none>,/* spi_mosi_m0 */<1 RK_PC2 6 &pcfg_pull_none>;};};
};
再次重新编译kernel后下载至开发板后测试,发现还是和之前一样的情况,但是/sys/class/里已经又backlight文件了,说明backlight驱动是添加成功了,那问题应该是出现引脚控制上了,全局搜索gpio-backlight,发现这个在gpio_backlight.c文件里出现了,但是这个文件并没有被编译。
好了,出现这个问题的原因应该是找到,那就启用这个gpio_backlight的功能吧,在配置文件luckfox_rv1106_linux_defconfig末尾处添加
CONFIG_BACKLIGHT_GPIO=y
再次编译kernel后下载进开发板,发现LCD可以正常点亮,测试花屏和清屏功能都正常。到此我手上的1.44寸LCD驱动是调试完成了。可以通过如下命令控制背光打开和关闭。
# 关闭
echo 0 > /sys/class/backlight/backlight/brightness
# 打开
echo 1 > /sys/class/backlight/backlight/brightness
测试视频