Buildroot根文件系统之psplash加载logo和进度条

本文介绍了如何在Buildroot根文件系统中集成psplash来显示启动时的logo和进度条。通过准备图片、使用make-image-header.sh脚本转换图片、修改源代码和Makefile、创建autogen.sh脚本以及编写启动脚本来实现这一功能。此外,还涉及到了psplash的配置修改,如颜色和尺寸调整。
摘要由CSDN通过智能技术生成

Buildroot根文件系统之psplash加载logo和进度条

一、思路分析

1、准备两张图片,一张作为背景图,一张作为进度条背景框
2、使用psplash里make-image-header.sh脚本,将图片转换为头文件。
3、修改psplash.c文件,图片头文件替换为刚刚生成的头文件。
4、制作 autogen.sh 脚本,用于生成 Makefile。
5、修改Makefile.am文件, 图片头文件替换为刚刚生成的头文件。
6、使能环境变量。
7、make即可得到psplash 和 psplash-write文件
8、将psplash 和 psplash-write放到文件系统/usr/bin目录下即可。
9、编写系统启动脚本加载图片和进度条

二、一键运行脚本

编写autogen.sh用于生成Makefile文件,内容如下:

#!/bin/bash
aclocal
autoheader
automake --add-missing
autoconf

最终生成psplash 和 psplash-write文件脚本imx6ull_psplash.sh,内容如下:

#!/bin/sh
rm psplash psplash-write

./make-image-header.sh logo-psplash.png POKY
./make-image-header.sh logo-psplash-bar.png BAR	

./autogen.sh

./configure --host=arm-linux-gnueabihf
make

三、板子上根文件系统启动脚本

psplash对Yocto生成的根文件系统有很好的支持,直接将psplash 和 psplash-write放到文件系统/usr/bin目录下即可,具体在/etc/init.d/rc文件中分步执行。

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

四、psplash配置修改

psplash-color.h修改背景和进度条颜色
logo图片可以不是全屏的分辨率,调整背景色与logo背景一致

#ifndef _HAVE_PSPLASH_COLORS_H
#define _HAVE_PSPLASH_COLORS_H

/* This is the overall background color */
//#define PSPLASH_BACKGROUND_COLOR 0xec,0xec,0xe1 原来接近白色
#define PSPLASH_BACKGROUND_COLOR 0x00,0x00,0x00   //背景改为黑色

/* 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

psplash-config.h

#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-poky-img.h和psplash-bar-img.h文件
BAR_IMG_WIDTH和BAR_IMG_HEIGHT 修改为0可关闭进度条显示

/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */

#define BAR_IMG_ROWSTRIDE (920)
#define BAR_IMG_WIDTH (230)   
#define BAR_IMG_HEIGHT (28)    
#define BAR_IMG_BYTES_PER_PIXEL (4) /* 3:RGB, 4:RGBA */
#define BAR_IMG_RLE_PIXEL_DATA ((uint8*) 

产品介绍
https://seeker.taobao.com/?spm=a1z10.1-c.0.0.2efa68c7mlyvtY

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值