@lumen 讯为的MIPI屏 淘宝有卖的三四百吧
https://m.tb.cn/h.fqYJmck?tk=40Pf2hVcPMg
yaoxiaoyao 发布的帖子
-
回复: D1移植讯为7寸MIPI屏
-
linuxfb屏幕旋转90度
前言
事情是这样的,在开发板上使用Qt来做一些界面开发,但是我们是用的屏幕是800*1280的屏幕,也就是横向打点,就是说宽比长要大,做界面的话不太好看,所以在不改变驱动和设备树的情况下,在应用层实现屏幕旋转也能满足我们的需求。
由于开发板上面没有显卡,像openGL、EGLFS这种来实现屏幕旋转也不现实,所以最终还是只能使用Linuxfb。但是Qt5的Linuxfb不支持旋转,所以需要拿到QT Linuxfb的源码自己添加一些参数就能实现了。
网上找了一下,只找到了一个5.4的patch,直接用用不了,所以就要只能自己来改源码,
这里用的是buildroot来构建Qt系统的,下面介绍如何获取并修改源码,如果不想修改的可以直接复制补丁文件,生成patch,打patch。一、源码获取
在buildroot构建系统中,有一个dl目录,存放的都是各种源码,其中QT的源码就放在里面。
我们将源码拷贝一份,创建git仓库,使用git进行打补丁。修改后,生成pach,将pach打入源码中即可。二、修改源码
<font color=#999AAA >代码如下:
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen .cpp index cb8962d4..9c89a4a3 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -287,7 +287,7 @@ static void blankScreen(int fd, bool on) } QLinuxFbScreen::QLinuxFbScreen(const QStringList &args) - : mArgs(args), mFbFd(-1), mTtyFd(-1), mBlitter(0) + : mArgs(args), mFbFd(-1), mTtyFd(-1), mBlitter(0), mRotation(90) { mMmap.data = 0; } @@ -310,9 +310,10 @@ bool QLinuxFbScreen::initialize() { QRegularExpression ttyRx(QLatin1String("tty=(.*)")); QRegularExpression fbRx(QLatin1String("fb=(.*)")); - QRegularExpression mmSizeRx(QLatin1String("mmsize=(\\d+)x(\\d+)")); + QRegularExpression mmSizeRx(QLatin1String("mmsize=(\\d+)x(\\d+)")); QRegularExpression sizeRx(QLatin1String("size=(\\d+)x(\\d+)")); QRegularExpression offsetRx(QLatin1String("offset=(\\d+)x(\\d+)")); + QRegularExpression rotationRx(QLatin1String("rotation=(0|90|180|270)")); QString fbDevice, ttyDevice; QSize userMmSize; @@ -334,6 +335,8 @@ bool QLinuxFbScreen::initialize() ttyDevice = match.captured(1); else if (arg.contains(fbRx, &match)) fbDevice = match.captured(1); + else if (arg.contains(rotationRx, &match)) + mRotation = match.captured(1).toInt(); } if (fbDevice.isEmpty()) { @@ -372,9 +375,17 @@ bool QLinuxFbScreen::initialize() mDepth = determineDepth(vinfo); mBytesPerLine = finfo.line_length; QRect geometry = determineGeometry(vinfo, userGeometry); + QRect originalGeometry = geometry; + if( mRotation == 90 || mRotation == 270 ) + { + int tmp = geometry.width(); + geometry.setWidth(geometry.height()); + geometry.setHeight(tmp); + } + mGeometry = QRect(QPoint(0, 0), geometry.size()); mFormat = determineFormat(vinfo, mDepth); - mPhysicalSize = determinePhysicalSize(vinfo, userMmSize, geometry.size()); + mPhysicalSize = determinePhysicalSize(vinfo, userMmSize,originalGeometry.size()); // mmap the framebuffer mMmap.size = finfo.smem_len; @@ -384,11 +395,11 @@ bool QLinuxFbScreen::initialize() return false; } - mMmap.offset = geometry.y() * mBytesPerLine + geometry.x() * mDepth / 8; + mMmap.offset = originalGeometry.y() * mBytesPerLine + originalGeometry.x() * mDepth / 8; mMmap.data = data + mMmap.offset; QFbScreen::initializeCompositor(); - mFbScreenImage = QImage(mMmap.data, geometry.width(), geometry.height(), mBytesPerLine, mFormat); + mFbScreenImage = QImage(mMmap.data, originalGeometry.width(), originalGeometry.height(), mBytesPerLine, mFormat); mCursor = new QFbCursor(this); @@ -413,8 +424,27 @@ QRegion QLinuxFbScreen::doRedraw() mBlitter = new QPainter(&mFbScreenImage); mBlitter->setCompositionMode(QPainter::CompositionMode_Source); - for (const QRect &rect : touched) - mBlitter->drawImage(rect, mScreenImage, rect); + QVector<QRect> rects = touched.rects(); + for (int i = 0; i < rects.size(); i++) + { + if( mRotation == 90 || mRotation == 270 ) + { + mBlitter->translate(mGeometry.height()/2, mGeometry.width()/2); + } + else if( mRotation == 180 ) + { + mBlitter->translate(mGeometry.width()/2, mGeometry.height()/2); + } + if( mRotation != 0 ) + { + mBlitter->rotate(mRotation); + mBlitter->translate(-mGeometry.width()/2, -mGeometry.height()/2); + } + + mBlitter->drawImage(rects[i], mScreenImage, rects[i]); + + mBlitter->resetTransform(); + } return touched; } diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h index c7ce455e..f7076bf1 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h @@ -64,6 +64,7 @@ private: QStringList mArgs; int mFbFd; int mTtyFd; + int mRotation; QImage mFbScreenImage; int mBytesPerLine;
源码修改完成后,初始化git仓库,打补丁。
git init git add . git commit -m "test" git format-patch HEAD^
三、将补丁拷贝到指定目录
buildroot构建系统,它会自动将补丁打上,所以我们只需要将上面生成的补丁放到指定目录下即可。
目录如下:neza-d1-buildroot/package/qt5/qt5base
下图即是我们添加的补丁。
四、编译
make
编译完成即可完成屏幕旋转了
五、添加环境变量
由于屏幕旋转过去了,但是触摸屏还没旋转,所以我们需要添加QT环境变量配置触摸屏,这里用的是TSLIB进行触摸屏校准的。
在/etc/profile文件最后添加下面内容,其中TSLIB_TSDEVICE后面的event根据自己屏幕event设备进行填写。export TSLIB_CONSOLEDEVICE=none export TSLIB_FBDEVICE=/dev/fb0 export TSLIB_TSDEVICE=/dev/input/event5 export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0 export QT_QPA_GENERIC_PLUGINS=tslib:$TSLIB_TSDEVICE
重启系统即可。
-
D1移植讯为7寸MIPI屏
1、修改驱动源码
内核源码驱动路径:tina-d1-open/lichee/linux-5.4/drivers/video/fbdev/sunxi/disp2/disp/lcd
uboot源码驱动路径:tina-d1-open/lichee/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/lcd
因为驱动框架是一样的,我们只需要修改屏幕初始化参数就可以了。这里我修改的就是tft08006.c文件修改内核源码
static void lcd_power_off(u32 sel) @@ -189,225 +191,69 @@ static void lcd_bl_close(u32 sel) struct LCM_setting_table { u8 cmd; u32 count; - u8 para_list[32]; + u8 para_list[64]; }; static struct LCM_setting_table lcm_tft08006_setting[] = { - {0xFF, 3, {0x98, 0x81, 0x03} }, - {0x01, 1, {0x00} }, - {0x02, 1, {0x00} }, - {0x03, 1, {0x53} }, - {0x04, 1, {0x53} }, - {0x05, 1, {0x13} }, - {0x06, 1, {0x04} }, - {0x07, 1, {0x02} }, - {0x08, 1, {0x02} }, - {0x09, 1, {0x00} }, - {0x0a, 1, {0x00} }, - …… - {0x11, 0, {} }, - {REGFLAG_DELAY, REGFLAG_DELAY, {120} }, - - {0x29, 0, {} }, - {REGFLAG_DELAY, REGFLAG_DELAY, {120} }, - - {REGFLAG_END_OF_TABLE, REGFLAG_END_OF_TABLE, {} } + {0xE0, 2, {0xAB, 0xBA} }, + {0xE1, 2, {0xBA, 0xAB} }, + {0xB0, 1, {0x00} }, + {0xB1, 4, {0x10, 0x01, 0x47, 0xFF} }, + {0xB2, 6, {0x0C, 0x0E, 0x04, 0x14, 0x14, 0x14} }, + {0xB3, 3, {0x56, 0xD3, 0x00} }, + {0xB4, 3, {0x22, 0x30, 0x04} }, + {0xB5, 1, {0x00} }, + {0xB6, 7, {0xB0, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00} }, + {0xB7, 8, {0x0E, 0x00, 0xFF, 0x08, 0x08, 0xFF, 0xFF, 0x00} }, + {0xB8, 7, {0x05, 0x12, 0x29, 0x49, 0x48, 0x00, 0x00} }, + {0xB9, 38, {0x4D, 0x42, 0x38, 0x31, 0x33, 0x27, 0x2F, 0x1B, 0x36, 0x35, 0x35, 0x53, 0x41, 0x49, 0x3D, 0x3D, 0x33, 0x29, 0x26, 0x4C, 0x42, 0x39, 0x31, 0x33, 0x27, 0x2F, 0x1B, 0x36, 0x35, 0x35, 0x53, 0x41, 0x49, 0x3D, 0x3D, 0x33, 0x29, 0x26} }, + {0xBA, 8, {0x00, 0x00, 0x00, 0x44, 0x24, 0x00, 0x00, 0x00} }, + {0xBB, 3, {0x76, 0x00, 0x00} }, + {0xBC, 2, {0x00, 0x00} }, + {0xBD, 5, {0xFF, 0x00, 0x00, 0x00, 0x00} }, + {0xBE, 1, {0x00} }, + {0xC0, 16, {0x98, 0x76, 0x12, 0x34, 0x33, 0x33, 0x44, 0x44, 0x06, 0x04, 0x8A, 0x04, 0x0F, 0x00, 0x00, 0x00} }, + {0xC1, 10, {0x53, 0x94, 0x02, 0x85, 0x06, 0x04, 0x8A, 0x04, 0x54, 0x00} }, + {0xC2, 12, {0x37, 0x09, 0x08, 0x89, 0x08, 0x10, 0x22, 0x21, 0x44, 0xBB, 0x18, 0x00} }, + + {0xC3, 22, {0x9C, 0x1D, 0x1E, 0x1F, 0x10, 0x12, 0x0C, 0x0E, 0x05, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x07, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24} }, + {0xC4, 22, {0x1C, 0x1D, 0x1E, 0x1F, 0x11, 0x13, 0x0D, 0x0F, 0x04, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24} }, + {0xC5, 3, {0xE8, 0x85, 0x76} }, + {0xC6, 2, {0x20, 0x20} }, + {0xC7, 22, {0x41, 0x01, 0x0D, 0x11, 0x09, 0x15, 0x19, 0x4F, 0x10, 0xD7, 0xCF, 0x19, 0x1B, 0x1D, 0x03, 0x02, 0x25, 0x30, 0x00, 0x03, 0xFF, 0x00} }, + {0xC8, 6, {0x61, 0x00, 0x31, 0x42, 0x54, 0x16} }, + {0xC9, 5, {0xA1, 0x22, 0xFF, 0xCD, 0x23} }, + {0xCA, 2, {0x4B, 0x43} }, + {0xCC, 4, {0x2E, 0x02, 0x04, 0x08} }, + {0xCD, 8, {0x0E, 0x64, 0x64, 0x20, 0x1E, 0x6B, 0x06, 0x83} }, + {0xD0, 3, {0x27, 0x10, 0x80} }, + {0xD1, 4, {0x00, 0x0D, 0xFF, 0x0F} }, + {0xD2, 4, {0xE3, 0x2B, 0x38, 0x00} }, + {0xD4, 11,{0x00, 0x01, 0x00, 0x0E, 0x04, 0x44, 0x08, 0x10, 0x00, 0x07, 0x00} }, + {0xD5, 1, {0x00} }, + {0xD6, 2, {0x00, 0x00} }, + {0xD7, 4, {0x00, 0x00, 0x00, 0x00} }, + {0xE4, 3, {0x08, 0x55, 0x03} }, + {0xE6, 8, {0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} }, + {0xE7, 3, {0x00, 0x00, 0x00} }, + + {0xE8, 7, {0xD5, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00} }, + {0xE9, 1, {0xFF} }, + {0xF0, 5, {0x12, 0x03, 0x20, 0x00, 0xFF} }, + {0xF1, 26, {0xA6, 0xC8, 0xEA, 0xE6, 0xE4, 0xCC, 0xE4, 0xBE, 0xF0, 0xB2, 0xAA, 0xC7, 0xFF, 0x66, 0x98, 0xE3, 0x87, 0xC8, 0x99, 0xC8, 0x8C, 0xBE, 0x96, 0x91, 0x8F, 0xFF} }, + {0xF3, 1, {0x03} }, + {0xF4, 26, {0xFF, 0xFE, 0xFC, 0xFA, 0xF8, 0xF4, 0xF0, 0xE8, 0xE0, 0xD0, 0xC0, 0xA0, 0x80, 0x7F, 0x5F, 0x3F, 0x2F, 0x1F, 0x17, 0x0F,0x0B, 0x07, 0x05, 0x03, 0x01, 0x00} }, + {0xF5, 26, {0xFF, 0xFE, 0xFC, 0xFA, 0xF8, 0xF4, 0xF0, 0xE8, 0xE0, 0xD0, 0xC0, 0xA0, 0x80, 0x7F, 0x5F, 0x3F, 0x2F, 0x1F, 0x17, 0x0F,0x0B, 0x07, 0x05, 0x03, 0x01, 0x00} }, + {0xF6, 26, {0xFF, 0xFE, 0xFC, 0xFA, 0xF8, 0xF4, 0xF0, 0xE8, 0xE0, 0xD0, 0xC0, 0xA0, 0x80, 0x7F, 0x5F, 0x3F, 0x2F, 0x1F, 0x17, 0x0F,0x0B, 0x07, 0x05, 0x03, 0x01, 0x00} }, + {0xF7, 7, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, + {0xF8, 7, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, + {0xF9, 7, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, + {0xFA, 25, {0x00, 0x84, 0x12, 0x21, 0x48, 0x48, 0x21, 0x12, 0x84, 0x69, 0x69, 0x5A, 0xA5, 0x96, 0x96, 0xA5, 0x5A, 0xB7, 0xDE, 0xED, 0x7B, 0x7B, 0xED, 0xDE, 0xB7} }, + {0xFB, 23, {0x00, 0x12, 0x0F, 0xFF, 0xFF, 0xFF, 0x00, 0x38, 0x40, 0x08, 0x70, 0x0B, 0x40, 0x19, 0x50, 0x21, 0xC0, 0x27, 0x60, 0x2D, 0x00, 0x00, 0x0F} }, + {0xE3, 2, {0x20, 0x21} }, + {0x11, 0, {0x00} }, + {REGFLAG_DELAY, REGFLAG_DELAY, {200}}, + {0x29, 0, {0x00} }, + + {REGFLAG_DELAY, REGFLAG_DELAY, {20}}, + {REGFLAG_END_OF_TABLE, REGFLAG_END_OF_TABLE, {}}
修改uboot源码
static void lcd_power_off(u32 sel) @@ -189,225 +191,69 @@ static void lcd_bl_close(u32 sel) struct LCM_setting_table { u8 cmd; u32 count; - u8 para_list[32]; + u8 para_list[64]; }; static struct LCM_setting_table lcm_tft08006_setting[] = { - {0xFF, 3, {0x98, 0x81, 0x03} }, - {0x01, 1, {0x00} }, - {0x02, 1, {0x00} }, - {0x03, 1, {0x53} }, - {0x04, 1, {0x53} }, - {0x05, 1, {0x13} }, - {0x06, 1, {0x04} }, - {0x07, 1, {0x02} }, - {0x08, 1, {0x02} }, - {0x09, 1, {0x00} }, - {0x0a, 1, {0x00} }, - …… - {0x11, 0, {} }, - {REGFLAG_DELAY, REGFLAG_DELAY, {120} }, - - {0x29, 0, {} }, - {REGFLAG_DELAY, REGFLAG_DELAY, {120} }, - - {REGFLAG_END_OF_TABLE, REGFLAG_END_OF_TABLE, {} } + {0xE0, 2, {0xAB, 0xBA} }, + {0xE1, 2, {0xBA, 0xAB} }, + {0xB0, 1, {0x00} }, + {0xB1, 4, {0x10, 0x01, 0x47, 0xFF} }, + {0xB2, 6, {0x0C, 0x0E, 0x04, 0x14, 0x14, 0x14} }, + {0xB3, 3, {0x56, 0xD3, 0x00} }, + {0xB4, 3, {0x22, 0x30, 0x04} }, + {0xB5, 1, {0x00} }, + {0xB6, 7, {0xB0, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00} }, + {0xB7, 8, {0x0E, 0x00, 0xFF, 0x08, 0x08, 0xFF, 0xFF, 0x00} }, + {0xB8, 7, {0x05, 0x12, 0x29, 0x49, 0x48, 0x00, 0x00} }, + {0xB9, 38, {0x4D, 0x42, 0x38, 0x31, 0x33, 0x27, 0x2F, 0x1B, 0x36, 0x35, 0x35, 0x53, 0x41, 0x49, 0x3D, 0x3D, 0x33, 0x29, 0x26, 0x4C, 0x42, 0x39, 0x31, 0x33, 0x27, 0x2F, 0x1B, 0x36, 0x35, 0x35, 0x53, 0x41, 0x49, 0x3D, 0x3D, 0x33, 0x29, 0x26} }, + {0xBA, 8, {0x00, 0x00, 0x00, 0x44, 0x24, 0x00, 0x00, 0x00} }, + {0xBB, 3, {0x76, 0x00, 0x00} }, + {0xBC, 2, {0x00, 0x00} }, + {0xBD, 5, {0xFF, 0x00, 0x00, 0x00, 0x00} }, + {0xBE, 1, {0x00} }, + {0xC0, 16, {0x98, 0x76, 0x12, 0x34, 0x33, 0x33, 0x44, 0x44, 0x06, 0x04, 0x8A, 0x04, 0x0F, 0x00, 0x00, 0x00} }, + {0xC1, 10, {0x53, 0x94, 0x02, 0x85, 0x06, 0x04, 0x8A, 0x04, 0x54, 0x00} }, + {0xC2, 12, {0x37, 0x09, 0x08, 0x89, 0x08, 0x10, 0x22, 0x21, 0x44, 0xBB, 0x18, 0x00} }, + + {0xC3, 22, {0x9C, 0x1D, 0x1E, 0x1F, 0x10, 0x12, 0x0C, 0x0E, 0x05, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x07, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24} }, + {0xC4, 22, {0x1C, 0x1D, 0x1E, 0x1F, 0x11, 0x13, 0x0D, 0x0F, 0x04, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24} }, + {0xC5, 3, {0xE8, 0x85, 0x76} }, + {0xC6, 2, {0x20, 0x20} }, + {0xC7, 22, {0x41, 0x01, 0x0D, 0x11, 0x09, 0x15, 0x19, 0x4F, 0x10, 0xD7, 0xCF, 0x19, 0x1B, 0x1D, 0x03, 0x02, 0x25, 0x30, 0x00, 0x03, 0xFF, 0x00} }, + {0xC8, 6, {0x61, 0x00, 0x31, 0x42, 0x54, 0x16} }, + {0xC9, 5, {0xA1, 0x22, 0xFF, 0xCD, 0x23} }, + {0xCA, 2, {0x4B, 0x43} }, + {0xCC, 4, {0x2E, 0x02, 0x04, 0x08} }, + {0xCD, 8, {0x0E, 0x64, 0x64, 0x20, 0x1E, 0x6B, 0x06, 0x83} }, + {0xD0, 3, {0x27, 0x10, 0x80} }, + {0xD1, 4, {0x00, 0x0D, 0xFF, 0x0F} }, + {0xD2, 4, {0xE3, 0x2B, 0x38, 0x00} }, + {0xD4, 11,{0x00, 0x01, 0x00, 0x0E, 0x04, 0x44, 0x08, 0x10, 0x00, 0x07, 0x00} }, + {0xD5, 1, {0x00} }, + {0xD6, 2, {0x00, 0x00} }, + {0xD7, 4, {0x00, 0x00, 0x00, 0x00} }, + {0xE4, 3, {0x08, 0x55, 0x03} }, + {0xE6, 8, {0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} }, + {0xE7, 3, {0x00, 0x00, 0x00} }, + + {0xE8, 7, {0xD5, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00} }, + {0xE9, 1, {0xFF} }, + {0xF0, 5, {0x12, 0x03, 0x20, 0x00, 0xFF} }, + {0xF1, 26, {0xA6, 0xC8, 0xEA, 0xE6, 0xE4, 0xCC, 0xE4, 0xBE, 0xF0, 0xB2, 0xAA, 0xC7, 0xFF, 0x66, 0x98, 0xE3, 0x87, 0xC8, 0x99, 0xC8, 0x8C, 0xBE, 0x96, 0x91, 0x8F, 0xFF} }, + {0xF3, 1, {0x03} }, + {0xF4, 26, {0xFF, 0xFE, 0xFC, 0xFA, 0xF8, 0xF4, 0xF0, 0xE8, 0xE0, 0xD0, 0xC0, 0xA0, 0x80, 0x7F, 0x5F, 0x3F, 0x2F, 0x1F, 0x17, 0x0F,0x0B, 0x07, 0x05, 0x03, 0x01, 0x00} }, + {0xF5, 26, {0xFF, 0xFE, 0xFC, 0xFA, 0xF8, 0xF4, 0xF0, 0xE8, 0xE0, 0xD0, 0xC0, 0xA0, 0x80, 0x7F, 0x5F, 0x3F, 0x2F, 0x1F, 0x17, 0x0F,0x0B, 0x07, 0x05, 0x03, 0x01, 0x00} }, + {0xF6, 26, {0xFF, 0xFE, 0xFC, 0xFA, 0xF8, 0xF4, 0xF0, 0xE8, 0xE0, 0xD0, 0xC0, 0xA0, 0x80, 0x7F, 0x5F, 0x3F, 0x2F, 0x1F, 0x17, 0x0F,0x0B, 0x07, 0x05, 0x03, 0x01, 0x00} }, + {0xF7, 7, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, + {0xF8, 7, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, + {0xF9, 7, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, + {0xFA, 25, {0x00, 0x84, 0x12, 0x21, 0x48, 0x48, 0x21, 0x12, 0x84, 0x69, 0x69, 0x5A, 0xA5, 0x96, 0x96, 0xA5, 0x5A, 0xB7, 0xDE, 0xED, 0x7B, 0x7B, 0xED, 0xDE, 0xB7} }, + {0xFB, 23, {0x00, 0x12, 0x0F, 0xFF, 0xFF, 0xFF, 0x00, 0x38, 0x40, 0x08, 0x70, 0x0B, 0x40, 0x19, 0x50, 0x21, 0xC0, 0x27, 0x60, 0x2D, 0x00, 0x00, 0x0F} }, + {0xE3, 2, {0x20, 0x21} }, + {0x11, 0, {0x00} }, + {REGFLAG_DELAY, REGFLAG_DELAY, {200}}, + {0x29, 0, {0x00} }, + + {REGFLAG_DELAY, REGFLAG_DELAY, {20}}, + {REGFLAG_END_OF_TABLE, REGFLAG_END_OF_TABLE, {}}
2、修改设备树
这里只把重要的参数列出来了,内核设备树和uboot设备树要保持一致。
;---------------------------------------------- &lcd0 { lcd_used = <1>; lcd_driver_name = "tft08006"; lcd_backlight = <100>; lcd_if = <4>; lcd_x = <800>; lcd_y = <1280>; lcd_width = <80>; lcd_height = <80>; lcd_dclk_freq = <60>; lcd_pwm_used = <1>; lcd_pwm_ch = <2>; lcd_pwm_freq = <1000>; lcd_pwm_pol = <0>; lcd_pwm_max_limit = <255>; lcd_hbp = <40>; lcd_ht = <860>; lcd_hspw = <20>; lcd_vbp = <24>; lcd_vt = <1330>; lcd_vspw = <4>; lcd_dsi_if = <0>; lcd_dsi_lane = <4>;
3、触摸屏驱动配置
到Tina根目录下make kernel_menuconfig将下面驱动配置上
修改设备树
在twi0下增加触摸屏子节点
4、编译打包、测试
-
D1移植rtl8723wifi驱动
1、获取rtl8723驱动源码
源码上传到了码云:https://gitee.com/yao-xiaoyao/rtl8723.git
2、源码结构
3、修改源码支持linux5.4
需要修改文件rtl8821cu/os_dep/os_intfs.c--- a/rtl8821cu/os_dep/os_intfs.c +++ b/rtl8821cu/os_dep/os_intfs.c @@ -28,6 +28,8 @@ MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); MODULE_AUTHOR("Realtek Semiconductor Corp."); MODULE_VERSION(DRIVERVERSION); +MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
需要修改文件rtl8821cu/os_dep/rtw_cfgvendor.c
--- a/rtl8821cu/os_dep/rtw_cfgvendor.c +++ b/rtl8821cu/os_dep/rtw_cfgvendor.c #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) .policy = VENDOR_CMD_RAW_DATA, ++++ .maxattr = 1 #endif
4、交叉编译
make ARCH=riscv CROSS_COMPILE=/home/linux/tina-d1-open/prebuilt/gcc/linux-x86/riscv/toolchain-thead-glibc/riscv64-glibc-gcc-thead_20200702/bin/riscv64-unknown-linux-gnu- KSRC=/home/linux/tina-d1-open/lichee/linux-5.4
5、下载到开发板上面insmod
-
fastboot烧录env、uboot、system分区问题
1、用type-c线把开发板和电脑连接,上电进入uboot下,输入fastboot
2、到ubuntu下
重新烧录env分区
显示成功,但是uboot界面报错。
3、到uboot源码下搜索错误
发现这里直接报错 return了
不知道为什么 ,求解 -
D1添加LED_GPIO灯出现的问题
1、在板级设备树根节点添加三个LED灯
2、在内核添加LEDS-GPIO驱动支持
Device Drivers --->
[ * ]LED Support --->
< * > LED Class Support
< * > LED Support for GPIO connected LEDs
3、编译、打包
确定已经编译
4、烧录固件,启动
没有LED设备
可是在这个路径下生成了一堆文件,好像不是想要的那种,没法用
-
D1wifi连接异常
这里是从官网拿的SDK直接编译后的固件进行烧写的系统
1.配置wpc_supplicant.conf文件
这里ssid和psk确定没有问题
2.连接
一直报异常,dhcp获取不到IP不上,但是可以识别到附近的wifi