tag 标签: plymouth

相关博文
  • 热度 2
    2024-1-26 14:31
    1458 次阅读|
    0 个评论
    By Toradex秦海 1). 简介 嵌入式 Linux 下传统实现 Splash Screen 的方式是通过替换 kernel 默认的 TUX 小企鹅 logo 为定制的开机画面图片来实现嵌入式设备开机图片,虽然比较成熟且可以保证开机画面加载比较早,但是存在的问题首先是对嵌入式设备不同显示接口的兼容性不好,另外每次修改适配都需要重新编译内核,维护起来不是很方便,然后就是只能支持静态图片无法支持动画。基于上述原因,使用专门的 Splash Screen 工具来实现开机画面逐渐成为嵌入式设备的主流方向,本文就简单演示使用 Plymouth 工具来实现动态开机画面的示例。 本文所演示的平台来自于ToradexVerdiniMX8MM 嵌入式平台,基于NXP iMX8M Mini系列ARM处理器,主要核心架构为Cortex-A53。 2 ) . 硬件 准备 a). Verdin iMX8MM ARM 核心版配合 Dahlia 载板,并通过 DSI-LVDS Adapter 连接 10inch LVDS 液晶显示屏 以及调试串口以便测试。 3). 关于 Plymouth a). Plymouth 是一个实现 Linux 启动过程中开机画面的工具软件,其启动的时间非常早,通过 initramfs 帮助可以在 Linux 内核加载同时启动,甚至要早于 Linux rootfs 文件系统挂载。Plymouth 可以方便的实现开关机图片或者动画。 b). 关于 Plymouth 更多详细介绍以及源代码请自行参考如下资料。 ./ Plymouth 官方页面 Plymouth ./ Plymouth 源代码 https://gitlab.freedesktop.org/plymouth/plymouth ./ Plymouth 深入配置使用说明 Plymouth - ArchWiki 4 ). 通过 Ycoto 环境配置 Plymouth 并编译 Ycoto Linux BSP Image a). 配置 Ycoto Project 编译环境 ./ 参考这里配置基本的 Ycoto Project 编译环境 Build a Reference Image with Yocto Project/OpenEmbedded | Toradex Developer Center ./ 参考如下文章配置定制化 layer 通过Yocto Project定制嵌入式Yocto Linux镜像 b). 在定制化 layer meta-customer-demos 下面添加 layer 配置文件 --------------------------------------- $ mkdir -p ../oe_core/layers/meta-customer-demos/conf $ cd .../oe_core/layers/meta-customer-demos/conf ### create layer.conf file ### # We have a conf and classes directory, append to BBPATH BBPATH .= ":${LAYERDIR}" # We have recipes-* directories, add to BBFILES BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend" BBFILE_COLLECTIONS += "customer-demos" BBFILE_PATTERN_customer-demos = "^${LAYERDIR}/" BBFILE_PRIORITY_customer-demos = "24" # Let us add layer-specific bbappends which are only applied when that # layer is included in our configuration BBFILES += "${@' '.join('${LAYERDIR}/%s/recipes*/*/*.bbappend' % layer \ for layer in BBFILE_COLLECTIONS.split())}" # Add layer-specific bb files too BBFILES += "${@' '.join('${LAYERDIR}/%s/recipes*/*/*.bb' % layer \ for layer in BBFILE_COLLECTIONS.split())}" LAYERDEPENDS_customer-demos = " \ core \ yocto \ openembedded-layer gnome-layer multimedia-layer networking-layer \ " LAYERSERIES_COMPAT_customer-demos = "hardknott honister kirkstone" --------------------------------------- c). 在定制化 layer meta-customer-demos 下面添加 Plymouth 相关配置文件 ./ 增加 Plymouth bb file --------------------------------------- $ cd .../oe_core/layers/meta-customer-demos/ $ mkdir -p recipes-core/plymouth $ cd recipes-core/plymouth ### cteate plymouth_%.bbappend file ### FILESEXTRAPATHS:prepend := "${THISDIR}/files:" SRC_URI += " \ file://toradexlogo-white.png \ file://spinner.plymouth \ " PACKAGECONFIG = "pango drm" EXTRA_OECONF += "--with-udev --with-runtimedir=/run" do_install:append () { install -m 0644 ${WORKDIR}/toradexlogo-white.png ${D}${datadir}/plymouth/themes/spinner/watermark.png install -m 0644 ${WORKDIR}/spinner.plymouth ${D}${datadir}/plymouth/themes/spinner/spinner.plymouth } --------------------------------------- ./ 添加 Plymouth 使用的 theme 文件 和 background logo 图片文件,这里使用的是一个配合屏幕分辨率的白色背景图片,因此 spinner 图标会被遮盖,实际使用可以根据需要修改图片文件和 theme 配置。 --------------------------------------- $ mkdir files $ cp .../toradexlogo-white.pngfiles $ cd files ### cteate spinner theme file spinner.plymouth ### Name=Spinner Description=Adoption of official Spinner Theme for Toradex. ModuleName=two-step Font=Cantarell 12 TitleFont=Cantarell Light 30 ImageDir=/usr/share/plymouth/themes/spinner DialogHorizontalAlignment=.5 DialogVerticalAlignment=.382 TitleHorizontalAlignment=.5 TitleVerticalAlignment=.382 HorizontalAlignment=.5 VerticalAlignment=.7 WatermarkHorizontalAlignment=.5 WatermarkVerticalAlignment=.45 Transition=none TransitionDuration=0.0 BackgroundStartColor=0x000000 BackgroundEndColor=0x000000 ProgressBarBackgroundColor=0x606060 ProgressBarForegroundColor=0xffffff MessageBelowAnimation=true --------------------------------------- d). 由于 Plymouth 是文件系统组件,通过 Linux kernel 加载完成后在使能systemd 来启动,这样就会导致比较大的延迟;为了尽可能使 Plymouth 在系统启动过程中尽早启动,可以添加包含 Plymouth 的 Initramfs 镜像使得 Plymouth 在 Linux Kernel 加载过程中即同步启动了。 ./ 添加 Initramfs bb 定义以及相关文件,对应需要 files 目录下的相关文件请参考 这里 --------------------------------------- $ cd .../oe_core/layers/meta-customer-demos/recipes-core $ mkdir -p initramfs-framework/files $ cd initramfs-framework ### cteate initramfs-framework_1.0.bbappend file ### FILESEXTRAPATHS:prepend := "${THISDIR}/files:" SRC_URI += "\ file://plymouth \ file://kmod \ file://0001-Mount-run-with-tmpfs.patch \ file://0002-only-scan-for-block-devices.patch \ " PACKAGES:append = " \ initramfs-module-plymouth \ initramfs-module-kmod \ " SUMMARY:initramfs-module-plymouth = "initramfs support for plymouth" RDEPENDS:initramfs-module-plymouth = "${PN}-base plymouth ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd-udev-rules', '', d)}" FILES:initramfs-module-plymouth = "/init.d/02-plymouth" SUMMARY:initramfs-module-kmod = "initramfs support for loading kernel modules" RDEPENDS:initramfs-module-kmod = "${PN}-base" FILES:initramfs-module-kmod = "\ /init.d/01-kmod \ /etc/modules-load.d/* \ " do_install:append() { install -m 0755 ${WORKDIR}/plymouth ${D}/init.d/02-plymouth install -m 0755 ${WORKDIR}/kmod ${D}/init.d/01-kmod } # Adding modules so plymouth can show the splash screen during boot SRC_URI:append:mx8-nxp-bsp = " file://50-imx8-graphics.conf" RDEPENDS:initramfs-module-kmod:append:mx8-nxp-bsp = " \ kernel-module-display-connector \ kernel-module-lontium-lt8912b \ " do_install:append:mx8-nxp-bsp() { install -d ${D}/etc/modules-load.d/ install -m 0755 ${WORKDIR}/50-imx8-graphics.conf ${D}/etc/modules-load.d/50-imx8-graphics.conf } --------------------------------------- ./ 添加 initramfs image 定义文件 --------------------------------------- $ cd .../oe_core/layers/meta-customer-demos/recipes-core $ mkdir images $ cd images ### cteate initramfs-plymouth-splash-image.bb file ### DESCRIPTION = "Toradex plymouth splash demo initramfs image" PACKAGE_INSTALL = "initramfs-framework-base initramfs-module-udev \ initramfs-module-rootfs initramfs-module-debug \ initramfs-module-plymouth ${VIRTUAL-RUNTIME_base-utils} base-passwd \ initramfs-module-kmod" SYSTEMD_DEFAULT_TARGET = "initrd.target" # Do not pollute the initrd image with rootfs features IMAGE_FEATURES = "splash" export IMAGE_BASENAME = "initramfs-plymouth-splash-image" IMAGE_LINGUAS = "" LICENSE = "MIT" IMAGE_FSTYPES = "cpio.gz" IMAGE_FSTYPES:remove = "wic wic.gz wic.bmap wic.vmdk wic.vdi ext4 ext4.gz teziimg" IMAGE_CLASSES:remove = "image_type_torizon image_types_ostree image_types_ota image_repo_manifest license_image qemuboot" # avoid circular dependencies EXTRA_IMAGEDEPENDS = "" inherit core-image nopackages IMAGE_ROOTFS_SIZE = "8192" # Users will often ask for extra space in their rootfs by setting this # globally. Since this is a initramfs, we don't want to make it bigger IMAGE_ROOTFS_EXTRA_SPACE = "0" IMAGE_OVERHEAD_FACTOR = "1.0" BAD_RECOMMENDATIONS += "busybox-syslog" --------------------------------------- e). 由于增加了 initramfs image,就需要修改 distroboot 启动文件 boot.scr 来调整启动进程,这里通过修改 u-boot-distro-boot 文件来适配,对应的 files 目录下的文件完整内容请参考 这里 --------------------------------------- $ cd .../oe_core/layers/meta-customer-demos/ $ mkdir -p recipes-bsp/u-boot/files $ cd recipes-bsp/u-boot ### cteate u-boot-distro-boot.bbappend file ### FILESEXTRAPATHS:prepend := "${THISDIR}/files:" SRC_URI:append = " \ file://boot.cmd.in \ " --------------------------------------- f). 另外,对于 Verdin iMX8M Mini,由于显示部分是通过 DSI-LVDS Bridge 来实现的,为了使得在 initramfs 阶段就可以加载相关驱动,需要修改 Linux Kernel 配置,而对于其他 iMX8/iMX8X/iMX8MP 如果是原生 LVDS/HDMI 接口则无需修改。 --------------------------------------- $ cd .../oe_core/layers/meta-customer-demos/ $ mkdir -p recipes-kernel/linux/files $ cd recipes-kernel/linux ### cteate linux-toradex%.bbappend file ### FILESEXTRAPATHS:prepend := "${THISDIR}/files:" # Prevent the use of in-tree defconfig unset KBUILD_DEFCONFIG SRC_URI += "\ file://defconfig \ " --------------------------------------- ./ files 目录下的完整 defconfig 文件请见 这里 ,主要修改了如下几个驱动的配置 --------------------------------------- -CONFIG_DRM_PANEL_LVDS=m +CONFIG_DRM_PANEL_LVDS=y -CONFIG_DRM_SEC_MIPI_DSIM=m +CONFIG_DRM_SEC_MIPI_DSIM=y -CONFIG_DRM_TI_SN65DSI83=m +CONFIG_DRM_TI_SN65DSI83=y -CONFIG_DRM_IMX_SEC_DSIM=m +CONFIG_DRM_IMX_SEC_DSIM=y --------------------------------------- g). 最后配置完成的 meta-customer-demos 文件结构如下 --------------------------------------- $ tree meta-customer-demos/ meta-customer-demos/ ├── conf │ └── layer.conf ├── recipes-bsp │ └── u-boot │ ├── files │ │ └── boot.cmd.in │ └── u-boot-distro-boot.bbappend ├── recipes-core │ ├── images │ │ ├── initramfs-ostree-torizon-image.bb │ │ └── initramfs-plymouth-splash-image.bb │ ├── initramfs-framework │ │ ├── files │ │ │ ├── 0001-Mount-run-with-tmpfs.patch │ │ │ ├── 0002-only-scan-for-block-devices.patch │ │ │ ├── 50-imx8-graphics.conf │ │ │ ├── kmod │ │ │ ├── plymouth │ │ │ └── rootfs │ │ └── initramfs-framework_1.0.bbappend │ └── plymouth │ ├── files │ │ ├── spinner.plymouth │ │ └── toradexlogo-white.png │ └── plymouth_%.bbappend └── recipes-kernel └── linux ├── files │ └── defconfig └── linux-toradex%.bbappend 13 directories, 17 files --------------------------------------- h). 为了将 initramfs 集成到编译生成的 Image 压缩包内,需要修改如下 image_type 配置文件 --------------------------------------- --- a/layers/meta-toradex-bsp-common/classes/image_type_tezi.bbclass +++ b/layers/meta-toradex-bsp-common/classes/image_type_tezi.bbclass @@ -8,7 +8,7 @@ WKS_FILE_DEPENDS:append = " tezi-metadata virtual/dtb" DEPENDS += "${WKS_FILE_DEPENDS}" IMAGE_BOOT_FILES_REMOVE = "${@make_dtb_boot_files(d) if d.getVar('KERNEL_IMAGETYPE') == 'fitImage' else ''}" -IMAGE_BOOT_FILES:append = " overlays.txt ${@'' if d.getVar('KERNEL_IMAGETYPE') == 'fitImage' else 'overlays/*;overlays/'}" +IMAGE_BOOT_FILES:append = " overlays.txt initramfs-plymouth-splash-image-${MACHINE}.cpio.gz;initramfs-plymouth-splash-image.img ${@'' if d.getVar('KERNEL_IMAGETYPE') == 'fitImage' else 'overlays/*;overlays/'}" IMAGE_BOOT_FILES:remove = "${IMAGE_BOOT_FILES_REMOVE}" RM_WORK_EXCLUDE += "${PN}" --------------------------------------- i). 修改 build/conf/bblayer.conf 文件添加相关 layer --------------------------------------- --- a/build/conf/bblayers.conf 2023-03-30 11:13:22.946533642 +0800 +++ b/build/conf/bblayers.conf 2023-11-17 16:03:01.666129480 +0800 @@ -35,6 +35,7 @@ ${TOPDIR}/../layers/meta-freescale-distro \ ${TOPDIR}/../layers/meta-toradex-demos \ ${TOPDIR}/../layers/meta-qt5 \ + ${TOPDIR}/../layers/meta-customer-demos\ \ \ ${TOPDIR}/../layers/meta-toradex-distro \ --------------------------------------- j). 修改 build/conf/local.conf 文件,增加 Plymouth 和 initramfs 相关定义 --------------------------------------- # add plymouth support CORE_IMAGE_EXTRA_INSTALL += "plymouth" INITRAMFS_IMAGE = "initramfs-plymouth-splash-image" INITRAMFS_FSTYPES = "cpio.gz" --------------------------------------- k). 重新编译生成 Ycoto Linux BSP Image --------------------------------------- $ MACHINE="verdin-imx8mm" PARALLEL_MAKE="-j 4" BB_NUMBER_THREADS="4" bitbake tdx-reference-multimedia-image --------------------------------------- l). 参考 这里 的说明将上述修改下重新编译生成的 Ycoto Linux Image 通过 Toradex Easy Installer 更新到 Verdin iMX8MM 模块。 5). Plymouth Splash 部署测试 a). 安装好上述编译的 Image 后,参考 这里 说明配置合适的 Device-tree Overlay 文件来适配屏幕;然后配置如下 U-boot 环境变量来显示 Splash,且缩短加载时间 --------------------------------------- # setenv tdxargs ‘quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3’ # setenv bootdelay 0 # saveenv && reset --------------------------------------- b). 为了保证 Plymouth Splash和 Qt Demo App切换更自然,且中间不会被 Weston Desktop 中断,需要修改一下一些 Systemd Service 文件 --------------------------------------- --- a/lib/systemd/system/plymouth-quit.service +++ b/lib/systemd/system/plymouth-quit.service @@ -1,6 +1,6 @@ Description=Terminate Plymouth Boot Screen -After=rc-local.service plymouth-start.service systemd-user-sessions.service +After=rc-local.service plymouth-start.service systemd-user-sessions.service waylan d-app-launch.service ExecStart=-/bin/plymouth quit --retain-splash --- a/lib/systemd/system/serial-getty@.service +++ b/lib/systemd/system/serial-getty@.service @@ -12,7 +12,7 @@ Documentation=man:agetty(8) man:systemd-getty-generator(8) Documentation=http://0pointer.de/blog/projects/serial-console.html BindsTo=dev-%i.device -After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service getty -pre.target +After=dev-%i.device systemd-user-sessions.service getty-pre.target After=rc-local.service # If additional gettys are spawned during boot then we should make --- a/lib/systemd/system/weston.service +++ b/lib/systemd/system/weston.service @@ -13,7 +13,7 @@ After=systemd-user-sessions.service # If Plymouth is used, we want to start when it is on its way out. -After=plymouth-quit-wait.service +#After=plymouth-quit-wait.service # D-Bus is necessary for contacting logind. Logind is required. Wants=dbus.socket --- a/etc/xdg/weston/weston.ini +++ b/etc/xdg/weston/weston.ini @@ -6,6 +6,7 @@ repaint-window=16 #enable-overlay-view=1 modules=screen-share.so +shell=kiosk-shell.so # #size=1920x1080 --------------------------------------- b). 最后部署完成的测试效果如下,实测从开机到出现 Splash 画面大约5秒,另外 Plymouth splash 默认除了支持开机画面,在 reboot 重启和 poweroff 关机的时候也会同样显示 splash 画面 动画演示如下 ​ 6). 总结 本文基于嵌入式 Linux 简单演示了 Plymouth splash 开机画面的部署和测试。
  • 热度 13
    2014-7-25 12:05
    2613 次阅读|
    0 个评论
    调试Plymouth,经常会遇到关机可以正常显示动画,但是开机却总是保持charge球的情况;并且还会遇到hot-dog老是自动应用且删除不了的问题。 其实答案总是在最明显的地方,就看你能不能留意到,还是把它当作背景噪声忽略掉。 在前面的调试过程中,我学习到了基本的Plymouth应用步骤,主要是这么几步: plymouthd plymouth --show-splash plymouth quit plymouth-set-default-theme --list plymouth-set-default-theme xxx 而update-alternatives命令,只在自己制作theme的时候用到,yum时是用不到的,所以答案就在上面的plymouth*五条命令中。之前采用kernel command line观察Plymouth的启动信息时,总是会发现这么一行: find_system_default_splash:System default splash is configured to be 'charge' 就是说,虽然执行了plymouth-set-default-theme solar命令,但是默认的theme并没有改过来。 执行: plymouth-set-default-theme --help 会出现下面的信息: Plymouth theme chooser usage: plymouth-set-default-theme { --list | --reset | | --help }   -h, --help             Show this help message   -l, --list             Show available themes   -r. --reset            Reset to default theme   -R, --rebuild-initrd   Rebuild initrd (necessary after changing theme)              Name of new theme to use (see --list for available themes) 注意-R这个参数,它提示在改变theme之后需要重新编译initrd。所以,再执行: plymouth-set-default-theme -R 会出现下面的信息: /usr/share/plymouth/themes//.plymouth does not exist ************************************************* ****更正:这条命令实际上应该是这样的: plymouth-set-default-theme -R solar 就可以顺利调用dracut命令了,但是还是要注意的是它生成的是: initrd-3.15.6-200.fc20.i686.img 而不是: initramfs-3.11.10-301.fc20.i686.img 问题是,我的Fedora20采用的是前者,这从/boot/grub2/grub.cfg里面也能看出来: =========== linux   /vmlinuz-3.11.10-301.fc20.i686 root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=fedora/root  rhgb quiet LANG=en_US.UTF-8 initrd /initramfs-3.11.10-301.fc20.i686.img =========== 因为此时以boot为根目录,所以vmlinuz和initramfs都放在了/boot下面。那initrd和initramfs的区别是什么呢? http://www.linux.com/learn/linux-training/92607-the-kernel-newbie-corner-qinitrdq-and-qinitramfsq-whats-up-with-that ============================= In a nutshell, when your bootloader (GRUB?) loads your Linux kernel, it is of course the kernel's job to finish the boot process. But to do so, it might require particular drivers to be able to work with, say, hardware RAID controllers, or a network, and so on. And developing on where those critically important drivers are, the kernel might not have the ability to load them, hence, the creation of a preliminary root file system that would contain just enough in the way of loadable modules to give the kernel access to the rest of the hardware. 很多人对initrd很熟悉,因为在GRUB bootloader里面经常看到它的身影,以前,initrd包含了压缩了的文件系统镜像,你需要root权限才能访问它。 而initramfs(initial RAM file system)是更早的potential root file system(?),它能够被编译进内核。so,mkinitrd的步骤还是要执行的! ************************************************* ============================ http://advancelinux.blogspot.com/2013/06/how-to-rebuild-initrd-or-initramfs-in.html ============================ The inital RAM disk (initrd) is an initial root file system that is mounted prior to when the real root file system is available. It is necessary to rebuild the Initrd images in following scenarios to include the proper kernel modules, files, and configuration directives 1. If adding new hardware to a system that may be used very early in the boot process. 2. If changing configuration files that may be used very early in the boot process. 3. If changing the options on a kernel module. ============================ 首先保存initrd的备份: mv /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).img.bak 然后重新编译initrd: mkinitrd -f -v /boot/initrd-$(uname -r).img $(uname -r) -f参数意思是强制覆盖已存在的img,-v参数意思是打印所有的信息。当执行完这个命令之后reboot,就会发现开关机动画都漂亮的出现啦~~~ (对于RHEL 3,4,5来说是mkinitrd,对RHEL 6来说是新命令dracut,mkinitrd也是可以用的。Fedora20里面两个命令都有,但我只采用了mkinitrd,哪位有兴趣的童鞋可以试试dracut~~~) 补充:获取屏幕分辨率的命令,除了xdpyinfo之外,还有xrandr。  
  • 热度 16
    2014-7-24 14:37
    2027 次阅读|
    0 个评论
    参考从这个帖子下载下来的mytheme示例: =========================== http://brej.org/blog/?cat=16 =========================== 注意Plymouth不支持’\‘转义回车符,所以如果有很长很长的一行,那就写很长很长的一行吧! 以下是qilang-tech.script的内容,主要是修改它: =========================== progress_box.x = Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; progress_box.y = Window.GetHeight() * 0.7 - progress_box.image.GetHeight() / 2; progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); progress_bar.original_image = Image("progress_bar.png"); progress_bar.sprite = Sprite(); progress_bar.x = Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2; progress_bar.y = Window.GetHeight() * 0.7 - progress_bar.original_image.GetHeight() / 2; progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1); fun progress_callback(duration, progress) {         if (progress_bar.image.GetWidth() != Math.Int(progress_bar.original_image.GetWidth() * progress))         {                 progress_bar.image = progress_bar.original_image.Scale(progress_bar.original_image.GetWidth(progress_bar.original_image) * progress, progress_bar.original_image.GetHeight());                 progress_bar.sprite.SetImage(progress_bar.image);         } } Plymouth.SetBootProgressFunction(progress_callback); fun quit_callback() { } Plymouth.SetQuitFunction(quit_ballback); =========================== 懒得写注释了,其实看函数的名字就明白了~~~ 主要功能是,1.设置一张漂亮的背景图片,2.放置一个漂亮的logo,3.放置一个显示开机进度的条(由box和bar两张图片组合)。 Plymouth的调试就到此为止,Good Luck! NOTE: 如果执行下面的命令: plymouth-set-default-theme qilang-tech 出现提示: /usr/lib/plymouth/script.so does not exist 就需要执行: yum install plymouth-plugin-script
  • 热度 18
    2014-7-22 17:06
    4148 次阅读|
    3 个评论
    Fedora20默认的开机动画是一个名为charge的不规则Fedora球,随着开机进度接近尾声,这个球也会显示灌满。其实还有很多更加炫酷的开机动画,自己也可以加入独特的logo。要实现它,需要安装一个名为Plymouth的软件。 Plymouth,既是英国的一座城市名字,也是一个汽车品牌。在Linux系统里面,它是一个为Fedora提供开机动画的项目: ************************************************************** https://wiki.archlinux.org/index.php/plymouth ============================================================= Plymouth is a project from Fedora providing a flicker-free graphical boot process. It relies on kernel mode setting (KMS) to set the native resolation of the display as early as possible, then provides an eye-candy splash screen leading all the way up to the login manager. ************************************************************** Fedora20是默认安装有Plymouth的,省掉了安装步骤,不过它自带的theme并不多,可以通过下面这个命令下载: yum install plymouth* (貌似hot-dog这个theme是yum的时候就应用了,而且比较难删除,为此我至少重装了四次系统,所以还是不要yum所有的内容而是想安装的主题。) (参考 http://brej.org/blog/?cat=16) Plymouth调试步骤一:准备测试机器。 当然可以在自己的PC机上调试Plymouth,但是重复的关机启动还是有点让人厌烦,而且不能测试的时候不能上网浏览需要的信息,因此准备一台测试机器会方便很多。另外,貌似使用虚拟机或者X11插件也可以。我使用了另外一台安装有Fedora20的笔记本电脑。 Plymouth调试步骤二:进入runlevel 3。 首先确认系统中是否有KMS(Fedora20具备),然后打开target的sshd服务,7使用master的ssh连接它,获取root权限。(之所以使用ssh,是因为调试Plymouth的时候无法输入任何键盘指令。) 然后在ssh下,使用telinit命令将target的runlevel设置为3: telinit 3 此时target就应该退出了图形界面,进入命令行了。 Plymouth调试步骤三:运行demo。 plymouthd plymouth --show-splash plymouth quit 它们的作用分别是,启动daemon、运行theme、退出。 要查看所有可用的theme,就使用命令: plymouth-set-default-theme --list 要选择要运行的theme,就使用命令: plymouth-set-default-theme xxx (solar非常漂亮~~~) ************************************************************** 在应用theme时,出现关机有新动画,但是开机还是charge的情况。有论坛说使用命令: update-alternatives --install /usr/share/plymouth/themes/default.plymouth \ default.plymouth /usr/share/plymouth/themes/solar/solar.plymouth 100 update-alternatives --config default.plymouth; 但是貌似即使执行了也没什么效果。为了观察plymouth的调试结果,可以将使用kernel command line生成日志文件。给内核传递参数有三种方法,第一通过内核build,第二是通过startup文件,第三是查看runtime的/proc或者/sys。 ============================================================= https://wiki.ubuntu.com/Kernel/KernelBootParameters ============================================================= 这篇是我见过写得最对口的~ 修改startup时的kernel command line有两种方法:temporarily和permenently,后者主要是通过修改/etc/default/grub文件,在GRUB_CMDLINE_LINUX_DEFAULT那一行增加自己的内容既可。这里增加: plymouth:debug=file:/var/log/plymouth-debug.log 再执行: update-grub 但是实际上,Fedora20并没有这个上面这个命令,而是需要执行: grub2-mkconfig -o /boot/grub2/grub.cfg ============================================================= 执行完这个命令之后,/var/log/plymouth-debug.log就会生成了,神奇的是,原来无法出现的开机动画现在居然出现了! (补充:虽然在target机器上开机关机都可以了,但是在master机器上实验同样的步骤还是不行,so,先跳过,等调试完后面的步骤再回来看。。。) ************************************************************** Plymouth调试步骤四:制作自己的theme。 在Plymouth下,plugin和theme是有区别的,theme会使用plugin并给它传递参数。theme一般存放在/usr/share/plymouth/themes目录下,要新建一个theme,可以先复制已存在的,然后重新命名它并把内容替换掉。"For more customisability you can write your own plugin in C which is, to be honest, not very easy."因为http://brej.org/blog/?cat=16这个帖子提供的theme制作方法比较复杂,所以这里参考了一个比较简单的帖子: http://giridharangm.blogspot.com/2013/08/change-ubuntu-splash-screen-create-your.html A.新建/usr/share/plymouth/theme/maria_theme目录; B.制作一张想用来当作背景的图片,记住是PNG格式的,此时可以使用xdpyinfo来获取屏幕分辨率; C.将图片拷贝进入maria_theme目录; D.编辑maria_theme.plymouth文件: Name=maria_theme Description=Theme Test by Marianna_z ModuleName=script ImageDir=/usr/share/plymouth/themes/maria_theme ScriptFile=/usr/share/plymouth/themes/maria_theme/maria_theme.script E.编辑maria_theme.script文件; wallpaper_image=Image("green.png"); screen_width=Window.GetWidth(); screen_height=Window.GetHeight(); resized_wallpaper_image=wallpaper_image.Scale(screen_width,screen_height); wallpaper_sprite=Sprite(resized_wallpaper_image); wallpaper_sprite.setZ(-100); F.安装theme; 安装theme使用的是update-alternatives命令: update-alternatives --install /usr/share/plymouth/themes/default.plymouth \ default.plymouth /usr/share/plymouth/themes/maria_theme/maria_theme.plymouth 100 update-alternatives --config default.plymouth G.调试theme; 除了前面提到的使用master的ssh调试之外,还有一种方法,分别在target的两个终端上执行: plymouthd --debug --tty='tty' --no-daemon plymouthd --show-splash 至此为止,就能够将开机动画和关机动画换成自己的green.png图片了,目前它还是静止的背景。