根文件系统移植之tslib移植记录

一 移植步骤:

1. 下载tslib

点我进入下载地址或使用git命令下载:
git 地址– https://github.com/kergoth/tslib.git

2. 进入下载或解压出来的tslib目录

3. 执行下面几条命令:

anzyelay@ubuntu:tslib$ ./autogen.sh  //得到configure
anzyelay@ubuntu:tslib$ ./configure  --host=arm-linux  --prefix=安装目录 CC=交叉编译器绝对路径
anzyelay@ubuntu:tslib$ make
anzyelay@ubuntu:tslib$ sudo make install

anzyelay@ubuntu:安装目录$ ls    //成功后在安装目录有如下文件
bin  etc  include  lib

不用绝对路径会出些问题,一定要绝对路径。

4. 将要用到的库文件和可执行程序移入根文件系统中对应目录。

两种方法:

  • 下面->后的”/”指的是根文件系统的目录,不是你PC机的根目录,这个适合tslib稳定后移植

    • 库:tslib/lib/文件下除去pkgconfig目录以外的其他所有文件 -> /lib
    • 程序:tslib/bin文件下所有文 -> /bin
    • 配置:tslib/etc/ts.conf文件 -> /etc/ts.conf
  • 还可以选将整个目录放到根目录下的某个目录,但在配置环境变量时要做相应改变,这个适合开始移植时改错,

5. 更改文件系统的配置文件和添加环境变量

  • ts.conf:依据你开发板的触摸屏资料取消一个注释,这里取消下面的,不对就一个一个的试吧。

    # Uncomment if you’re using a Sharp Zaurus SL-C700/C750/C760/C860
    module_raw corgi

  • 在/etc/profile 中根据自己的文件系统加入以下配置:

    export TSLIB_TSDEVICE=/dev/ts0 #此处如果选event0则ts.conf中要选module_raw input
    export TSLIB_CONFFILE=/etc/ts.conf
    export TSLIB_PLUGINDIR=/lib/ts
    export TSLIB_CALIBFILE=/temp/pointercal #这里是配置校准文件保存地方的,可更改
    export TSLIB_CONSOLEDEVICE=none
    export TSLIB_FBDEVICE=/dev/fb0

    上一步如果是用的方法2,则配置如下:

    export TS_ROOT=/usr/local/tslib #tslib移动到文件系统里的目录
    export TSLIB_TSDEVICE=/dev/input/ts0
    export TSLIB_CONFFILE=$TS_ROOT/etc/ts.conf
    export TSLIB_PLUGINDIR=$TS_ROOT/lib/ts
    export TSLIB_CALIBFILE=/temp/pointercal
    export TSLIB_CONSOLEDEVICE=none
    export TSLIB_FBDEVICE=/dev/fb0
    export PATH=$TS_ROOT/bin:$PATH
    export LD_LIBRARY_PATH=$TS_ROOT/lib:$LD_LIBRARY_PATH

    这些配置意思查看tslib/README说明如下:

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

6. 执行ts_calibrate校正

[root@bst:/]# ts_calibrate
xres = 480, yres = 272
Took 26 samples…
Top left : X = 162 Y = 209
Took 30 samples…
Top right : X = 866 Y = 210
Took 31 samples…
Bot right : X = 871 Y = 581
Took 31 samples…
Bot left : X = 155 Y = 584
Took 24 samples…
Center : X = 515 Y = 395
-35.559814 0.535173 0.001486
-46.847839 0.000662 0.461112
Calibration constants: -2330448 35073 97 -3070220 43 30219 65536


二 遇到的问题汇总:

1.在执行./autogen.sh 时出现:

./autogen.sh: 3: autoreconf: not found

产生的原因是因为没有安装 automake 工具,安装命令如下:
sudo apt-get install autoconf automake libtool

2.执行./configure时出现如下错误:

  • erro1:

    libtool: install: error: cannot install `linear.la’ to a directory not ending in /usr/local/lib/ts
    make[2]: * [install-pluginexecLTLIBRARIES] Error 1
    make[2]: Leaving directory `/home/anzyelay/Desktop/arm/tslib/plugins’
    make[1]: * [install-am] Error 2
    make[1]: Leaving directory `/home/anzyelay/Desktop/arm/tslib/plugins’
    make: * [install-recursive] Error 1

    错误处理,在每次./configure后都要make clean再执行make.

  • error2:

    libtool: install: (cd /home/anzyelay/Desktop/arm/tslib/plugins; /bin/bash /home/anzyelay/Desktop/arm/tslib/libtool –tag CC –mode=relink arm-linux-gcc -DTS_POINTERCAL=\”/home/anzyelay/Desktop/arm/tslib_install/etc/pointercal\” -DTSLIB_INTERNAL -fvisibility=hidden -DGCC_HASCLASSVISIBILITY -O2 -Wall -W -module -avoid-version -o linear.la -rpath /home/anzyelay/Desktop/arm/tslib_install/lib/ts linear.lo ../src/libts.la )
    libtool: relink: arm-linux-gcc -shared -fPIC -DPIC .libs/linear.o -Wl,-rpath -Wl,/home/anzyelay/Desktop/arm/tslib_install/lib -L/home/anzyelay/Desktop/arm/tslib_install/lib -lts -O2 -Wl,-soname -Wl,linear.so -o .libs/linear.so
    /home/anzyelay/Desktop/arm/tslib/libtool: line 8968: arm-linux-gcc: command not found
    libtool: install: error: relink `linear.la’ with the above command before installing it
    make[2]: * [install-pluginexecLTLIBRARIES] Error 1

    要指明CC如下,一定要用绝对地址,不然出下面第3个错误:

    anzyelay@ubuntu:~/Desktop/arm/tslib$ ./configure  --host=arm-linux --prefix=/home/anzyelay/Desktop/arm/myrootfs/usr/local/tslib CC=/usr/local/arm/4.4.3/bin/arm-linux-gcc
    

前面配置,make都一路OK,但在make install时出错如下:

```
/bin/bash ../libtool   --mode=install /usr/bin/install -c   linear.la dejitter.la variance.la pthres.la ucb1x00.la corgi.la collie.la h3600.la mk712.la arctic2.la tatung.la dmc.la linear_h2200.la input.la galax.la touchkit.la '/home/anzyelay/Desktop/arm/tslib/build/lib/ts'
libtool: install: warning: relinking `linear.la'
libtool: install: (cd /home/anzyelay/Desktop/arm/tslib/plugins; /bin/bash /home/anzyelay/Desktop/arm/tslib/libtool  --tag CC --mode=relink arm-linux-gnueabi-gcc -DTS_POINTERCAL=\"/home/anzyelay/Desktop/arm/tslib/build/etc/pointercal\" -DTSLIB_INTERNAL -fvisibility=hidden -DGCC_HASCLASSVISIBILITY -O2 -Wall -W -module -avoid-version -o linear.la -rpath /home/anzyelay/Desktop/arm/tslib/build/lib/ts linear.lo ../src/libts.la )
libtool: relink: arm-linux-gnueabi-gcc -shared  -fPIC -DPIC  .libs/linear.o   -Wl,-rpath -Wl,/home/anzyelay/Desktop/arm/tslib/build/lib -L/home/anzyelay/Desktop/arm/tslib/build/lib -lts  -O2   -Wl,-soname -Wl,linear.so -o .libs/linear.so
/home/anzyelay/Desktop/arm/tslib/libtool: line 8968: arm-linux-gnueabi-gcc: command not found
libtool: install: error: relink `linear.la' with the above command before installing it
make[2]: *** [install-pluginexecLTLIBRARIES] Error 1
make[2]: Leaving directory `/home/anzyelay/Desktop/arm/tslib/plugins'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/home/anzyelay/Desktop/arm/tslib/plugins'
make: *** [install-recursive] Error 1

```

修改CC=项为其绝对地址,如下,
错误时

anzyelay@ubuntu:tslib$ ./configure --host=arm-linux --prefix=`pwd`/build CC=arm-linux-gcc

正确时

anzyelay@ubuntu:tslib$ ./configure --host=arm-linux --prefix=`pwd`/build CC=/usr/local/arm/4.9.4/bin/arm-linux-gcc

虽然我编译环境也设好了,可以找到arm-linux-gcc,但就是出错,使用绝对地址时就OK。

4.执行ts_calibrate出错如下

  • error1:
    /bin/ts_calibrate: line 1: syntax error: unexpected end of file
    file了下发现居然是x86的文件,不是arm的。

    anzyelay@ubuntu:myrootfs$ file bin/ts_calibrate 
    bin/ts_calibrate: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xb79294591df01693dcc3ae349c4995c59a527f80, not stripped

    后来发现PC机的PATH变量复原了,应该是sudo su后转回来是复原的,查看/etc/profile是正常的,重新执行了下source /etc/profile,查看PATH正常了。再重新编译安装后正常:

    anzyelay@ubuntu:myrootfs$ file usr/local/tslib/bin/ts_calibrate 
    usr/local/tslib/bin/ts_calibrate: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped
    
  • error2:

    [root@bst:/]# ts_calibrate
    ts_calibrate: error while loading shared libraries: libts-1.0.so.0: wrong ELF class: ELFCLASS64

    这个是由于库文件不对造成的,看是否把tslib/lib/libts-1.0.so.0移到了/lib下,如果是用方法2整个tslib目录移的则要指定库文件的搜索路径如下:
    export TS_ROOT=/usr/local/tslib
    export LD_LIBRARY_PATH=$TS_ROOT/lib:$LD_LIBRARY_PATH

  • error3:

    [root@bst:/]# ts_calibrate
    xres = 480, yres = 272
    ts_read: Invalid argument

    因为我的ts.conf中选的模块是“module_raw corgi”,故更改配置文件中的TSLIB_TSDEVICE变量如下

    export TSLIB_TSDEVICE=/dev/input/event0 
    修改为
    export TSLIB_TSDEVICE=/dev/input/ts0

    深入探究发现有以下对应关系:
    /dev/input/event0 <—>module_raw input
    /dev/input/ts0 <—>module_raw corgi
    两者都是可以的,只要ts.conf和profile写上对应配置。

  • error 4

    root@~# ts_calibrate 
    xres = 800, yres = 480
    tslib: Selected device is not a touchscreen (must support ABS and KEY event types)
    Took 3 samples...
    Top left : X = 1993966148 Y = 20672392
    Took 3 samples...
    Top right : X = 1993966148 Y = 20672392
    Took 3 samples...
    Bot right : X = 1993966148 Y = 20672392
    Took 3 samples...
    Bot left : X = 1993966148 Y = 20672392
    Took 3 samples...
    Center : X = 1993966148 Y = 20672392
    0.348604 -0.002357 0.227393
    -0.214578 0.004819 -0.464815
    Calibration constants: 22846 -154 14902 -14062 315 -30462 65536

    从Selected device is not a touchscreen这句看是TSLIB_TSDEVICE配置出错了,检查下:

    export TSLIB_TSDEVICE=/dev/input/event0

    查看下设备

    root@/etc# cat /proc/bus/input/devices 
    I: Bus=0019 Vendor=0000 Product=0000 Version=0000
    N: Name="20cc000.snvs-pwrkey"
    P: Phys=snvs-pwrkey/input0
    S: Sysfs=/devices/soc0/soc.0/2000000.aips-bus/20cc000.snvs-pwrkey/input/input0
    U: Uniq=
    H: Handlers=kbd event0 evbug 
    B: PROP=0
    B: EV=3
    B: KEY=100000 0 0 0
    
    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="iMX6UL TouchScreen Controller"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input1
    U: Uniq=
    H: Handlers=mouse0 event1 evbug 
    B: PROP=0
    B: EV=b
    B: KEY=400 0 0 0 0 0 0 0 0 0 0
    B: ABS=3
    
    I: Bus=0003 Vendor=0c45 Product=6340 Version=0000
    N: Name="USB 2.0 Camera"
    P: Phys=usb-ci_hdrc.1-1.1/button
    S: Sysfs=/devices/soc0/soc.0/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb1/1-1/1-1.1/1-1.1:1.0/input/input3
    U: Uniq=
    H: Handlers=kbd event2 evbug 
    B: PROP=0
    B: EV=3
    B: KEY=100000 0 0 0 0 0 0
    

    触摸屏是应该是event1,修改之重启,再次执行ts_calibrate

你可能感兴趣的:(fl2440-linux,linux-fs)