測試平台
宿主機平台:Ubuntu 12.04.4 LTS
目標機:Easy-ARM IMX283
目標機內核:Linux 2.6.35.3
tslib 1.4 下載 https://gitlab.com/tslib/tslib/-/archive/1.4/tslib-1.4.tar.gz
備注:建議用 tslib 1.0(測試正常)
tslib 1.4編譯移植
1.tslib編譯
tslib編譯依賴
sudo apt-get install autoconf automake autogen libtool libsysfs-dev
解壓,automake生成makefile
tar xzf tslib-1.4.tar.gz cd tslib-1.4 ./autogen.sh
出現以下問題
反映的是一些宏定義沒有定義,aclocal是個掃描程序, 負責掃描configure.ac中所有的宏定義並展開;
出現上述應該是相關宏定義工具沒有安裝(但所有依賴工具均安裝OK)或者 aclocal 出現問題;
查詢 aclocal 路徑
aclocal --print-ac-dir
但在對應目錄卻發現沒有次目錄 ,應該是不同版本安裝、或系統升級導致文件夾丟失
chmod 777 /usr/local/share
將 usr/share/aclocal 文件夾拷貝到 /usr/local/share 下;
在此運行 ./autogen.sh
2. 編譯配置、編譯及安裝
新建安裝文件目錄
mkdir -p install chmod 777 install
編譯配置
./configure --prefix=$(pwd)/install --host=arm-linux ac_cv_func_malloc_0_nonnull=yes CC=arm-fsl-linux-gnueabi-gcc
然后編譯 make,出現錯誤
input-raw.c: In function 'check_fd': input-raw.c:188: error: 'ABS_MT_PRESSURE' undeclared (first use in this function) input-raw.c:188: error: (Each undeclared identifier is reported only once input-raw.c:188: error: for each function it appears in.) input-raw.c:199: error: 'ABS_MT_SLOT' undeclared (first use in this function) input-raw.c: In function 'ts_input_read_mt': input-raw.c:515: error: 'ABS_MT_PRESSURE' undeclared (first use in this function) input-raw.c:520: error: 'ABS_MT_TOOL_X' undeclared (first use in this function) input-raw.c:525: error: 'ABS_MT_TOOL_Y' undeclared (first use in this function) input-raw.c:540: error: 'ABS_MT_DISTANCE' undeclared (first use in this function) input-raw.c:577: error: 'ABS_MT_SLOT' undeclared (first use in this function) make[2]: *** [input-raw.lo] 錯誤 1 make[2]:正在離開目錄 `/home/vmuser/wtools/tslib-1.4/plugins' make[1]: *** [all-recursive] 錯誤 1 make[1]:正在離開目錄 `/home/vmuser/wtools/tslib-1.4' make: *** [all] 錯誤 2
這主要是 tslib 1.4 的 input與 linux 內核的不匹配,使用高版本 linux 內核應該沒有該問題
首先 交叉編譯工具的 input.h 應該 與 使用Linux 內核 的 input,h 的 ENV_VERSION 一致;
tslib-1.4/plugins/input-raw.h
#ifndef ABS_MT_POSITION_X #define ABS_MT_SLOT 0x2f /* MT slot being modified */ #define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ #define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ #define ABS_MT_POSITION_X 0x35 /* Center X touch position */ #define ABS_MT_POSITION_Y 0x36 /* Center Y touch position */ #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ #define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ #define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ #define ABS_MT_TOOL_X 0x3c /* Center X tool position */ #define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */ #endif
而 Linux 2.6.35的內核的 也就是常用的 linux/input
#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ #define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ #define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */ #define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */ #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
不支持某些觸摸類型的定義,因此需要手動添加到頂層頭文件中,因為后面的 ts_test_mt.c 也會使用
#define ABS_MT_SLOT 0x2f /* MT slot being modified */
#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ #define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ #define ABS_MT_TOOL_X 0x3c /* Center X tool position */ #define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */
我們將這些添加到 tslib-1.4/config.h 中,后面編譯出錯的文件 在頭部添加 #include "config.h" 即可
我這里主要在以下文件添加
tslib-1.4/tools/ts_uinput.c
tslib-1.4/tests/ts_test_mt.c
tslib-1.4/tests/ts_print_mt.c
tslib-1.4/tests/ts_print_raw_mt.c
然后 make 正常
make inatall
可以看到該指定的安裝目錄instal下l有4 個文件夾 /bin 、 /etc 、 /lib 、 /include
3. tslib移植及測試
先將上面安裝 install 文件見 拷貝到 nfs 調試目錄 並命名為 tslib
通過nfs掛載將 tslib 下載到開發板的 /usr/local/下
root@EasyARM-iMX28x /mnt/vm_tools# cp -r tslib /usr/local/
修改開發板的環境變量文件,添加如下內容
vi /etc/profile
#指定 tslib 目錄路徑 export TSLIB_ROOT=/usr/local/tslib #指定 tslib 插件文件的路徑 export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts #指定 tslib 配置文件的路徑 export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf #指定觸摸屏設備 export TSLIB_TSDEVICE=/dev/input/ts0 #指定校准文件的存放位置 export TSLIB_CALIBFILE=/etc/pointercal #指定鼠標設備 export QWS_MOUSE_PROTO=/dev/input/ts0 #指定幀緩沖設備 export TSLIB_FBDEVICE=/dev/fb0
#添加 tslib 庫
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSLIB_ROOT/lib
tslib測試:校准測試
cd /usr/local/tslib/bin
# ./ts_calibrate
開發板出現校准界面,則至此, tslib 的安裝和移植已經成功完成。
觸摸設備檢測
hexdump /dev/input/event0