Article Title: proficient in initramfs build stepbystep (10 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
29. toolchain
When using the uclibc library in init ramfs, the key is to build the uclibc toolchain. There are two main ways to build uclibc toolchain: (1) automatically build with buildroot tool (http://buildroot.uclibc.org/), which is also the official standard practice of uclibc. (2) Use the CLFS Embedded manual method for manual creation. Currently, CLFS Embedded is still under development and can be viewed at http://cross-lfs.org/view/clfs-embedded/x86.
We briefly describe how to use the buildroot tool to build the uclbic toolchain:
(1) Get buildroot.
We recommend that you use the svn command to download it from its version Library:
Svn co svn: // uclibc.org/trunk/buildroot
To use the svn command, you must first install the subversion software package. During the download process, the connection may be interrupted abnormally. In this case, re-execute the preceding command to continue the download, which may be repeated multiple times.
(2) Configure buildroot
We only need to configure the toolchain. In the top-level directory of buildroot, run
Make menuconfig
Command, configure the following based on the default configuration
Target Architecture: i386
Target Architecture Variant: i686
Package Selection for the target: cancel the BusyBox option (selected by default)
Target filesystem options: Cancel ext2 root filesystem (selected by default)
Toolchain --> Toolchain type: Buildroot toolchain
(3) Compile
Run
Make
Command, the buildroot tool will automatically download the required source files and automatically compile them. After one or two hours, the toolchain will be compiled. The compiled toolchain is located
Buildroot/build_i686/staging_dir/usr/bin/
Directory. The prefix for tool commands is i686-linux -.
Thirty. Compile Busybox to statically connect to the uclibc Library
Generally, the uclibc library is used to statically connect it to the busybox. The procedure is as follows:
(1) Add the directory of uclibc toolchain to PATH.
In ~ /. Add the following to the bash_profile file:
# Set PATH so it has des uclibc toolchain if it exist
If [-d ~ /Buildroot/build_i686/staging_dir/usr/bin]; then
PATH = "$ {PATH }":~ /Buildroot/build_i686/staging_dir/usr/bin
Fi
(2) configure the busybox static Connection Library.
On the busybox configuration page, select:
Build Options --> Build BusyBox as a static binary (no shared libs)
(3) Compile
Run
Make CROSS_COMPILE = i686-linux-
Command "cross-compile" busybox.
The final compilation generates an executable file with a static connection. You do not need to copy the library file in init ramfs.
. Use buildroot to automatically build init ramfs
Buildroot is actually a powerful root file system construction tool. It uses uclibc and busybox as the basis for system construction. toolchain is only an intermediate product for building the system. Init ramfs is a special root file system. Of course, it can be automatically built using buildroot. The following is a brief description of the construction method:
(1) Configuration
Perform the following configuration on the buildroot configuration page:
Package Selection for the target: select
Busybox
Run Busybox's own full installation
Use minimal target skeleton
Target filesystem options --> cpio the root filesystem --> comprassion method: gzip
(2) Compile
Run
Make
Command to compile.
(3) Output
The constructed cpio file is
Buildroot/binaries/rootfs.i686.cpio.gz
The same directory also contains an uncompressed file: rootfs. i686.cpio
The directory is
Buildroot/project_build_i686/uclibc/root
You can modify and adjust the original init ramfs in this directory, and then package and generate a new init ramfs using the cpio command.
(4) Adjustment
Directly use the root.i686.cpio.gz generated by buildrootas init ramfs.
Can't open/dev/tty1: No such file or directory
Can't open/dev/tty2: No such file or directory
Can't open/dev/tty3: No such file or directory
Error messages are output cyclically, and the system cannot run normally.
The error occurs because the corresponding device file is not generated in the/dev directory of init ramfs. Make the following adjustments:
1) Add an initialization script file S10mountfs to the etc/init. d directory under the build directory (buildroot/project_build_i686/uclibc/root ).
#! /Bin/sh
Mount-t proc/proc
Mount-t sysfs/sys
Mdev-s
2) Change the setuid attribute of busybox; otherwise, the mount command cannot be executed. Run the following command in the build directory (buildroot/project_build_i686/uclibc/root ):
Chmod-s bin/busybox
Command.
After the two adjustments are completed, execute them in the build directory (buildroot/project_build_i686/uclibc/root ).
Find. | cpio-o-H newc | gzip> ../init ramfs.cpio.gz
Command to regenerate the cpio package file of init ramfs.
(5) Running Effect
Run the new init ramfs and the system displays a logon prompt. Enter the user name root. If the password is blank, you can enter a linux System of mini.
Buildroot is an automatic building tool with powerful functions and flexible configuration. Its detailed usage and configuration methods are beyond the scope of this article. It may be described in a specific article in the future.