-
安装依赖
apt-get install automake autoconf libtool libsysfs-dev
-
下载tslib
mkdir /opt/systemmake/tslib
mkdir /opt/systemmake/tslib/output/
cd /opt/systemmake/tslib
资源下载链接
https://github.com/15903016222/tslib
-
解压tslib
unzip tslib-master.zip
-
编译
cd tslib-master
清理配置
./autogen-clean.sh
输出
Removing autogenned files...
Done.
自动配置
./autogen.sh
输出
autom4te: cannot create autom4te.cache: No such file or directory
aclocal: error: echo failed with exit status: 1
autoreconf: aclocal failed with exit status: 1
liefyuan@ubuntu:/home/tslib$ sudo ./autogen.sh
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4/internal'.
libtoolize: copying file 'm4/internal/libtool.m4'
libtoolize: copying file 'm4/internal/ltoptions.m4'
libtoolize: copying file 'm4/internal/ltsugar.m4'
libtoolize: copying file 'm4/internal/ltversion.m4'
libtoolize: copying file 'm4/internal/lt~obsolete.m4'
configure.ac:58: installing './compile'
configure.ac:24: installing './config.guess'
configure.ac:24: installing './config.sub'
configure.ac:7: installing './install-sh'
configure.ac:7: installing './missing'
Makefile.am: installing './INSTALL'
plugins/Makefile.am: installing './depcomp'
echo "ac_cv_func_malloc_0_nonnull=yes" > tmp.cache
配置
./configure --host=arm-linux --cache-file=tmp.cache --prefix=/opt/systemmake/tslib/output/tslib_1_4 CC=/opt/ToolChain/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc
说明
prefix:tslib安装的位置
CC:自己环境中的交叉编译器,必须是绝对路径
输出
configure: creating cache tmp.cache
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
...
config.status: creating etc/Makefile
config.status: creating plugins/Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating tools/Makefile
config.status: creating doc/Makefile
config.status: creating tslib.pc
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
编译
time ( make -j 16 )
输出
real 0m3.428s
user 0m7.579s
sys 0m2.851s
root@user:/opt/systemmake/tslib/tslib-master#
-
安装
make install
会安装在 /opt/systemmake/tslib/output/tslib_1_4 目录下,也就是上面配置时指定的prefix的位置
-
查看
root@user:/opt# ls /opt/systemmake/tslib/output/tslib_1_4
bin etc include lib share
查看是否是ARM结构
如果不是就重新做
root@user:/opt# file /opt/systemmake/tslib/output/tslib_1_4/bin/ts_calibrate
/opt/tslib1.4/bin/ts_calibrate: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=e74122101ee6549fa45f1333f1253f4f6d62458e, with debug_info, not stripped
-
移植
将安装路径下的整个tslib文件夹,下载至开发开发板上,我存放的路径为/opt/tslib_1_4
配置环境
开发板
vim /etc/profile
配置内容如下
echo "tslib_1_4 init start"
export TSLIB_ROOT=/opt/tslib_1_4
export TSLIB_TSDEVICE=/dev/input/event0
export QWS_MOUSE_PROTO=tslib:/dev/input/mouse0
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_TSEVENTTYPE=input
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CONSOLEDEVICE=none
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSLIB_ROOT/lib
echo "tslib_1_4 init finish"
说明
TSLIB_ROOT:tslib的安装路径
TSLIB_TSDEVICE:看你的/dev/input/下的哪一个是触摸屏
QWS_MOUSE_PROTO:看你的/dev/input/下的哪一个是鼠标
source /etc/profile
-
测试tslib
/opt/tslib_1_4/bin/ts_test // 运行 ts_test 测试触摸是否正常,点击界面的 Draw 测试
/opt/tslib_1_4/bin/ts_test_mt // 运行 ts_test 测试触摸是否正常,点击界面的 Draw 测试
cat /dev/urandom > /dev/fb0
cat /dev/zero > /dev/fb0
-
使用第一条命令可以让屏幕出现雪花
-
使用第二条命令可以让屏幕变黑
问题说明
测试有原始数据打印,一般需要运行
./ts_calibrate
来校准一下触摸屏,才能使用的。下次上电就不用校准了,直接用了。