In the development of a Linux-based embedded simulation platform, the appearance and customization of terminals are an important issue. The string and monotonous penguin icons that scroll on the screen at startup make embedded devices unable to break away from the traces of PC. The monotonous "White Paper and black text" style on the Linux console can be described as a great deal. Transforming the Linux console to display boot information and logos in a beautiful And customizable manner has become an important task of Embedded Linux applications.
The open source project bootsplash (http://www.bootsplash.org/) provides a perfect solution to this problem. Boot-
Splash patches the kernel to change the Linux framebuffer console's support for graphic display. Through user spaceProgramAllows you to customize the startup logo, set the console background, and display and hide the character information during startup, and even supports animated display of the boot screen. This article describes how to use splashboot to create a boot screen, including Kernel patches and user space settings.
1. kernel patch and control tools
1.1 Kernel patches supporting bootsplash
For different kernel versions, corresponding Kernel patches are provided on the bootsplash site. The kernel version we use is 2.4.23. Download and patch the kernel:
Cd/usr/src/Linux
make mrproper
patch-Np1-I .. /bootsplash-3.0.7-2.4.23.diff
re-compile the kernel:
make menuconfig
choose the following parameters:
code maturity level options --->
prompt for development and/or incomplete code/drivers
Block devices ---> RAM disk support
Block devices ---> initial RAM disk (initrd) support
console drivers ---> video mode selection support
console driver S ---> frame-buffer support --->
support for frame buffer devices
vesa vga graphics console
Use splash screen instead of boot logo
then compile the kernel:
make Dep & make bzimage
then copy the generated kernel to/boot:
cp arch/i386/boot/bzimage/boot/Linux-bootsplash
in this case, the new kernel bzimage is the kernel that supports bootsplash, the rest is the customization of bootsplash.
1.2 install the user space program
Download the bootsplash tool, decompress it, and install it:
Tar-zxf bootsplash-3.0.7.tar.gz
CD bootsplash-3.0.7/utilities
Make
CP fbresolution fbmngplay fbtruetype splash/sbin/
In this way, the installation of the user space tool is completed. In fact, bootsplash uses the following four programs: the Splash program creates the image resources that need to be displayed under framebuffer into a tool for starting the ramdisk; fbmngplay reads MNG files and plays animations; fbtruetype displays TrueType fonts; fbresolution checks resolution. The script mentioned later only reads the configuration file using different parameters and calls the above programs.
2 boot logo customization
2.1 set the theme of the splash screen
the preceding installed splash user space program contains A program splash, it requires a configuration file to specify which image to use and whether to hide the output of text information. We can see that "theme" is a collection of configuration files, images, and other required files required by the splash tool. There are many theme options available, and we can also customize theme. For convenience, we download theme-linux.tar.bz2 and use it as theme.
Create the directory/etc/bootsplash/themes and decompress theme-linux.tar.bz2 to the directory. The current directory structure should be:
/etc/bootsplash/themes/Linux
readers can look at the bootsplash-1024x768.cfg under this directory to observe the configuration file format. This simple file contains few options. In fact, it only clearly shows the image to be displayed, the color and background color of the text displayed on the console, and the location of the text information output. In addition, do not forget that it can also specify the location of the file to be displayed in verbose and silent modes. In silent mode, do not display the startup information. replace it with an optional progress bar (this requires more settings about a outsourcing script ). Based on this configuration file, you can modify it to display your favorite images and use your favorite mode.
2.2 Use the splash tool to install the splash theme to initrd
in the early stages of system startup, the kernel cannot read or write the hard disk. To display images at this stage, where should the images be placed? The answer is to write the image into ramdisk so that it can be read at startup, because partition has not been loaded yet. Of course, you don't have to worry about making initrd. the splash tool can be easily done. The splash tool automatically generates an initrd Based on the selected configuration file (theme. All you need to do is execute the following command:
splash-S-F/etc/bootsplash/themes/ARCH/config/arch-1024-boot.cfg/boot/initrd. splash
the generated initrd. splash is a new initrd. Add it to grub or Lilo.
modify grub or lilo as follows:
Add or modify the following lines in GRUB:
kernel (hd0, 3) /boot/vmlinuz −2.4.21 −melenas root =/dev/hda4 VGA = 791 splash = silent
initrd (hd0, 3)/boot/initrd. splash
Add or modify the following lines in lilo:
VGA = 791
initrd =/boot/initrd. splash
append = "Splash = silent"
to see what these lines mean:
VGA = 791: boot splash is displayed in 1024x768 resolution and 65000 (16-bit color. The framebuffer settings should be based on the resolution and color depth of the theme we use.
splash = silent: The Boot splash is displayed in silent mode. If you want to use vebose mode, you only need to delete this line. Verbose mode is the default mode.
initrd =/boot/initrd. Splash ).
after LILO or grub is updated, you can see the beautiful startup screen.
3. display the startup progress bar
First, we need to figure out the progress (which is copied to the/sbin directory together with the Splash program ). Progress can draw a quadrilateral on the framebuffer device (/dev/fb0 by default. Run progress without any parameters. We can see the list of optional parameters of this program. The following parameters are of interest:
X: X coordinate of the Quadrilateral start point
Y: Y coordinate of the Quadrilateral start point
DX: the width of the Quadrilateral.
DY: the height of the Quadrilateral.
Color: The color of the Quadrilateral. This is a hexadecimal number, which indicates the same color on the web page.
Example:
Progress 0 0 512 384 ffffff
A white quadrilateral will be drawn in the upper left corner of the screen, which occupies 1/4 of the screen.
SS 256 192 521 384 fcd192
A yellow quadrilateral will be drawn in the middle of the screen.
The results of these examples should be run on the TTY terminal. do not view the results on konsole or xterm window.
After figuring out the usage of progress, let's see how to associate it with system startup. Debian startupCodeIt can be seen that its startup script completes a Service Program (XFS, Cron, samba or other service programs) each time it starts) then, use the PROGRESS program to draw a quadrilateral of the specified size at the specified position. In Debian, there are two startup scripts: first run/etc/init. d/RCs and then run/etc/init. d/RC. The following describes the/etc/init. d/RCS code. Note that this script calls the script at each rulevel at a time. We add code for drawing a quadrilateral to the Code, and add the code to the Code to be represented by a blacklist:
<Ccid_nobr>
<Ccid_code> # initialization variable J # J is the width of the progress bar J = 20 for I in/etc/RCs. D/S ?? * Do [! & #8722; F "$ I"] & continue # Start of the progress bar # ensure that the width of the progress bar does not exceed the range of IF (j <616) then # Call the SS program at this time, painting is one unit wider than the previous one #(15 pixels) progress bar # x y DX dy color/usr/local/bin/progress 204 667 $ J 21 fcd123 let J = J + 15 fi # End progress bar draw case "$ I" in *. SH) (trap & #8722; int quit tstp set start. $ I); *) # After traversing the sh file, the promoter process $ I start; esac done |
The code above draws the first part of the Quadrilateral. We need to draw the second part related to/etc/init. d/RC. To smooth the first part of the painting, we need to know where the first part of the Quadrilateral painting ends.
<Ccid_nobr>
# danger_var = 395 J = danger_var for I in/etc/rc $ runlevel. d/S * do [! & Amp; #8722; F $ I] & continue if [$ previous! = N] & [$ previous! = S] then # Find start script in previous runlevel and # Stop script in this runlevel. # suffix =$ {I #/etc/rc $ runlevel. d/S [0 & #8722; 9] [0 & #8722; 9]} Stop =/etc/rc $ runlevel. d/K [0 & #8722; 9] [0 & #8722; 9] $ suffix previus_start =/etc/rc $ previous. d/S [0 & #8722; 9] [0 & #8722; 9] $ suffix # if there is a start script in the previous level # And _ No _ Stop script in this level, we don "t # Have To re & #8722; start the Servi Ce. # [& #8722; F $ previus_start] & [! & #8722; F $ stop] & continue fi # continue progress bar Drawing # ensure that the width of the progress bar does not exceed the range if (j <616 )) then/usr/local/bin/progress 204 666 $ J 21 fcd123 let J = J + 15 fi # Draw the end progress bar case "$ runlevel" in 0 | 6) startup $ I stop; *) Startup $ I start; esac done
|
This Code follows the same method to draw a quadrilateral progress bar. But what is danger_var? As mentioned above, in order to smoothly follow the first part of the painting, we need to know where the first part of the Quadrilateral painting ends. This location is recorded using danger_var. Again, how can I upload the variables in the first script to the second script? You can add the following code at the end of the first script/etc/init. d/RCS:
Sed "s/danger_var = [0 − 9] */danger_var =" $ J "/g"/etc/init. d/rc>/tmp/boots
MV/tmp/boots/etc/init. d/RC
Chmod 755/etc/init. d/RC
The code above clearly obtains the J value and searches for the string "danger_var =…" in the rc of the second script file ..." Change it to "J value at danger_var = end", save the modified file as/tmp/boots, and rename it/etc/init. d/RC and change the execution permission.
If you use danger_var as the variable name to pass the Location Value, note that no name conflict exists in other startup scripts.
Now, restart your computer and enjoy the beautiful boot progress bar.
4 Conclusion
Through the kernel patch provided by the open-source bootsplash project and various user space tools, you can beautify and customize the console in framebuffer. This is of great significance for the development of the embedded simulation environment platform. This makes the embedded simulation environment platform reduce the traces of PCs to a certain extent and become a personalized and highly customizable platform.
References:
Dennis herbrich, arch Linux bootsplash-howto. http://www.archlinux.org
[2] Pedro Jurado Maqueda, Bulma: graphic boot with bootsplash and progress bar In Debian. http://bulma.net/
[3] Easy To win bootsplash. http://www.linuxsir.org/bbs/
Link: http://linux.ccidnet.com/art/302/20070807/1170067_1.html