1. qtopia已经可以使用触摸屏了。但是qtopia里面的qt为qt2,太旧了。为此仍然希望采用qte3来设计应用程序。
要让qte-3.3.5支持触摸屏有两种途径:
l 采用2.4的驱动结构,传送TS_event到qte中,按上面方法配置qte。
l 采用2.6的驱动结构,由于这个驱动传递的信息是到input层,qte不能直接获取,因此需要用到tslib,而此时,需要想办法让qte3.3.5支持tslib。Howto?
3. 使qte3.3.5支持tslib,按照patch的方法,增加两个文件到src/embedded/下,修改相应文件(src/embedded/qmousedriverfactory_qws.cpp, src/embedded/qt_embedded.pri,configure),其余同1。
./configure –embedded arm –thread –qvfb –qconfig-large –qt-mouse-tslib –I$QTDIR/include –L$QTDIR/lib –lts
这里需要强制指定tslib库位置,否则,会报错找不到libts。
重新配置时,需要/usr/bin/gmake confclean
结果make仍然报错,说libts不兼容。
/usr/bin/ld: skipping incompatible /home/hjcai/qt-arm/qte-arm-tslib/lib/libts.so when searching for -lts
/usr/bin/ld: cannot find –lts
4. 编译tslib-1.4
l echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.autogen #为了防止出现undefined reference to `rpl_malloc' 错误
l CONFIG_SITE=arm-linux.autogen ./configure CC=arm-linux-gcc CXX=arm-linux-g++ --host=arm-s3c2410-linux-gnu --target=arm-s3c2410-linux-gnu --disable-input --disable-arctic2 --disable-mk712 --disable-collie --disable-corgi --disable-ucb1x00 --disable-linear-h2200 --with-gnu-ld --prefix=$PWD/build
l Make
l make install
2007-05-03
1. qte编程时,可以把unix环境编程的代码直接嵌入到qte程序中,包括需要的头文件等。此时,如果用qte-x86的qvfb进行测试,要小心,因为代码的内容可能是针对arm目标板的。因此,调试工作可能需要在目标板上进行。
2. 再次尝试给qte3.3.5添加tslib支持(成功!)
2.1 编译qte3.3.5
l cp uic bin/
l (关键步骤,否则编译时会报错如上libts不兼容)$ echo yes |./configure -embedded arm -thread
$ cd src/moc
$ make
l 手动patch,增加两个文件到src/embedded/下(src/embedded/qmousetslib_qws.h, src/embedded/qmousetslib_qws.cpp),修改相应文件(src/embedded/qmousedriverfactory_qws.cpp, src/embedded/qt_embedded.pri,configure)
l 拷贝tslib.h到include,libts.so等库到lib下。
l $ echo yes |./configure -embedded arm –thread –qt-mouse-tslib –I$QTDIR/include –L$QTDIR/lib –lts
l make
l make install
2.2 拷贝文件到目标板
拷贝qte3.3.5/lib到目标板,拷贝tslib的build目录到目标板(记住,要拷贝和编译qte时使用的相同的tslib版本)
2.3 设置环境变量
export QTDIR=/hjcai
export LD_LIBRARY_PATH=/hjcai/lib
export QWS_MOUSE_PROTO=tslib:/dev/input/tsraw0
export TSLIB_TSDEVICE=/dev/input/tsraw0
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CONFFILE=/hjcai/build/etc/ts.conf
export TSLIB_PLUGINDIR=/hjcai/build/share/ts/plugins
export TSLIB_TSEVENTTYPE="H3600"
export TSLIB_CALIBFILE=/etc/pointercal
2.4 触摸屏校正
先进行触摸屏校正,注释掉build/etc/ts.conf中的dejitter模块,执行build/bin下的ts_calibrate程序,此时会在/etc下生成pointercal文件。
2.5 测试
拷贝qte3.3.5下examples/hello/hello文件到目标板,修改权限,然后执行
./hello –qws
发现程序可以用触摸屏控制。
1. 驱动学习
编译主机内核2.6.8.1的驱动,Makefile如下:
# To build modules outside of the kernel tree, we run "make"
# in the kernel source tree; the Makefile these then includes this
# Makefile once again.
# This conditional selects whether we are being included from the
# kernel Makefile or not.
ifeq ($(KERNELRELEASE),)
# Assume the source tree is where the running kernel was built
# You should set KERNELDIR in the environment if it's elsewhere
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
# The current directory is passed to sub-makes as argument
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
else
# called from kernel build system: just declare what our modules are
obj-m := hello.o
endif
在hello目录下make,生成了hello.ko,可以insmod而且lsmod可以看到hello,但没有输出hello信息.
原因:kde屏蔽了信息,可以通过dmesg /var/log/message 或dmesg /proc/kmesg
编译arm内核(2.6.14)的驱动,Makefile如下:
# To build modules outside of the kernel tree, we run "make"
# in the kernel source tree; the Makefile these then includes this
# Makefile once again.
# This conditional selects whether we are being included from the
# kernel Makefile or not.
obj-m := hello.o
KERNELDIR ?=/home/hjcai/linux-2.6.14
# The current directory is passed to sub-makes as argument
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
在hello目录下make,生成了hello.ko,拷贝到目标板上insmod .
file hello.ko,发现是针对arm的目标文件。
结果报错:
# insmod hello.ko
insmod: cannot mmap `hello.ko': Invalid argument
问题已解决:原因是通过u盘拷贝的.ko文件到目标板后截断为0字节。估计是u盘文件系统不同的原因。
用rx命令通过串口传输该模块到目标板执行,正确。
2007-03-03
1. 安装qt-embdedded-free-3.3.5,
tar qt-embedded-free-3.3.5.tar.gz
cd qt-embedded-free-3.3.5
export QTDIR=$PWD
./configure –qvfb(应该还要加-thread 选项,暂时没加,以后需要重新编译)
make
(8:40~9:20编译完成,机器性能好啊,呵呵)
2. 安装qt-x11--free-3.3.5:(为了获得uic工具)
tar qt-x11-free-3.3.5.tar.gz
cd qt-x11-free-3.3.5
export QTDIR=$PWD
./configure -thread
make
make –C tools/qvfb
cp tools/qvfb/qvfb bin/
cp tools/qvfb/qvfb ../qt-embedded-free-3.3.5/bin
3. 执行程序
cd qt-embedded-free-3.3.5
export QTDIR=$PWD
export PATH=$PWD/bin:$PATH
export LD_LIBRARY_PATH=$PWD/lib
cd examples/hello
qvfb &
./hello –qws
正确执行。
2007-3-4
1. 交叉编译qte-3.3.5过程:
cd qte-arm-3.3.5
cp /usr/local/arm/3.4.1/bin/arm-linux-g++ /bin
export QTDIR=$PWD
./configure –embedded arm –thread –qvfb –no-kbd(以后增加该选项)
make
首先,-debug选项会使make时报错。取消-debug选项。
其次,仍然报错,提示bin/uic,命令未找到。从网上调查发现,需要把qt-x11主机版的bin/uic工具拷贝到qte/bin下面。
此时编译通过。
2007-3-5
1. mount /dev/ub/a/part1/ /mnt
cp /mnt/libqte-mt.so.3.3.5 /lib
报错:unable to handle kernel paging request at virtual address 00005848
…
kernel panic-not syncing:Aiee,killing interrupt handler.
2. 通过文件系统方式来加入qte库
cd busybox-1.2.2.1
make menuconfig
make TARGET_ARCH=arm CROSS=/usr/local/arm/3.4.1/bin/arm-linux- PREFIX=/home/hjcai/myrootfs/ all install
cd ../myrootfs
cp ../linuxrc .
cp ../qte-arm-3.3.5/lib/libqte.so.3.3.5 lib
ln –s libqte.so.3.3.5 libqte.so
ln –s libqte.so.3.3.5 libqte.so.3
ln –s libqte.so.3.3.5 libqte.so.3.3
cd ..
chmod –R 777 myrootfs
mkyaffsimage myrootfs myrootfs.img
3. qte程序开发过程:
l 利用qt-x11的designer,uic生成.c,.cpp文件(qte designer工具只能在qvfb中调用,不方便)
uic *.ui -o *.h
uic *.ui –I *.h –o *.cpp
l 编写好各种源文件,包括main.cpp
l qmake –projet
l qmake
l make
l 生成可执行文件
l 通过qvfb测试
l 拷贝源代码,包括.pro文件到qte0-arm目录下,
l 在新环境下重复上述步骤,设置QTE-arm的环境变量QTDIR,PATH,LD_LIBRARY_PATH,使用qmake时保证使用的时QTE-arm的qmake。
l 拷贝到目标版运行。
问题是,交叉编译时,如何设置?
4. 执行结果:
# export LD_LIBRARY_PATH=/lib
# cd hjcai/
# ls
hello-static test
hello libqte-mt.so.3.3.5
hello-dynamic lost+found
# ./hello –qws
报错:
./hello: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
对主机版qte的hello程序:
ldd hello
linux-gate.so.1 => (0xffffe000)
libqte.so.3 => /home/hjcai/qt/qt-embedded-free-3.3.5/lib/libqte.so.3 (0x40016000)
libdl.so.2 => /lib/libdl.so.2 (0x40765000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x40769000)
libm.so.6 => /lib/tls/libm.so.6 (0x4083b000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x4085e000)
libc.so.6 => /lib/tls/libc.so.6 (0x40867000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
加入需要的库进行测试,记住必须使用交叉编译器生成的库,在/usr/local/arm/3.4.1/arm-linux/lib下。
报错:
# ./hello -qws
QWSServerSocket: could not bind to file /tmp/qtembedded-unknown/QtEmbedded-0
Error: File exists
Failed to bind to /tmp/qtembedded-unknown/QtEmbedded-0
# ls /tmp
qtembedded-unknown
# ls /tmp/qtembedded-unknown/
#
在内核中添加network->socket支持,重新编译内核,结果如下:
# ./hello -qws
Can't open framebuffer device /dev/fb0
: driver cannot connect
5. 关于qte几个环境变量在qte程序运行中的作用
l PATH添加qt下bin目录的作用在于可以在命令行中直接输入qvfb,designer等命令。如果不这样做,可以进bin目录,./qvfb执行
l QTDIR的作用在于,有些程序需要用到字库即QTDIR/lib/fonts,如果不设该变量,把fonts文件夹拷贝到系统默认的qt文件夹下也可以。
l LD_LIBRARY_PATH变量可不设置
1. 建立/dev/fb/0的连接
cd /dev
ln –s /dev/fb/0 fb0
cd /hjcai
./hello –qws
Cannot find font definition file /home/hjcai/qt-arm/qte-arm-3.3.5/lib/fonts/fontdir - is Qt installed correctly?
因此,下一步拷贝相应的字库/qte-3.3.5/lib/fonts到文件系统中。
问题:如果将整个/fonts(14M)放到root分区下,空间不够。因此放到usr分区下,此时需要重新制作usr分区的yaffs镜像。
Mkdir usr
Mkdir usr/lib
Cp ~/fonts/ usr/lib
Mkyaffsimage usr usr.img
然后在vivi中loadyaffs user x,将usr.img下载到文件系统中。
重新将hello程序拷贝到hjcai下
设定环境变量:
export QTDIR=/hjcai
./hello –qws &
hello程序成功在lcd上显示。^_^^_^
每次执行,需要重新建立连接,并且设定环境变量QTDIR。
# ./hello -qws &
# Creating mouse: Auto
Cannot open keyboard
QServerSocket: failed to bind or listen to the socket
#
但还是正常显示了。
2007-2-2
1. 自编应用程序无法在目标机上运行的原因:程序是动态编译,而busybox是静态链接。因此,解决办法有两个:
l 静态编译程序
l 动态链接busybox
2. 动态链接busybox的方法是在配置选项中取消静态链接选项,选择编译共享链接库。但这样制作出的文件系统有问题,无法启动,信息如下:
VFS: Mounted root (yaffs filesystem).
Mounted devfs on /dev
Freeing init memory: 92K
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
后来,从网上得知,需要在文件系统lib库中添加一些库。从交叉编译器3.4.1/arm-linux/lib中拷贝了以下库到lib中:
ld-2.3.2.so
libc-2.3.2.so
libm-2.3.2.so
结果,还是启动不了,启动信息同上。
2007-2-7
1. 静态busybox文件系统中运行静态函数hello成功。
arm-linux-gcc -static hello.c -o hello
然后通过优盘拷贝到目标板下,运行正确。
但是,gcc -static hello.c -o hello还是报错:
/usr/bin/ld:cannot find -lc
collect2:ld returned 1 exit status
2. 按网友指示,在文件系统lib中建立连接,同3.4.1/arm-linux/lib中的一样。Busybox采用动态连接。
加了那些库ld,libc,libm以及建的连接后,文件系统镜像达到6M多,用串口传输需要近15分钟,因此长远看,需要找速度更快的传输方式,例如usb。
成功 !^_^^_^!!!!动态交叉编译的程序hello在板子上运行也正常。
总结动态连接busybox生成yaffs文件系统:
l 配置busybox
# Build Options
#
# CONFIG_STATIC is not set
CONFIG_BUILD_LIBBUSYBOX=y
# CONFIG_FEATURE_FULL_LIBBUSYBOX is not set
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
# CONFIG_LFS is not set
USING_CROSS_COMPILER=y
CROSS_COMPILER_PREFIX="/usr/local/arm/3.4.1/bin/arm-linux-"
# CONFIG_BUILD_AT_ONCE is not set
l make TARGET_ARCH=arm CROSS=/usr/local/arm/3.4.1/bin/arm-linux- PREFIX=/home/hjcai/myrootfs/ all install
l 拷贝3.4.1/arm-linux-/lib中函数库到文件系统lib目录下,内容如下:
$ ll lib
总用量 6028
-rwxrwxrwx 1 root root 131480 2月 7 21:22 ld-2.3.2.so*
lrwxrwxrwx 1 root root 11 2月 7 21:24 ld-linux.so.2 -> ld-2.3.2.so*
drwxrwxrwx 2 root root 4096 2月 7 21:23 ldscripts/
lrwxrwxrwx 1 root root 19 2月 7 21:14 libbusybox.so -> libbusybox.so.1.
2.2*
lrwxrwxrwx 1 root root 19 2月 7 21:14 libbusybox.so.1 -> libbusybox.so.
1.2.2*
lrwxrwxrwx 1 root root 19 2月 7 21:14 libbusybox.so.1.2 -> libbusybox.s
o.1.2.2*
-rwxrwxrwx 1 root root 88472 2月 7 21:14 libbusybox.so.1.2.2*
-rwxrwxrwx 1 root root 1560352 2月 7 21:19 libc-2.3.2.so*
-rwxrwxrwx 1 root root 2928806 2月 7 21:19 libc.a*
-rwxrwxrwx 1 root root 7748 2月 7 21:19 libc_nonshared.a*
-rwxrwxrwx 1 root root 30155 2月 7 21:19 libcrypt-2.3.2.so*
-rwxrwxrwx 1 root root 23246 2月 7 21:19 libcrypt.a*
lrwxrwxrwx 1 root root 13 2月 7 21:27 libcrypt.so -> libcrypt.so.1*
lrwxrwxrwx 1 root root 17 2月 7 21:27 libcrypt.so.1 -> libcrypt-2.3.2.s
o*
-rwxrwxrwx 1 root root 164 2月 7 21:19 libc.so*
lrwxrwxrwx 1 root root 13 2月 7 21:25 libc.so.6 -> libc-2.3.2.so*
-rwxrwxrwx 1 root root 249 2月 7 21:19 libc.so_orig*
-rwxrwxrwx 1 root root 546854 2月 7 21:20 libm-2.3.2.so*
-rwxrwxrwx 1 root root 772774 2月 7 21:20 libm.a*
-rwxrwxrwx 1 root root 812 2月 7 21:20 libmcheck.a*
-rwxrwxrwx 1 root root 22220 2月 7 21:20 libmemusage.so*
lrwxrwxrwx 1 root root 9 2月 7 21:28 libm.so -> libm.so.6*
lrwxrwxrwx 1 root root 13 2月 7 21:28 libm.so.6 -> libm-2.3.2.so*
l 删除myrootfs下的linuxrc,完成自己的linuxrc。用bash解释。
l chmod 777 linuxrc
l mkyaffsimage myrootfs myrootfs.img
l reset目标板
l vivi>loadyaffs root x,在超级终端下用xmodem传输。
l vivi>boot,成功进入系统。