linux修改内核logo和增加开机进度条
修改内核logo
1.将我们准备好的 logo-linux.png 图片拷贝到drivers/video/logo 这个目录下
2.我们需要把 png 格式的图片转换成 ppm 格式,安装sudo apt-get install netpbm这个工具
3.创建linux_logo_png_to_ppm.sh脚本将png图片转换成ppm格式,脚本内容如下:
#!/bin/sh
rm logo_linux_clut224.c
rm logo_linux_clut224.opngtopnm logo-linux.png > logo-linux.pnm
pnmquant 224 logo-linux.pnm > logo-linux224.pnm
pnmtoplainpnm logo-linux224.pnm > logo_linux_clut224.ppm
chmod 777 linux_logo_png_to_ppm.sh
./linux_logo_png_to_ppm.sh
回到linux源码的根目录重新编译源码
make zImgae -j8
如果重新跑内核没有显示Logo:
1.图片尺寸超过了屏幕的分辨
2.检查设备树的LCD
增加开机进度条
linux内核启动的时候首先显示开机Logo,当"init"进程创建完成后,Linux从内核态切换到用户态,init程序通过/etc/inittab文件进行配置,进而执行/etc/init.d/rcS脚本,然后执行/etc/init.d/下的所有脚本开启相应的服务与功能。在执行执行/etc/init.d/下脚本开启服务的时候可能会比较耗时,因此在此阶段增加一个进度条可提示当前服务的开启情况。
1.下载 psplash 源码并解压
下载psplash:gitclone git://git.yoctoproject.org/psplash
tar -vxf psplash.tar.gz
psplash-poky.png和psplash-bar.png分别是显示的Logo和进度条
2.安装下面的库,否则编译会报错
sudo apt-get install libgdk-pixbuf2.0-dev
3.制作 autogen.sh 脚本,用于生成 Makefile,autogen.sh脚本内容如下
#!/bin/bashaclocalautoheaderautomake --add-missingautoconf
chmod 777 autogen.sh
4.将logo-linux.png图片复制到psplash目录下
5.编写auto_generate.sh脚本一键自动生成paplash和psplash-write可执行文件,auto_generate.sh脚本内容如下
#!/bin/sh
rm psplash
rm psplash-write
cp logo-linux.png psplash-poky.png -f
./make-image-header.sh psplash-poky.png POKY
./make-image-header.sh psplash-bar.png BAR
./autogen.sh
./configure --host=arm-linux-gnueabihf
make
1.首先是删除psplash和psplash-write
2.将logo-linux.png重命名为psplash-poky.png
3../configure是配置交叉编译工具链
chmod 777 auto_generate.sh
./auto_generate.sh
最后 将编译生成的 psplash 和 psplash-write 文件拷贝到开发板文件系统/usr/bin 目录下。
6.新建psplash.sh 脚本,并将其拷贝到开发板文件系统的/etc/init.d/目录下,psplash.sh 脚本内容如下
#!/bin/sh### BEGIN INIT INFO# Provides: psplash# Required-Start:# Required-Stop:# Default-Start: S# Default-Stop:### END INIT INFOread CMDLINE < /proc/cmdlinefor x in $CMDLINE; docase $x inpsplash=false)echo "Boot splashscreen disabled"exit 0;;;esacdoneexport TMPDIR=/mnt/.psplashmount tmpfs -t tmpfs $TMPDIR -o,size=40krotation=0if [ -e /etc/rotation ]; thenread rotation < /etc/rotationfi/usr/bin/psplash --angle $rotation &
chmod 777 psplash.sh
脚本最后执行psplash程序,传参当前屏幕的角度,psplash运行起来后刷Logo图片,创建管道文件阻塞等待psplash-write程序向管道文件中写入进度条更新命令参数
7.linux启动顺序执行/etc/inittab-->/etc/init.d/rcS。rcS内容如下
#!/bin/sh
#
# rcS Call all S??* scripts in /etc/rcS.d in
# numerical/alphabetical order.
#
# Version: @(#)/etc/init.d/rcS 2.76 19-Apr-1999 miquels@cistron.nl
#PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel# Make sure proc is mounted
#
[ -d "/proc/1" ] || mount /proc#
# Source defaults.
#
. /etc/default/rcS#
# Trap CTRL-C &c only in this shell so we can interrupt subprocesses.
#
trap ":" INT QUIT TSTP#
# Call all parts in order.
#
exec /etc/init.d/rc S
最后执行了/etc/init.d/下的rc脚本文件,传参S,rc文件内容如下
#!/bin/sh
#
# rc This file is responsible for starting/stopping
# services when the runlevel changes.
#
# Optimization feature:
# A startup script is _not_ run when the service was
# running in the previous runlevel and it wasn't stopped
# in the runlevel transition (most Debian services don't
# have K?? links in rc{1,2,3,4,5} )
#
# Author: Miquel van Smoorenburg <miquels@cistron.nl>
# Bruce Perens <Bruce@Pixar.com>
#
# Version: @(#)rc 2.78 07-Nov-1999 miquels@cistron.nl
#. /etc/default/rcS
export VERBOSEstartup_progress() {step=$(($step + $step_change))if [ "$num_steps" != "0" ]; thenprogress=$((($step * $progress_size / $num_steps) + $first_step))elseprogress=$progress_sizefiecho "PROGRESS is $progress $runlevel $first_step + ($step of $num_steps) $step_change $progress_size"if type psplash-write >/dev/null 2>&1; thenTMPDIR=/mnt/.psplash psplash-write "PROGRESS $progress" || truefi#if [ -e /mnt/.psplash/psplash_fifo ]; then# echo "PROGRESS $progress" > /mnt/.psplash/psplash_fifo#fi
}#
# Start script or program.
#
startup() {# Handle verbosity[ "$VERBOSE" = very ] && echo "INIT: Running $@..."case "$1" in*.sh)# Source shell script for speed.(trap - INT QUIT TSTPscriptname=$1shift. $scriptname);;*)"$@";;esacstartup_progress
}# Ignore CTRL-C only in this shell, so we can interrupt subprocesses.trap ":" INT QUIT TSTP# Set onlcr to avoid staircase effect.stty onlcr 0>&1# Limit stack size for startup scripts[ "$STACK_SIZE" == "" ] || ulimit -S -s $STACK_SIZE# Now find out what the current and what the previous runlevel are.runlevel=$RUNLEVEL# Get first argument. Set new runlevel to this argument.[ "$1" != "" ] && runlevel=$1if [ "$runlevel" = "" ]thenecho "Usage: $0 <runlevel>" >&2exit 1fiprevious=$PREVLEVEL[ "$previous" = "" ] && previous=Nexport runlevel previous# Is there an rc directory for this new runlevel?if [ -d /etc/rc$runlevel.d ]then# Find out where in the progress bar the initramfs got to.PROGRESS_STATE=0#if [ -f /dev/.initramfs/progress_state ]; then# . /dev/.initramfs/progress_state#fi# Split the remaining portion of the progress bar into thirdsprogress_size=$(((100 - $PROGRESS_STATE) / 3))case "$runlevel" in0|6)# Count down from -100 to 0 and use the entire barfirst_step=-100progress_size=100step_change=1;;S)# Begin where the initramfs left off and use 2/3# of the remaining spacefirst_step=progress_sizeprogress_size=$(($progress_size * 3))step_change=1;;*)# Begin where rcS left off and use the final 1/3 of# the space (by leaving progress_size unchanged)first_step=$(($progress_size * 2 + $PROGRESS_STATE))step_change=1;;esacnum_steps=0for s in /etc/rc$runlevel.d/[SK]*; docase "${s##/etc/rc$runlevel.d/S??}" ingdm|xdm|kdm|reboot|halt)break;;esac#遍历脚本的数量num_steps=$(($num_steps + 1))donestep=0# First, run the KILL scripts.if [ $previous != N ]thenfor i in /etc/rc$runlevel.d/K[0-9][0-9]*do# Check if the script is there.[ ! -f $i ] && continue# Stop the service.startup $i stopdonefi# Now run the START scripts for this runlevel.for i in /etc/rc$runlevel.d/S*do[ ! -f $i ] && continueif [ $previous != N ] && [ $previous != S ]then## Find start script in previous runlevel and# stop script in this runlevel.#suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffixprevious_start=/etc/rc$previous.d/S[0-9][0-9]$suffix## If there is a start script in the previous level# and _no_ stop script in this level, we don't# have to re-start the service.#[ -f $previous_start ] && [ ! -f $stop ] && continueficase "$runlevel" in0|6)startup $i stop;;*)startup $i start;;esacdonefi#Uncomment to cause psplash to exit manually, otherwise it exits when it sees a VC switch
if [ "x$runlevel" != "xS" ] && [ ! -x /etc/rc${runlevel}.d/S??xserver-nodm ]; thenif type psplash-write >/dev/null 2>&1; thenTMPDIR=/mnt/.psplash psplash-write "QUIT" || trueumount -l /mnt/.psplashfi
fi
chmod 777 rc
rc脚本启动/etc/rcS.d下的所有脚本文件并更新进度条显示
1.将进度条分成3份
2.遍历/etc/rcS.d/目录下的Sxx脚本文件数量
3.从三分之一的地方开始走进度条,留三分之二来提示脚本的执行进度,每执行完一个脚本步进1,所有脚本执行完毕进度条走到尽头100%。
num_steps=10 脚本文件的数量
first_step=100/3=33 从三分之一的地方开始递增
progress_size=100/3*2=66 将三分之二的进度条分割为num_steps来走进度
progress=$((($step * $progress_size / $num_steps) + $first_step))
progress=$((($step * 66 / 10) + 33))
每执行一个脚本step++
如果需要从0%开始走进度到100%,修改first_step=0,progress_size=100
/etc/rcS.d/目录下的Sxx脚本其实都是/etc/init.d/目录下的软链接
按照Sxx文件的xx由小到大顺序执行脚本开启相应的服务
总结:psplash.sh脚本把psplash程序运行起来后,创建一个管道文件,阻塞等待rc脚本中通过psplash-write程序向管道中写入更新进度条的命令参数。
关于psplash是否显示提示文字和logo显示的位置可在psplash-config.h中配置
/** pslash - a lightweight framebuffer splashscreen for embedded devices.** Copyright (c) 2014 MenloSystems GmbH* Author: Olaf Mandel <o.mandel@menlosystems.com>** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2, or (at your option)* any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.**/#ifndef _HAVE_PSPLASH_CONFIG_H
#define _HAVE_PSPLASH_CONFIG_H/* Text to output on program start; if undefined, output nothing */
#define PSPLASH_STARTUP_MSG ""/* Bool indicating if the image is fullscreen, as opposed to split screen */
#define PSPLASH_IMG_FULLSCREEN 0/* Position of the image split from top edge, numerator of fraction */
#define PSPLASH_IMG_SPLIT_NUMERATOR 5/* Position of the image split from top edge, denominator of fraction */
#define PSPLASH_IMG_SPLIT_DENOMINATOR 6#endif
关于psplash进度条的颜色可在psplash-colors.h中配置
/** pslash - a lightweight framebuffer splashscreen for embedded devices.** Copyright (c) 2012 sleep(5) ltd* Author: Tomas Frydrych <tomas@sleepfive.com>** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2, or (at your option)* any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.**/#ifndef _HAVE_PSPLASH_COLORS_H
#define _HAVE_PSPLASH_COLORS_H/* This is the overall background color */
#define PSPLASH_BACKGROUND_COLOR 0xec,0xec,0xe1/* This is the color of any text output */
#define PSPLASH_TEXT_COLOR 0x6d,0x6d,0x70/* This is the color of the progress bar indicator */
#define PSPLASH_BAR_COLOR 0x6d,0x6d,0x70/* This is the color of the progress bar background */
#define PSPLASH_BAR_BACKGROUND_COLOR 0xec,0xec,0xe1#endif
linux修改内核logo和增加开机进度条相关推荐
- 迅为i.MX6ULL 开发板开机进度条修改文档
转自:迅为IMX6ULL开发板使用手册第七十一章 硬件平台:迅为i.MX6ULL 开发板 本章节介绍的是iTOP-iMX6ULL-修改开机进度条的显示和修改步骤,使用的资料已经放到了开发板网盘资料中路 ...
- 为Linux的cp和mv命令添加进度条
为Linux的cp和mv命令添加进度条 cp和mv可能是大家日常中使用最多的Linux命令之一.但是有一个突出的问题是这两个命令都不会有任何提示信息,这在操作大文件时候只能干等.可能大家对此已经习以为 ...
- WINCE6开机进度条
大致思路,在NBoot或EBoot加开机进度条,由于WINCE启动主要时间都花在读取NK,因此每读取一定的页,就在屏上画一条固定高度的线,并记录画线的位置,下次接着画,直到读取完NK,这样就产生的进度 ...
- linux系统启动卡住不动了,CentOS启动失败 卡在开机进度条certmonger解决
新安装的CentOS6.4,第一次开机便卡在了进度条那里,一开始以为是反应慢,需要多等些时间,大概5分钟后还是不行,估计是出问题了. 重启后按Esc或者F5键,可以查看系统启动过程,卡在哪里,我的是在 ...
- linux修改内核禁用模块,sysctl以及利用sysctl禁用ipv6模块
目前在大部分的实际生产环境中ipv6并没有被大规模使用,所以在很多的服务器上ipv6的模块的开启往往会带来很多安全隐患和麻烦,那么我们就需要禁用掉ipv6的模块,以前只是利用ip6tables来关闭i ...
- psplash开机进度条制作
一.思路分析 准备两张图片,一张作为背景图,一张作为进度条背景框 使用psplash里make-image-header.sh脚本,将图片转换为头文件. 修改psplash.c文件,图片头文件替换为刚 ...
- linux cp源码_为Linux的cp和mv命令添加进度条
cp和mv可能是大家日常中使用最多的Linux命令之一.但是有一个突出的问题是这两个命令都不会有任何提示信息,这在操作大文件时候只能干等.可能大家对此已经习以为常,但是其实上也有解决解决方法,本文我们 ...
- linux添加用户命令_为Linux的cp和mv命令添加进度条
cp和mv可能是大家日常中使用最多的Linux命令之一.但是有一个突出的问题是这两个命令都不会有任何提示信息,这在操作大文件时候只能干等.可能大家对此已经习以为常,但是其实上也有解决解决方法,本文我们 ...
- linux的yum命令无法使用在哪里下载_Linux 知识分享:为Linux的cp和mv命令添加进度条...
cp和mv可能是大家日常中使用最多的Linux命令之一.但是有一个突出的问题是这两个命令都不会有任何提示信息,这在操作大文件时候只能干等.可能大家对此已经习以为常,但是其实上也有解决解决方法,本文我们 ...
最新文章
- 使用Python,OpenCV转换颜色空间,追踪对象的轨迹
- python3 的 round 函数的 练习
- C语言编程的几个小注意事项1
- 《深入浅出MFC》第六章 MFC程序的生死因果
- 一名合格的电子工程师,不能逃避的“梗”
- python中坐标怎么表示_如何在Python中以像素表示(有限)平面上的坐标
- hdu 3652 B-number 数位dp
- dw怎么打开html模板,Dreamweaver中如何使用模板
- openmvide使用需要什么插件_什么伺服电机需要加装减速机才能使用?
- MathType 插入定义的chapter and section break后无法隐藏
- 相分离相关文章阅读Intrinsically disordered linkers determine the interplay between phase separation and gelat
- HTML5实践 -- 介绍css3中的几个属性:text-shadow、box-shadow 和 border-radius
- android 调用音乐播放器,android调用音乐播放器,三种方
- 不打补贴战,快狗打车凭什么冲刺“同城货运第一股”?
- 谱尼测试凭借现代化的测试平台
- 什么是单页网站设计?受欢迎的原因在哪?
- pdf怎样删除其中一页简单教程
- OpenCV - C++ -图像处理 //使用
- 用Android手机充当台式电脑的摄像头、麦克风和音箱
- CSDN日报20170304——《令人比较失落的IT圈子-关于华为裁员》