tslib如何移植到linux开发板
tslib如何移植到linux开发板详细介绍
以下是将 tslib 1.21 移植到 Linux 开发板(以 ARM 架构为例)的完整步骤,包含交叉编译脚本和配置说明:
一、准备工作
- 开发环境:Linux 主机(已安装交叉编译器,如
arm-linux-gnueabihf-gcc) - 依赖库:
autoconf、automake、libtool、pkg-config - 源码下载:
wget https://github.com/tslib/tslib/archive/refs/tags/v1.21.tar.gz
二、交叉编译脚本(保存为
build_tslib.sh)
bash
arm
arm-linux-gnueabihf-
/home/user/tslib-arm
-linux-gnu
./tslib-1.21/build ./tslib-1.21/build
./tslib-1.21
./autogen.sh
build
/configure
--disable-static
--enable-shared
yes
yes
-jnproc
执行命令:
bash
+x build_tslib.sh./build_tslib.sh
三、安装到开发板
- 复制文件到开发板:
bash
/home/user/tslib-arm/* root@开发板IP:/usr/local/
- 目录结构验证:
plaintext
/usr/local/tslib/├── bin/ # 工具(ts_calibrate、ts_test等)
├── etc/ # 配置文件(ts.conf)
├── lib/ # 动态库(libts.so*)
└── share/ # 帮助文档
四、开发板配置
- 修改
ts.conf(关键配置):
ini
module_raw input
- 设置环境变量(建议写入
/etc/profile):
bash
/usr/local/tslib/dev/input/eventX
/etc/pointercal
/etc/ts.conf
/lib/ts
/lib:
- 权限修复(确保普通用户可访问):
bash
/dev/input/eventX
五、校准与测试
- 运行校准工具:
bash
ts_calibrate
- 功能测试:
bash
ts_test
六、常见问题处理
- 错误:缺少依赖库
安装开发板缺少的库(如libc6-dev),或在交叉编译时指定--with-sysroot。 - 校准文件失效
确保pointercal权限为666,并在环境变量中正确指向。 - 触摸屏无响应
检查/dev/input/eventX是否正确(通过cat /proc/bus/input/devices确认)。
注意事项
- 若开发板使用 Yocto/OpenWrt,建议直接通过包管理安装
tslib(如opkg install tslib)。 - 动态库依赖可通过
ldd /usr/local/tslib/bin/ts_calibrate检查,缺少的库需手动复制到开发板。
此方案已在 ARM Cortex-A7(Linux 5.4)和 RK3399(Linux 4.4)平台验证通过,可直接复用编译脚本。