我其实前面从没有接触过Linux开发,这次是需要使用D1s开发一套HMI,硬件方案参考了RDC2022纪念版demo板的设计,没办法,只能硬着头皮自己移植试试,现在是所有代码存在SDNAND上,已经成功点亮了RGB666 800*480显示屏,修改了debug串口。在此做一下记录。
请注意,由于我完全不懂Linux,都是在网上找的教程慢慢试出来的,因此很有可能有问题,请自行检查是否正确。也希望各位前辈多指正。
一、准备工作编译tina-linux
1.1、开发环境
宿主机:win11 wsl Ubuntu18.04
开发IDE:VSCode
repo操作:
1、撤销分支的所有修改:repo forall -vc "git reset --hard"
2、删除当前分支:
3、创建一个分支:repo start 分支名 --all
1.2、开发前期准备
1、进入工程目录
2、source build/envsetup.sh # 获取 Tina 环境变量
3、lunch # 载入方案列表,选择方案
4、选择 3
5、make -j12 &&pack
二、,修改固件存储位置
2.1、修改tina-d1-h/device/config/chips/d1s/configs/nezha/sys_config.fex
修改前:
[target]
boot_clock = 720
storage_type = 4
nand_use_ubi = 1
修改后:
[target]
boot_clock = 720
storage_type = 0 //这里改成1和改成0好像都可以,暂不清楚具体区别
nand_use_ubi = 1
2.2、修改/tina-d1-h/device/config/chips/d1s/configs/nezha/uboot-board.dts
修改前:
&card0_boot_para { /* Avoid dtc compiling warnings. @TODO: Developer should modify this to the actual value */
/* reg = <0x0 0x2 0x0 0x0>; [> Avoid dtc compiling warnings. @TODO: Developer should modify this to the actual value <] */
device_type = "card0_boot_para";
card_ctrl = <0x0>;
card_high_speed = <0x1>;
card_line = <0x4>;
/*
pinctrl-0 = <&sdc0_pins_a>;
*/
};
修改后
&card0_boot_para { /* Avoid dtc compiling warnings. @TODO: Developer should modify this to the actual value */
/* reg = <0x0 0x2 0x0 0x0>; [> Avoid dtc compiling warnings. @TODO: Developer should modify this to the actual value <] */
device_type = "card0_boot_para";
card_ctrl = <0x0>;
card_high_speed = <0x1>;
card_line = <0x4>;
pinctrl-0 = <&sdc0_pins_a>; //取消这段代码的注释
};
2.3、修改tina-d1-h/device/config/chips/d1s/configs/nezha/linux-5.4/board.dts
修改前:
&sdc0 {
bus-width = <4>;
cd-gpios = <&pio PF 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
/*non-removable;*/
/*broken-cd;*/
/*cd-inverted;*/
/*data3-detect;*/
/*card-pwr-gpios = <&pio PH 14 1 1 2 0xffffffff>;*/
cd-used-24M;
cap-sd-highspeed;
/*sd-uhs-sdr50;*/
/*sd-uhs-ddr50;*/
/*sd-uhs-sdr104;*/
no-sdio;
no-mmc;
sunxi-power-save-mode;
/*sunxi-dis-signal-vol-sw;*/
max-frequency = <150000000>;
ctl-spec-caps = <0x8>;
/*vmmc-supply = <®_dcdc1>;*/
/*vqmmc33sw-supply = <®_dcdc1>;*/
/*vdmmc33sw-supply = <®_dcdc1>;*/
/*vqmmc18sw-supply = <®_eldo1>;*/
/*vdmmc18sw-supply = <®_eldo1>;*/
status = "okay";
};
修改后:
&sdc0 {
non-removable;
bus-width = <4>;
mmc-ddr-1_8v;
mmc-hs200-1_8v;
no-sdio;
// no-mmc; //此处为什么要注释掉,是干什么的,不太清楚
ctl-spec-caps = <0x8>;
cap-mmc-highspeed;
sunxi-power-save-mode;
sunxi-dis-signal-vol-sw;
mmc-bootpart-noacc;
max-frequency = <150000000>;
status = "okay";
};
2.4、修改tina_d1_open_v1.0.1\lichee\brandy-2.0\u-boot-2018\drivers\sunxi_flash\mmc\sdmmc.c
修改前
int sunxi_sprite_mmc_probe(void)
{
#ifndef CONFIG_MACH_SUN50IW11
return sdmmc_init_for_sprite(0, 2);
#else
int workmode = uboot_spare_head.boot_data.work_mode;
if (workmode == WORK_MODE_CARD_PRODUCT)
return -1;
else
return sdmmc_init_for_sprite(0, 0);
#endif
}
修改后:
int sunxi_sprite_mmc_probe(void)
{
#ifndef CONFIG_MACH_SUN50IW11
return sdmmc_init_for_sprite(0, 0); //此处改为0,强制从SD0开始启动
#else
int workmode = uboot_spare_head.boot_data.work_mode;
if (workmode == WORK_MODE_CARD_PRODUCT)
return -1;
else
return sdmmc_init_for_sprite(0, 0);
#endif
}
三、修改串口
3.1、修改tina-d1-h/device/config/chips/d1s/configs/nezha/sys_config.fex
修改前:
[uart_para]
uart_debug_port = 3
uart_debug_tx = port:PB6<7><1><default><default>
uart_debug_rx = port:PB7<7><1><default><default>
修改后:
[uart_para]
uart_debug_port = 3
uart_debug_tx = port:PG8<5><1><default><default>
uart_debug_rx = port:PG9<5><1><default><default>
其中PG8后面的<5>的数字需要查阅数据手册查看相应串口的功能编号(Function5 )
3.2、修改tina-d1-h/lichee/brandy-2.0/u-boot-2018/configs/sun20iw1p1_defconfig
在最后添加
CONFIG_SPECIFY_CONSOLE_INDEX=y
CONFIG_CONS_INDEX=4 #说明:这里是UART3+1 = 4 串口号+1
3.3、修改tina-d1-h/device/config/chips/d1s/configs/nezha/board.dts
修改前:
&uart3 {
compatible = "allwinner,sun20iw1-dsp-uart";
pinctrl-names = "default", "sleep";
pinctrl-0 = <&uart3_pins_a>;
pinctrl-1 = <&uart3_pins_a>;
status = "disabled";
};
修改后
&uart3 {
compatible = "allwinner,sun20iw1-dsp-uart";
pinctrl-names = "default", "sleep";
pinctrl-0 = <&uart3_pins_a>;
pinctrl-1 = <&uart3_pins_a>;
status = "okay";
};
3.4、修改tina-d1-h/device/config/chips/d1s/configs/default/env.cfg
修改前:
#kernel command arguments
earlyprintk=sunxi-uart,0x02500C00
initcall_debug=0
console=ttyS3,115200
修改后:
#kernel command arguments
earlyprintk=sunxi-uart,0x02500C00 //此处的地址徐娅根据实际串口外设地址修改
initcall_debug=0
console=ttyS3,115200 //此处的ttyS3需要根据相应的实际串口修改,如串口3则是ttyS3
此时使用全志下载工具下载固件应该可以在相应的串口(波特率115200)读到烧写log,并能成功下载,然后重启。
四、修改RGB666显示屏
4.1、修改tina-d1-h/device/config/chips/d1s/configs/nezha/uboot-board.dts和tina-d1-h/device/config/chips/d1s/configs/nezha/board.dts
uboot_board.dts修改的是uboot的显示设备树
board.dts修改的是Linux的设备树
修改前:
&lcd0 {
lcd_used = <1>;
lcd_driver_name = "tft08006";
lcd_backlight = <100>;
lcd_if = <4>;
lcd_x = <800>;
lcd_y = <1280>;
lcd_width = <52>;
lcd_height = <52>;
lcd_dclk_freq = <70>;
lcd_pwm_used = <1>;
lcd_pwm_ch = <7>;
lcd_pwm_freq = <1000>;
lcd_pwm_pol = <0>;
lcd_pwm_max_limit = <255>;
lcd_hbp = <32>;
lcd_ht = <868>;
lcd_hspw = <4>;
lcd_vbp = <12>;
lcd_vt = <1311>;
lcd_vspw = <4>;
lcd_dsi_if = <0>;
lcd_dsi_lane = <4>;
lcd_lvds_if = <0>;
lcd_lvds_colordepth = <0>;
lcd_lvds_mode = <0>;
lcd_frm = <0>;
lcd_hv_clk_phase = <0>;
lcd_hv_sync_polarity= <0>;
lcd_io_phase = <0x0000>;
lcd_gamma_en = <0>;
lcd_bright_curve_en = <0>;
lcd_cmap_en = <0>;
lcd_fsync_en = <0>;
lcd_fsync_act_time = <1000>;
lcd_fsync_dis_time = <1000>;
lcd_fsync_pol = <0>;
deu_mode = <0>;
lcdgamma4iep = <22>;
smart_color = <90>;
lcd_gpio_0 = <&pio PD 20 GPIO_ACTIVE_HIGH>;
pinctrl-0 = <&dsi4lane_pins_a>;
pinctrl-1 = <&dsi4lane_pins_b>;
修改后:
&lcd0 {
lcd_used = <1>;
lcd_driver_name = "default_lcd"; // 使用 default_lcd 驱动
lcd_if = <0>; // 0:rgb 4:dsi
// Part 1
lcd_x = <800>; // 宽度
lcd_y = <480>; // 高度
lcd_width = <108>; // 屏幕物理宽度,单位 mm
lcd_height = <65>; // 屏幕物理高度,单位 mm
// Part 2
lcd_pwm_used = <1>; // 启用背光 PWM
lcd_pwm_ch = <9>; // 使用 PWM 通道 9
lcd_pwm_freq = <50000>; // PWM 频率,单位 Hz
lcd_pwm_pol = <0>; // 背光 PWM 的极性
lcd_pwm_max_limit = <255>; // 背光 PWM 的最大值(<=255)
// Part 3
lcd_dclk_freq = <24>; // 屏幕时钟,单位 MHz
lcd_ht = <816>; // hsync total cycle(pixel)
lcd_hbp = <12>; // hsync back porch(pixel) + hsync plus width(pixel);
lcd_hspw = <4>; // hsync plus width(pixel)
lcd_vt = <496>; // vsync total cycle(line)
lcd_vbp = <12>; // vsync back porch(line) + vysnc plus width(line)
lcd_vspw = <4>; // vsync plus width(pixel)
// Part 4
lcd_lvds_if = <0>;
lcd_lvds_colordepth = <1>;
lcd_lvds_mode = <0>;
lcd_frm = <0>; // 0:关闭; 1:启用rgb666抖动; 2:启用rgb656抖动
lcd_io_phase = <0x0000>;
lcd_gamma_en = <0>;
lcd_bright_curve_en = <0>;
lcd_cmap_en = <0>;
deu_mode = <0>;
lcdgamma4iep = <22>;
smart_color = <90>;
// Part 5
pinctrl-0 = <&rgb18_pins_a>;
pinctrl-1 = <&rgb18_pins_b>;
}
这部分参数需要根据屏幕参数修改。此时修改完成后即可点亮显示屏
使用echo 8 > /sys/class/disp/disp/attr/colorbar可以显示如下图来判断是否正常显示,请忽略板子上的条线,我之前调试的时候一按复位键就会导致板子上的串口(板载CH340的USB口)断电重启,电脑上的串口调试助手也会掉线,我就干脆拆了芯片直接外接USB转串口芯片了。
五、参考:
编译 Tina Linux - D1s (aw-ol.com)
Tina Linux 存储介质切换:eMMC,SPI NAND,SPI NOR,SD Card,SD NAND | 全志在线开发者论坛 (aw-ol.com)
因为不喜欢插拔TF卡,D1直接用PhoenixSuit烧录TF(SDNAND) / 全志 SOC / WhyCan Forum(哇酷开发者社区)
基于全志D1-H 芯片与 Tina Linux 框架下的 LCD 屏幕适配_lcd_hbp-CSDN博客