本文記錄修改 Linux Kernel 開機 Logo(支援 224 色模式)並實現置中全螢幕顯示的完整流程,包含圖片轉換、Kernel 配置、原始碼修改與編譯驗證。
.ppm,儲存時選擇「ASCII」格式。logo_linux_clut224.ppm,複製到核心原始碼 drivers/video/logo/ 覆蓋同名檔案。logo_linux_clut224.c 與 logo_linux_clut224.o,重新編譯核心時會自動重新生成。執行 make menuconfig 勾選:
Device Drivers → Graphics support →
[*] Bootup logo →
[*] Standard 224-color Linux logo
Device Drivers → Graphics support → Console display driver support →
[*] Framebuffer Console support
重新編譯核心(make zImage 或完整建構),啟動即可看到新 Logo,但預設靠左上角顯示。
drivers/video/fbmem.c 的 fb_show_logo_line()// 原始碼片段
// image.dx = 0;
// image.dy = y;
image.width = logo->width;
image.height = logo->height;
// 新增:計算置中偏移
image.dx = (info->var.xres / 2) - (image.width / 2);
image.dy = (info->var.yres / 2) - (image.height / 2);
drivers/video/console/fbcon.c 的 fbcon_prepare_logo()logo_height = fb_prepare_logo(info, ops->rotate);
// 新增:將 logo 區域整體下移至螢幕垂直置中
logo_height += (info->var.yres / 2) - (logo_height / 2);
修改完成後,Kernel Logo 會置中顯示,但隨即被 Android 開機第一畫面(白色「ANDROID」文字)快速刷新覆蓋。實際產品中需進一步屏蔽或延遲 Android 開機動畫(修改 init.rc 或 BootAnimation 服務啟動時機),否則 Kernel Logo 只有閃現瞬間。