Reprint Embedded Linux GUI--DIRECTFB + gtk Extreme Tips __linux

Source: Internet
Author: User
Tags bz2 cairo gtk mkdir touch vector font

Copyright Disclaimer: This document all the rights belong to Me (kendych@sina.com.cn), for commercial use Xu I agree, if unable to contact me, Subject to the consent of the www.directfb.com.cn owner, for non-commercial use, without any permission, but please respect my signature right, and indicate the source www.directfb.com.cn and attach this statement.
Tags: embedded GUI arm Linux DIRECTFB GTK tslib
1 Preface
A few years ago, once developed an embedded product, now the market still exists, but because of the rapid upgrading of electronic products, many components are not procured, in order to continue the product life cycle, plans to develop a new version on the Linux platform. And on the GUI on Linux became a big problem, the first useful Minigui plan, but also with the company, but the cost I can not afford. (Minigui as a domestic excellent embedded GUI, if not the cost of the problem, should be the best choice.) Qt I also looked under, is also charged, did not study carefully. At first I intended to use Microwindow, but later found that this thing has not been updated for a long time, a lot of bugs. The final gaze on the GTK, the beginning to start, do not know exactly suitable for do not fit to do embedded GUI, finally do not know where to see an introduction said Nokia has products are used GTK, I think since others can do, I can do. The first to do this, the relevant information is too little, there is no bottom, but after two months (long Point) of efforts to finally solve all the problems, only a stone landing. Personally think, with the help of this article, if you have a junior high level embedded Linux knowledge, perhaps one day will be able to solve the problem, the longest will not exceed one weeks.
2 Preparation work
Hardware environment: Linux host one, if you like using Windows, you can use a VMware virtual Linux system on the Windows host. Embedded development kit, including embedded Development Board, LCD screen with touch screen and related cable.
Software Environment: x86 Linux distribution, configured Framebuffer, and installed FTP server, Telnet server, TFTP server, NFS server, GCC and related software, cross compiler, development kit kernel 2.6 of the source package.
I am using the release of Ubuntu 7.10, embedded development version of the 2440 series of Samsung CPU, how to build the development environment is not covered in this article, please refer to other documents. The crossover compiler uses 3.4.1 of its own compilation, starting with the 3.4.1 of the development suite, and why do you use your own compilation instead of a development kit? Here is the first scroll of this article: because some algorithms in the vector font used in GTK use floating-point operations, and the 24XX-series CPU hard floating-point does not support (I do not have the knowledge, this is one of my colleagues said, is not he meant, I am not sure, if your CPU is not this series, Please review the relevant information, as long as the cross compiler with soft floating-point operation support, it should be no problem, so before you start, check the cross compiler there is no--with-float=soft this option. After I use the development version of the compiled from the compile, run GTK program, always have this hint "shape engine failure, expect ugly output." The offending font is, and all the characters on the screen are not displayed, button because the characters can not be displayed, compressed into a line, this problem plagued me for several days, I began to think that the font is set up the problem, and then help colleagues, he listened to my description, Speculation may be a floating-point operation problem, let me use our own compile the cross compiler recompile, see if we can solve the problem, the result is really solved.
3 Choice of Source package
Choose GTK to do embedded GUI is a painful choice, if you choose a commercial GUI such as Minigui, others will give you the whole good, you take over to use it, or with wince, or with Windows compatible. The choice of GTK GUI, 15 software packages written by different organizations (individuals), and different versions of each package, and the lack of authoritative guidance on the web, how to choose the right version and how to integrate is indeed a very complex issue.
I first from the x86 to build a GTK environment began, first I choose the latest version, and then, see the introduction said, GTK on the framebuffer run there are two modes: DIRECTFB and LINUX-FB, and the LINUX-FB project seems to have stopped, The main direction is DIRECTFB, then look for a DIRECTFB + GTK in English documents, the basic choice of the latest version, and a lot of bags can be used with the system, the compiler must be the source code on it, the beginning how the compilation is not successful, I am desperate to find release Out of the latest GTK source version (probably July 4, 08), I downloaded the first time, quickly compiled, and in framebuffer mode Gtk-demo and some test run a little problem.
After familiar with the compilation process, I first attempt to compile this latest version, compile the first package glib-2.16.4 failed. I read a lot of information about cross compiling DIRECTFB+GTK on the Internet, there is a shell script to write it seems to be good, but do not understand, although I have contacted Unix for more than 10 years, but also once in Unix to do a relatively large project, but later, Linux is a personal interest, Read some, play some, did not do things, shell programming has seen, a lot of things have been half solved, he that document look at me silly, this person really cattle. But the choice of the source package can be used for reference.
My choice:
1) tslib-1.0.tar.bz2
Touch screen Originally I was the last one, but if you need to touch the screen support, it is best to take care of him in the first. This is actually tslib.14, why became 1.0, I do not know, how to compile is not difficult, difficult in how to configure, related documents please read my other document "Arm-linux Tslib", of course, which document may not help you to fix, you need to use your intelligence, You may need to read the kernel-screen-driven source code. My Development suite Touch-screen controller is the CPU itself with the ad converter, kernel driver is compatible with H3600, so I ts.conf file Module_raw module set to h3600. If you use the Samsung 24XX series of CPUs, perhaps using the same way as I do, use the same configuration may be, if not, you may want to read the touch-screen-driven source code and Tslib Module_raw source, find a matching module on the line.
The position of the tslib of Arm-linux http://www.directfb.com.cn/viewthread.php?tid=388&extra=page%3D1

2) freetype-2.3.5.tar.bz2
3) glib-2.12.13.tar.bz2
4) libpng-1.2.19.tar.bz2
This module was originally I do not need, I compile GTK when I want to disable this module, configure can not be completed.
5) zlib-1.2.3.tar.bz2
6) jpegsrc.v6b.tar.gz
This module is what I have to, but when compiling GTK, configure said that can not find this module jpeglib.h, I also studied for a long time,
7) tiff-3.7.4.tar.gz
This module I do not need, but compiled, eventually, I will not adopt this module.
8) directfb-1.1.1.tar.gz
In the beginning I used is 1.1.0, basically normal, finally touch screen, run program DIRECTFB how also load unsuccessful Nputdrivers module libdirectfb_ Tslib.so, after reading the relevant code, found that this version of the DFB module after loading, do not read TSLIB related environment variables, directly loaded/dev/input/tslibn some equipment, and my development board up, there is no these devices, 1.1.0 after the version, The relevant code has been amended, I've also tried the latest version of the DFB 1.2.1, but this version of DF B is a bit of a problem with the GTK version that follows the good core, unable to compile the following GTK, I read the relevant code for the DFB 1.1.1, found that it has been modified, selected this version, runs the GTK program, The DFB started loading the Tslib modules, but only the modules that successfully tslib the Module_raw were loaded, and subsequent modules failed to load. What reason does not explain here, later say.
9) atk-1.19.3.tar.bz2
expat-2.0.1.tar.gz)
One) libxml2-2.6.29.tar.gz
) fontconfig-2.4.2.tar.gz
PANGO-1.16.4.TAR.BZ2)
) cairo-1.4.10.tar.gz
) gtk+-2.10.14.tar.bz2
The final compilation of this module, the completion of the compilation means that we successfully completed the compilation work, I configure this module encountered two problems: the first to find Pango, and finally see a lot, just know before configure need to set this environment variable export ldflags= "-l$prefix/lib-wl,-rpath, $PREFIX/lib". What do you mean, I don't know, why do I have this set I don't know. The second can not find jpeglib.h, I analyzed the log, found is in the test g++ compile, can not find the jpeglib.h, and test gcc compilation is no problem, I set up in configure before this export cppflags="-i $PREFIX/include" environment variables, tell g++ where to find Jpeglib.h.
4 Cross-compilation
The installation directory of all the packages that are compiled on the host system is/USR/GTKDFB, of course, you can use other directories, but must not conflict with the host environment, the cross-compiled things installed to the host system default location, may cause some unpredictable consequences of your host system. Start compiling below
1) tslib
Export PREFIX=/USR/GTKDFB
Echo "ac_cv_func_malloc_0_nonnull=yes" >arm-linux.cache
./configure--host=arm-linux--prefix= $PREFIX--cache-file=arm-linux.cache--enable-inputapi=no
Make
Make install
Only need to specify prefix an environment variable before compiling, this module compiles the following compile basic need below three
Export Ldflags=-l$prefix/lib
Export cflags="-g-i$prefix/include"
Export Pkg_config_path= $PREFIX/lib/pkgconfig
2) GLib
Echo Ac_cv_type_long_long=yes>arm-linux.cache
Echo Glib_cv_stack_grows=no>>arm-linux.cache
Echo Glib_cv_uscore=no>>arm-linux.cache
Echo Ac_cv_func_posix_getpwuid_r=yes>>arm-linux.cache
CC=ARM-LINUX-GCC./configure--host=arm-linux--build=i686-pc-linux--prefix= $PREFIX--cache-file=arm-linux.cache
Make
Make install
3) ATK
./configure--host=arm-linux--prefix= $PREFIX
Make
Make install
4) jpeg-6b
./configure--prefix= $PREFIX--enable-shared--enable-static
To modify a generated makefile file:
# The name of your C compiler:
cc= GCC should be CC=ARM-LINUX-GCC (modified according to the location of your own cross compiler)
# library (. A) file Creation command
ar= ar rc ar= arm-linux-ar RC (IBID.)
# Second Step-a creation (use "touch" if not needed)
ar2= ranlib ar2=arm-linux-ranlib (IBID.)
mkdir $PREFIX/man
mkdir $PREFIX/man/man1
Make
Make Install-lib
5) zlib
CC=ARM-LINUX-GCC./configure--prefix= $PREFIX--shared
Make
Make install
6) libpng
./configure--host=arm-linux--prefix= $PREFIX
Make
Make install
7) Expat
./configure--host=arm-linux--prefix= $PREFIX
Make
Make install
8) FreeType
./configure--host=arm-linux--prefix= $PREFIX
Make
Make install
9) Libxml
./configure--host=arm-linux--prefix= $PREFIX
Make
Make install
Fontconfig)
Export LIBXML2_CFLAGS=-I$PREFIX/INCLUDE/LIBXML2
Export libxml2_libs="-l$prefix/lib-lxml2"
./configure--host=arm-linux--prefix= $PREFIX--with-freetype-config= $PREFIX/bin/freetype-config--with-arch=arm
Make
Make install
One) TIFF
./configure--host=arm-linux--prefix= $PREFIX--enable-shared
Make
Make install
) DIRECTFB
./configure--host=arm-linux--prefix= $PREFIX--with-gfxdrivers=none--with-inputdrivers=all--enable-png- Enable-jpeg--disable-tiff--enable-zlib--enable-sdl=no--enable-gif=no--disable-x11
Make
Make install
CAIRO)
./configure--host=arm-linux--prefix= $PREFIX--without-x--disable-xlib--disable-xlib-xrender- Enable-freetype--disable-win32--enable-pdf--enable-ps--disable-svg--enable-png
Make
Make install
Do not know why, GTK must have PDF and PS support, no can not complete configure, no way, I had to open here, in fact, can not really support, because the PDF and other things did not add in. I wonder if there is any improvement in the later GTK version.
) Pango
Modify the Configure file to change some of the following parameters to True
Have_cairo=true
Have_cairo_png=true
Have_cairo_ps=true
Have_cairo_pdf=true
Have_cairo_freetype=true
./configure--host=arm-linux--prefix= $PREFIX--enable-cairo--without-x
Make
Make install
) GTK
Export Ldflags="-l$prefix/lib-wl,-rpath, $PREFIX/lib"
Export cppflags="-i$prefix/include"
./configure--host=arm-linux--prefix= $PREFIX--with-gdktarget=directfb--without-x--without-libtiff
Make
Make install
5 Development Board Operating environment
The core of the Development Board is 2.6, all drivers have finished, file system with NFS loading, in the host system is located on the/arm/root/root_nfs, I was compiled, just get the board, but the best, before compiling, it is best to familiarize yourself with the Development Board, I make a good few days before the development Board to run up Because 2.6 of the kernel used Uboot is different from the uboot used by 2.4 kernel. I've never done it before and it's been bothering me for days.
On the host system, the/USR/GTKDFB directory is copied to the/arm/root/root_nfs/usr directory, and when the Development Board is running, the compiled things will be in the/USR/GKTDFB directory.
1) Pangorc
Mkdir/arm/root/root_nfs/usr/gtkdfb/etc/pango
Create file/arm/root/root_nfs/usr/gtkdfb/etc/pango/pangorc file contents as follows
# PANGORC file for uninstalled operation.
# We set the path as.. /modules, such.
# Top level Build Subdirs.
#
[Pango]
Modulefiles =/usr/gtkdfb/etc/pango/pango.modules
Modulespath =/usr/gtkdfb/lib/pango/1.6.0/modules
Running on the host system above
The following command runs on the Development Board
/usr/gtkdfb/bin/pango-querymodules > /usr/gtkdfb/etc/pango/pango.modules
2) Gfxdrivers
The following command runs on the Development Board, but eliminates a warning
Mkdir/usr/gtkdfb/lib/directfb-1.1-0/gfxdrivers
3) Gdk-pixbuf.loaders
The following command runs on the Development Board
mkdir/usr/gtkdfb/etc/gtk-2.0
/usr/gtkdfb/bin/gdk-pixbuf-query-loaders > /usr/gtkdfb/etc/gtk-2.0/gdk-pixbuf.loaders
4) Gtk.immodules
The following command runs on the Development Board
/usr/gtkdfb/bin/gtk-query-immodules-2.0 > /usr/gtkdfb/etc/gtk-2.0/gtk.immodules
5) fonts.conf
In the/usr/gtkdfb/etc/fonts directory there is a fonts.conf file, in this file configured a number of font information, in the host system to open the file/arm/root/root_nfs/usr/gtkdfb/etc/fonts/ fonts.conf, modify <! --Font Directory list--> This line of things, set the correct font directory. Of course, the premise needs to copy the font to the appropriate directory/arm/root/root_nfs. For example, Ubuntu settings are as follows
<! --Font Directory list-->
<dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts</dir>
<dir>~/.fonts</dir>
The easiest way to do this is to copy the contents of Ubuntu into the/arm/root/root_nfs relative directory so that the file can be unmodified. But in the end you can not do so, because the embedded is not required so many fonts, as long as we need, do not need to cut off, to understand this document should also be necessary.
6) DIRECTFBRC
This file I have not used, I have to do it, because the first encounter a problem that is his problem, but not its problem, so up to now, I have not yet. Forum on VCVC0 said, there is no this file, the program loading is very slow, there is a lot faster, here to a link, I do not elaborate
http://www.directfb.com.cn/viewthread.php?tid=373
Here is the content of the post. And now I'm not even imagining my use.
How to configure a DIRECTFBRC configuration file based on arm.
I ran the application in my Development board. If there is no DIRECTFBRC file in the/etc directory, the program will take a long time to display.
I simply set the DIRECTFBRC content as follows:
System=fbdev
fbdev=/dev/fb/0
Wm=default
mode=640x480
Depth=32
Pixelformat=rgb32
The startup speed of the program is much faster, do not know what is the reason.
There is also the question of whether Direct's wm can manage the GTK window. Or there is no window manager based on embedded development that can be used.
6 The last Scroll
Now you are running the test on the board GTK source code, should be no problem, if there is a problem, it will go back to painstakingly repaired. Finally, a problem came, the USB mouse can control the mouse pointer on the screen, touch screen does not respond, obviously my tslib test program running a certain problem also did not, the DFB compiler also correctly failed Tslib This library, how is it going? This is the last scroll, and I am only so willing to call this documentThe secrets of the Supreme, and because of the secret, I think, to solve this problem requires considerable technical level.
First of all, it is complicated to explain this problem. First of all, the DFB initialization, DFB load first read DIRECTFBRC, read some settings, and then load the auxiliary module, the load of the module is dynamic, loaded with the Dlopen method. Tslib loading some modules is also loaded in this way. The application dynamically links to the DFB library, loads the modules that can be loaded, and loads the libdirectfb_tslib.so, which dynamically links to the Libts.so library, dynamically loading libdirectfb_tslib.so at the same time doing some initial Start the work of Tslib, the initial tslib will dynamically load some modules of tslib, these four modules pthres, Variance, dejitter, linear will be used libts.so this library a function tslib_parse_vars, Because libdirectfb_tslib.so is loaded with Dlopen, loading the tslib on the four modules, do not know where to find the function Tslib_parse_vars, and the Tslib test program has been dynamically linked libts.so, loading function Tslib_parse_vars can be correctly identified when the tslib is in the upper speed module.
Knowing the reason, it is easy to solve the problem. Link to the application dynamically linked to the library libts.so on it, I modify the GTK source tests directory under the makefile
Ldflags =-l/usr/gtkdfb/lib-lts-wl,-rpath,/usr/gtkdfb/lib
Recompile these test programs, copy to the Development Board, run, everything OK
7 Conclusion
In retrospect, it's really hard to build an embedded DFB+GTK GUI development platform, and do not say that so many different organizations and individuals to write the package, that is, everyone's environment is also diverse, can give you the help of the few people, encounter problems, you can only in the vast network to find solutions. It may take a lot of energy to solve any problem. If your project funds allow, or please support the domestic excellent GUI software ――minigui, you encounter problems, should be very quickly and satisfactorily resolved, will undoubtedly speed up the progress of your project development. Of course, DFB+GTK is also a good choice, when you solve the problem, you will learn a lot of things, but also bring you a great sense of achievement.
Finally, thanks to the writers of these open-source software packages, it is their selfless devotion that gives us the opportunity to learn these good code. Also thanks to those pioneers who shared their experiences on the Internet, it was their spark that inspired me and led me to the problem-solving direction. I dedicate this article to them and thank them again. At the same time, this article is dedicated to www.directfb.com.cn and the altar master Echo, as well as every present and future member of the Forum. I have just published two short texts on the forum, and I am honored that Mr Echo has invited me to be a moderator.
The construction of the environment I basically finished, the project needs, I have to do other things. If you are doing a similar job, have encountered some problems, I hope this article can help you. If you see this article elsewhere (I want to have a website reproduced in this article), please visit www.direcfb.com.cn, perhaps you can get more information.


Disclaimer: I do not guarantee that this document is completely correct, if you see any inappropriate places, welcome to communicate with me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.