LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 11619|回复: 53

装饰终端,bootsplash的vesafb解决方案

[复制链接]
发表于 2009-2-4 21:31:36 | 显示全部楼层 |阅读模式
实践机器:Gentoo X86_64 gentoo-sources-2.6.28-r1
关键字:bootsplash, framebuffer, vesafb

一.内核配置
1.开启framebuffer的支持,以下为必须选项

  1. Device Drivers  --->
  2.   Graphics support  --->
  3.     <*> Support for frame buffer devices  --->

  4.                  [*]   VESA VGA graphics support
  5.     Console display driver support  --->
  6.         <*> Framebuffer Console support

  7.                  [*]   Support for the Framebuffer Console Decorations
复制代码


下面这个选项一般X用户都已开启

  1. Processor type and features --->
  2.    [*] MTRR (Memory Type Range Register) support
复制代码

只要能用fbterm,或mplayer播放视频、fbida查看图片等任一依赖framebuffer
的工具就可以知道framebuffer支持已经打开了

正确使用vesafb应该在dmesg有其信息

  1. dmesg | grep vesafb
  2. [    0.000000] Command line: root=/dev/sda2 rootfstype=ext4 quiet vga=865  video=vesafb:mtrr:3 splash=silent,fadein,theme:natural_gentoo console=tty1
  3. [    0.000000] Kernel command line: root=/dev/sda2 rootfstype=ext4 quiet vga=865  video=vesafb:mtrr:3 splash=silent,fadein,theme:natural_gentoo console=tty1
  4. [    0.404665] vesafb: framebuffer at 0xd5000000, mapped to 0xffffc20004100000, using 8000k, total 14336k
  5. [    0.404672] vesafb: mode is 1280x800x32, linelength=5120, pages=1
  6. [    0.404676] vesafb: scrolling: redraw
  7. [    0.404681] vesafb: Truecolor: size=8:8:8:8, shift=24:16:8:0
复制代码


2.需加载initramfs/initrd的支持

  1. General setup  --->
  2.   [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support  
  3.   ()    Initramfs source file(s)
复制代码

如果不能加载initrd的话,framebuffer将只能做到console decoration而没有开关机的loading画面


3.在bootsplash界面时可以按F2切换verbose模式

  1. Device Drivers --->
  2.     Input Device Support --->
  3.         <*> Event Interface
复制代码


二.软件包安装
1.splashutils工具
USE="mng png fbcondecor" emerge splashutils
mng和png为支持splash themes images需要,fbcondecor即framebuffer console decoration
命令euse -i fbcondecor的解释
[-    ] fbcondecor (media-gfx/splashutils):
Support for the fbcondecor kernel patch.
其实是在splashutils中是增加一个rc脚本来启动fbsplash


splashutils的依赖之一为klibc,而不同版本的klibc编译时依赖特定版本的内核源码,如目前的1.5.12-r1需要2.6.26的kernel源码。
当然这些它是自动完成的,我是解释一下klibc要下载几十MB源代码的原因。

2.主题包
emerge media-gfx/splash-themes-gentoo
20080914版本(keywords为~x86或~amd64)包含natural_gentoo, gentoo, emergence主题
emerge media-gfx/splash-themes-livecd
可安装2004.3~2007.0各个版本,目前最新版是livecd-2007.0主题


三.主题与grub参数
1.选择主题
ls /etc/splash可以看到已安装的可用主题,本例使用natural_gentoo

2.制作initrd镜像
# /usr/sbin/splash_geninitramfs -g /boot/initrd -r 1280x800 -v natural_gentoo
-g指定生成的镜像文件路径
-r可以指定只生成特定分辨率的镜像,需要所用主题能提供的
ls /etc/splash/natural_gentoo/
1024x768.cfg   1280x800.cfg  1600x1200.cfg  800x600.cfg
1280x1024.cfg  1440x900.cfg  1680x1050.cfg  images

3.grub.conf设置
用你喜爱的编辑器编辑 /boot/grub/grub.conf
在kernel一行中参照我的例子编辑,重点在kernel和initrd两行

  1. default=0
  2. timeout=0
  3. hiddenmenu

  4. title Gentoo Linux 2.6.28-r1
  5.         root (hd0,0)
  6.         kernel /bzImage root=/dev/sda2  rootfstype=ext4 quiet vga=865 video=vesafb:ywrap,mtrr:3 splash=silent,fadein,theme:natural_gentoo console=tty1
  7.         initrd /initrd
复制代码

bzImage为内核,更多的人会命名为如gentoo-kernel-2.6.18-r1的形式
root=/dev/sda2是我的根目录 rootfstype指定ext4格式可以避免kernel加载时分别尝试ext2,ext3等其支持的格式
quiet参数不显示内核加载信息,即dmesg的前一段
vga=865是1280x800-32的表示方法,可以改为vga=791(1024x768),vga=869(1440x900)等,把vga=791(经典型号?)搜索一下并结合需要测试可以找到更多选择
因为在我的14寸小屏终端上用1280x800比1440x900舒服,所以选择了865;众所周知,这影响不了X的1440x900

video=vesafb:ywrap,mtrr:3
ywrap是一个卷屏(scroll)加速选项,还可以是ypan,redraw(依次速度递减)等,这个设置对我没效果,貌似是使用vesafb-tng和uvesafb设置这个才有作用。
dmesg | grep scroll
[    0.404771] vesafb: scrolling: redraw

mtrr:3中的3可参考这个表,越低越安全,越高越快,3最合适,在我的尝试中好像只可以是3或不是3,设置为3时cat /proc/mtrr可以看到有多出reg03这一行,设置为其它就只有reg00~reg02。

  1.     0 - Disabled (equivalent to nomtrr) (default)
  2.     1 - Uncacheable
  3.     2 - Write-back
  4.     3 - Write-combining
  5.     4 - Write-through
复制代码

下面引自kernel相应介绍

  1. Enabling write-combining allows bus write transfers to be combined
  2. into a larger transfer before bursting over the PCI/AGP bus.
  3. This can increase performance of image write operations 2.5 times or more.
复制代码

说到mtrr设置为3可神奇了,在scrolling依然是redraw的情况下仍可以提高二倍多的scroll速度,有兴趣的可以运行time dmesg尝试,当然也可以time cat个大文件。
除此之外,在我的T61上设置后还可以在bootsplash刚好100%时启动X(xdm加到rc中的情况下),即看不到终端的任何东西,感觉就像是fedora10的什么技术。
于是这一段我的设置后来改为了仅为video=vesafb:mtrr:3

splash=silent,fadein,theme:natural_gentoo
silent或verbose选择是默认显示进度条画面还是显示有背景的终端;建议加上fadein,淡出显示splash;theme指定主题,即前面选择的natural_gentoo
console=tty1或CONSOLE=/dev/tty1
重定向kernel和initscript输出信息的终端,有这个才能让bootsplash的进度条正确完成。

initrd /initrd,和/bzImage一样,可以/boot/initrd,因为/boot下有个boot软链接指向/boot
initrd使内核加载时运行制作好的镜像,关于内核启动加载initrd,initramfs以及怎么自己制作程序镜像让内核可以加载,建议查看相关文档。

4.fbcondecor
记得要rc-update add fbcondecor,这个脚本的作用可以看dmesg,它把fb背景应用到每一个终端

  1. dmesg | grep fbcondecor
  2. [    0.593238] fbcondecor: console 0 using theme 'natural_gentoo'
  3. [    0.670568] fbcondecor: switched decor state to 'on' on console 0
  4. [   14.223007] fbcondecor: console 1 using theme 'natural_gentoo'
  5. [   14.279603] fbcondecor: switched decor state to 'on' on console 1
  6. [   14.388608] fbcondecor: console 2 using theme 'natural_gentoo'
  7. [   14.446137] fbcondecor: switched decor state to 'on' on console 2
  8. [   14.505730] fbcondecor: console 3 using theme 'natural_gentoo'
  9. [   14.566159] fbcondecor: switched decor state to 'on' on console 3
  10. [   14.625255] fbcondecor: console 4 using theme 'natural_gentoo'
  11. [   14.681741] fbcondecor: switched decor state to 'on' on console 4
  12. [   14.740266] fbcondecor: console 5 using theme 'natural_gentoo'
  13. [   14.798652] fbcondecor: switched decor state to 'on' on console 5
  14. [ 1121.703854] fbcondecor: console 0 using theme 'natural_gentoo'
  15. [ 1121.723619] fbcondecor: switched decor state to 'on' on console 0
  16. #前两句是由initrd产生,后面两句是从X切换到tty1由fbcondecor重新生成
复制代码


四.参考
http://www.linuxsir.cn
http://www.gentoo-wiki.com
我的内核配置文件: https://docs.google.com/Doc?id=dttt8m6_5crvw9fg9
Thinkpad T61 7663
感谢百度和google,感谢接受折腾的机器。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
 楼主| 发表于 2009-2-4 21:34:30 | 显示全部楼层
最近放假比较闲,而Gentoo月报两个月没出现了不用翻译,看到这么多人折腾framebuffer,于是随便写了写,多多指教,有错请提出改正。
回复 支持 反对

使用道具 举报

发表于 2009-2-4 21:42:21 | 显示全部楼层
感谢楼主分享

虽然我是直接KDM进X...

标记一下..也许以后会用到
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-2-4 22:09:37 | 显示全部楼层
bootsplash是在kdm前出现的...
补了两张图,第一张是把命令随便写进init.d里抓的。
回复 支持 反对

使用道具 举报

发表于 2009-2-4 22:18:51 | 显示全部楼层
Post by hezhit;1943957
bootsplash是在kdm前出现的...
补了两张图,第一张是把命令随便写进init.d里抓的。


额...不是字符界面的背景图片吗...

开机画面倒是不错...明天试试

PS:你的用户名很牛...
回复 支持 反对

使用道具 举报

发表于 2009-2-4 22:23:14 | 显示全部楼层
感谢兄弟
最近这方面的帖子不少,但兄弟的帖子显然是花了不少心思的
回复 支持 反对

使用道具 举报

发表于 2009-2-4 22:33:43 | 显示全部楼层
不错,学习了
ati新驱动又要我重新编译内核才能安装,那顺便用楼主的方法搞个启动画面
回复 支持 反对

使用道具 举报

发表于 2009-2-4 22:49:44 | 显示全部楼层
很漂亮,恭喜恭喜
目前還用不上...用slim了,也少關機重啟(嘻嘻,找不到用的理由了吧)

日後編譯內核再弄~~~
回复 支持 反对

使用道具 举报

发表于 2009-2-4 22:52:11 | 显示全部楼层
呵呵,学习了,原来有那么多参数,
rc-update add fbcondecor 是 boot 还是 default?
回复 支持 反对

使用道具 举报

发表于 2009-2-4 22:59:58 | 显示全部楼层
为啥我用vga=865就不行呢?
启动后提示:Undefined video mode number:361
kernel /boot/kernel-2.6.28-gentoo-r1-radeon root=/dev/sda4 rootfstype=ext4 vga=865 video=vesafb:ywrap,mtrr:3 splash=silent,fadein,theme:natural_gentoo console=tty1 quiet
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表