Chinaunix首页 | 论坛 | 博客
  • 博客访问: 434029
  • 博文数量: 53
  • 博客积分: 2746
  • 博客等级: 少校
  • 技术积分: 829
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-14 10:41
文章分类

全部博文(53)

文章存档

2016年(2)

2013年(1)

2012年(7)

2011年(10)

2010年(5)

2009年(20)

2008年(8)

我的朋友

分类: LINUX

2011-11-16 11:59:46

目  的: 测试此 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环境中编译: 
 
  1. # PREFIX="/usr/minigui"
  2. root@100servers:/home/longjindong# export PATH=/usr/local/arm_linux_4.3/usr/bin:$PATH
  2、编译tslib-1.0:
  1. pwd
  2. /home/longjindong/src/gui/minigui
  3. cd tslib-1.0
  4. ./configure --build=i686-pc-linux --target=arm-linux --host=arm-linux --enable-inputapi=no --prefix="$PREFIX" ac_cv_func_malloc_0_nonnull=yes
  5. make install
  6. 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 改动后如下:
  1. /*
  2. ** $Id: dummy.c 7335 2007-08-16 03:38:27Z xgwang $
  3. **
  4. ** dummy.c: The dummy IAL engine.
  5. **
  6. ** Copyright (C) 2003 ~ 2007 Feynman Software.
  7. ** Copyright (C) 2001 ~ 2002 Wei Yongming.
  8. **
  9. ** Created by Wei Yongming, 2001/09/13
  10. */
  11.                                                                                                                                      
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <unistd.h>
  16. #include <fcntl.h>
  17. #include <tslib.h>
  18. #include "common.h"
  19.                                                                                                                                      
  20. #ifdef _DUMMY_IAL
  21. #include <sys/ioctl.h>
  22. #include <sys/poll.h>
  23. #include <sys/types.h>
  24. #include <sys/stat.h>
  25. #include <linux/kd.h>
  26.                                                                                                                                      
  27. #include "misc.h"
  28. #include "ial.h"
  29. #include "dummy.h"
  30.                                                                                                                                      
  31. #ifdef _DEBUG
  32.         #undef _DEBUG
  33. #endif
  34.                                                                                                                                      
  35. #if 1 /*打开调试,看操作时的信息*/
  36.         #ifndef _DEBUG
  37.                 #define _DEBUG
  38.         #endif
  39. #endif
  40.                                                                                                        
  41. #define MAX_MOUSE_X 319
  42. #define MAX_MOUSE_Y 239
  43.                                                                                                                                      
  44. /* for storing data reading from /dev/event0 */
  45. typedef struct {
  46.         unsigned short pressure;
  47.         unsigned short x;
  48.         unsigned short y;
  49.         unsigned short pad;
  50. } TS_EVENT;
  51.                                                                                                                                      
  52. static int mou***, mousey;
  53. static TS_EVENT ts_event;
  54. static struct tsdev *ts;
  55.                                                                                                                                      
  56. /************************ Low Level Input Operations **********************/
  57. /*
  58. * Mouse operations -- Event
  59. */
  60. static int mouse_update(void)
  61. {
  62.         return 1;
  63. }
  64.                                                                                                                                      
  65. static void mouse_getxy (int* x, int* y)
  66. {
  67.         if (mou*** < 0) mou*** = 0;
  68.         if (mousey < 0) mousey = 0;
  69.         if (mou*** > MAX_MOUSE_X) mou*** = MAX_MOUSE_X;
  70.         if (mousey > MAX_MOUSE_Y) mousey = MAX_MOUSE_Y;
  71.                                                                                                                                      
  72. #ifdef _DEBUG
  73.         printf ("mou*** = %d, mousey = %d\n", mou***, mousey);
  74. #endif
  75.         *x = mou***;
  76.         *y = mousey;
  77. }
  78.                                                                                                                                      
  79. static int mouse_getbutton(void)
  80. {
  81.         return ts_event.pressure;
  82. }
  83.                                                                                                                                      
  84. #ifdef _LITE_VERSION
  85. static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except, struct timeval *timeout)
  86. #else
  87. static int wait_event (int which, fd_set *in, fd_set *out, fd_set *except,
  88. struct timeval *timeout)
  89. #endif
  90. {
  91.         struct ts_sample sample;
  92.         int ret = 0;
  93.         int fd;
  94.         fd_set rfds;
  95.         int e;
  96.         if (!in) {
  97.                 in = &rfds;
  98.                 FD_ZERO (in);
  99.         }
  100.         fd = ts_fd(ts);
  101.         if ((which & IAL_MOUSEEVENT) && fd >= 0) {
  102.                 FD_SET (fd, in);
  103. #ifdef _LITE_VERSION
  104.         if (fd > maxfd) maxfd = fd;
  105. #endif
  106.         }
  107. #ifdef _LITE_VERSION
  108.         e = select (maxfd + 1, in, out, except, timeout) ;
  109. #else
  110.         e = select (FD_SETSIZE, in, out, except, timeout) ;
  111. #endif
  112.         if (e > 0) {
  113. // input events is coming
  114.                 if (fd > 0 && FD_ISSET (fd, in)) {
  115.                 FD_CLR (fd, in);
  116.                 ts_event.x=0;
  117.                 ts_event.y=0;
  118.                 ret = ts_read(ts, &sample, 1);
  119.                 if (ret < 0) {
  120.                         perror("ts_read()");
  121.                         exit(-1);
  122.                 }
  123.                 ts_event.x = sample.x;
  124.                 ts_event.y = sample.y;
  125.                 ts_event.pressure = (sample.pressure > 0 ? 4:0);
  126. // if (ts_event.pressure > 0 &&
  127.                 if((ts_event.x >= 0 && ts_event.x <= MAX_MOUSE_X) &&
  128.                 (ts_event.y >= 0 && ts_event.y <= MAX_MOUSE_Y)) {
  129.                         mou*** = ts_event.x;
  130.                         mousey = ts_event.y;
  131. // printf("ts_event.x is %d, ts_event.y is %d------------------------------------->\n",ts_event.x ,ts_event.y);
  132.                 }
  133.         //#ifdef _DEBUG
  134.         // if (ts_event.pressure > 0) {
  135.         // 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);
  136.         // }
  137.         //#endif
  138.                 ret |= IAL_MOUSEEVENT;
  139.                 return (ret);
  140.                 }
  141.         }
  142.         else if (e < 0) {
  143.                 return -1;
  144.         }
  145.         return (ret);
  146. }
  147.                                                                                                                                      
  148.                                                                                                                                      
  149. BOOL InitDummyInput(INPUT* input, const char* mdev, const char* mtype)
  150. {
  151.         char *ts_device = NULL;
  152.         if ((ts_device = getenv("TSLIB_TSDEVICE")) != NULL) {
  153.                 // open touch screen event device in blocking mode
  154.                 ts = ts_open(ts_device, 0);
  155.         } else {
  156. #ifdef USE_INPUT_API
  157.                 ts = ts_open("/dev/input/0raw", 0);
  158. #else
  159.                 ts = ts_open("/dev/touchscreen/ucb1x00", 0);
  160. #endif
  161.         }
  162. #ifdef _DEBUG
  163.         printf ("TSLIB_TSDEVICE is open!!!!!!!!!!!\n");
  164. #endif
  165.         if (!ts) {
  166.                 perror("ts_open()");
  167.                 exit(-1);
  168.         }
  169.         if (ts_config(ts)) {
  170.                 perror("ts_config()");
  171.                 exit(-1);
  172.         }
  173.         input->update_mouse = mouse_update;
  174.         input->get_mouse_xy = mouse_getxy;
  175.         input->set_mouse_xy = NULL;
  176.         input->get_mouse_button = mouse_getbutton;
  177.         input->set_mouse_range = NULL;
  178.         input->wait_event = wait_event;
  179.         mou*** = 0;
  180.         mousey = 0;
  181.         ts_event.x = ts_event.y = ts_event.pressure = 0;
  182.         return TRUE;
  183. }
  184. void TermDummyInput(void)
  185. {
  186.         if (ts)
  187.         ts_close(ts);
  188. }
  189. #endif /* _DUMMY_IAL */
  说明:这些代码是拷贝网上前辈们的,我只是根据我的环境做简单修改。
  3)编译libminigui:
  1. cd libminigui-1.6.10
  2. ./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"
  3. make install
  4. cd ..
  说明:(1)CPPFLAGS和LDFLAGS,把上面编译的tslib库加进来;
        (2)如果不想显示鼠标光标,加上 --disable-cursor。
  4. minigui-res-1.6.10:
     这个只是资源文件,只要 make install 安装到/usr/local/lib/minigui/res/即可,完后移到NUC950板上,也是这个路径,以便minigui应用运行时需要。
  1. cd minigui-res-1.6.10
  2. make install
  3. cd ..
  5. 编译 popt-1.14:
  1. cd popt-1.14
  2. ./configure --prefix="$PREFIX" --host=arm-linux
  3. make install
  4. cd ..
  6. 编译 mde-1.6.10:
    1)把源码中的用到“rindex”函数的地方,替换成“strrchr”。
    2)编译mde: 
  1. cd mde-1.6.10
  2. ./configure --prefix="$PREFIX" --host=arm-linux CPPFLAGS=-I"$PREFIX/include" LDFLAGS=-L"$PREFIX/lib"
  3. make
  4. cp -a src/picview "$PREFIX"
  5. cd "$PREFIX/picview"
  6. 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中
  1. cp -dr /usr/minigui /home/longjindong/nuc950-2.6.35.4/nuc900bsp/nfs-boot/usr
  2. mkdir -p /home/longjindong/nuc950-2.6.35.4/nuc900bsp/nfs-boot/usr/local/lib/
  3. 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 中:
  1. export TSLIB_CONFFILE=/usr/minigui/etc/ts.conf
  2. export TSLIB_PLUGINDIR=/usr/minigui/lib/ts
  3. export TSLIB_TSDEVICE=/dev/input/event0
  4. export LD_LIBRARY_PATH=/usr/minigui/lib
  5. export TSLIB_CALIBFILE=/etc/pointercal
    2)打开/usr/minigui/etc/ts.conf文件中的如下内容:
  1. module_raw input
  2. module linear
    3)cp /usr/minigui/etc/MiniGUI.cfg /etc/ 并配置如下内容:
  1. [system]
  2. gal_engine=fbcon
  3. defaultmode=320x240-16bpp
  4. ial_engine=dummy
  5. mdev=/dev/input/event0
  6.  [fbcon]
  7. defaultmode=320x240-16bpp
   4)执行ts_calibrate,生成 /etc/pointercal 触摸屏校正文件
  1. /usr/minigui/ts_calibrate
      然后点显示屏中上十。
   5)运行picview
  1. cd /usr/minigui/picview/
  2. ./picview &

如果不出意外,就可以看到界面。然后看一下就知道怎么回事了。

参考:

http://enchen.blog.51cto.com/716040/148170

http://blog.csdn.net/futurepeter/article/details/5583136

 

阅读(1735) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~