FlyZhy.Org logo Projects - Rebuilding Kernel

Before
HowTo
Unicon
Bootsplash
Download
Patching
Building
Configuring
Executing
After
Hackers only
References

The steps and notices of rebuilding kernel for the Slackware Linux on my computer (including bootsplash and UNICON).

Before

It's different to rebuild 2.4.x and 2.6.x kernel, but they have the same prerequisite knowledge:

If you are familiar with them, you will feel easy on this section, but if not, you will learn more than here.

top

HowTo

Unicon

UNICON is a CJK (Chinese/Japanese/Korean) Linux console input and display system. It can support console virtual terminals, GPM mouse, keyboard, and almost all video devices using the kernel frame buffer. It supports multiple language fonts with a font manager so each virtual console can display a different font and input method. UNICON also can display IBM table characters mixed with double byte language encodings.

And I only use UNICON for Chinese display in the console of my Slackware Linux.

Bootsplash

Bootsplash is the graphical boot process for the linux kernel although it is not yet a part of the official kernel. It is, however included in several major distributions.

I really enter into the graphical world of Linux using bootsplash.

Download

Notice: the version of the UNICON and bootsplash must be correspond with that of the Linux kernel.

bootsplash
UNICON
kernel
Homepage

Patching

Actually the bootsplash and the UNICON are patch files for Linux kernel, so we must patch them into Linux official kernel before rebuilding it.

kernel
#cp /path/to/linux-2.6.15.tar.bz2 /usr/src/
#cd /usr/src/
#tar xvfj linux-2.6.15.tar.bz2
#rm linux
#ln -sf linux-2.6.15 linux
bootspalsh
#cp /path/to/bootsplash-3.1.6-2.6.15.diff /usr/src/
#cd /usr/src/linux/
#patch -p1 < ../bootsplash-3.1.6-2.6.15.diff
patching file drivers/char/keyboard.c
patching file drivers/char/n_tty.c
patching file drivers/char/vt.c
patching file drivers/video/Kconfig
patching file drivers/video/Makefile
patching file drivers/video/bootsplash/Kconfig
patching file drivers/video/bootsplash/Makefile
patching file drivers/video/bootsplash/bootsplash.c
patching file drivers/video/bootsplash/bootsplash.h
patching file drivers/video/bootsplash/decode-jpg.c
patching file drivers/video/bootsplash/decode-jpg.h
patching file drivers/video/bootsplash/render.c
patching file drivers/video/console/bitblit.c
patching file drivers/video/console/fbcon.c
patching file drivers/video/console/fbcon.h
patching file drivers/video/vesafb.c
patching file include/linux/console_struct.h
patching file include/linux/fb.h
UNICON
#cp /path/to/vd_unicon-kernel-fonts-20040205.patch.bz2 /usr/src/
#cd /usr/src/
#bunzip2 vd_unicon-kernel-fonts-20040205.patch.bz2
#cd /usr/src/linux/
#patch -p1 < ../vd_unicon-kernel-fonts-20040205.patch
patching file drivers/video/unicon/font_big5_16.h
patching file drivers/video/unicon/font_eucjp16.h
patching file drivers/video/unicon/font_gb16.h
patching file drivers/video/unicon/font_gbk16.h
patching file drivers/video/unicon/font_jis16.h
patching file drivers/video/unicon/font_kscm16.h
#cp /path/to/vd_unicon-kernel-20060103-2.6.15.patch /usr/src/
#cd /usr/src/linux/
#patch -p1 < ../vd_unicon-kernel-20060103-2.6.15.patch
patching file drivers/char/consolemap.c
patching file drivers/char/selection.c
patching file drivers/char/vt.c
Hunk #26 succeeded at 3484 (offset 25 lines).
patching file drivers/video/Kconfig
patching file drivers/video/Makefile
Hunk #1 succeeded at 9 with fuzz 2 (offset 1 line).
patching file drivers/video/console/bitblit.c
Hunk #1 FAILED at 18.
Hunk #2 succeeded at 228 (offset 24 lines).
Hunk #3 succeeded at 453 (offset 7 lines).
Hunk #4 succeeded at 487 (offset 24 lines).
Hunk #5 succeeded at 634 (offset 15 lines).
Hunk #6 succeeded at 665 (offset 24 lines).
1 out of 6 hunks FAILED -- saving rejects to file drivers/video/console/bitblit.c.rej
patching file drivers/video/console/fbcon.c
Hunk #1 FAILED at 106.
Hunk #2 succeeded at 123 (offset 3 lines).
Hunk #4 succeeded at 960 (offset 7 lines).
Hunk #5 succeeded at 1240 (offset 10 lines).
Hunk #6 succeeded at 1257 (offset 7 lines).
Hunk #7 succeeded at 1524 (offset 10 lines).
Hunk #8 succeeded at 1572 (offset 7 lines).
Hunk #9 succeeded at 1595 (offset 10 lines).
Hunk #10 succeeded at 1663 (offset 7 lines).
Hunk #11 succeeded at 1677 (offset 10 lines).
Hunk #12 succeeded at 1692 (offset 7 lines).
Hunk #13 succeeded at 1711 (offset 10 lines).
Hunk #14 succeeded at 1740 (offset 7 lines).
Hunk #15 succeeded at 1868 (offset 14 lines).
Hunk #16 succeeded at 1956 (offset 11 lines).
Hunk #17 succeeded at 2645 (offset 41 lines).
Hunk #18 succeeded at 2736 (offset 11 lines).
Hunk #19 succeeded at 3171 (offset 41 lines).
1 out of 19 hunks FAILED -- saving rejects to file drivers/video/console/fbcon.c.rej
patching file drivers/video/console/unicon.c
patching file drivers/video/unicon/COPYING
patching file drivers/video/unicon/CREDITS
patching file drivers/video/unicon/ChangeLog.TL
patching file drivers/video/unicon/Kconfig
patching file drivers/video/unicon/Makefile
patching file drivers/video/unicon/encode-big5.c
patching file drivers/video/unicon/encode-eucjp.c
patching file drivers/video/unicon/encode-gb.c
patching file drivers/video/unicon/encode-gbk.c
patching file drivers/video/unicon/encode-jis.c
patching file drivers/video/unicon/encode-kscm.c
patching file drivers/video/unicon/encode-sjis.c
patching file drivers/video/unicon/unikey.h
patching file drivers/video/unicon/xl_fm.c
patching file drivers/video/unicon/xl_funckeys.h
patching file drivers/video/unicon/xl_hzfb.c
patching file drivers/video/unicon/xl_hzfb.h
patching file drivers/video/unicon/xl_key.h
patching file drivers/video/unicon/xl_keyhooks.c
patching file drivers/video/unicon/xl_keyhooks.h
patching file drivers/video/unicon/xl_keymasks.c
patching file drivers/video/unicon/xl_unikey.c
patching file include/linux/fb_doublebyte.h
You must notice that there are two errors here happens as says:
1 out of 6 hunks FAILED -- saving rejects to file drivers/video/console/bitblit.c.rej
1 out of 19 hunks FAILED -- saving rejects to file drivers/video/console/fbcon.c.rej
That's because we have patched bootsplash which also modified the two files:
drivers/video/console/bitblit.c
drivers/video/console/fbcon.c
So we must modify these two files manually as follows (look through the xxx.c.rej file for reference):
18 #include <linux/console.h>
19 #include <asm/types.h>
20 #include "fbcon.h"
21 #ifdef CONFIG_BOOTSPLASH
22 #include "../bootsplash/bootsplash.h"
23 #endif
24
25 /*
26  * Accelerated handlers.
27  */

to

18 #include <linux/console.h>
19 #include <asm/types.h>
20 #include "fbcon.h"
21 #ifdef CONFIG_BOOTSPLASH
22 #include "../bootsplash/bootsplash.h"
23 #endif
24 #ifdef CONFIG_UNICON
25 #include "unicon.c"
26 extern struct display fb_display[MAX_NR_CONSOLES];
27 #endif
28
29 /*
30  * Accelerated handlers.
31  */
110     FBCON_LOGO_DONTSHOW     = -3    /* do not show the logo */
111 };
112
113 static struct display fb_display[MAX_NR_CONSOLES];
114 signed char con2fb_map[MAX_NR_CONSOLES];
115 static signed char con2fb_map_boot[MAX_NR_CONSOLES];

to

110     FBCON_LOGO_DONTSHOW     = -3    /* do not show the logo */
111 };
112
113 #ifdef CONFIG_UNICON
114 struct display fb_display[MAX_NR_CONSOLES];
115 #else
116 static struct display fb_display[MAX_NR_CONSOLES];
117 #endif
118
119 signed char con2fb_map[MAX_NR_CONSOLES];
120 static signed char con2fb_map_boot[MAX_NR_CONSOLES];

Building

#cd /usr/src/linux/
#make menuconfig

The most configuration options is decided by your own computer hardware and system, but in order to use bootsplash and UNICON we introduced above, the following options must be chosen:

Code maturity level options  --->[*] Prompt for development and/or incomplete code/drivers
Processor type and features  --->[*] MTRR (Memory Type Range Register) support
             Device Drivers  --->
                    Block devices  --->
                                       <*> Loopback device support
                                       <*> RAM disk support
                                       (4096) Default RAM disk size
                                       [*]   Initial RAM disk (initrd) support
                 Graphics support  --->[*] Support for frame buffer devices
                                       [*]   VESA VGA graphics support
        Console display driver support  --->[*]   Video mode selection support
                                            <*> Framebuffer Console support
              Bootsplash configuration  --->[*] Bootup splash screen

and

Device Drivers  --->Graphics support  --->
                                          [*]   UNICON console support (EXPERIMENTAL)
                                          <M>     UNICON GB Font support
                                          <M>     UNICON GBK Font support
                                          <M>     UNICON Big5 Font support
                                          <M>     UNICON EUC-JP Font support
                                          <M>     UNICON JIS Font support
                                          <M>     UNICON Shift-JIS Font support
                                          <M>     UNICON KSCM Font support

then

#make
#make modules_install
#cp /usr/src/linux/arch/i386/boot/bzImage /boot/kernel-2.6.15
#cp /usr/src/linux/System.map /boot/System.map-2.6.15
#cp /usr/src/linux/.config /boot/config-2.6.15

Configuring

bootsplash
UNICON
lilo
#cp /path/to/lilo.bmp /boot/
others
NOTICE
Make sure that the files in /etc/rc.d/ is executable:
#chmod +x /etc/rc.d/rc.bootsplash
#chmod +x /etc/rc.d/rc.splash
#chmod +x /etc/rc.d/rc.unicon
#chmod +x /etc/rc.d/rc.local

Executing

#lilo
#reboot

The command lilo will make the modification of /etc/lilo.conf be effect.

top

After

After rebooting and log in the console, to enjoy the display system for Chinese in console, type

#/usr/local/bin/unicontrol --gbk

top

Hackers only

I have modified some configuration of above to make the bootsplash be different from each tty. To do this, download some bootsplash themes on this page. And put them into /etc/bootsplash/themes/ and modify the file /etc/rc.d/rc.splash to

#! /bin/bash
#
# Author: Danilo Levantesi <vagninu@virgilio.it>
#
# This is the script to enable the console background image.
# Put it in your /etc/rc.d/ and add in /etc/rc.d/rc.local:
# if [ -x /etc/rc.d/rc.splash ]; then
#   . /etc/rc.d/rc.splash
# fi
#
test -f /proc/splash || exit 5
test -x /sbin/splash || exit 5
#
sleep 5
echo "verbose" > /proc/splash
splashv=`cat /proc/splash`
res="${splashv##*, }"
test "$splashv" != "$res" || exit 5
res="${res%)*}"
echo "Setting up splash screens ($res)"
#
splcfg=/etc/bootsplash/themes/current/config/bootsplash-$res.cfg
spljpg=etc/bootsplash/themes/current/images/bootsplash-$res.jpg
#
# start_console : first fb console to display bootsplash
# console numeber is zero based!
# start_console = 1 Ctrl+Alt+F2
#start_console=1
# end_console : last fb console to display bootsplash
# end_console = 5 Ctrl+Alt+F6
#end_console=5
#
#for ((unit=$start_console;unit<=$end_console;unit++)); do
#  /sbin/splash -s -u "$unit" -n "$splcfg"
#done
#
# bootsplash for vga=791 1024x768
#/sbin/splash -s -u 1 -n /etc/bootsplash/themes/SwirlPool/config/bootsplash-1024x768.cfg
#/sbin/splash -s -u 2 -n /etc/bootsplash/themes/73labAllstar/config/bootsplash-1024x768.cfg
#/sbin/splash -s -u 3 -n /etc/bootsplash/themes/WarmAqua/config/bootsplash-1024x768.cfg
#/sbin/splash -s -u 4 -n /etc/bootsplash/themes/Frugalware/config/bootsplash-1024x768.cfg
#/sbin/splash -s -u 5 -n /etc/bootsplash/themes/Linux/config/bootsplash-1024x768.cfg
#
# bootsplash for vga=788 800x600
# /sbin/splash -s -u 0 -n /etc/bootsplash/themes/dragon/config/bootsplash-800x600.cfg
/sbin/splash -s -u 1 -n /etc/bootsplash/themes/compact/config/bootsplash-800x600.cfg
/sbin/splash -s -u 2 -n /etc/bootsplash/themes/gnu/config/bootsplash-800x600.cfg
/sbin/splash -s -u 3 -n /etc/bootsplash/themes/frugalware/config/bootsplash-800x600.cfg
/sbin/splash -s -u 4 -n /etc/bootsplash/themes/slackware/config/bootsplash-800x600.cfg
/sbin/splash -s -u 5 -n /etc/bootsplash/themes/darkblue/config/bootsplash-800x600.cfg

top

References

Kernel Rebuild
bootsplash
UNICON

1. The symbol "+" stands for adding the following lines into the file in front of "+".