Embedded-linux-GUI-Porting-DirectFB-and-GTK
基于QtEmbedded的嵌入式Linux应用程序的实现
信I■与电IBChina Computer&Communication 张件件欢与泉用2021年第4期基于Qt/Embedded的嵌入式Linux应用程序的实现蔡国理李滕苑振东(酒泉卫星发射中心63636部队,甘肃酒泉732750)摘要:Qt/Embedded作为一种编程方法,能够实现面向全体对象编程,是线下主流的编程方法.基于此,笔者首先分析了Qt/Embedded和嵌入式Linux应用程序的概况,进而设计了嵌入式Linux应用程序内核体系结构,基于Qt/Embedded 支持的转义字符序列,打造嵌入式Linux应用汇编语言程序。
关键词:Qt/Embedded;嵌入式Linux应用程序;编程语言中图分类号:TP343.7文献标识码:A文章编号:1003-9767(2021)04-105-03Implementation of Embedded Linux Application Program Based on Qt/EmbeddedCAI Guoli,LI Teng,YUAN Zhendong(Jiuquan Satellite Launch Center63636Forces,Jiuquan Gansu732750,China) Abstract:As a programming method,Qt/Embedded can realize all-object-oriented programming and is the mainstream offline programming method.Based on this,the author first analyzed the overview of Qt/Embedded and embedded Linux applications, and then designed the embedded Linux application kernel architecture,based on the escape character sequence supported by Qt/ Embedded,to create an embedded Linux application assembly language program.Keywords:Qt/Embedded;device circuit;embedded Linux applications;programming language0引言在以往针对嵌入式Linux应用程序的开发实现中,主要通过Microwindows/NanoX实现嵌入式Linux应用程序,经常会出现性能不稳定的现象叫基于此,本文将Qt/Embedded 应用在嵌入式Linux应用程序实现中,致力于通过Qt/ Embedded提高嵌入式Linux应用程序的整体性能。
directfb 安装
Download the directfb from ∙Mandatory tarballs:∙DirectFB-x.x.x.tar.gz∙linux-fusion-x.x.tar.gz∙Optional tarballs:∙DirectFBGL-x.x.x.tar.gz∙FusionSound-x.x.x.tar.gzBuild Fusion DirectFB driverTo build the fusion device driver the source for the Linux kernel your system is running must be installed. If this is the case then continue with the following sequence of actions. If not then skip this chapter and continue with building DirectFB itself.Unpack Linux Fusion driver (linux-fusion-1.1.tar.gz):Unpack DirectFB-x.x.x.tar.gz:$> tar -xzvf DirectFB-x.x.x.tar.gz -C directory_where_to_unpackBuild the DirectFB's fusion driver:$> cd /linux-fusion-x.x/$> make#> make installCopy fusion.h into /usr/include/linux directory:#> cp linux/include/linux/fusion.h /usr/include/linuxBuild DirectFBUnpack DirectFB-x.x.x.tar.gz:#> tar -xzvf DirectFB-x.x.x.tar.gz -C directory_where_to_unpackConfigure DirectFB:#> cd /DirectFB-x.x.x/If the Fusion DirectFB driver has been compiled and installed against your running version of the Linux kernel, then the DirectFB configure-line looks like this: (If not the --enable-multi can be omitted.)#> ./configure --enable-multi#> make#> make installadd the path (on my system)export PKG_CONFIG_PATH=/usr/local/lib/pkgconfigexport LD_LIBRARY_PATH=/usr/local/libdon't forget to insmodinsmod fusion.ko。
嵌入式Linux系统软件移植流程
嵌入式Linux系统软件移植流程本文主要讨论Embedded Linux的系统软件移植流程,假设映象文件已经编译、链接完成。
关于映象文件及driver等的创建在其他文档中详细描述。
1.映象文件本文以X-Hyper255B开发板为例,映象文件为:x-boot255:bootloaderzImage:kernelrootfs.img:文件系统2.烧写bootloader首先需要通过JTAG把bootloader烧入目标板的FLASH中,如果PC机是Linux系统则执行以下命令:Jflash-XHYPER255 x-boot255也可以使用Windows系统的烧写程序来烧写Jflash.exe x-boot2553.bootp和fttp配置要使用bootloader通过以太网下载文件,需要在PC机(Linux系统)上建立bootp和fttp 配置。
3.1.建立bootp•在PC机上安装/XHYPER255/RPM中的bootp包rpm –i bootp-2.4.3-7.i386.rpm•在PC机上创建bootp文件/etc/xinetd.d/bootp,其内容如下:service bootps{disable = nosocket_type = dgramprotocol = udpwait = yesuser = rootserver = /usr/sbin/bootpd}•创建bootptab文件/etc/bootptab,其内容如下:test:\ht=1:\ha=0x123456789A00:\ip=192.168.1.50:\sm=255.255.255.0其中,test:标号ht:硬件类型(1=以太网)ha:开发板上网卡芯片的MAC地址ip:开发板上网卡芯片的IP地址sm:子网掩码•重新启动PC的xinetd/etc/rc.d/init.d/xinetd restart3.2.建立tftp•在PC机上安装/XHYPER255/RPM中的tftp包rpm -i tftp-server-0.17-9.i386.rpm•在PC机上创建tftp文件/etc/xinetd.d/tftp,其内容如下:service tftp{disable = nosocket_type = dgramprotocol = udpwait = yesuser = rootserver = /usr/sbin/in.tftpdserver_args = -s /tftpboot}server_args指出了PC机存放下载文件的目录,只有该目录下的文件才能被下载到开发板上。
directfb概述
I.DirectFB 可以用来做什么DirectFB是图形API存在于Frame Buffer层之上与高级图形管理层如GTK+等之下的。
它可以以很小的系统资源占用来提供图形硬件加速功能,提供类如多路a通道渲染模型等高级图像操作。
它不修改Linux内核,除了标准C库没有其他库的依赖。
应用在了基于Linux系统的DTV显示系统的研发和其他有关Linux显示界面的项目上。
支持市面上绝大多数显示卡,支持键盘、鼠标、遥控器、游戏手柄、触摸屏等输入设备。
支持JPEG、PNG、GIF、mpeg1/2、AVI、MOV、Flash、Video4Linux、DirectFB bitmap font和TrueType等音视频文件和字体。
关于DirectFB的介绍可以参考:/DirectFB/index.php/directfb/overview.html/directfb/about.html/docs/ELC2008/elc2008_directfb_gfx.pdf上层API支持DirectFB的有:XDirectFB、DirectFBGL、GTK+、DFBTerm、DFBSee、DFBPoint、MythTV、Qt on DirectFB、SDL(SimpleDirectmedia Layer)。
本文主要参考:/images/d/d4/Elc2008_directfb_gfx.pdfII.DirectFB 在系统中的位置从结构来讲,对于一般的MMP,DTV和STB来说,上面两幅图是比较经典的结构。
DirectFB都处于QT,GTK+这样的高级GUI框架的下面,系统驱动的上面。
从功能方面来讲,下面两幅图比较形象的说明了DirectFB的主要作用:图形,文字的处理(DirectFB把TS经过Decoder处理之后的码流,再加上图形和文字,一起传给视频的芯片)III.DirectFB 怎么使用选择一个合适的DirectFB版本,下载并安装DirectFB的代码可以从这里下载:/index.php?path=Main%2FDownloads建立DirectFB的配置文件directfbrcDirectFB的配置可以参考,里面有对directfbrc的详细介绍/wiki/index.php/Configuring_DirectFB中文的可以参考这里:/weiliqun/blog/item/6f4ba4ebe601eee2cf1b3e57.html运行DirectFB的例子程序,如果运行成功,则可以开始编写基于DirectFB的应用程序了。
英创Linux工控主板对韦根信号的支持
英创Linux工控主板对韦根信号的支持Wiegand(韦根)协议是由摩托罗拉公司定制的一种通讯协议,它适用于涉及门禁控制系统的读卡器和卡片的许多特性。
韦根数据输出由两条数据线DATA0和DATA1,和公共的信号地GND组成。
在没有数据输出时,DATA0和DATA1都保持高电平(典型为+5V电平),若输出'0'时,DATA0输出低脉冲而DATA1保持为高电平,输出'1'时,DATA1输出低脉冲而DATA0保持为高。
典型的低脉冲宽度为50us,输出每一bit之前的间隔为1ms(如下图,实际的信号电平和时序由实际的韦根读卡器决定)。
韦根协议包含很多种格式来传输串行数据,英创公司工控主板支持最常用的韦根26 bit和韦根34 bit 格式。
韦根26是已经广泛使用的通用工业校准,一个“韦根包”有26位数据,第1位为第1到第13位的偶校验,最后1位为第14到第26位的奇校验,中间24位为数据位。
对于韦根34格式,即一个“韦根包”有34位数据,常见的格式为第1位为第1到第17位的偶校验,最后1位为第18到第34位的奇校验,中间32位为数据位。
英创公司为Linux工控主板提供了支持韦根协议的设备驱动模块,在命令行输入insmod wiegand-gpio.ko即完成驱动程序的加载。
linux韦根驱动支持应用程序通过非阻塞的轮询操作(select)和异步通知的方式读取韦根数据,这里我们建议使用非阻塞轮询方式。
以非阻塞方式O_NONBLOCK打开设备文件后,使用num = read(fd,buffer,len)读取韦根数据,只读取Site Code和User Code,不包含奇偶校验位,各参数意义如下:输入参数:fd:int, 韦根设备文件描述符;len:buffer长度,固定4字节,小于4字节提示错误;输出参数:buffer:char *, read结果缓存,固定4字节,根据不同返回值num,具有不同意义;返回值:num:int, 读取成功时,表示读取的字节数,具体意义如下:num = 4,读取成功,数据格式为wiegand 34,buffer [0-1]为Site Code,buffer [2-3]为User Code;num = 3,读取成功,数据格式为wiegand 26,buffer [0]=0,buffer [1]为Site Code,buffer [2-3]为User Code;num = 1,读取成功,数据格式为键盘按键(部分读卡器有此功能),buffer [0]=0,buffer [1]为按键值;num = -1,读取失败,buffer [0]存错误码:-1 //格式错误,长度不匹配-2 //偶校验错误-3 //奇校验错误-4 //用户传入buffer空间太小英创各个主板连接韦根信号的定义如下:韦根读卡器通常输出5V TTL电平,而英创工控主板的GPIO要求输入电平不能超过3.3V,所以韦根读卡器输出的信号需要经过转换后才能与英创主板的GPIO相连。
关于嵌入式Linux操作系统的内核调试技术详解
关于嵌入式Linux操作系统的内核调试技术详解近年处理器技术发展速度加快,嵌入式领域发生了翻天覆地的变化。
特别是网络的普及,消费电子异军突起,嵌入式与互联网成为最热门的技术。
在所有操作系统中,Linux是发展很快、应用很广泛的一种操作系统。
Linux的开放性以及其他优秀特性使其成为嵌入式系统开发的首选。
总的来说,嵌入式开发所面临的问题主要表现在以下几个方面。
涉及多种CPU 及多种OS嵌入式的CPU或处理器包括MIPS、PPC、ARM,XScale等不同的架构,这些处理器上运行的操作系统也有VxWorks、Linux、C/OS、WinCE等多种。
在一个企业之内,可能会同时使用好几种处理器,甚至几种嵌入式操作系统。
如果需要同时调试多种类型的电路板,那复杂性是可想而知的。
这也是我们选用瑞士Abatron公司的BDI2000的原因之一,它是一款功能强大的JTAG/BDM通用仿真器。
它支持:PPC/MIPS/ARM/XSCALE/ CPU12/CPU32/M-CORE/ColdFire等多种处理器,支持Windows/Linux系统平台,以及多种第三方调试器,并且对Flash的烧写也很简单方便。
开发工具种类繁多通常各种操作系统有各自的开发工具,在同一系统下开发的不同阶段也会应用不同的开发工具。
如在用户的目标板开发初期,需要硬件仿真器来调试硬件系统和基本的引导程序,然后进行操作系统及驱动程序的开发调试。
在调试应用程序阶段可以使用交互式的开发环境进行软件调试,在测试阶段需要一些专门的测试工具软件进行功能和性能的测试。
在生产阶段需要固化程序及出厂检测等等。
BDI2000可以适应开发的各个阶段,节约企业的支出和简化管理难度。
对目标系统的观察和控制由于嵌入式硬件系统千差万别,软件模块和系统资源也多种多样,要使系统能正常工作,软件开发者必须要对目标系统具有完全的观察和控制能力,例如硬件的各种寄存器、内存空间、操作系统的信号量、消息队列、任务、堆栈等。
openembeddedminiprogram 参数 -回复
openembeddedminiprogram 参数-回复OpenEmbedded是一个开源的嵌入式Linux发行版构建框架,它被广泛用于构建各种Linux发行版、嵌入式系统和IoT设备。
它提供了一个灵活的、可扩展的构建工具链,能够满足不同的需求和场景。
本文将逐步介绍OpenEmbedded的参数配置以及相关内容。
1. 什么是OpenEmbedded?OpenEmbedded是一个构建系统,可以用于构建嵌入式Linux发行版。
它提供了一个从源代码到最终镜像文件的完整构建工作流程,支持多种处理器架构和操作系统。
通过OpenEmbedded,开发者可以定制自己的嵌入式系统,包括选择所需的软件包、配置文件系统、定制应用程序等。
2. OpenEmbedded的主要特点- 灵活性:OpenEmbedded支持各种处理器架构和操作系统,可以根据需求进行定制。
- 可扩展性:OpenEmbedded提供了一套模块化的构建框架,可以方便地添加或移除软件包。
- 自动化:OpenEmbedded的构建过程是自动化的,可以节省开发者的时间和精力。
- 社区支持:OpenEmbedded有一个庞大的社区和活跃的开发者,可以提供支持和解决问题。
3. 参数配置在使用OpenEmbedded构建嵌入式系统时,有一些重要的参数需要配置。
下面是一些常见的配置参数:- MACHINE:指定目标机器的配置,包括处理器架构、硬件平台等。
比如,可以设置为"raspberrypi3"表示针对树莓派3开发板进行构建。
- DISTRO:选择要构建的发行版。
OpenEmbedded提供了一些默认的发行版,如"poky"、"angstrom"等。
开发者也可以根据自己的需求定制。
- PACKAGE_CLASSES:指定软件包的类型。
有几种类型可供选择,如"package_rpm"、"package_deb"、"package_ipk"等。
EmbeddedLinux技术与概念解析
EmbeddedLinux技术与概念解析引言Embedded Linux技术基于开放源码的资源,并且已经是当今最重要的嵌入式应用技术之一。
Embedded Linux是烧录在目标装置上的系统,1个Embedded Linux系统包含Linux kernel与root filesystem 2大部分,Embedded Linux系统到底包含哪些组成要素构成,本文将由概念的层面进行解析。
本文由于目前的目标装置,都必须嵌入极为复杂的功能,所以嵌入式操作系统(Embedded system)成为嵌入式系统不可或缺的要素。
由于嵌入式系统是功能导向的系统,因此必须设计、选择或购买正确(或适合)的目标装置,才能开始实作并嵌入嵌入式系统。
因此,嵌入式系统技术是以功能、与目标装置为分类的1种技术。
例如,与PDA相关的目标装置(即硬件)、与MP3播放器相关的目标装置、与3G手机相关的目标装置...等等;使用这些目标装置所开发的特定功能系统,便是PDA的嵌入式系统、MP3音乐播放的嵌入式系统、3G手机的嵌入式系统。
Embedded Linux其实并不是1个操作系统,而是代表应用Linux 系统于Embedded system的名词。
Embedded Linux的技术核心主轴是在研究如何将Linux系统嵌入至嵌入式目标装置里。
Embedded Linux是基于Linux系统的特殊应用,当然也要符合众多标准才行。
LSB与FHS标准是重要的2大标准,跟随标准不但可以提供系统间的兼容性,也可以提供我们1个Linux系统的建构依据。
GNU/Linux的2个标准由FSG (Free Standards Group) 所主持的 LSB (Linux Standard Base) 项目即是在制定GNU/Linux 标准。
根据LSB标准所发展的GNU/Linux系统,才能提供应用程序最小的可执行环境,并且可在依循LSB标准的Linux distributions上执行无误。
嵌入式linux启动信息完全注释
嵌入式linux启动信息完全注释摘要我们在这里讨论的是对嵌入式linux系统的启动过程的输出信息的注释,通过我们的讨论,大家会对嵌入式linux启动过程中出现的、以前感觉熟悉的、但却又似是而非的东西有一个确切的了解,并且能了解到这些输出信息的来龙去脉。
嵌入式linux的启动信息是一个很值得我们去好好研究的东西,它能将一幅缩影图呈现在我们面前,来指导我们更加深入地理解linux内核。
关键字:linux,嵌入式,启动,bootloader正文作为一名嵌入系统开发者,你一定遇到过下面的情景:在某论坛上看到一篇帖子,上面贴着嵌入式linux开发板启动时的有关信息,然后大家在帖子里讨论着这个启动过程中出现的问题,随机举例如下:上面的这些输出信息,也可能包括你自己正在做的嵌入式linux开发板的输出信息,其中的每一行,每一个字的含义,你是否深究过,或者说大部分的含义你能确切地知道的?本人想在这里结合本人在实践中一些体会来和广大嵌入式linux的开发者一起读懂这些信息。
我们在这里将以一个真实的嵌入式linux系统的启动过程为例,来分析这些输出信息。
启动信息的原始内容将用标记标出,以区别与注释。
嵌入式linux的启动主要分为两个阶段:①第一部分bootloader启动阶段②第二部分linux 内核初始化和启动阶段第一节:start_kernel第二节:用户模式( user_mode )开始,start_kernel结束第三节:加载linux内核完毕,转入cpu_idle进程第一部分 : bootloader启动Bootloader头信息,版本,编译时间等,这个因不同的bootloader的设计而有所不同,由此你能看出bootloader的版本信息,有很多使用的是通用的bootloader,如u-boot,redboot等。
将bootloader加载到内存ram中的0x90060000处,即将bootloader加载到内存的高端地址处。
基于Qt/Embedded和Linux的嵌入式GUI的研究与实现
( 武汉 理 工大学 自动 化学 院 , 武汉 4 07 ) 300
摘要 :介绍了QU mb d e E e d d和 Q o i t pa的开发环境建立的过程及其应用程序 【】 1 的开发流程与移植方法。重 点讲述 了如何在 U u n x中建立 Q / mb d e t E edd 的开发环境和应用程序的实现 与移植过 程。文 章的背景是为了开发出一个污 水处理系统人机操作界面 .在此基础上所做研 究的总结。
关键词: Q E e d d L u ; I 嵌入式系统 / t mb d e ; i x GU ; n 中图分类号: T 2 2 P 1 文献标识码 : A
De i n a d p e sg n l l men f m t o
E mb d e e d d GUlb s n Q a ed o tEmb d ed a d iu / e d n Ln x
LI Bo U .ZH 0 U e g i K - u
22 Q /mb d e . t E e d d和 Qtpa面向宿主机的开发环境的建立 oi
22 1 建立开发环境 所需的安装软件包 ..
() k 一 .1trg ( 1t e11. .z 用于生成 Ma ei ma a k fe文件 的辅助工具) l ()te e d d 237tr zQtpa建立的基础 ) 2q—mb d e -... . ( o i ag ()tx 232trg ( 3q— l-... .z 用于生成 mo 1 a c和 uc两 个工具) i ()tpafe 一... r zQtpa源代码包) 4qo i-re170t . ( o i ag
222 开发环境 建立过程 ..
首先,为了在 P C机上模拟运行 Q o i, tpa 需要用到对应 Q 版本 t 的库文件 ,因此需要修改 /t/ . . n g以适应 自己将 要安装 的 ecl S c f d O oi Qt 开发平 台。其次 ,分别解压和设置以上各个软件包环境变量 【] 5, 命令如下 :
使用buildroot完全自定义自己的embedded linux系统(nand)
$cd -
$cd linux-3.4
$git checkout -b sunxi-3.4-cb origin/sunxi-3.4-cb
$cd -
步骤四:编译并生成固件
$cd ~/mylinux
$tools/build.sh
brw------- 1 root root 93, 2 Jan 1 1970 /dev/nandb
brw------- 1 root root 93, 3 Jan 1 1970 /dev/nandc
brw------- 1 root root 93, 4 Jan 1 1970 /dev/nandd
2)修改指定分区容量大小
这里举个简单的例子,把nandd(也就是我们linux的根分区)容量从原来的512MB调整到2GB
,只需要在sys_config.fex的
[partition3]
class_name = DISK
name = rootfs
size_hi = 0
[down_num]
down_num = 4
[download0]
part_name = bootloader
pkt_name = BOOTLOADER_00000
encrypt = 0
[download1]
part_name = env
pkt_name = ENVIROMENT_00000
教程五 红外控制例子
在做好自己的系统后,下面我们写一个简单的红外控制计算机的例子(具体控制需要自己实现,这里是一个demo)
a)烧写完linux,上电
主流嵌入式Linux下GUI解决方案
❖ qvfb:运行Qt 的虚拟缓冲帧工具 ❖ 把显示结果输出到虚拟缓冲帧,出现桌面环境
Qt/E 、Qtopia
❖ qte/qtopia在2410s上的移植
软件环境
❖ PC 机操作系统REDHAT LINUX 9.0
Qt/E 、Qtopia
测试Qt/E桌面环境 ❖有源文件progressbar.cpp ❖指定环境变量TMAKEPATH=…/qws/linux-x86-g++ ❖使QTDIR指向Qt/Embedded的安装路径以及库 ❖progen –t app.t –o progressbar.pro(生成工程文 件.pro) ❖tmake -o Makefile hello.pro(生成Makefile文件) ❖使用LINUX系统自带的make进行整个程式的编译联接 ❖生成二进制的可执行文件progressbar ❖运行qvfb来模拟Virtual framebuffer(指定模拟器长、 宽)
交叉编译qtopia
Qt/E 、Qtopia
❖ qte/qtopia在2410s上的移植
建立宿主机和开发板的通讯
❖ export QTDIR=$PWD export PATH=$QTDIR/bin:$PATH(指定命令搜索路径 ) export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH(共享 库路径 )
配置qt-embedded编译选项
❖ ./configure -system-jpeg -gif -no-xft -qconfig qpe -qvfb -depths 4,8,16,32
embedded嵌入式系统知识点
1、CMD:即连接器命令文件。
输入指明输出,描述了硬件资源中的存储资源以及代码、变量、常量等与存储空间的对应关系。
根据目标系统寄存器的配置,以及用户自定义的程序和数据的存放地址,由汇编器产生的浮动地址目标文件,生成绝对地址可执行文件。
2、CMD文件的用途:①描述配置:-o 编译后的输出文件;-l 副文件;-stack 栈的大小;-heap 堆的大小②描述内存空间的分布情况开始于结束的位置③内容空间的分配:内容与存储空间对应。
内容包括代码、变量、常量、矢量、far4、RTS6000.lib,即实时运行库文件,保证能够有C语言的实时运行支撑环境5、进行性能分析测试的目的:检验程序是否能达到实时必要需求关注点:①空间复杂度:代码的尺寸(size)②时间复杂度:调用次数、周期(单次运行时间)6、DMA:即直接存储器访问。
其功能是在CPU不介入下实现存储器映象两个区域之间数据的传输。
实现过程:①确定使用的通道②对选定通道的寄存器进行设置:主控寄存器、源/目的地址寄存器、计数寄存器●主控寄存器只能设置(star)启动或停止,可查询(status)状态(是否中断或结束)7、线性汇编改写的格式1)定义函数名称、实现参数传递。
2)为暂时存放临时数据的寄存器定名,由.reg ( register)完成。
3)数据初始化。
4)处理程序的循环体部分。
首先定义一个标号作为循环返回的标志;之后,将循环变量vptr(即count)减一;利用C6x指令的条件执行功能通过对vptr是否为零的判断条件执行跳转指令。
最后,.return实现数据的返回。
5)一切工作完成后,使用.endproc作为函数结束的标志。
●记住变量所是的寄存器(.reg)8、完整的汇编程序包括:数据初始化、子程序、复位程序、连接器命令文件9、C程序的优化用到的方法:循环展开、内联函数、字访问(强制类型转换)1、嵌入式系统:以应用为中心、以计算机技术为基础,软硬件可裁剪,应用系统对功能、可靠性、成本、体积、功耗和应用环境有特殊要求的专用计算机系统。
DirectFb总结
DirectFB总结第一、DirectFB 简介1、DirectFB是一个轻量级的提供硬件图形加速,输入设备处理和抽象的图形库,它集成了支持半透明的视窗系统以及在LinuxFramebuffer驱动之上的多层显示。
它是一个用软件封装当前硬件无法支持的图形算法来完成硬件加速的层。
DirectFB是为嵌入式系统而设计。
它是以最小的资源开销来实现最高的硬件加速性能。
2、DirectFB所处结构层次如图:DirectFB依赖于Frame Buffer层。
在使用DirectFb之前,必须先对FB进行初始化。
通常Generic GFX Driver模块主要是检查是否有能被DirectFb加速的硬件,如果有,就由GFX drivers 模块对硬件进行加速。
如果没有,则直接软件操作。
下图为DirectFB的组成模块:从这五个文件可以看出,DirectFb主要由这五部分组成:Gfxdrivers:上面有所介绍,主要是对硬件进行加速。
Inputdrivers:主要是对输入设备的驱动,如(鼠标,键盘等输入设备)。
Interfaces:主要包括图片解码接口,视频解码接口,字库接口等。
Systems:系统接口,如(处理时钟,多线程处理等)。
Wm:用于窗口管理等。
第二、DirectFB 中一些主要数据类型之间的关系层(Layers)表示一块儿独立的图像缓冲区。
大多数的嵌入式设备都有多个层。
他们由硬件使用合适的alpha值来blending,然后显示。
表面(Surface)用来保存像素数据的保留内存区域。
DirectFB的Drawing和blitting操作最终都是作用于表面(surfaces)上.表面的内存可以从显存(video memory)(MMZ)得到,也可以从系统内存(system meomroy)得到,这由给定的限制决定。
主层(Primary Surface)表示特定层的frame buffer的特殊表面。
如果主表面是单缓冲的,任何作用到这个主层的操作,都会直接在屏幕上见到。
QtforEmbeddedLinuxQt5.4
QtforEmbeddedLinuxQt5.4With the release of Qt 5.0, Qt no longer contains its own window system implementation: QWS is no longer a supported platform. For single-process use cases, the Qt Platform Abstraction is a superior solution. Multiple graphical processes will be supported through Wayland.There are multiple platform plugins that are potentially usable on Embedded Linux systems: EGLFS, LinuxFB, KMS, DirectFB, Wayland. The availability of these depend on the configuration of Qt. The default platform plugin is also device specific. For instance, on many boards eglfs will be chosen as the default one. If the default is not suitable, the QT_QPA_PLATFORM environment variable parameter can be used to request another plugin. Alternatively, for quick tests, the -platform command-line can be used with the same syntax.Configuring for a Specific DeviceBuilding Qt for a given device requires a toolchain and a sysroot. Additionally, some devices require vendor specific adaptation code for EGL and OpenGL ES 2.0 support. This is not relevant for non-accelerated platforms, for example the ones using the LinuxFB plugin, however neither OpenGL nor Qt Quick 2 will be functional in such a setup.The directory qtbase/mkspecs/devices contains configuration and graphics adaptation code for a number of devices. For example, linux-rasp-pi-g++ contains build settings for the Raspberry Pi and an implementation of the eglfs hooks (vendor-specific adaptation code). This means that the eglfs platform plugin will be automatically built with the correct, Raspberry Pi-specific adaptation code. The device is selectedthrough the configure tool's -device parameter. The name that follows after this argument must, at least partially, match one of the subdirectories under devices.Below is an example configuration for the Raspberry Pi. For most Embedded Linux boards the configure command will look very similar. The most important parameters are -device and -sysroot../configure -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=$TOOLCHAIN/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- -sysroot $ROOTFS -prefix /usr/local/qt5 See Qt Configure Options for more information.Platform Plugins for Embedded Linux DevicesEGLFSEGL is an interface between OpenGL and the native windowing system. Qt can use EGL for context and surface management, however the API contains no platform specifics: The creation of a native window (which will not necessarily be an actual window on the screen) must still be done by platform-specific means. Hence the need for the board and vendor-specific adaptation code (the so-called eglfs hooks).EGLFS is a platform plugin for running Qt5 applications on top of EGL and OpenGL ES 2.0 without an actual windowing system (like X11 or Wayland). In addition to Qt Quick 2 and native OpenGL applications it supports software-rendered windows (for example QWidget) too. In the latter case the widgets' contents are rendered using the CPU into images which are then uploaded into textures and composited by the plugin.This is the recommended plugin for modern Embedded Linux devices that include a GPU.EGLFS forces the first top-level window (be it either a QWidget or a QQuickView) to become fullscreen. This window is also chosen to be the root widget window into which all other top-level widgets (for example dialogs, popup menus or combobox dropdowns) are composited. This is necessary because with EGLFS there is always exactly one native window and EGL window surface, and these belong to the widget or window that is created first. This approach works well when there is a main window that exists for the entire lifetime of the application and all other widgets are either non top-levels or are created afterwards, once the main window is shown.There are further restrictions for OpenGL-based windows. As of Qt 5.3, eglfs supports a single, fullscreen GL window (for example, an OpenGL-based QWindow, a QQuickView or a QGLWidget). Opening additional OpenGL windows or mixing such windows with QWidget-based content is not supported and will terminate the application with an error message.If necessary, eglfs can be configured via environment variables:•QT_QPA_EGLFS_FB - Overrides the framebuffer device. The default is /dev/fb0. On most embedded platforms this is not very relevant because the framebuffer is used only for querying settings like the display dimensions. On certain devices however this parameter provides the ability to specify which display to use in multiple display setups, similarly to the fb parameter in LinuxFB.•QT_QPA_EGLFS_WIDTH and QT_QPA_EGLFS_HEIGHT - Contain the screen width and height in pixels. While eglfs will try to determine the dimensions from the framebuffer device /dev/fb0, this will not always work and manually specifying the sizes may become necessary.•QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT - Physical screen width and height in millimeters. On platforms where the framebuffer device /dev/fb0 is not available or the query is not successful, the values are calculated based on a default DPI of 100. This variable can be used to override any such defaults.•QT_QPA_EGLFS_DEPTH - Overrides the color depth for the screen. On platforms where the framebuffer device /dev/fb0 is not available or the query is not successful, the default of 32 is used. This variable can be used to override any such defaults. Note that this affects only the color depth value reported by QScreen. It has no connection to EGL configurations and the color depth used for OpenGL rendering.•QT_QPA_EGLFS_SWAPINTERVAL - By default a swap interval of 1 will be requested. This enables synchronizing to the displays vertical refresh. The value can be overridden with this environment variable. For instance, passing 0 will disable blocking on swap, resulting in running as fast as possible without any synchronization.•QT_QPA_EGLFS_FORCEVSYNC - When set, eglfs requests FBIO_WAITFORVSYNC on the framebuffer device.•QT_QPA_EGLFS_FORCE888 - When set, the red, green and blue color channel sizes are ignored whenever creating a new context, window or offscreen surface. Instead, the plugin will request a configuration with 8 bits per channel. This can be helpful on devices where configurations with less than 32 or 24 bits per pixel are chosen by default but are known not to be suitable, for example, due to banding effects. Instead of changing all the applications, this variable provides an easier shortcut to force 24/32 bpp configurations for a given device.•QT_QPA_EGLFS_DEBUG - When set, some debugging information is printed on the debug output. For example, the input QSurfaceFormat and the properties of the chosen EGL configuration are printed whenever creating a new context. Together with Qt Quick's QSG_INFO variable, this can provide useful information for troubleshooting issues related to the EGL configuration.LinuxFBThis plugin writes directly to the framebuffer. Only software-rendered content is supported. Note that on some setups the display performance is expected to be limited.The linuxfb plugin allows specifying additional settings by passing them in the QT_QPA_PLATFORM environment variable or -platform command-line option. For example, QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1 specifies that the framebuffer device /dev/fb1 should be used instead of the default fb0. Multiple settings can be specfified by separating them with a colon.•fb=/dev/fbN - Specifies the framebuffer devices. On multiple display setups this will typically allow running the application on different displays. For the time being there is no way to use multiple framebuffers from one Qt application.•size=<width>x<height> - Specifies the screen size in pixels. The plugin will try to query the display dimensions, both physical and logical, from the framebuffer device. This may not always lead to proper results however, and therefore it may become necessary to explicitly specify the values.•mmSize=<width>x<height> - Physical width and height in millimeters.•offset=<width>x<height> - Offset in pixels specifying thetop-left corner of the screen. The default position is at (0, 0).•nographicsmodeswitch - Do not switch the virtual terminal to graphics mode (KD_GRAPHICS). In addition to switching to graphics mode, the blinking cursor and screen blanking are normally disabled too. When this parameter is set, these are also skipped.•tty=/dev/ttyN - Overrides the virtual console. Only used when nographicsmodeswitch is not set.KMSAn experimental platform plugin using kernel modesetting and drm (Direct Rendering Manager).InputWhen no windowing system is present, the mouse, keyboard and touch input are read directly via evdev or using helper libraries like tslib. Note that this requires that devices nodes /dev/input/event* are readable by the user. eglfs has all the evdev input handling code built-in, while linuxfb relies on the traditional and somewhat limited -plugin command-line parameters. Input on linuxfbTo enable keyboard, mouse, touch or tablet support with linuxfb, pass QT_QPA_GENERIC_PLUGINS=evdevkeyboard,evdevmouse,evdev touch,... in the environment or, alternatively, -plugin evdevkeyboard, -plugin evdevmouse, -plugin evdevtouch, or -plugin evdevtablet on the command-line. Most of these can take a device node parameter, for example QT_QPA_GENERIC_PLUGINS=evdevmouse:/dev/event1, in case the Qt's automatic device discovery (based either on libudev or a walkthrough of /dev/input/event*) is not functional or misbehaving.Input on eglfsFor eglfs, parameters like the device node name can be set in the environment variables QT_QPA_EVDEV_MOUSE_PARAMETERS,QT_QPA_EVDEV_KEYBOARD_PARAMETERS and QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS. Additionally, the built-in input handlers can be disabled by setting QT_QPA_EGLFS_DISABLE_INPUT to 1. On some touch screens the coordinates will need to be rotated. This can be enabled by setting QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS to rotate=180.MouseThe mouse cursor will show up whenever QT_QPA_EGLFS_HIDECURSOR (for eglfs) or QT_QPA_FB_HIDECURSOR (for linuxfb) is not set and Qt's libudev-based device discovery reports that at least one mouse is available. When libudev support is not present, the mouse cursor will always show up unless explicitly disabled via the environment variable.Hot plugging is supported, but only if Qt was configured with libudev support (that is, if the libudev development headers are present in the sysroot at configure time). This allows connecting or disconnecting an input device while the application is running. On eglfs the mouse cursor will disappear and reappear appropriately.KeyboardThe evdev keyboard handler supports the following extra parameters:•/dev/input/... - Specifies the name of the input device. When not given, Qt will look for a suitable device either vialibudev or by walking through the available nodes.•grab - Enables grabbing the input device.•keymap - Specifies the name of a custom keyboard map file.•enable-compose - Enables compositing.•repeat-delay - Sets a custom key repeat delay.•repeat-rate - Sets a custom key repeat rate.On Embedded Linux systems that do not have their terminal sessions disabled, the behavior when pressing a key can be confusing due to having the input event processed both by the Qt application and the tty. To overcome this, the following options are available:•EGLFS, LinuxFB and KMS attempt to disable the terminal keyboard on application startup by setting the tty's keyboard mode to K_OFF. This prevents keystrokes from going to the terminal. If the standard behavior needs to be restored for some reason, set the environment variable QT_QPA_ENABLE_TERMINAL_KEYBOARD to 1. Note that this will not work when the application is launched from a remote console (for example, via ssh) and the terminal keyboard input will remain enabled.•An alternative approach is to use the evdev keyboard handler's grab parameter by passing grab=1in QT_QPA_EVDEV_KEYBOARD_PARAMETERS. This results in trying to get a grab on the input device which, if successful, means that no other components in the system receive events from it as long as the Qt application is running. This approach is more suitable for applications started remotely as it does not need access to the tty device.•Finally, for many specialized Embedded Linux images it will not make sense to have the standard terminal sessions enabledin the first place. Refer to your build environment's documentation on how to disable them. For example, when generating images using the Yocto Project, unsetting SYSVINIT_ENABLED_GETTYS will result in having no getty process running, and thus no input, on any of the virtual terminals.Note: Special system key combinations, such as console switching (Ctrl+Alt+Fx) or zap (Ctrl+Alt+Backspace) are not currently supported and will get ignored.To generate a custom keymap, the kmap2qmap utility can be used. This can be found in the qttools module. The source files have to be in standard Linux kmap format that is e.g. understood by the kernel's loadkeys command. This means one can use the following sources to generate qmap files:•The Linux Console Tools (LCT) project.•Xorg X11 keymaps can be converted to the kmap format with the ckbcomp utility.•As kmap files are plain text files, they can also be hand crafted.kmap2qmap is a command line program, that needs at least 2 files as parameters. The last one will be the generated .qmap file, while all the others will be parsed as input .kmap files. For example:kmap2qmap i386/qwertz/de-latin1-nodeadkeys.kmap include/tin1.inc de-latin1-nodeadkeys.qmap Note: kmap2qmap does not support all the (pseudo) symbols that the Linux kernel supports. When converting a standard keymap, a number of warnings will be shown regarding Show_Registers, Hex_A, and so on; these messages can safely be ignored.TouchFor some resistive, single-touch touch screens it may be necessary to fall back to using tslib instead of relying on the Linux multitouch protocol and the event devices. For modern touch screens this should not be necessary. tslib support can be enabled by passing -plugin tslib instead of evdevtouch. To change the device, set the environment variable TSLIB_TSDEVICE or pass the device name on the command-line.Platform Plugins for Windowing Systems on Embedded Linux DevicesXCBThis is the X11 plugin used on regular desktop Linux platforms. In some embedded environments, that provide X and the necessary development files for xcb, this plugin will function just like it does on a regular PC desktop.Note: On some devices there is no EGL and OpenGL support available under X because the EGL implementation is not compatible with Xlib. In this case the XCB plugin will be built without EGL support, meaning that Qt Quick 2 or other OpenGL-based applications will not work with this platform plugin. It can still be used however to run software-rendered applications (based on QWidget for example).As a general rule, the usage of XCB on embedded devices is not advisable. Plugins like eglfs are likely to provide better performance, and hardware acceleration.WaylandWayland is a light-weight windowing system; or more precisely, it is a protocol for clients to talk to a display server.The Qt Wayland module provides a wayland platform plugin that allows Qt application to connect to a Wayland compositor.。
qtforembeddedlinuxanddirectfb
Qt for Embedded Linux and DirectFBQt for Embedded Linux and DirectFBIntroductionDirectFB is an open source LGPL licensed project founded by Denis Oliver Kropp and generally chip vendors start out with the official version and implement their own plugins to optimize the operations their hardware supports.We recommend using Qt 4.6 or later with DirectFB. Support for DirectFB was introduced into Qt for Embedded Linux as a labs project for Qt 4.3 and folded into Qt as a screen driver for Qt 4.4, but not supported fully. In Qt 4.5, major changes were made to make it work with the optimized raster paint engine. These changes were further improved in Qt ing DirectFB with QtDirectFB is centered around Surfaces which is the equivalent of a QPaintDevice. In the Qt/DirectFB plugin, DirectFB maps onto either a QPixmap or a QWindowSurface which essentially means that drawing onto QPixmap or a QWidgetcan be accelerated and drawing onto any other paint device (e.g. QImage) cannot.ConfigureWhen configuring Qt there are two options, from which you can choose: ./configure-plugin-gfx-directfb./configure -qt-gfx-directfbWith either mode, Qt will try the following to look for the DirectFB includes/epkg-configUse directfb-configCheck in yourqmake.confOften the values returned frompkg-config/directfb-config indicates the locations of thelibs/headers on the target rootfs, rather than their location on your host. The safest option is usually to explicitly populate these variables in your qmake.conf like this:QT_CFLAGS_DIRECTFB =/opt/toolchain/gcc4.3_mipsel_linux/usr/include/directfb-D_REENTRANTQT_LIBS_DIRECTFB =-L/opt/toolchain/gcc4.3_mipsel_linux/usr/lib/-ldirect-ldirectfb -lfusionNote: While DirectFB supports amulti-process setup through a kernel-extension called Fusion this setup is not well tested with Qt.Supported graphics operationsIDirectFBSurface supports blitting, filling, drawing lines rects etc, but it does not support everything Qt allows you to do. E.g. painter paths, polygons, complex transformations, antialiasing, gradients. Some of these things are handled in newer versions ofDirectFB and could be supported by Qt. They are seemingly optional at the driver level, so you need to have fall back code paths for older drivers and drivers on which this is not implemented.The QDirectFBPaintEngine is a subclass of the QRasterPaintEngine, thus essentially supporting everything QRasterPaintEngine supports. This means that it supports all graphical operations that Qt supports, but certain operations will have to fall back to software rendering and that should be avoided due to performance issues. Instead, these operations should be rendered into a QPixmap once, and then reuse the pixmap.Note: Fallbacks to software rendering should be avoided. If unsupported operations are used, the paint engine must fallback to the QRasterPaintEngine engine. A good debugging tip is to make Qt warn you when such fall backs occur, and to disable the fall back and only return. Debugging options are listed below.DirectFB driverDirectFB also provides an abstraction for keyboard and mouse drivers. This simplifies the process of getting the target hardware up and running. It also brings us to a feature fragmentation issue between different versions of DirectFB.The Qt DirectFB driver currently supportsDirectFB versions >= 0.9. Still, there are large differences in what each actual implementation handles correctly. It is relatively common not to properly support DirectFB windows, so Qt needs to handle this case with a different code path. In addition, certain drivers do not properly support DirectFB's cursor handling. This means Qt has to have a code path for rendering the cursor itself when this is the case. Some drivers do not let us createpreallocated surfaces which means we have to have a conditional code path for that case.Optimize performance using define optionsQt/DirectFB comes with a number of defines that can be either uncommented in directfb.pri or added to the QT_DEFINES_DIRECTFB variable in your qmake.conf.Note: The defines have been moved from src/plugins/gfxdrivers/directfb/directfb.pro to src/gui/embedded/directfb.pri#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|D RAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|D RAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSP ANS|DRAW_ROUNDED_RECT #DEFINES +=\"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$D IRECTFB_DRAWINGOPERATIONS\"#DEFINES +=\"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DI RECTFB_DRAWINGOPERATIONS\"As demonstrated above, you need to tell Qt which drawing operations you want to warn/disable. Since there are varying implementations of DirectFB from manufacturer to manufacture, different operations will be optimized. This require you to define the operations you want to warn about or disable. These are listed above in the DIRECTFB_DRAWINGOPERATIONS variable.You can also customize this with environment variables.E.g. If you want to disable fallbacks for drawPixmap and fillRect and also get a warning printed on stderr when a fallback would have happened. $ exportQT_DIRECTFB_WARN_ON_RASTERFALLBACKS="FILL _RECT|DRAW_PIXMAP"$ exportQT_DIRECTFB_DISABLE_RASTERFALLBACKS="FILL_RECT|DRAW_PIXMAP"$ ./app -qws -display directfbFollowing is a table showing which options you have.DefineoptionDescriptionQT_DIRECTFB_IMAGECACHEDefining this means that Qt will cache an IDirectFBSurface per QImage you draw based on its cacheKey(). Use this define if your application draws many QImages that remain the same. Note that if you in this situation draw an image and then change it, by calling bits() or opening a QPainter on it, the cache will not benefit you. You can control the cache size with the imageCacheSize connectoption.QT_NO_DIRECTFB_WMIf your DirectFB implementation does not support windows, you have to define this to make Qt work properly. You can test this by checking if the df_window example runs well. This means that all drawing operations onto a QWidgetinvolves an extra blitting step since Qt essentially first has to draw into an off-screen buffer and then blit this buffer to the back buffer of the primary surface. Finally, Qt must flip the back buffer to the front buffer, which usually involves another blit. Still, blits are usually very fast with DirectFB.To work around this you can make your widget paint on screen,Qt::WA_PaintOnScreen but this comes with other limitations. This should be avoided if you want more than one full-screen window in your application. In addition, it will not work without proper DirectFB mouse support from the layer. Also, see QT_NO_DIRECTFB_LAYER for more.QT_NO_DIRECTFB_LAYERIf your DirectFB display layer cannot be used for e.g. drawing mouse cursor, creating windows you have to define this. Defining this also requires defining QT_NO_DIRECTFB_WM and involves making Qt render the cursor rather than letting DirectFB do it.QT_NO_DIRECTFB_PALETTEDefine this if your DirectFB driver does not support surfaces with color tables. The effect of defining this is that Qt will have to convert images with QImage::Format_Indexed8 format to another format before renderingthem.QT_NO_DIRECTFB_PREALLOCATEDDefine this if your DirectFB driver does not support creating a surface with preallocated data. This will make a more frequent use of memcpy() when drawing images. If you define this, you might want to consider definingQT_DIRECTFB_IMAGECACHE for better image rendering performance.QT_NO_DIRECTFB_MOUSE andQT_NO_DIRECTFB_KEYBOARDDefine this if your driver does not provide keyboard/mouse events through CreateInputEventBuffer. This means that Qt cannot use DirectFB to receive keyboard/mouse events and if you want such events in your application, you will have to provide another driver. For more info see Qt for Embedded Linux Pointer Handling and Qt for Embedded Linux Character InputQT_DIRECTFB_TIMINGDefine this when debugging to get output on stderr about the frames per second.QT_NO_DIRECTFB_OPAQUE_DETECTIONWhe n blitting a surface Qt has to decide whether to set the DSBLIT_BLEND_ALPHACHANNEL flag. If you load an image from file or network data that has a format that includes an alpha channel, the image might still be completely opaque. Normally Qt runs through every pixel to check if there really is an alpha channel there. This involves some overhead but usually pays off in the end because blitting is cheaper than blending. If you define this Qt will assume that an image with a format that has alpha channel contains at least one pixel with an alpha value != 255.QT_DIRECTFB_SUBSURFACEDefining this enables a mode that tries to minimize overhead fromlocking/unlocking surfaces. Note that this currently is experimental.QT_DIRECTFB_WINDOW_AS_CURSORDe fine this if your DirectFB implementation supports windows but can not render the cursor properly. This involves creating a small top level window and moving it around when the cursor moves. It does not always performwell.QT_NO_DIRECTFB_IMAGEPROVIDERBy default Qt will use DirectFB to load QPixmaps from disk/memory. If your DirectFB implementation does not support this it might make sense to define this. If you see strange rendering issues with pixmaps that have an alpha channel defining this could solve theproblem.QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE Define this to make sure Qt always keeps at least one IDirectFBImageProvider object alive. This is to avoid considerable overhead when the first IDirectFBImageProvider is created, the last IDirectFBImageProvider is removed.。
嵌入式Linux用户图形界面编程
3.SVGALib SVGALib是Linux系统中最早出现的非X图形支持库,是Linux下的VGA驱动函 数库。虽然它的品质有点低,支援显卡种类也不多,但是有许多的游戏及程序都 是用它来做开发,可以算是非官方的标准了。这个库从最初对标准VGA兼容芯片 的支持开始,已经发展到对老式SVGA芯片,以及现今流行的高级视频芯片的支持。 它为用户提供了在控制台上进行图形编程的接口,使用户可以在PC兼容系统上方 便地获得图形支持。但该系统也存在一些不足: SVGALib从最初的vgalib发展而来,保留了老系统的许多接口,而这些接口 却不能良好地适应新显示芯片的图形能力。 未能较好地隐藏硬件细节。许多操作,不能自动使用显示芯片的加速能力支 持。 可移植性差。SVGALib目前只能运行在x86平台上,除Alpha平台,对其他平 台的支持能力较差。 SVGALib作为一个老的图形支持库,目前的应用范围越来越小,尤其在 Linux内核增加了FrameBuffer驱动支持之后,有逐渐被其他图形库替代的趋势。 4.LibGGI LibGGI是一个跨平台的绘图库,可以建立一个一般性的图形接口,这个抽象接 口连同相关的输入(鼠标、键盘、游戏杆等)接口一起,可以方便地运行在X Window、SVGALib、FrameBuffer等之上。建立在LibGGI之上的应用程序,不经 重新编译,就可以在上述这些底层图形接口上运行。 在Linux上,LibGGI是通过调用FrameBuffer或SVGALib来完成图形操作的,可 能速度比较慢。但在某些不支持FrameBuffer或vga的系统上,采用LibGGI仍然是 一种不错的选择。
嵌入式GUI要求简单、直观、可靠、占用资源小且反应快速,以适应系统硬件 资源有限的条件。另外,由于嵌入式系统硬件本身的特殊性,嵌入式GUI应具备高 度可移植性与可裁减性,以适应不同的硬件条件和使用需求。总体来讲,嵌入式 GUI具备以下特点: 体积小; 运行时耗用系统资源小; 上层接口与硬件无关,高度可移植; 高可靠性; 在某些应用场合应具备实时性。 一个能够移植到多种硬件平台上的嵌入式GUI系统,应至少抽象出两类设备: 基于图形显示设备(如VGA卡)的图形抽象层GAL(Graphic Abstract Layer)和 基于输入设备(如键盘,触摸层等)的输入抽象层IAL(Input Abstract Layer)。 GAL层完成系统对具体的显示硬件设备的操作,最大限度地隐藏各种不同硬件的技 术实现细节,为程序开发人员提供统一的图形编程接口。IAL层则需要实现对于各 类不同输入设备的控制操作,提供统一的调用接口,如图9.2所示。GAL层与IAL层 设计概念的引入,可以显著提高嵌入式GUI的可移植性。
编译linux外部驱动模块时的基础知识
编译linux外部驱动模块时的基础知识为了清晰的编译Linux内核,内核编译系统使用Kbuild规则对编译的过程以及依赖进行规约。
在内核模块的编译中,为了保持与内核源码的兼容以及传递编译链接选项给GCC,也使用Kbuild规则。
内核模块的源代码可以在内核源码树中,也可以在内核源码树外,当使用Kbuild时,两种情况的编译方式也大致相似。
一般的内核模块在开发时,都是放在源码树外的。
本文主要是针对源码树外部的内核模块的编译。
为了屏蔽内核模块编译的复杂性,开发人员需要编写额外的Makefile,最终让编译内核模块就像编译普通的应用程序一样,敲入”make”就行了。
本文后面就给了一个实例。
编译外部模块在编译外部模块之前,需要首先准备好当前内核的配置以及内核头文件,同时,当前内核的modules enable选项应该开启(编译内核时指定)。
命令行选项使用如下命令编译外部模块:make CC kernerl_src_dir M=ext_module_path其中-C表明make要调用kernel_src_dir下的Makefile,该Makefile就是内核的Makefile,M为该Makefile的参数,指定外部模块源码的路径。
当Makefile接收到M参数时,就默认编译外部模块。
例如,当前目录下存放一个外部模块的源码,其编译命令如下:make CC /lib/modules/`uname -r`/build M=`pwd`其中uname Cr获取当前运行内核的版本,pwd为当前源码路径,将其展开之后为:make CC /lib/modules/ 2.6.42.9/build M=/home/user/hello其中/lib/modules/ 2.6.42.9/build是指向内核源码目录的符号链接。
编译完成之后,要安装驱动时,调用如下命令:make CC /lib/modules/`uname -r`/build M=`pwd` modules_install编译目标modules编译外部模块,默认目标就是modulesmodules_install安装编译成功了的外部模块,默认的安装目录为/lib/modules/kernel_release/extra/,前缀可以同过*****_MOD_PATH 指定。
Emind-Linux使用教程
Emind の Linux使用教程有很多人都想体验下Emind的美,但是,对于小白的我们不开森了,这怎么连个安装教程都没有呢,今天我就给大家带来LinuxのOpenthos的安装教程。
[要求][EasyBCD安装法]:EasyBCD 软件[软碟通安装法]:软碟通、U盘EasyBCD安装法一、准备工作(在WIN下操作完成)1 从官网上下载镜像文件,大小接近1GB。
下载EasyBCD最新版安装。
2 格出一个盘,点击右键格式化后删除。
这个盘8G以上比较稳妥。
3 安装好EasyBCD 后,启动软件:按照上图的序号点击,会打开一个记事本文件menu.lst,将文件尾部并保存:title Install Linuxroot (hd0,0)kernel (hd0,0)/vmlinuz boot=casper iso-scan/filename=/EmindOS.iso ro quiet splash locale=zh_CN.UTF-8initrd (hd0,0)/initrd.lz到此,EasyBCD部分就操作完了。
下面将下载的iso文件放到某个盘的根目录下(记住一定要改为这个名字,也就是要保证和你下载的iso镜像文件名一致!!!),然后用虚拟光驱或解压缩软件将iso打开,将casper文件夹目录下的vmlinuz和 initrd.lz复制或解压到C盘根目录下。
二、安装过程电脑重启后,就会发现启动菜单会多了一项NeoGrub Bootloader,选择NeoGrub Bootloader启动项,就会进入Emind桌面,先不要急着点击点桌面上的安装系统图标。
先点击桌面左上角应用程序—附件—终端,输入s udo umount -l /isodev ice后回车。
这主要是为了防止安装过程中出现“无法卸载挂载点”的错误。
然后可以点击桌面上的安装Linux一步步按照提示选择安装了。
这里介绍一下安装过程中涉及到的分区问题:安装的时候选择“手动分区”(或者选择使用全部空闲)1 选择“free space”(空闲空间)2 点击“New partition”(新建分区)3 选择新分区的类型:Primary(主分区)(安装双系统且已安装Windows的话,/分区的类型选择Primary或者Logical都可以,其它分区选择Logical逻辑分区。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
嵌入式linux GUI--DirectFB + GTK至尊秘笈版权申明: 本文档一切权利归本人(kendych@)所有,用于商业用途徐征得本人同意,如无法联系到本人,须征得所有者同意;用于非商业用途的,无需任何许可,但请尊重本人的署名权,并注明出处及附加本申明。
关键词: 嵌入式GUI arm linux DirecrFB GTK tslib1 前言数年前,曾经开发过一个嵌入式的产品,如今市场依然存在,但由于电子产品的升级换代很快,许多元器件都采购不到了,为了延续产品的生命周期,计划在 linux平台上开发新的版本。
而在linux上的GUI上成了大问题,最开始有用Minigui的打算,也同飞漫公司联系过,但费用我这里无法承受。
(Minigui作为国产优秀的嵌入式GUI,如果不是费用的问题,应该是最优的选择。
) QT我也看了下,也是收费的,没有仔细研究。
最开始我打算用MicroWindow的,但后来发现这个东西好久没有更新了,bug一大堆。
最后的目光停留在GTK上,最开始无从下手,不知道到底适合不适合做嵌入式GUI,最后不知道在哪里看到一个介绍说诺基亚有产品是用GTK的,觉得既然别人能做得,我也能做得。
最开始做这个,相关资料太少,一点底都没有,但经过两个月(长了点)的努力,终于解决了所有问题,才一颗石头落地。
个人认为,在本文的帮助下,如果你拥有初中级的嵌入式linux的知识,也许一天就能解决问题,最长也不会超过一个星期。
2 准备工作硬件环境:linux主机一台,如果你喜欢用windows,可以在windows主机上用vmware 虚拟一个linux系统。
嵌入式开发套件,包括嵌入式开发板、带触屏的液晶屏及相关连接电缆。
软件环境:x86 linux发行版,配置好framebuffer,并安装好ftp server、telnet server、tftp server、nfs server、gcc及相关软件、交叉编译器、开发套件的kernel 2.6的源码包。
本人用的是Ubuntu 7.10的发行版,嵌入式开发版采用三星的2440系列cpu,如何搭建开发环境不在本文讨论范围之类,请参考其他文档。
交叉编译器用的是自己编译的 3.4.1,最开始采用的是开发套件带的 3.4.1,为什么要用自己编译的而不用开发套件自带的呢? 这里说本文第一个秘笈:由于GTK采用的矢量字体里一些算法使用了浮点运算,而24xx系列的cpu硬浮点不支持(我没有相关知识,这是我的一个同事说得,是不是他本来意思,我都不敢确定,如果你的cpu不是这个系列的,请查看相关资料),只要在交叉编译器里加上软浮点运算支持,就应该没有问题了,所以在开始之前,先检查交叉编译器里有没有--with-float=soft这个选项。
在我使用开发版自带的编译完成编译后,运行gtk的程序,总是有这个提示”shape engine failure, expect ugly output. the offending font is”,而屏幕上所有字符都显示不出来,button由于字符无法显示,被压缩成一条线,这个问题困扰我好几天,我开始以为是字库设置的问题,后来求助同事,他听了我的描述后,猜测可能是浮点运算的问题,让我用我们自己编译的交叉编译器重新编译一下,看看能不能解决问题,结果真的解决了。
3 源码包的选择选用GTK做嵌入式GUI是个痛苦的选择,如果选用商业GUI如MiniGui,别人都给你整好了,你拿过来用就可以了,或者用Wince,还是与 windows兼容的。
而选用GTK做GUI,不同组织(个人)编写的15个软件包,各个软件包又有不同的版本,而网上又没有权威的指南,如何选择合适的版本以及如何整合确实是个非常复杂的问题。
我是先从在x86上搭建GTK环境开始的,首先我选用最新版本,然后,看到介绍说,GTK在framebuffer上运行有两种模式: DirectFB和linux-fb,而linux-fb的项目好像已经停止,主要方向是DirecrFB,后来查的有个DirecrFB + GTK的英文文档,基本都选用最新的版本,而且很多包都可以使用系统自带的,编译必须的源码就可以了,最开始怎么也编译不成功,我快绝望的时候,发现释放出一个最新的GTK源码版本(大概是08年7月4日),我第一时间下载下来,很快就编译出来了,并且在framebuffer模式下gtk-demo以及一些test 运行一点问题都没有。
熟悉了编译过程后,我先尝试用交叉编译这个最新版本,编译第一个包glib-2.16.4就失败了。
我在网上阅读了很多关于交叉编译 DirecrFB+GTK的的资料,有个用shell脚本写的好像不错,但是看不懂呀,虽然我接触unix都十多年了,还曾经在unix下做个一比较大型的项目,但后来,linux都是个人兴趣,看了一些,玩了一些,没做过东西,shell编程看过,好多东西一直半解,他那篇文档看的我都傻了,这人真牛。
但源码包的选择是可以借鉴的。
我的选择:1) tslib-1.0.tar.bz2触摸屏本来我是最后弄的,但如果你需要触屏支持,最好在一开始就搞定他。
这个其实是tslib.14,为啥成了1.0的了,我也不知道,如何编译不是很难,难在怎么配置,相关文档请阅读本人的另外一篇文档《arm-linux之tslib》,当然哪片文档可能并不能帮你搞定,你需要动用你的聪明才智,你也许需要阅读kernel里触屏驱动的源码。
我的开发套件触屏控制器是用的cpu本身的AD转换器,kernel里的驱动是兼容H3600的,所以我在ts.conf文件里module_raw模块设置为h3600。
如果你用的三星的24XX系列的cpu,也许使用的方式跟我相同,使用同样的配置也许可以,如果不行,可能要阅读触屏驱动的源码及tslib的module_raw的源码,找到匹配的模块就行了。
《arm-linux之tslib》的位置/viewthread.php?tid=388&extra=page%3D12) freetype-2.3.5.tar.bz23) glib-2.12.13.tar.bz24) libpng-1.2.19.tar.bz2这个模块本来我是不需要的,我在编译GTK的时候想disable这个模块,configure无法完成。
5) zlib-1.2.3.tar.bz26) jpegsrc.v6b.tar.gz这个模块是我必须的,但编译GTK的时候,configure说找不到这个模块的jpeglib.h,我也研究了好久,7) tiff-3.7.4.tar.gz这个模块我不需要,但编译了,最终,我不会采用这个模块。
8) DirectFB-1.1.1.tar.gz最开始我采用的是1.1.0,基本正常,最后弄触屏的时候,运行程序DirectFB怎么也加载不成功nputdrivers里的模块 libdirectfb_tslib.so,阅读了相关代码后,发现这个版本的DFB的这个模块加载后,不读取tslib的相关环境变量,直接加载 /dev/input/tslibn些设备,而我的开发板起来后,根本没有这些设备,1.1.0之后的版本,相关代码做过修正,我也尝试了最新版本的 DFB 1.2.1,但这个版本的DF B跟好核后面选用的GTK的版本配合有点问题,无法编译后面的GTK,我阅读DFB 1.1.1的相关代码,发现已经修正,选用了这个版本,运行GTK程序,DFB开始加载tslib的相关模块,但只加载成功tslib的 module_raw的模块,后面的模块加载失败。
什么原因这里不做解释,后面再说。
9) atk-1.19.3.tar.bz210) expat-2.0.1.tar.gz11) libxml2-2.6.29.tar.gz12) fontconfig-2.4.2.tar.gz13) pango-1.16.4.tar.bz214) cairo-1.4.10.tar.gz15) gtk+-2.10.14.tar.bz2这个模块最后编译,编译完成意味着我们成功完成了编译工作,我configure这个模块的时候碰到了两个问题:第一找不到pango,最后看到好多,才知道在configure前需要设置这个环境变量export LDFLAGS="-L$PREFIX/lib -Wl,-rpath,$PREFIX/lib" 这个啥意思,我不知道,为什么这样设我也不知道。
第二找不到jpeglib.h,我分析了log,发现是在测试g++编译的时候,找不到 jpeglib.h,而测试gcc编译是没有问题的,我在configure前设置了这个export CPPFLAGS="-I$PREFIX/include"环境变量,告诉g++编译器到哪里找jpeglib.h。
4 交叉编译在宿主系统上交叉编译后的所有包的安装目录为/usr/gtkdfb,当然,你可以使用其他的目录,但绝不能跟主机环境相冲突,将交叉编译后东西安装到宿主系统的默认位置,可能会导致你的宿主系统某些不可预知的后果。
下面开始编译1) Tslibexport PREFIX=/usr/gtkdfbecho "ac_cv_func_malloc_0_nonnull=yes" >arm-linux.cache./configure --host=arm-linux --prefix=$PREFIX --cache-file=arm-linux.cache--enable-inputapi=nomakemake install编译前只需要指定PREFIX一个环境变量,这个模块编译下面的编译基本都需要以下三个export LDFLAGS=-L$PREFIX/libexport CFLAGS="-g -I$PREFIX/include"export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig2) glibecho ac_cv_type_long_long=yes>arm-linux.cacheecho glib_cv_stack_grows=no>>arm-linux.cacheecho glib_cv_uscore=no>>arm-linux.cacheecho ac_cv_func_posix_getpwuid_r=yes>>arm-linux.cacheCC=arm-linux-gcc ./configure --host=arm-linux --build=i686-pc-linux --prefix=$PREFIX --cache-file=arm-linux.cachemakemake install3) atk./configure --host=arm-linux --prefix=$PREFIXmakemake install4) jpeg-6b./configure --prefix=$PREFIX --enable-shared --enable-static修改生成的Makefile文件:# The name of your C compiler:CC= gcc 该成 CC=arm-linux-gcc (根据你自己交叉编译器的位置修改)# library (.a) file creation commandAR= ar rc 该成AR= arm-linux-ar rc (同上)# second step in .a creation (use "touch" if not needed)AR2= ranlib 该成 AR2=arm-linux-ranlib (同上)mkdir $PREFIX/manmkdir $PREFIX/man/man1makemake install-lib5) zlibCC=arm-linux-gcc ./configure --prefix=$PREFIX –sharedmakemake install6) libpng./configure -host=arm-linux --prefix=$PREFIXmakemake install7) expat./configure -host=arm-linux --prefix=$PREFIXmakemake install8) freetype./configure -host=arm-linux --prefix=$PREFIXmakemake install9) libxml./configure -host=arm-linux --prefix=$PREFIXmakemake install10) fontconfigexport LIBXML2_CFLAGS=-I$PREFIX/include/libxml2export LIBXML2_LIBS="-L$PREFIX/lib -lxml2"./configure --host=arm-linux --prefix=$PREFIX --with-freetype-config=$PREFIX/bin/freetype-config --with-arch=armmakemake install11) tiff./configure --host=arm-linux --prefix=$PREFIX --enable-sharedmakemake install12) 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-x11makemake install13) 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-pngmakemake install不知道为什么,gtk非要有pdf和ps的支持,没有就无法完成configure,没办法,我只好在这里就打开,其实也不能真正支持,因为pdf等东西根本没有加进来。