Ubuntu下交叉编译tslib库并移植到ARM板上

环境:Ubuntu-14.04

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

tslib版本:tslib-1.4


一、交叉编译tslib

自行下载tslib,下载之后:

1、解压、进入

$ tar zxvf tslib-1.4.tar.gz
$ 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

出错信息:

ts_test.o: In function `main':
ts_test.c:(.text+0x52c): undefined reference to `rpl_malloc'
fbutils.o: In function `open_framebuffer':
fbutils.c:(.text+0x108): undefined reference to `rpl_malloc'
collect2: ld returned 1 exit status
make[2]: *** [ts_test] 错误 1
make[2]:正在离开目录 `/root/library/tslib/tslib/tests'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/root/library/tslib/tslib'
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注释掉


重新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:

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

解决2:

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


问题3:

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

解决3:

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


问题4:

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

解决4:

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

如下图:



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


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

过程输出如下:

/usr/local/tslib/bin # ./ts_calibrate 
xres = 800, yres = 480
Took 1 samples...
Top left : X =   32 Y =   52
Took 1 samples...
Top right : X =  741 Y =   28
Took 1 samples...
Bot right : X =  738 Y =  431
Took 1 samples...
Bot left : X =   44 Y =  431
Took 1 samples...
Center : X =  398 Y =  242
13.063293 0.997416 -0.011207
3.655334 0.016685 0.970556
Calibration constants: 856116 65366 -734 239556 1093 63606 65536 

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


2、配置环境变量

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

 41 Environment Variables
 42 =====================
 43 
 44 TSLIB_TSDEVICE          TS device file name.
 45                 Default (non inputapi): /dev/touchscreen/ucb1x00
 46                 Default (inputapi): /dev/input/event0
 47 TSLIB_CALIBFILE         Calibration file.
 48                 Default: ${sysconfdir}/pointercal
 49 TSLIB_CONFFILE          Config file.
 50                 Default: ${sysconfdir}/ts.conf
 51 TSLIB_PLUGINDIR         Plugin directory.
 52                 Default: ${datadir}/plugins
 53 TSLIB_CONSOLEDEVICE     Console device.
 54                 Default: /dev/tty
 55 TSLIB_FBDEVICE          Framebuffer device.
 56                 Default: /dev/fb0


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

$ vi /etc/profile

在最后添加上以下几行:

# touchscreen lib - tslib
export TS_ROOT=/usr/local/tslib  
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TS_ROOT/lib
export TSLIB_CONSOLEDEVICE=none                     
export TSLIB_FDDEVICE=/dev/fb0 
export TSLIB_TSDEVICE=/dev/event0
export TSLIB_CALIBFILE=$TS_ROOT/etc/pointercal
export TSLIB_CONFFILE=$TS_ROOT/etc/ts.conf   
export TSLIB_PLUGINDIR=$TS_ROOT/lib/ts    

使生效

$ source /etc/profile

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



猜你喜欢

转载自blog.csdn.net/qq_30155503/article/details/80117395