目 的: 测试此 CPU JPEG 图片显示能力
环 境: 1)i386-linux : Ubuntu 10.10
2)arm -linux : Linux version 2.6.35.4
3)CrossToolchain : arm-uClibc-gcc4.3.4
4)arm - GUI : MiniGUI 1.6.10 及相关程序。
难 点:因为是uClibc及其版本问题吧,移植难度大,拿这套工具编译microwindows-0.91不通过,由于时间关系,没去解决;qt-everywhere-opensource-src-4.6.3和MiniGUI 1.6.10做一些改动后可以编译。由于MiniGUI 1.6.10相对较小,就移MiniGUI 1.6.10。
准备相关原码:
1)libminigui-1.6.10.tar.gz #开发库
2)minigui-res-1.6.10.tar.gz #字体、图标、位图和鼠标光标等资源文件
3)mde-1.6.10.tar.gz #综合演示程序,要用到里面的picview
4)popt-1.14.tar.gz #没有它mde-1.6.10编译不通过
5)tslib-1.0
将它们放在 中并解压好。
另外其它依赖库:zlib、png、jpeg等库armtoolchain里面有。tslib-1.0 NUC950 BSP里面有拷贝过来编译。
开始编译:
1、配置编译环境,为了不心要的麻烦,我就在root环境中编译:
- # PREFIX="/usr/minigui"
- root@100servers:/home/longjindong# export PATH=/usr/local/arm_linux_4.3/usr/bin:$PATH
2、编译tslib-1.0:
- pwd
- /home/longjindong/src/gui/minigui
- cd tslib-1.0
- ./configure --build=i686-pc-linux --target=arm-linux --host=arm-linux --enable-inputapi=no --prefix="$PREFIX" ac_cv_func_malloc_0_nonnull=yes
- make install
- cd ../
说明:(1).要加 ac_cv_func_malloc_0_nonnull=yes ,不然会有 fbutils.c:(.text+0xa68): undefined reference to `rpl_malloc' 错误。
3、编译libminigui-1.6.10
1)、为了mde能编译通过,把libminigui-1.6.10里所有与bzero、rindex的地方相应的都改成memset(加上参数“0”)和strrchr;因为uClibc有没bzero,index,rindex函数,要用memset,strchr,strrchr来代替,这在移植其它软件时也发现过;不然会bzero等错误。
2)、为了与tslib匹配,能用触摸屏,src/ial/dummy.c 改动后如下:
- /*
- ** $Id: dummy.c 7335 2007-08-16 03:38:27Z xgwang $
- **
- ** dummy.c: The dummy IAL engine.
- **
- ** Copyright (C) 2003 ~ 2007 Feynman Software.
- ** Copyright (C) 2001 ~ 2002 Wei Yongming.
- **
- ** Created by Wei Yongming, 2001/09/13
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <tslib.h>
- #include "common.h"
-
- #ifdef _DUMMY_IAL
- #include <sys/ioctl.h>
- #include <sys/poll.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <linux/kd.h>
-
- #include "misc.h"
- #include "ial.h"
- #include "dummy.h"
-
- #ifdef _DEBUG
- #undef _DEBUG
- #endif
-
- #if 1 /*打开调试,看操作时的信息*/
- #ifndef _DEBUG
- #define _DEBUG
- #endif
- #endif
-
- #define MAX_MOUSE_X 319
- #define MAX_MOUSE_Y 239
-
- /* for storing data reading from /dev/event0 */
- typedef struct {
- unsigned short pressure;
- unsigned short x;
- unsigned short y;
- unsigned short pad;
- } TS_EVENT;
-
- static int mou***, mousey;
- static TS_EVENT ts_event;
- static struct tsdev *ts;
-
- /************************ Low Level Input Operations **********************/
- /*
- * Mouse operations -- Event
- */
- static int mouse_update(void)
- {
- return 1;
- }
-
- static void mouse_getxy (int* x, int* y)
- {
- if (mou*** < 0) mou*** = 0;
- if (mousey < 0) mousey = 0;
- if (mou*** > MAX_MOUSE_X) mou*** = MAX_MOUSE_X;
- if (mousey > MAX_MOUSE_Y) mousey = MAX_MOUSE_Y;
-
- #ifdef _DEBUG
- printf ("mou*** = %d, mousey = %d\n", mou***, mousey);
- #endif
- *x = mou***;
- *y = mousey;
- }
-
- static int mouse_getbutton(void)
- {
- return ts_event.pressure;
- }
-
- #ifdef _LITE_VERSION
- static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except, struct timeval *timeout)
- #else
- static int wait_event (int which, fd_set *in, fd_set *out, fd_set *except,
- struct timeval *timeout)
- #endif
- {
- struct ts_sample sample;
- int ret = 0;
- int fd;
- fd_set rfds;
- int e;
- if (!in) {
- in = &rfds;
- FD_ZERO (in);
- }
- fd = ts_fd(ts);
- if ((which & IAL_MOUSEEVENT) && fd >= 0) {
- FD_SET (fd, in);
- #ifdef _LITE_VERSION
- if (fd > maxfd) maxfd = fd;
- #endif
- }
- #ifdef _LITE_VERSION
- e = select (maxfd + 1, in, out, except, timeout) ;
- #else
- e = select (FD_SETSIZE, in, out, except, timeout) ;
- #endif
- if (e > 0) {
- // input events is coming
- if (fd > 0 && FD_ISSET (fd, in)) {
- FD_CLR (fd, in);
- ts_event.x=0;
- ts_event.y=0;
- ret = ts_read(ts, &sample, 1);
- if (ret < 0) {
- perror("ts_read()");
- exit(-1);
- }
- ts_event.x = sample.x;
- ts_event.y = sample.y;
- ts_event.pressure = (sample.pressure > 0 ? 4:0);
- // if (ts_event.pressure > 0 &&
- if((ts_event.x >= 0 && ts_event.x <= MAX_MOUSE_X) &&
- (ts_event.y >= 0 && ts_event.y <= MAX_MOUSE_Y)) {
- mou*** = ts_event.x;
- mousey = ts_event.y;
- // printf("ts_event.x is %d, ts_event.y is %d------------------------------------->\n",ts_event.x ,ts_event.y);
- }
- //#ifdef _DEBUG
- // if (ts_event.pressure > 0) {
- // printf ("mouse down: ts_event.x = %d, ts_event.y = %d,ts_event.pressure = %d\n",ts_event.x,ts_event.y,ts_event.pressure);
- // }
- //#endif
- ret |= IAL_MOUSEEVENT;
- return (ret);
- }
- }
- else if (e < 0) {
- return -1;
- }
- return (ret);
- }
-
-
- BOOL InitDummyInput(INPUT* input, const char* mdev, const char* mtype)
- {
- char *ts_device = NULL;
- if ((ts_device = getenv("TSLIB_TSDEVICE")) != NULL) {
- // open touch screen event device in blocking mode
- ts = ts_open(ts_device, 0);
- } else {
- #ifdef USE_INPUT_API
- ts = ts_open("/dev/input/0raw", 0);
- #else
- ts = ts_open("/dev/touchscreen/ucb1x00", 0);
- #endif
- }
- #ifdef _DEBUG
- printf ("TSLIB_TSDEVICE is open!!!!!!!!!!!\n");
- #endif
- if (!ts) {
- perror("ts_open()");
- exit(-1);
- }
- if (ts_config(ts)) {
- perror("ts_config()");
- exit(-1);
- }
- input->update_mouse = mouse_update;
- input->get_mouse_xy = mouse_getxy;
- input->set_mouse_xy = NULL;
- input->get_mouse_button = mouse_getbutton;
- input->set_mouse_range = NULL;
- input->wait_event = wait_event;
- mou*** = 0;
- mousey = 0;
- ts_event.x = ts_event.y = ts_event.pressure = 0;
- return TRUE;
- }
- void TermDummyInput(void)
- {
- if (ts)
- ts_close(ts);
- }
- #endif /* _DUMMY_IAL */
说明:这些代码是拷贝网上前辈们的,我只是根据我的环境做简单修改。
3)编译libminigui:
- cd libminigui-1.6.10
- ./configure --prefix="$PREFIX" --host=arm-linux --enable-autoial --build=i386-linux --with-target-name=fbcon --with-style=classic --with-osname=linux --enable-rbf16 CPPFLAGS=-I"$PREFIX/include" LDFLAGS=-L"$PREFIX/lib -lts"
- make install
- cd ..
说明:(1)CPPFLAGS和LDFLAGS,把上面编译的tslib库加进来;
(2)如果不想显示鼠标光标,加上 --disable-cursor。
4. minigui-res-1.6.10:
这个只是资源文件,只要 make install 安装到/usr/local/lib/minigui/res/即可,完后移到NUC950板上,也是这个路径,以便minigui应用运行时需要。
- cd minigui-res-1.6.10
- make install
- cd ..
5. 编译 popt-1.14:
- cd popt-1.14
- ./configure --prefix="$PREFIX" --host=arm-linux
- make install
- cd ..
6. 编译 mde-1.6.10:
1)把源码中的用到“rindex”函数的地方,替换成“strrchr”。
2)编译mde:
- cd mde-1.6.10
- ./configure --prefix="$PREFIX" --host=arm-linux CPPFLAGS=-I"$PREFIX/include" LDFLAGS=-L"$PREFIX/lib"
- make
- cp -a src/picview "$PREFIX"
- cd "$PREFIX/picview"
- rm {Makefile*,picview.c,picview.o} -fr
说明:编译好 mde-1.6.10 并把它 copy 到 /usr/minigui 中,方便一起copy到板上运行。
到这,编译工作就完成了。
NUC950板中运行minigui应用:
声明:为了方便我跑的是 NFS 。文件系统路径为 /home/longjindong/nuc950-2.6.35.4/nuc900bsp/nfs-boot。
1. 把刚才在ubuntu中编译好的 minigui 到 NUC950 NFS中
- cp -dr /usr/minigui /home/longjindong/nuc950-2.6.35.4/nuc900bsp/nfs-boot/usr
- mkdir -p /home/longjindong/nuc950-2.6.35.4/nuc900bsp/nfs-boot/usr/local/lib/
- cp -a /usr/local/lib/minigui /home/longjindong/nuc950-2.6.35.4/nuc900bsp/nfs-boot/usr/local/lib/
注意:这里有两步,第一步拷贝minigui库及picview应用;第二步拷贝资源文件。
2. 到NUC950板中配置及运行picview:
1)把下面环境变量加到 /etc/profile 中:
- export TSLIB_CONFFILE=/usr/minigui/etc/ts.conf
- export TSLIB_PLUGINDIR=/usr/minigui/lib/ts
- export TSLIB_TSDEVICE=/dev/input/event0
- export LD_LIBRARY_PATH=/usr/minigui/lib
- export TSLIB_CALIBFILE=/etc/pointercal
2)打开/usr/minigui/etc/ts.conf文件中的如下内容:
- module_raw input
- module linear
3)cp /usr/minigui/etc/MiniGUI.cfg /etc/ 并配置如下内容:
- [system]
- gal_engine=fbcon
- defaultmode=320x240-16bpp
- ial_engine=dummy
- mdev=/dev/input/event0
- [fbcon]
- defaultmode=320x240-16bpp
4)执行ts_calibrate,生成 /etc/pointercal 触摸屏校正文件
- /usr/minigui/ts_calibrate
然后点显示屏中上十。
5)运行picview
- cd /usr/minigui/picview/
- ./picview &
如果不出意外,就可以看到界面。然后看一下就知道怎么回事了。
参考:
http://enchen.blog.51cto.com/716040/148170
http://blog.csdn.net/futurepeter/article/details/5583136
阅读(1745) | 评论(0) | 转发(0) |