Reprinted embedded Linux Gui-directfb + GTK Supreme secret

Source: Internet
Author: User
Tags cairo gtk vector font

Copyright statement: All rights herein are owned by me (kendych@sina.com.cn) and shall be subject to my consent for commercial purposes. If I cannot contact me, I shall obtain the consent of the owner of www.directfb.com.cn; for non-commercial purposes, no permission is required, but please respect your authority and indicate the source www.directfb.com.cn and add this statement.
Keywords: Embedded gui arm Linux directfb GTK tslib
1 Preface
 

A few years ago, an embedded product was developed and still exists in the market. However, due to the rapid upgrading of electronic products, many components cannot be purchased. To continue the product lifecycle, plan
Develop a new version on Linux. On Linux, the GUI has become a major problem. At first, the intention to use MiniGUI was also contacted with the company, but I cannot afford the cost here.
. (MiniGUI, as an excellent embedded GUI in China, should be the best choice if it is not a matter of cost .)
I also read QT, which is also charged and I did not study it carefully. At first, I planned to use microwindow, but later I found that this item had not been updated for a long time, and there were a lot of bugs. Last glance
In GTK, I had no idea at the very beginning. I don't know whether it is suitable for Embedded GUI or where it is. Finally, I Don't Know Where To see an introduction saying that Nokia has products that use GTK. I think that since others can do it, me too
Yes. At the very beginning, there was too little relevant information and there was no base at all. However, after two months of hard work, we finally solved all the problems and finally got a stone. I personally think that with the help of this article, such
If you have intermediate embedded Linux knowledge, you may be able to solve the problem in one day, and the maximum length will not exceed one week.
2. Preparations
Hardware environment: One Linux host. If you prefer Windows, you can use VMware to virtualize a Linux system on a Windows host. Embedded Development Kit, including Embedded Development Board, LCD screen with touch screen, and related connection cables.
Software environment: x86 Linux release, with framebuffer configured, install the source code package of FTP server, telnet server, TFTP server, NFS server, GCC, related software, cross compiler, and Development Kit kernel 2.6.
 
I use ubuntu.
The release version of 7.10 and the embedded development version adopt Samsung's 2440 series CPU. How to set up a development environment is not covered in this article. Please refer to other documents. The cross compiler uses its own compilation.
3.4.1. The developer kit 3.4.1 was used at the beginning. Why should I use my own compilation instead of the built-in developer kit?
The first secret in this article: some algorithms in GTK's vector font use floating point operations, but the hard floating point of the 24xx series CPU is not supported (I have no relevant knowledge, one of my colleagues said:
If your CPU is not in this series, please check the relevant information), as long as you add soft floating point Operation Support to the cross compiler, there should be no problem, so
Before starting, check whether the cross compiler has the -- with-float = soft option. After I use the built-in compilation of the Development edition to complete the compilation, the program that runs GTK always has this
The following message is displayed: "shape engine failure, please CT uugly output. The offending font
Is ", and all the characters on the screen cannot be displayed. Because the button cannot be displayed, It is compressed into a line. This problem has plagued me for several days. I started to think it was a problem with font settings, later
After listening to my description, he guessed it could be a problem with floating point operations. Let me recompile it with our own cross compiler to see if it can solve the problem, the result is actually solved.
3. source code package selection
 
It is a painful choice to use GTK for Embedded GUI. If you use commercial GUI such as MiniGUI, other people will give it to you. You can use it, or use wince or
Windows compatibility. GTK is used as the GUI, and 15 software packages compiled by different organizations (individuals) have different versions of each software package. However, there is no authoritative guide on the Internet, and how to choose an appropriate one?
Version and integration are indeed very complicated issues.
I started by setting up the GTK environment on x86. First, I chose the latest version.
There are two modes to run on framebuffer: directfb
And Linux-FB, while the Linux-FB project seems to have stopped. The main direction is directfb. Later I checked a directfb +
The latest version is used for the English documents of GTK, and many packages can be built with the system. You can compile the required source code. At the beginning, the compilation fails, when I was desperate, I found that
The latest GTK source code version (around July 4) was released. I downloaded it for the first time and quickly compiled it. In framebuffer mode, GTK-demo and
Some test tasks have no problems at all.

After getting familiar with the compilation process, I first try to use the latest version of cross-compilation. compiling the first package glib-2.16.4 fails. I have read a lot about cross-compilation on the Internet.
The directfb + GTK materials seem to be well written using shell scripts, but I don't understand it. Although I have been familiar with Unix for more than a decade, I have made a bigger one in UNIX.
But later, Linux was a personal interest. I read some of it, played some of it, and did not do anything. I have seen it in shell programming, and I have been doing a lot of things for a long time, I am so stupid to read his document.
However, the source code package can be used for reference.
My options:
1) tslib-1.0.tar.bz2
 
The touch screen was the last thing I did, but if you need touch screen support, you 'd better fix it in the first place. This is actually tslib.14. I don't know why it became 1.0. How to compile it?
It is very difficult. how to configure it is difficult. For more information about the relevant documentation, please read another article, "tslib of arm-Linux". Of course, which document may not be able to help you solve this problem, you need to use your intelligence
Smart, you may need to read the source code of the touch screen driver in the kernel. In my Development Kit, the touch screen controller uses the active converter of the CPU itself, and the driver in the kernel is compatible with h3600, so
In the Ts. conf file, set the module_raw module to h3600. If you use Samsung's 24xx series CPU, you may use the same method as me.
Yes. If not, you may need to read the source code of the touch screen driver and the module_raw source code of tslib to find the matching module.
The position http://www.directfb.com.cn/viewthread.php of "arm-Linux tslib? Tid = 388 & amp; extra = Page % 3d1

2) freetype-2.3.5.tar.bz2
3) glib-2.12.13.tar.bz2
4) libpng-1.2.19.tar.bz2
I don't need this module. I want to disable this module when compiling GTK, and configure cannot be completed.
Zlib-1.2.3.tar.bz2 (5)
6) Explain src.v6b.tar.gz
This module is mandatory for me, but when compiling GTK, configure said that the kernel Lib. H of this module could not be found. I have studied it for a long time,
7) tiff-3.7.4.tar.gz
I don't need this module, But I compiled it. In the end, I won't use this module.
8) DirectFB-1.1.1.tar.gz
 
 
At first, I used 1.1.0, which is basically normal. Finally, when I got a touch screen, how can I load modules in nputdrivers when I run the directfb program?
Libdirectfb_tslib.so. After reading the relevant code, the module of DFB in this version is found to be loaded without reading the related environment variables of tslib.
Some devices are/dev/input/tslibn, and my Development Board does not have these devices at all. Versions later than 1.1.0 have been corrected by the relevant code. I also tried the latest version.
DFB 1.2.1. However, this version of df B is a bit difficult to work with the GTK version selected after the kernel. I cannot compile the later GTK.
1.1.1 related code, found to have been corrected, select this version, run the GTK program, DFB starts to load tslib related modules, but only load tslib
Module_raw module. The subsequent modules cannot be loaded. I will not explain the reason here. I will discuss it later.
9) atk-1.19.3.tar.bz2
10) expat-2.0.1.tar.gz
11) libxml2-2.6.29.tar.gz
12) fontconfig-2.4.2.tar.gz
13) pango-1.16.4.tar.bz2
14) cairo-1.4.10.tar.gz
15) gtk2017-2.10.14.tar.bz2
 
 
The final compilation of this module means that we have successfully completed the compilation. I encountered two problems in configure: first, I couldn't find pango, and finally I saw a lot of problems.
Before configure, you need to set the environment variable export ldflags = & quot;-L $ prefix/lib.
-Wl,-rpath, $ prefix/lib & quot;
I don't know why. Second, I couldn't find mongolib. h. I analyzed the log and found that it was not found during G ++ compilation.
Using Lib. H, and testing GCC compilation is okay. I set this export before configure.
Cppflags = & quot;-I $ prefix/include & quot; environment variable, tell G ++ where to find the Compiler
Using Lib. h.
4. Cross-Compilation
The installation directory of all packages after cross-compiling on the host system is/usr/gtkdfb. Of course, you can use other directories, but they must not conflict with the host environment, installing the cross-compiled items to the default location of the host system may cause unpredictable consequences of your host system. Compile
1) tslib
Export prefix =/usr/gtkdfb
Echo & quot; ac_cv_func_malloc_0_nonnull = Yes & quot; & gt; arm-linux.cache
./Configure -- Host = arm-Linux -- prefix = $ prefix -- cache-file = arm-linux.cache -- enable-inputapi = No
Make
Make install

You only need to specify the prefix environment variable before compilation. The compilation of this module requires the following three
Export ldflags =-L $ prefix/lib
Export cflags = & quot;-g-I $ prefix/include & quot;
Export pkg_config_path = $ prefix/lib/pkgconfig

2) glib
Echo ac_cv_type_long_long = Yes & gt; arm-linux.cache
Echo glib_cv_stack_grows = No & gt; arm-linux.cache
Echo glib_cv_uscore = No & gt; arm-linux.cache
Echo ac_cv_func_posix_getpwuid_r = Yes & gt; 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
Modify the generated makefile:
# The name of your C compiler:
Cc = GCC cc = arm-Linux-GCC (based on your own cross-compiler location)
# Library (. a) File Creation command
AR = ar RC this is AR = arm-Linux-ar RC (same as above)
# Second Step in. A creation (use & quot; touch & quot; if not needed)
AR2 = ranlib: AR2 = arm-Linux-ranlib (same as above)
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

10) fontconfig
Export libxml2_cflags =-I $ prefix/include/libxml2
Export libxml2_libs = & quot;-L $ prefix/lib-lxml2 & quot;
./Configure -- Host = arm-Linux -- prefix = $ prefix -- With-FreeType-Config = $ prefix/bin/FreeType-config -- With-arch = arm
Make
Make install

11) tiff
./Configure -- Host = arm-Linux -- prefix = $ prefix -- enable-shared
Make
Make install

12) 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

13) Cairo
./Configure
-- Host = arm-Linux -- prefix = $ prefix -- without-X -- disable-xlib
-- Disable-xlib-xrender -- enable-directfb -- enable-FreeType
-- Disable-win32 -- enable-PDF -- enable-Ps -- disable-SVG -- enable-PNG
Make
Make install

I don't know why GTK must have support for PDF and PS. If it doesn't, it won't be able to complete Configure. No way, I have to open it here. In fact, GTK cannot really support it either, because PDF and other things are not added at all. I do not know whether the later GTK version has been improved.
14) pango
Modify the configure file and change 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

15) GTK
Export ldflags = & quot;-L $ prefix/lib-wl,-rpath, $ prefix/lib & quot;
Export cppflags = & quot;-I $ prefix/include & quot;
./Configure -- Host = arm-Linux -- prefix = $ prefix -- With-gdktarget = directfb -- without-X -- without-LibTIFF
Make
Make install
5 Development Board running environment
 
 
The kernel of the Development Board is 2.6, and all the drivers have been completed. The file system is loaded using NFS and located on/ARM/root/root_nfs in the host system. After compilation, just get the board
But it is best to familiarize yourself with the Development Board before compilation. I have worked on the Development Board for several days, because some of the uboot used by the 2.6 kernel is
The uboot used by kernel is different. I have never done it before, and it has been plagued for several days.
On the host system, copy the/usr/gtkdfb directory to the/ARM/root/root_nfs/usr directory. After the Development Board runs, all compiled items will be in the/usr/gktdfb directory.
1) pangorc
Mkdir/ARM/root/root_nfs/usr/gtkdfb/etc/pango
Create the/ARM/root/root_nfs/usr/gtkdfb/etc/pango/pangorc file as follows:
# Pangorc file for uninstalled operation.
# We set the path as ../modules, such that it works from any
# Top level build subdirs.
#

[Pango]
Modulefiles =/usr/gtkdfb/etc/pango. Modules
Modulespath =/usr/gtkdfb/lib/pango/1.6.0/modules

Run the preceding command on the host system.
The following command runs on the Development Board
/Usr/gtkdfb/bin/pango-querymodules & gt;/usr/gtkdfb/etc/pango. Modules
2) gfxdrivers
The following command runs on the Development Board to eliminate 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 & gt;/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 & gt;/usr/gtkdfb/etc/gtk-2.0/GTK. immodules
5) fonts. conf
 
There is a fonts. conf file in the/usr/gtkdfb/etc/fonts directory. Some font information is configured in this file to open the file in the host system.
/ARM/root/root_nfs/usr/gtkdfb/etc/fonts. conf, modify & lt ;! -- Font
Directory List
-- & Gt; set the correct font directory for the following lines. Of course, you must copy the font to the appropriate directory of/ARM/root/root_nfs. For example
Ubuntu settings are as follows:
& Lt ;! -- Font directory list -- & gt;
& Lt; Dir & gt;/usr/share/fonts & lt;/DIR & gt;
& Lt; Dir & gt;/usr/x11r6/lib/X11/fonts & lt;/DIR & gt;
& Lt; Dir & gt ;~ /. Fonts & lt;/DIR & gt;

The simplest way is to copy the contents in these directories of ubuntu to the directory relative to/ARM/root/root_nfs. In this way, this file can be left unchanged. But in the end, you certainly cannot do this, because there is no need for so many font libraries in the embedded system. We only need to cut down all the information we need and understand that this file should also be necessary.
6) directfbrc
I have never used this file. I used to figure it out because I thought it was his problem, but it was not his problem. So far, I haven't figured it out. Vcvc0 said on the forum that without this file, the program loading is very slow. If yes, it will be much faster. Here I will give a link, so I will not detail it.
Http://www.directfb.com.cn/viewthread.php? Tid = 373
The following is the post content. And now I am not imagining my usage.
How to configure the ARM-based directfbrc configuration file?
I ran the application on my Development Board. If the/etc directory does not contain the directfbrc file, it takes a long time for the program to display it.
I have set up directfbrc 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. I don't know why.

The problem is whether direct WM can manage the GTK window. Or is there any window manager that can be used based on embedded development.
6. Last tips
 
 
Now, if you run the test in the GTK source code package on the board, there should be no problem. If there is a problem, you have to go back and fix it. The last question is that the USB mouse can control the mouse pointer on the screen,
The touch screen does not respond. It is clear that my tslib test program has no problem, and the DFB compilation fails correctly. What is the problem?
This is the last secret, so I dare to call this documentSupreme secretBecause of this secret, I think it requires a considerable technical level to solve this problem.
 
First, it should be noted that this problem is complicated. Let's first talk about the DFB initialization. DFB loads the system first to read directfbrc, read some settings, and then load the auxiliary module. All modules are loaded dynamically.
Is loaded in dlopen mode. This method is also used to load some modules in tslib. The application dynamically links to the DFB library, loads the modules that can be loaded, and Loads
Libdirectfb_tslib.so. This module dynamically links to the libts. So library, dynamically loads libdirectfb_tslib.so
The initial tslib will dynamically load some tslib modules. The four modules pthres, variance, dejitter, and linear will
Use a function tslib_parse_vars in the libts. So library. Because libdirectfb_tslib.so is loaded with dlopen
When the last four modules of tslib are used, you do not know where to find the function tslib_parse_vars. The tslib test program has dynamically linked libts. So and loaded
The tslib_parse_vars function can be correctly recognized when the tslib speed-up module is used.
The problem is solved simply by knowing the cause. You can dynamically link the application to the library libts. So. I can modify the makefile under the tests directory of GTK source code.
Ldflags =-L/usr/gtkdfb/lib-lts-wl,-rpath,/usr/gtkdfb/lib
Re-compile these test programs, copy them to the Development Board, and run them. Everything is OK.
7 conclusion
 

In retrospect, it is really difficult to build an embedded DFB + gtk gui development platform, not to mention the packages written by so many different organizations and individuals, that is, the environment of each person is also very different.
There are almost no people who help you. When you encounter problems, you can only find a solution in the vast network. It may take a lot of effort to solve any problem. If your project funds allow, please support 1
MiniGUI, an excellent domestic GUI software, should be quickly solved and will undoubtedly speed up your project development. Of course, DFB + GTK is also good.
When you solve your own problems, you will learn a lot and bring you a great sense of accomplishment.

Finally, I would like to thank the authors of these open-source software packages for their selfless dedication so that we can have the opportunity to learn these excellent codes. I would also like to thank the pioneers who shared their experiences online.
It inspired me and guided me in solving the problem. I would like to thank them again for this document. At the same time, I will dedicate this article to www.directfb.com.cn and the Forum owner
Mr. echo and every current and future member of the Forum. I only posted two very short and concise articles on the Forum. It is a great honor for Mr. echo to invite me to become a moderator.
I have basically finished setting up the environment, and I have to do other things for the project. If you are doing a similar job and have encountered some problems, I hope this article will help you. If you see this article elsewhere (I hope to repost this article on a website), visit www.direcfb.com.cn. Maybe you can get more information.

Disclaimer: I do not guarantee that this document is completely correct. If you see anything inappropriate, please contact 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.