设置psplash开机图片,动画,功能配置

正常图片版本

下载psplash源码
https://git.yoctoproject.org/psplash/

  • 安装依赖环境
apt-get install build-essential libncurses5-dev 
apt-get install autoconf
apt-get install libtool
apt-get install gettext
apt-get install libglib2.0-dev
apt-get install libgtk2.0-dev
  • 准备开机图片

  • 使用psplash里make-image-header.sh脚本,将图片转换为头文件。
    ./make-image-header.sh xxxlogo.png POKY,生成图片文件xxxlogo.c,xxxlogo.h

  • 修改psplash.c文件,图片头文件替换为刚刚生成的头文件。
    在这里插入图片描述

  • 制作 autogen.sh 脚本,用于生成 Makefile,随后执行./autogen.sh
    脚本内容如下:

#!/bin/bash
aclocal
autoheader
automake --add-missing
autoconf
  • 配置交叉编译库:
source /opt/poky/1.7/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi #这一步好像不用也行,有问题就看看其他博主的文章
./configure --host=arm-linux
  • 修改Makefile.am文件, 图片头文件替换为刚刚生成的头文件。
    在这里插入图片描述

  • make即可得到psplash 和 psplash-write文件

  • 将psplash 和 psplash-write放到文件系统/usr/bin目录下即可。

  • 编写系统启动脚本加载图片和进度条(非yocto系统)
    注意:上面有些脚本执行可能需要权限,直接chmod +x xxx就行了

启动环境配置

yocto

需要psplash开机自启动,对于Yocto生成的根文件系统将psplash和psplash-write放到文件系统/usr/bin目录下就行,具体在/etc/init.d/rc文件中分步执行。

Buildroot

对于Buildroot根文件系统,将psplash 和 psplash-write放到文件系统/usr/bin目录下,编写S00paplash脚本,放到/etc/init.d/目录下,启动运行的第一个脚本。

#!/bin/sh 
### BEGIN INIT INFO
# Provides:             psplash
# Required-Start:
# Required-Stop:
# Default-Start:        S
# Default-Stop:
### END INIT INFO

read CMDLINE < /proc/cmdline
for x in $CMDLINE; do
        case $x in
        psplash=false)
		echo "Boot splashscreen disabled" 
		exit 0;
                ;;
        esac
done

export TMPDIR=/mnt/.psplash
mkdir -p $TMPDIR
mount tmpfs -t tmpfs $TMPDIR -o,size=40k

rotation=0
if [ -e /etc/rotation ]; then
	read rotation < /etc/rotation
fi

/usr/bin/psplash --angle $rotation &

psplash 和 psplash-write之间通过管道通信,S00paplash脚本启动了psplash加载了logo和进度条, psplash-write用于向进度条写入数据,修改/etc/init.d/rcS文件


#!/bin/sh

# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ;do

     # Ignore dangling symlinks (if any).
     [ ! -f "$i" ] && continue

     case "$i" in
	*.sh)
	    # Source shell script for speed.
	    (
		trap - INT QUIT TSTP
		set start
		. $i
	    )
	    ;;
	*)
	    # No sh extension, so fork subprocess.
	    $i start
	    ;;
    esac
     #15根据启动的脚本个数定
    progress=$(($progress+15))
    if type psplash-write >/dev/null 2>&1; then
        TMPDIR=/mnt/.psplash psplash-write "PROGRESS $progress" || true
    fi
done

kylin(或者其他无相关服务的文件系统)

/etc/rc.local

我目前用的kylin系统是没有/etc/rc.local文件的,不过也可以直接创建一个,然后直接根buildroot的操作步骤一样,我这里只测试了psplash。
在这里插入图片描述

然后在/usr/lib/systemd/system目录下可以看这几个文件只有rc-local.service是有的,另外两个service都被丢到垃圾桶了(/dev/null)
在这里插入图片描述

进入该文件可以看到
在这里插入图片描述

大概意思是会调用/etc/rc.local文件,所以我们在/etc/目录下直接创建rc.local就会被调用。

/usr/lib/systemd/system

除了上面那种方法,还可以使用在/usr/lib/systemd/system下创建服务,来调用我们的程序
在这里插入图片描述

以下文件的内容可以去buildroot或者yocto源码中 find | grep psplash 可以看到
psplash-start.service的内容如下:

[Unit]
Description=Start psplash boot splash screen
DefaultDependencies=no
RequiresMountsFor=/run
ConditionFileIsExecutable=/usr/bin/psplash

[Service]
Type=notify
ExecStart=/usr/bin/psplash
RemainAfterExit=yes

[Install]
WantedBy=sysinit.target

psplash-system.service的内容如下:

[Unit]
Description=Start psplash-systemd progress communication helper
DefaultDependencies=no
After=psplash-start.service
Requires=psplash-start.service
RequiresMountsFor=/run
ConditionFileIsExecutable=/usr/bin/psplash

[Service]
ExecStart=/usr/bin/psplash-systemd
RemainAfterExit=yes

[Install]
WantedBy=sysinit.target

然后将这两个文件拷贝到/etc/systemd/system目录下(好像不用也行)

在这里插入图片描述
然后将我们的服务设置开机自启动,相关的一些命令如下:

# 开机启动
systemctl enable psplash-start.service
# 关闭开机启动
systemctl disable psplash-start.service
# 启动服务
systemctl start psplash-start.service
# 停止服务
systemctl stop psplash-start.service
# 重启服务
systemctl restart psplash-start.service
# 查看服务状态
systemctl status psplash-start.service
systemctl is-active psplash-start.service
# 结束服务进程(服务无法停止时)
systemctl kill psplash-start.service

在这里插入图片描述
图片中/lib/和/usr/lib/是一样的,是/lib软链接过去的

开机动画,开机画面延时

这一部分的内容,可以自己修改源码,也可以去直接去这个https://download.csdn.net/download/chidaoqi1607/12373339下载。这个老哥也有一篇文章写开机动画的,大家可以参考一下https://blog.csdn.net/chidaoqi1607/article/details/105840790,我这里就不多说了(毕竟人家要收费的)。

源码部分功能修改

修改相关源文件
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

psplash-colors.h颜色配置文件(背景色 进度条颜色等)

/* This is the overall background color */
#define PSPLASH_BACKGROUND_COLOR 0x00,0x00,0x00        //整个背景的颜色

/* This is the color of any text output */
#define PSPLASH_TEXT_COLOR 0xFF,0xFF,0xFF//文本内容

/* This is the color of the progress bar indicator */
#define PSPLASH_BAR_COLOR 0xff,0x00,0x00               //进度条颜色
/* This is the color of the progress bar background */
#define PSPLASH_BAR_BACKGROUND_COLOR 0x00,0x00,0x00    //进度条的背景颜色

设置进度条 高度宽度 psplash_draw_progress(psplash.c)函数中

  /* 4 pix border */ //bar.png的(上下左右)边界到进度条区间隔4pix,如果间隔改了,此处应做修改.
  x      = ((fb->width  - BAR_IMG_WIDTH)/2) + 4 ;
  y      = SPLIT_LINE_POS(fb) + 4;
  width  = BAR_IMG_WIDTH - 8; 
  height = BAR_IMG_HEIGHT - 8;

设置LOGO 进度条的坐标

/* 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 1
//为0时:LOGO 居中
//为1时:LOGO 上部分屏居中(height*PSPLASH_IMG_SPLIT_NUMERATOR/PSPLASH_IMG_SPLIT_DENOMINATOR)
//屏分为上下两部分  上部分LOGO居中  下部分进度条居中     
/* 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

去掉进度条

psplash.c

/*
   //进度条上面的框框
  psplash_fb_draw_rect (fb, 
            0, 
            fb->height - (fb->height/6) - h, 
            fb->width,
            h,
            PSPLASH_BACKGROUND_COLOR);
*/

#if 0
  /* Draw progress bar border */
  psplash_fb_draw_image (fb, 
             (fb->width  - BAR_IMG_WIDTH)/2, 
             fb->height - (fb->height/6), 
             BAR_IMG_WIDTH,
             BAR_IMG_HEIGHT,
             BAR_IMG_BYTES_PER_PIXEL,
             BAR_IMG_RLE_PIXEL_DATA);
#endif

 // psplash_draw_progress (fb, 0);

或者将img.h的图片文件中的width和height设置为0

#define BAR_IMG_ROWSTRIDE(1400)
#define BAR_IMG_WIDTH(0)
#define BAR_IMG_HEIGHT(0)
#define BAR_IMG_BYTES_PER_PIXEL(4)

参考文章:
https://blog.csdn.net/al86866365/article/details/82287020
https://blog.csdn.net/chidaoqi1607/article/details/105840790
https://neucrack.com/p/91
https://blog.csdn.net/kunkliu/article/details/81125920

  • 36
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值