0.前言
? 在前面我們已經(jīng)學習了關于100ASK_V853-PRO編譯和燒寫,接下來就是在Tina SDK下去適配七寸RGB屏,購買鏈接為:https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-18944745104.11.669f1b7fE1ptyQ&id=611156659477
100ASK_V853-PRO開發(fā)板購買鏈接:100ASK_V853-PRO開發(fā)板
LCD_調試指南:https://tina.100ask.net/SdkModule/Linux_LCD_DevelopmentGuide-01/
Display_開發(fā)指南:https://tina.100ask.net/SdkModule/Linux_Display_DevelopmentGuide-01/
? 如果已經(jīng)使用我們的增加的補丁文件,默認啟動有Tina Linux的logo,同時還支持了lvgl示例和觸摸。可在開發(fā)板的串口終端上輸入lv_examples
,可以發(fā)現(xiàn)我們提供有5個lvgl示例。輸入lv_examples 0
,可運行第一個lvgl示例。
root@TinaLinux:/# lv_examples
lv_examples 0, is lv_demo_widgets
lv_examples 1, is lv_demo_music
lv_examples 2, is lv_demo_benchmark
lv_examples 3, is lv_demo_keypad_encoder
lv_examples 4, is lv_demo_stress
root@TinaLinux:/# lv_examples 0
wh=1024x600, vwh=1024x1200, bpp=32, rotated=0
Turn on double buffering.
Turn on 2d hardware acceleration.
Turn on 2d hardware acceleration rotate.
運行完成后可在七寸RGB屏上顯示LVGL V8的示例界面,同時支持觸摸控制示例。
1.適配七寸RGB屏的流程
? 由于Tina SDK中默認已經(jīng)支持RGB屏驅動,所以適配七寸RGB屏只注意以下幾個點:
? 1.修改設備樹
? 2.配置內核
? 3.修改Uboot配置
內核設備樹的位置:tina-v853-open/device/config/chips/v853/configs/100ask/board.dts
uboot設備樹的位置:tina-v853-open/device/config/chips/v853/configs/100ask/board.dts
修改內核配置:在tina的根目錄下執(zhí)行make kernel_menuconfig
修改uboot配置:進入uboot的根目錄tina-v853-open/brandy/brandy-2.0/u-boot-2018下執(zhí)行make menuconfig
內核驅動位置:tina-v853-open/kernel/linux-4.9/drivers/video/fbdev/sunxi/disp2/disp/lcd/default_panel.c
uboot驅動位置:
tina-v853-open/brandy/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/lcd/default_panel.c
2.檢查修改設備樹
在Tina根目錄下,輸入cd device/config/chips/v853/configs/100ask/
book@100ask:~/workspaces/tina-v853-open$ cd device/config/chips/v853/configs/100ask/
book@100ask:~/workspaces/tina-v853-open/device/config/chips/v853/configs/100ask$ vi board.dts
2.1 修改內核設備樹
修改 board.dts中的lcd0為:
&lcd0 {
/* part 1 */
lcd_used = <1>;
lcd_driver_name = "default_lcd";
lcd_backlight = <100>;
/* part 2 */
lcd_if = <0>;
lcd_hv_if = <0>;
/* part 3 */
lcd_x = <1024>;
lcd_y = <600>;
lcd_width = <154>;
lcd_height = <85>;
lcd_dclk_freq = <51>;
lcd_hbp = <140>;
lcd_ht = <1344>;
lcd_hspw = <20>;
lcd_vbp = <20>;
lcd_vt = <635>;
lcd_vspw = <3>;
lcd_pwm_used = <1>;
lcd_pwm_ch = <9>;
lcd_pwm_freq = <500>;
lcd_pwm_pol = <1>;
/* part 5 */
lcd_frm = <1>;
lcd_io_phase = <0x0000>;
lcd_gamma_en = <0>;
lcd_cmap_en = <0>;
lcd_hv_clk_phase = <0>;
lcd_hv_sync_polarity= <0>;
/* part 6 */
lcd_power = "vcc-lcd";
lcd_pin_power = "vcc-pd";
pinctrl-0 = <&rgb18_pins_a>;
pinctrl-1 = <&rgb18_pins_b>;
};
在&pio節(jié)點下增加rgb18_pins_a和rgb18_pins_b子節(jié)點,增加引腳復用功能
rgb18_pins_a: rgb18@0 {
allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5",
"PD6", "PD7", "PD8", "PD9", "PD10", "PD11",
"PD12", "PD13", "PD14", "PD15", "PD16", "PD17",
"PD18", "PD19", "PD20", "PD21";
allwinner,pname = "lcdd2", "lcdd3", "lcdd4", "lcdd5", "lcdd6", "lcdd7",
"lcdd10", "lcdd11", "lcdd12", "lcdd13", "lcdd14", "lcdd15",
"lcdd18", "lcdd19", "lcdd20", "lcdd21", "lcdd22", "lcdd23",
"lcdpclk", "lcdde", "lcdhsync", "lcdvsync";
allwinner,function = "lcd";
allwinner,muxsel = <2>;
allwinner,drive = <3>;
allwinner,pull = <0>;
};
rgb18_pins_b: rgb18@1 {
allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5",
"PD6", "PD7", "PD8", "PD9", "PD10", "PD11",
"PD12", "PD13", "PD14", "PD15", "PD16", "PD17",
"PD18", "PD19", "PD20", "PD21";
allwinner,pname = "lcdd2", "lcdd3", "lcdd4", "lcdd5", "lcdd6", "lcdd7",
"lcdd10", "lcdd11", "lcdd12", "lcdd13", "lcdd14", "lcdd15",
"lcdd18", "lcdd19", "lcdd20", "lcdd21", "lcdd22", "lcdd23",
"lcdpclk", "lcdde", "lcdhsync", "lcdvsync";
allwinner,function = "io_disabled";
allwinner,muxsel = <0xf>;
allwinner,drive = <3>;
allwinner,pull = <0>;
};
2.2 修改uboot設備樹
在同一目錄下修改uboot設備樹
book@100ask:~/workspaces/tina-v853-open/device/config/chips/v853/configs/100ask$ vi uboot-board.dts
&lcd0 {
lcd_used = <1>;
lcd_driver_name = "default_lcd";
lcd_backlight = <100>;
lcd_if = <0>;
lcd_hv_if = <0>;
lcd_x = <1024>;
lcd_y = <600>;
lcd_width = <154>;
lcd_height = <85>;
lcd_dclk_freq = <51>;
lcd_hbp = <140>;
lcd_ht = <1344>;
lcd_hspw = <20>;
lcd_vbp = <20>;
lcd_vt = <635>;
lcd_vspw = <3>;
lcd_pwm_used = <1>;
lcd_pwm_ch = <9>;
lcd_pwm_freq = <500>;
lcd_pwm_pol = <1>;
lcd_frm = <1>;
lcd_io_phase = <0x0000>;
lcd_gamma_en = <0>;
lcd_cmap_en = <0>;
lcd_hv_clk_phase = <0>;
lcd_hv_sync_polarity= <0>;
lcd_power = "vcc-lcd";
lcd_pin_power = "vcc-pd";
pinctrl-0 = <&rgb18_pins_a>;
pinctrl-1 = <&rgb18_pins_b>;
};
在&pio節(jié)點下增加rgb18_pins_a和rgb18_pins_b子節(jié)點,增加引腳復用功能
rgb18_pins_a: rgb18@0 {
allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5",
"PD6", "PD7", "PD8", "PD9", "PD10", "PD11",
"PD12", "PD13", "PD14", "PD15", "PD16", "PD17",
"PD18", "PD19", "PD20", "PD21";
allwinner,pname = "lcdd2", "lcdd3", "lcdd4", "lcdd5", "lcdd6", "lcdd7",
"lcdd10", "lcdd11", "lcdd12", "lcdd13", "lcdd14", "lcdd15",
"lcdd18", "lcdd19", "lcdd20", "lcdd21", "lcdd22", "lcdd23",
"lcdpclk", "lcdde", "lcdhsync", "lcdvsync";
allwinner,function = "lcd";
allwinner,muxsel = <2>;
allwinner,drive = <3>;
allwinner,pull = <0>;
};
rgb18_pins_b: rgb18@1 {
allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5",
"PD6", "PD7", "PD8", "PD9", "PD10", "PD11",
"PD12", "PD13", "PD14", "PD15", "PD16", "PD17",
"PD18", "PD19", "PD20", "PD21";
allwinner,pname = "lcdd2", "lcdd3", "lcdd4", "lcdd5", "lcdd6", "lcdd7",
"lcdd10", "lcdd11", "lcdd12", "lcdd13", "lcdd14", "lcdd15",
"lcdd18", "lcdd19", "lcdd20", "lcdd21", "lcdd22", "lcdd23",
"lcdpclk", "lcdde", "lcdhsync", "lcdvsync";
allwinner,function = "io_disabled";
allwinner,muxsel = <0xf>;
allwinner,drive = <3>;
allwinner,pull = <0>;
};
3.檢查修改內核配置和uboot配置
3.1 修改內核配置
在Tina的根目錄下輸入make kernel_menuconfig
book@100ask:~/workspaces/tina-v853-open$ make kernel_menuconfig
通過方向鍵,選擇并進入如下目錄,輸入Y開啟DISP Driver Support
→ Device Drivers
→ Graphics support
→ Frame buffer Devices
→ Video support for sunxi
<*> DISP Driver Support(sunxi-disp2)
如下圖所示:
選中后,通過方向鍵選擇Save,按下回車。
按下后會提示您是否確認保存?zhèn)浞?,選擇OK
此時我們所修改的配置將保存在tina-v853-open/kernel/linux-4.9/.config文件中,繼續(xù)按下回車退出。
保存完成后,通過方向鍵選擇Exit,一直選擇Exit,直到退出內核配置界面
3.2 修改uboot配置
想要修改uboot,需要進入tina-v853-open/brandy/brandy-2.0/u-boot-2018目錄下,執(zhí)行make menuconfig
book@100ask:~/workspaces/tina-v853-open$ cd brandy/brandy-2.0/u-boot-2018/
book@100ask:~/workspaces/tina-v853-open/brandy/brandy-2.0/u-boot-2018$ make menuconfig
通過方向鍵進入
→ Device Drivers
→ Graphics support
[*] DISP Driver Support(sunxi-disp2) --->
如下圖所示:
選中后,通過方向鍵選擇Save,按下回車。
按下后會提示您是否確認保存?zhèn)浞?,選擇OK
此時我們所修改的配置將保存在tina-v853-open/brandy/brandy-2.0/u-boot-2018/.config
文件中,繼續(xù)按下回車退出。
保存完成后,通過方向鍵選擇Exit,一直選擇Exit,直到退出uboot配置界面
4.七寸RGB屏驅動程序
內核和uboot中的驅動程序都是同一套,可以復用的。由于我們選中了sunxi-disp2,都會默認去編譯default_panel.c驅動程序。
內核驅動位置:tina-v853-open/kernel/linux-4.9/drivers/video/fbdev/sunxi/disp2/disp/lcd/default_panel.c
uboot驅動位置:
tina-v853-open/brandy/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/lcd/default_panel.c
/*
* drivers/video/sunxi/disp2/disp/lcd/default_panel.c
*
* Copyright (c) 2007-2019 Allwinnertech Co., Ltd.
* Author: zhengxiaobin
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include "default_panel.h"
static void LCD_power_on(u32 sel);
static void LCD_power_off(u32 sel);
static void LCD_bl_open(u32 sel);
static void LCD_bl_close(u32 sel);
static void LCD_panel_init(u32 sel);
static void LCD_panel_exit(u32 sel);
static void LCD_cfg_panel_info(panel_extend_para * info)
{
u32 i = 0, j=0;
u32 items;
u8 lcd_gamma_tbl[][2] =
{
//{input value, corrected value}
{0, 0},
{15, 15},
{30, 30},
{45, 45},
{60, 60},
{75, 75},
{90, 90},
{105, 105},
{120, 120},
{135, 135},
{150, 150},
{165, 165},
{180, 180},
{195, 195},
{210, 210},
{225, 225},
{240, 240},
{255, 255},
};
u32 lcd_cmap_tbl[2][3][4] = {
{
{LCD_CMAP_G0,LCD_CMAP_B1,LCD_CMAP_G2,LCD_CMAP_B3},
{LCD_CMAP_B0,LCD_CMAP_R1,LCD_CMAP_B2,LCD_CMAP_R3},
{LCD_CMAP_R0,LCD_CMAP_G1,LCD_CMAP_R2,LCD_CMAP_G3},
},
{
{LCD_CMAP_B3,LCD_CMAP_G2,LCD_CMAP_B1,LCD_CMAP_G0},
{LCD_CMAP_R3,LCD_CMAP_B2,LCD_CMAP_R1,LCD_CMAP_B0},
{LCD_CMAP_G3,LCD_CMAP_R2,LCD_CMAP_G1,LCD_CMAP_R0},
},
};
items = sizeof(lcd_gamma_tbl)/2;
for (i=0; ilcd_gamma_tbl[lcd_gamma_tbl[i][0] + j] = (value<<16) + (value<<8) + value;
}
}
info->lcd_gamma_tbl[255] = (lcd_gamma_tbl[items-1][1]<<16) + (lcd_gamma_tbl[items-1][1]<<8) + lcd_gamma_tbl[items-1][1];
memcpy(info->lcd_cmap_tbl, lcd_cmap_tbl, sizeof(lcd_cmap_tbl));
}
static s32 LCD_open_flow(u32 sel)
{
LCD_OPEN_FUNC(sel, LCD_power_on, 30); //open lcd power, and delay 50ms
LCD_OPEN_FUNC(sel, LCD_panel_init, 50); //open lcd power, than delay 200ms
LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 100); //open lcd controller, and delay 100ms
LCD_OPEN_FUNC(sel, LCD_bl_open, 0); //open lcd backlight, and delay 0ms
return 0;
}
static s32 LCD_close_flow(u32 sel)
{
LCD_CLOSE_FUNC(sel, LCD_bl_close, 0); //close lcd backlight, and delay 0ms
LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 0); //close lcd controller, and delay 0ms
LCD_CLOSE_FUNC(sel, LCD_panel_exit, 200); //open lcd power, than delay 200ms
LCD_CLOSE_FUNC(sel, LCD_power_off, 500); //close lcd power, and delay 500ms
return 0;
}
static void LCD_power_on(u32 sel)
{
sunxi_lcd_power_enable(sel, 0);//config lcd_power pin to open lcd power0
sunxi_lcd_pin_cfg(sel, 1);
}
static void LCD_power_off(u32 sel)
{
sunxi_lcd_pin_cfg(sel, 0);
sunxi_lcd_power_disable(sel, 0);//config lcd_power pin to close lcd power0
}
static void LCD_bl_open(u32 sel)
{
sunxi_lcd_pwm_enable(sel);
sunxi_lcd_backlight_enable(sel);//config lcd_bl_en pin to open lcd backlight
}
static void LCD_bl_close(u32 sel)
{
sunxi_lcd_backlight_disable(sel);//config lcd_bl_en pin to close lcd backlight
sunxi_lcd_pwm_disable(sel);
}
static void LCD_panel_init(u32 sel)
{
return;
}
static void LCD_panel_exit(u32 sel)
{
return ;
}
//sel: 0:lcd0; 1:lcd1
static s32 LCD_user_defined_func(u32 sel, u32 para1, u32 para2, u32 para3)
{
return 0;
}
__lcd_panel_t default_panel = {
/* panel driver name, must mach the name of lcd_drv_name in sys_config.fex */
.name = "default_lcd",
.func = {
.cfg_panel_info = LCD_cfg_panel_info,
.cfg_open_flow = LCD_open_flow,
.cfg_close_flow = LCD_close_flow,
.lcd_user_defined_func = LCD_user_defined_func,
},
};
;>@allwinnertech.com>
5.開啟觸摸功能
5.1修改設備樹
修改設備樹中的twi2節(jié)點下增加ctp觸摸子節(jié)點
&twi2 {
ctp@14 {
compatible = "allwinner,gsl3680";
device_type = "ctp";
reg = <0x14>;
status = "okay";
ctp_name = "gt9xxnew_ts";
ctp_twi_id = <0x2>;
ctp_twi_addr = <0x14>;
ctp_screen_max_x = <0x400>;
ctp_screen_max_y = <0x258>;
ctp_revert_x_flag = <0x0>;
ctp_revert_y_flag = <0x0>;
ctp_exchange_x_y_flag = <0x0>;
ctp_int_port = <&pio PH 7 6 1 3 0xffffffff>;
ctp_wakeup = <&pio PH 8 1 1 3 0xffffffff>;
//ctp-supply = ;
//ctp_power_ldo = ;
//ctp_power_ldo_vol = <3300>;
};
};
并在lcd0節(jié)點后面使能twi2節(jié)點和引腳復用功能。
&twi2 {
clock-frequency = <400000>;
pinctrl-0 = <&twi2_pins_a>;
pinctrl-1 = <&twi2_pins_b>;
pinctrl-names = "default", "sleep";
/* For stability and backwards compatibility, we recommend setting ‘twi_drv_used’ to 0 */
twi_drv_used = <0>;
twi-supply = ;
twi_pkt_interval = <0>;
//status = "disabled";
status = "okay";
};
5.2 修改內核配置
? 在Tina的根目錄下執(zhí)行make kernel_menuconfig
book@100ask:~/workspaces/tina-v853-open$ make kernel_menuconfig
進入下面的目錄輸入Y選中gt9xxnew touchscreen driver觸摸驅動
→ Device Drivers
→ Input device support
→ Touchscreens
<*> gt9xxnew touchscreen driver
如下圖所示
保存并退出內核配置界面
6.打開lvgl示例程序
在Tina的根目錄下,輸入make menuconfig
book@100ask:~/workspaces/tina-v853-open$ make menuconfig
進入如下目錄,并輸入Y選中l(wèi)v_examples
> Gui
> Littlevgl
<*> lv_examples................................. lvgl examples use lvgl-8.1.0
選中后保存并退出配置界面。
7.編譯并打包生成鏡像
由于我們第一次已經(jīng)完整編譯了系統(tǒng),現(xiàn)在修改后編譯系統(tǒng)的時間就不會特別長,具體時間取決于CPU的性能,在Tina的根目錄下執(zhí)行make -jN
,其中N為線程數(shù),增加線程數(shù)提高編譯速度。
book@100ask:~/workspaces/tina-v853-open$ make -j4
等待編譯完成后,輸入pack,打包生成鏡像
book@100ask:~/workspaces/tina-v853-open$ pack
打包生成鏡像后可以在tina-v853-open/out/v853/100ask/openwrt/目錄下找到新的鏡像文件
v853_linux_100ask_uart0.img,將該文件拷貝到windows電腦下備用。
8.燒錄新鏡像啟動開發(fā)板
使用全志PhoenixSuit燒寫工具進行新鏡像的燒寫,具體方法可以參見《100ASK_V853-PRO 環(huán)境配置及編譯燒寫》。
注意:需要在上電前連接七寸RGB屏,同時連接排線時需要注意排線的線序是否正確。
連接好七寸屏,再連接電源線和兩條Type-C數(shù)據(jù)線,將開關撥向電源接口的方向即可上電啟動開發(fā)板,在燒寫新鏡像完成后通過串口工具打開開發(fā)板的串口終端,進入Tina Linux的控制臺界面,輸入lv_examples 0
,即可在七寸RGB屏上顯示出LVGL的DEMO程序。
root@TinaLinux:/# lv_examples 0
wh=1024x600, vwh=1024x1200, bpp=32, rotated=0
Turn on double buffering.
Turn on 2d hardware acceleration.
Turn on 2d hardware acceleration rotate.
-
嵌入式
+關注
關注
5059文章
18973瀏覽量
302033 -
Linux
+關注
關注
87文章
11207瀏覽量
208717 -
AI
+關注
關注
87文章
29806瀏覽量
268103 -
開發(fā)板
+關注
關注
25文章
4896瀏覽量
97059 -
RGB屏
+關注
關注
0文章
9瀏覽量
1156
發(fā)布評論請先 登錄
相關推薦
評論