Linux_Logo 显示
使用 psplash 在嵌入式 Linux 开发板上实现自定义开机画面。
简介
psplash 是嵌入式 Linux 的轻量级开机画面工具,用于显示静态 Logo 和进度条。
适用场景: H618 系列开发板(Ubuntu 22.04)及其他 ARM Linux 开发板。
环境配置
# 安装依赖
sudo apt update
sudo apt install build-essential autoconf automake libtool git libgdk-pixbuf2.0-dev -y
# 下载源码
git clone git://git.yoctoproject.org/psplash
cd psplash
psplash 编译
1. 创建 autogen.sh 脚本
2. 执行和测试
# 执行自动配置脚本生成 Makefile.am 文件
chmod +x autogen.sh
./autogen.sh
# 生成 Makefile 并编译
./configure --host=arm-linux
make
# 测试运行
sudo ./psplash
# 预期结果:屏幕显示 poky 官方默认 Logo
Logo 替换
方式一:简单替换
方式二:自定义文件名
修改源码:
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ AM_CFLAGS = $(GCC_FLAGS) $(EXTRA_GCC_FLAGS) -D_GNU_SOURCE -DFONT_HEADER=\"$(FONT
psplash_SOURCES = psplash.c psplash.h psplash-fb.c psplash-fb.h \
psplash-console.c psplash-console.h \
psplash-colors.h psplash-config.h \
- psplash-poky-img.h psplash-bar-img.h $(FONT_NAME)-font.h
+ logo-img.h psplash-bar-img.h $(FONT_NAME)-font.h
BUILT_SOURCES = psplash-poky-img.h psplash-bar-img.h
--- a/psplash.c
+++ b/psplash.c
@@ -13,7 +13,8 @@
#include "psplash.h"
#include "psplash-config.h"
#include "psplash-colors.h"
-#include "psplash-poky-img.h"
+//#include "psplash-poky-img.h"
+#include "logo-img.h"
#include "psplash-bar-img.h"
重新编译:make clean && make
配置开机启动
1. 创建启动脚本 /etc/init.d/psplash.sh
#!/bin/sh
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
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 &
2. 创建 /usr/lib/systemd/system/psplash.service 服务
[Unit]
Description=Psplash Boot Logo
DefaultDependencies=no
[Service]
ExecStart=/etc/init.d/psplash.sh
Restart=always
Type=simple
[Install]
WantedBy=multi-user.target
3. 部署并启用
sudo cp psplash /usr/bin/
sudo chmod 755 /usr/bin/psplash
sudo chmod 755 /etc/init.d/psplash.sh
sudo systemctl enable psplash.service
sudo reboot
其他定制
- 禁用进度条和启动信息
--- a/psplash-config.h
+++ b/psplash-config.h
@@ -13,7 +13,7 @@
/* Text to output on program start; if undefined, output nothing */
#ifndef PSPLASH_DISABLE_STARTUP_MSG
-#define PSPLASH_STARTUP_MSG ""
+//#define PSPLASH_STARTUP_MSG ""
#endif
/* Bool indicating if the image is fullscreen, as opposed to split screen */
@@ -23,7 +23,7 @@
/* Bool indicated if the progress bar should be disabled */
#ifndef PSPLASH_DISABLE_PROGRESS_BAR
-#define PSPLASH_SHOW_PROGRESS_BAR 1
+//#define PSPLASH_SHOW_PROGRESS_BAR 1
#endif
/* Position of the image split from top edge, numerator of fraction */
diff --git a/psplash.c b/psplash.c
index 261dd1c..b506c0f 100644
- 关闭内核缓冲日志
--- a/source/kernel/linux-5.4-h618/arch/arm64/configs/linux_h618_defconfig
+++ b/source/kernel/linux-5.4-h618/arch/arm64/configs/linux_h618_defconfig
@@ -449,6 +449,7 @@ CONFIG_INPUT_UINPUT=y
CONFIG_INPUT_SENSOR=y
CONFIG_SUNXI_GPADC=y
# CONFIG_SERIO_SERPORT is not set
+CONFIG_VT_HW_CONSOLE_BINDING=y
# CONFIG_LEGACY_PTYS is not set
CONFIG_SERIAL_NONSTANDARD=y
CONFIG_N_HDLC=m
@@ -540,9 +541,6 @@ CONFIG_HDMI2_CEC_USER=y
CONFIG_TV_DISP2_SUNXI=y
CONFIG_DISP2_SUNXI_DEBUG=y
CONFIG_DISP2_SUNXI_COMPOSER=y
-CONFIG_FRAMEBUFFER_CONSOLE=y
-CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
-CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y
CONFIG_LOGO=y
CONFIG_SUNXI_GPU_TYPE="mali-g31"
CONFIG_SOUND=y
常见问题
- Q: 编译报错 "command not found" ?
A: sudo apt install build-essential autoconf automake libtool -y
- Q: 运行后屏幕无显示 ?
A: sudo ./psplash;检查:ls -l /dev/fb0
- Q: 开机启动不生效 ?
A: sudo systemctl status psplash.service;sudo journalctl -u psplash.service
- Q: Logo 显示异常 ?
A: 确保 PNG 格式,重新生成:./make-image-header.sh logo.png POKY