Kernel configuration and compilation
The Linux kernel can be configured, that is, it can be configured according to the user's needs. It is precisely because the Linux kernel can be freely configured and cropped to reduce the volume of the kernel, so that the Linux kernel can be transplanted to the ARM platform.
The Linux Kernel configuration procedure is as follows:
1. Clear temporary files, intermediate files, and configuration files (why? After a kernel is obtained, many junk files need to be cleared)
$ Make clean (delete junk files and keep the configuration file)
$ Make mrproper (delete a spam file to delete a configuration file)
$ Make distclean (delete junk files Delete configuration files Delete patch files)
2. Determine the hardware configuration of the target system, such as the CPU type, Nic model, network protocol to be supported, and modify the makefile.
3. Use one of the following commands to configure the kernel:
$ Make conifg interactive configuration based on text mode (after execution, it will be configured by asking questions during the configuration process)
$ Make menuconfig text-based menu Configuration
$ Make oldconfig use the difference between the existing configuration file (. config) and make config, only the configuration items that indicate new
$ Make xconfig graphical configuration option (graphical interface needs to be installed)
Some default symbols have the following meanings:
Y: Load
N: Do not load
M: loaded as a module
After the preceding congfig command is used, A. config file is automatically generated. The file information stores the Kernel configuration results.
To configure the ARM kernel, you can modify it based on the default configurations in arch.
Root =/dev/nfs RW nfsroot = 192.168.1.100:/source/rootfs IP = 192.168.1.200 init =/linuxrc console = ttysac0. 115200
Root specifies the root file system
RW/RO specifies the attributes of the mounted file system, read/write, read-only
Nfsroot specifies the NFS service mount point, <NFS server IP >:< export directory>
IP Address: Specify the target board IP Address
Init specifies the user space program called after kernel initialization. The default value is/sbin/init.
Console specifies the terminal for printing information
Memory size specified by MEM
Initrd specifies the memory location and size of the root file system during ramdisk boot
4. Compile the kernel
Make zimage
Make bzimage (BIG)
Difference: On the X86 platform, zimage can only be used for kernels smaller than KB
The compiled kernel is located in the arch/CPU/boot directory.
5. Compile the kernel module
Make modules
6. Install the kernel module
Make modules_install (copy the compiled kernel module from the kernel source code directory to/lib/modules)
7. Create init ramdisk
Mkinitrd initrd-$ version example: mkinitrd initrd-2.6.29 2.6.29 $ version can be obtained by querying the directory under/lib/modules, check whether the command in the previous step has a 2.6.29/directory under/lib/modules. After the command is executed, the "initrd-2.6.29" file is generated under the kernel root directory.
The role of init ramdisk: provides the ability for the kernel to simply use ramdisk. These capabilities include formatting A ramdisk, loading file system content to ramdisk, and using ramdisk as the root file system.
8. kernel installation because the Kernel File and init ramdisk are searched from the/boot directory when the Linux system is started, you need to copy the Kernel File and init ramdisk to the/boot directory. (1) CP. /ARCH/x86/boot/bzimage/boot/vmlinuz-$ version example: CP. /ARCH/x86/boot/bzimage/boot/vmlinuz-2.6.29 Note: vmlinuz-2.6.29 can be any name, here just take more meaningful name. (2) CP $ initrd/boot/$ initrd refers to the "initrd-2.6.29" file generated under the kernel root directory after the command mkinitrd initrd-$ version is executed, that is, the init ramdisk file. Example: CP initrd-2.6.29/boot/(3) Modify/etc/grub. conf or/etc/Lilo. conf to code: Title centos-base (2.6.18-238. EL5)
Root (hd0, 0)
Kernel/vmlinuz-2.6.18-238.el5 Ro root = label =/rhgb quiet
Initrd/initrd-2.6.18-238.el5.img copy and change:
Title Chen (2.6.29)
Root (hd0, 0)
Kernel/vmlinuz-2.6.29 Ro root = label =/rhgb quiet
Initrd/initrd-2.6.29
It is only according to the specific situation of this paper, the vmlinuz-2.6.18-238.el5 of kernel into vmlinuz-2.6.29, The initrd initrd-2.6.18-238.el5.img into initrd-2.6.29
** $ Version indicates the compiled kernel version. This document uses 2.6.29 (that is, $ version = 2.6.29 )**