arm tslib移植

转载:https://blog.****.net/qq_30155503/article/details/80117395

环境:Ubuntu-14.04

交叉编译器:arm-linux-gnueabi-4.5.1

tslib版本:tslib-1.4


一、交叉编译tslib

自行下载tslib,下载之后:

1、解压、进入

  1. $ tar zxvf tslib-1.4.tar.gz
  2. $ cd tslib

2、生成config文件

$ ./autogen.sh

若执行失败,可能因为没有安装相关的库,需安装交叉编译tslib必须的一些工具,输入:

$ sudo apt-get install autoconf automake libtool
然后再重新 ./autogen.sh


3、配置编译条件

./configure --host=arm-linux --prefix=/usr/local/arm/tslib
配置为交叉编译,安装在/usr/local/arm/tslib目录

执行完配置后,可查看一下Makefile文件,可见配置生效


4、编译、安装

$ make

出错信息:

  1. ts_test.o: In function `main':
  2. ts_test.c:(.text+0x52c): undefined reference to `rpl_malloc'
  3. fbutils.o: In function `open_framebuffer':
  4. fbutils.c:(.text+0x108): undefined reference to `rpl_malloc'
  5. collect2: ld returned 1 exit status
  6. make[2]: *** [ts_test] 错误 1
  7. make[2]:正在离开目录 `/root/library/tslib/tslib/tests'
  8. make[1]: *** [all-recursive] 错误 1
  9. make[1]:正在离开目录 `/root/library/tslib/tslib'
  10. make: *** [all] 错误 2
出错:编译tslib,执行make时提示undefined reference to `rpl_malloc'
是因为 config.h.in 文件中有
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc 把#undef malloc注释掉

arm tslib移植

重新make,成功。


5、安装

$ make install

在安装目录下可见成功安装了,有如下4个文件夹:

bin  etc  include  lib


二、移植到ARM开发板

1、将安装目录tslib下的动态库文件复制到ARM板上的usr/local目录下(或其他目录)

首先,添加环境变量:

$ export LD_LIBRARY_PATH=/usr/local/tslib/lib:$LD_LIBRARY_PATH

在ARM板上,进入tslib/bin目录,运行自带的触摸屏校准程序:

$ ./ts_calibrate 


问题1:

ts_open: No such file or directory

解决1:指定触摸屏设备(内核支持触摸屏驱动)

$ export TSLIB_TSDEVICE=/dev/event0

不确定哪个设备是触摸屏,可

$ cat event0   // 或其他event1 2 3
然后按下触摸屏,串口有信息输出则是


问题2:

  1. /usr/local/tslib/bin # ./ts_calibrate
  2. Couldnt open tslib config file: No such file or directory
  3. ts_config: No such file or directory

解决2:

$ export TSLIB_CONFFILE=/usr/local/tslib/etc/ts.conf


问题3:

  1. /usr/local/tslib/bin # ./ts_calibrate
  2. Couldnt load module pthres
  3. No raw modules loaded.
  4. ts_config: Success

解决3:

$ export TSLIB_PLUGINDIR=/usr/local/tslib/lib/ts


问题4:

  1. /usr/local/tslib/bin # ./ts_calibrate
  2. No raw modules loaded.
  3. ts_config: No such file or directory

解决4:

编辑 tslib/etc/ts.conf 文件, 至少开放一个module_raw(去掉注释),并删掉该行前面的空格。

如下图:

arm tslib移植


再次运行---成功,在ARM板上有显示了,提示你去校准。

arm tslib移植

追着“+”号点完五个点,结束。

过程输出如下:

  1. /usr/local/tslib/bin # ./ts_calibrate
  2. xres = 800, yres = 480
  3. Took 1 samples...
  4. Top left : X = 32 Y = 52
  5. Took 1 samples...
  6. Top right : X = 741 Y = 28
  7. Took 1 samples...
  8. Bot right : X = 738 Y = 431
  9. Took 1 samples...
  10. Bot left : X = 44 Y = 431
  11. Took 1 samples...
  12. Center : X = 398 Y = 242
  13. 13.063293 0.997416 -0.011207
  14. 3.655334 0.016685 0.970556
  15. Calibration constants: 856116 65366 -734 239556 1093 63606 65536

bin目录下的其他几个测试程序(ts_calibrate  ts_harvest    ts_print      ts_print_raw  ts_test)也可以跑来试下。


2、配置环境变量

先阅读下tslib源码目录下的 README 文档,有告诉你怎么配环境:

  1. 41 Environment Variables
  2. 42 =====================
  3. 43
  4. 44 TSLIB_TSDEVICE TS device file name.
  5. 45 Default (non inputapi): /dev/touchscreen/ucb1x00
  6. 46 Default (inputapi): /dev/input/event0
  7. 47 TSLIB_CALIBFILE Calibration file.
  8. 48 Default: ${sysconfdir}/pointercal
  9. 49 TSLIB_CONFFILE Config file.
  10. 50 Default: ${sysconfdir}/ts.conf
  11. 51 TSLIB_PLUGINDIR Plugin directory.
  12. 52 Default: ${datadir}/plugins
  13. 53 TSLIB_CONSOLEDEVICE Console device.
  14. 54 Default: /dev/tty
  15. 55 TSLIB_FBDEVICE Framebuffer device.
  16. 56 Default: /dev/fb0


根据上面的几个问题,可得综合配置。

$ vi /etc/profile

在最后添加上以下几行:

  1. # touchscreen lib - tslib
  2. export TS_ROOT=/usr/local/tslib
  3. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TS_ROOT/lib
  4. export TSLIB_CONSOLEDEVICE=none
  5. export TSLIB_FDDEVICE=/dev/fb0
  6. export TSLIB_TSDEVICE=/dev/event0
  7. export TSLIB_CALIBFILE=$TS_ROOT/etc/pointercal
  8. export TSLIB_CONFFILE=$TS_ROOT/etc/ts.conf
  9. export TSLIB_PLUGINDIR=$TS_ROOT/lib/ts

使生效

$ source /etc/profile

就可以了,跑tslib/bin目录下的几个测试程序试下。