Directfb porting (gui arm Linux directfb GTK tslib)

Source: Internet
Author: User
Tags cairo gtk vector font
Directfb Port 1
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, we plan to develop a new version on the Linux platform. On Linux, the GUI has become a major problem. At first, I tried to use MiniGUI and contacted the company, but I cannot afford the cost. (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. The final focus was on GTK. At first, I had no idea whether it was suitable for Embedded GUI or not. Finally, I did not know where to find a description that Nokia products use GTK, I think that since others can do it, I can do it too. 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, 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 am using the Ubuntu 7.10 release, and the embedded development version uses 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 the self-compiled 3.4.1 and the Development Kit 3.4.1 at the beginning. Why should I use my own compilation instead of the built-in development 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, this is what one of my colleagues said. I am not sure whether it is his intention. If your CPU is not in this series, please check the relevant information ), as long as soft floating point operations are supported in the cross compiler, there should be no problem, so before starting, check whether the cross compiler has the -- with-float = soft option. After compilation is completed by using the developed version, the GTK program always prompts "shape engine failure, failed CT ugly output. the offending font is ", and all the characters on the screen cannot be displayed. The button is compressed into a line because it cannot be displayed. This problem has plagued me for several days, I started to think it was a problem with font settings. Later I asked my colleague for help. After hearing my description, he guessed it could be a problem with floating point operations, let me use our self-compiled cross compiler to re-compile and see if the problem can be solved. 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 compatible with windows. GTK is used as the GUI, and 15 software packages compiled by different organizations (individuals) have different versions, but there is no authoritative guide on the Internet, choosing the right version and integration is indeed a very complicated issue.
I started by setting up the GTK environment on x86. First, I chose the latest version. Then, I can see that GTK runs in framebuffer in two modes: directfb and Linux-FB, while the Linux-FB project seems to have stopped. The main direction is directfb. Later I checked an English document about directfb + GTK, which is basically the latest version, in addition, many packages can be built with the system, and only the necessary source code can be compiled. At first, the compilation fails. When I was desperate, I found that a latest GTK source code version was released (around July 4). I downloaded it immediately and quickly compiled it, in framebuffer mode, GTK-demo and some test run without any problems.
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 of information about cross-compiling directfb + GTK on the Internet. I wrote a shell script, but I don't understand it. Although I have been familiar with Unix for more than a decade, I have also worked on a relatively large project in UNIX, but later I was very interested in Linux. I have read, played, and never done anything. I have seen it in shell programming, I have been reading many things for a long time. I am so stupid about 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. It's not very difficult to compile and how to configure it, please read another document, "tslib of arm-Linux". Of course, this document may not help you. You need to use your talents, 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 I set the module_raw module to h3600 In the Ts. conf file. If you use Samsung's 24xx series CPU, it may be used in the same way as me, or the same configuration may be used. If not, you may need to read the source code of the touch screen driver and the module_raw source code of tslib, and find the matching module.
The position http://www.directfb.com.cn/viewthread.php of "arm-Linux tslib? Tid = 388 & extra = Page % 3d12) 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. When I got the touch screen, how could I load the module libdirectfb_tslib.so in nputdrivers when I run the directfb program? after reading the relevant code, after loading this module of DFB, I did not read the environment variables of tslib and directly loaded some devices such as/dev/input/tslibn, these devices are not available at all. The Versions later than 1.1.0 and the related Code have been corrected. I also tried the latest version of DFB 1.2.1, however, this version of df B has some problems with the combination of the GTK version selected after the kernel, and cannot compile the later GTK. I read the relevant code of DFB 1.1.1 and found that it has been corrected, this version is used to run the GTK program. DFB starts to load the relevant tslib modules, but only the modules of tslib module_raw are loaded successfully. The subsequent modules fail to 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 when using configure: first, I couldn't find pango, and finally I saw a lot of problems, before configure, you must set the environment variable export ldflags = & quot;-L $ prefix/lib-wl,-rpath, $ prefix/lib & quot, I don't know why. Second, the producer lib cannot be found. h. I analyzed the log and found that runtime Lib was not found during G ++ compilation. h, but there is no problem in testing GCC compilation. I set this export cppflags = & quot;-I $ prefix/include & quot; environment variable before configure, tell the G ++ compiler where to find mongolib. 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-files = 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-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, but it is best to get familiar with the development board before compilation. I have worked on the Development Board for several days, because some things in the uboot used by the 2.6 kernel are different from those in the uboot used by the 2.4 kernel. 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
The/usr/gtkdfb/etc/fonts directory contains fonts. in this file, some font information is configured in the conf file. In the host system, open the file/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, the 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 problem is that the USB mouse can control the mouse pointer on the screen, and the touch screen does not respond. It is clear that my tslib test program has no problems, DFB compilation also fails. What is the problem? This is the final secret. I dare to call this document the supreme secret, because it is a 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 talk about the DFB initialization. DFB loads directfbrc first, reads some settings, and then loads the auxiliary module. The modules are loaded dynamically and loaded using dlopen. This method is also used to load some modules in tslib. The application dynamically links to the DFB library, loads loaded modules, and loads libdirectfb_tslib.so. This module dynamically links to libts. so this library dynamically loads libdirectfb_tslib.so and initializes tslib. In the initial tslib, some tslib modules are dynamically loaded. The four modules pthres, variance, dejitter, and linear will use libts. so a function tslib_parse_vars in this library, because libdirectfb_tslib.so is loaded with dlopen, when loading the last four modules of tslib, I do not know where to find the function tslib_parse_vars, the test program of tslib has dynamically linked libts. so, the tslib_parse_vars function can be correctly recognized when loading the speed-up module of tslib.
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 can 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 permit, please support the excellent domestic GUI software-MiniGUI. Your problems should be solved quickly and satisfactorily, it will undoubtedly speed up your project development. Of course, DFB + GTK is also a good choice. 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 on the Internet for their great popularity. They inspired me and guided me in solving the problem. I would like to thank them again for this document. At the same time, I would like to dedicate this article to www.directfb.com.cn, Mr. ECHO, the main account of the Forum, as well as all the current and future members 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.

 

 

 

For the establishment of the entire environment, it is recommended to read this article http://www.directfb.com.cn/viewthread.php? Tid = 383 & extra = Page % 3d4 embedded Linux Gui -- directfb + GTK Supreme secret
As mentioned, it is recommended that you first deal with tslib. the development environment of qq2440 is different from the environment in the secret. The process for compiling tslib is as follows:
Export prefix =/usr/local/directfb
Export ldflags =-L $ prefix/lib
Export cflags = "-O2-wall-w-duse_input_api-I $ prefix/include"
Export pkg_config_path = $ prefix/lib/pkgconfig

Echo "ac_cv_func_malloc_0_nonnull = yes"> arm-linux.cache
./Configure -- Host = arm-Linux -- prefix = $ prefix -- cache-file = arm-linux.cache -- enable-Debug
Make
Make install

Note: The duse_input_api macro controls whether/dev/input/event0 is used from the source code.

Next, follow the tips to avoid any problems. However, you must pay attention to the prefix. You can see that I use prefix =/usr/local/directfb, after compilation, copy the files used under $ prefix to the/usr/local/directfb directory of the Development Board, the host path is often different from the Development Board path, which is the root cause of errors such as system and id not found.
Because the touch screen is a mouse device, change didid_keyboard in gdk_display_open () to didid_mouse.Note that GTK +-2.12.12 is used
Google !!
The following are some configurations on the development board for your reference only:
System Environment dfbenv. RC
#! /Bin/sh
Export Path =/usr/local/directfb/bin: $ path
Export LD_LIBRARY_PATH =/lib:/usr/local/directfb/lib/directfb-1.3-0:/usr/local/directfb/lib/TS
Export tslib_consoledevice = none
Export tslib_fbdevice =/dev/FB/0
Export tslib_tsdevice =/dev/input/event0
Export tslib_calibfile =/usr/local/directfb/etc/pointercal
Export tslib_conffile =/usr/local/directfb/etc/ts. conf
Export tslib_plugindir =/usr/local/directfb/lib/TS

TS. conf
Module_raw Input
Module pthres pmin = 1
Module variance Delta = 30
Module dejitter Delta = 100
Module linear

Directfbrc:
No-Debug
System = fbdev
Fbdev =/dev/FB/0
WM = default
Mode = 240x320
Depth = 16
Pixelformat = rgb16

Run the GTK-demo test result on the Development Board and start to display the gray background. The above is a drop-down mouse pointer. After clicking the screen, it will become a common mouse pattern.
However, it will die in the future, and the result will be displayed as caught signal 4 (at 0x4096e890, illegal opcode). You have to continue checking the code.
There is nothing on the screen except the mouse. It seems that I still don't know where there is a problem. I don't know about GTK or directfb. It seems that this is not a good solution!Discovery: without setting the directfbrc file, there will be no "will be crashed ".

Related Article

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.