These days the reference to the country embedded experimental manuals and online information to complete the U-boot customization, core customization, RAMDisk root file system production, and success. Strike, summarize. This article refers to a lot of articles on the Internet, it is not noted. Thanks to the help of the heroes, if there is similar, hope forgive me.
Development environment: Red Hat Enterprise Edition 5
Cross-compilation Toolchain: arm-linux-gcc4.3.2
Embedded Linux kernel version: The friendly arm of the mini2440 Development Board CD comes with the kernel linux-2.6.32.2
Development Board: Mini2440-64mnand Flash
bootloader:u-boot-1.20
The steps are as follows:
1.u-boot Custom
Because more content, another day to summarize a bar, in this first not much to say
2. Unzip the kernel source tree
Specific steps refer to the friendly arm mini2440 Development Board User manual, specifically not detailed.
3. Modify Kernel configuration options
Make Menuconfig, open the Configuration menu and modify the two configuration items, respectively:
A): General setup--> Select Initial RAM filesystem and RAM disk ... Item
b): Devicedrivers-->block devices--> Select RAM Block devicesupport
Modified (4920) default RAM disk size Kbytes option for (8192) default RAM disk size Kbytes
It is important to note that RAMDisk is a memory virtual disk technology that is not essentially a file system that uses the file system when ext2 the file system. So be sure to enter the file Systems menu when make menuconfig, and choose <*>second Extended FS support. To provide kernel support for the ext2 file system.
Then save the configuration to exit.
This adds the RAMDisk startup function and RAMDisk driver support to the kernel.
4. Modify Kernel boot parameters
There are two methods:
A): Modify the No. 310 line of the. CONFIG to modify the definition of "config_cmdline"
Modified to Config_cmdline= "Initrd=0x32000000,0x200000root=/dev/ram rw console=ttysac0 mem=64m" save.
Starting from RAMDisk, RAMDisk compresses the file start address at the memory address 0x32000000, and the file size is 0x200000.
This parameter can also be entered in the Boot Options menu when Makemenuconfig arch=arm, and then modified in the default kernel command string. The effect is the same.
b): Or do not modify the No. 310 line of the. config cmdline definition, but instead use the U-boot bootargs environment variable to pass the startup parameters.
Also modify the environment variable to bootargs=initrd=0x31000000,0x200000root=/dev/ram RW init=/linuxrc console=ttysac0 Mem=64M
and saveenv save u-boot environment variable
Above a), B) The effect is the same. (Note: I only tried A, b not tried)
5. Compiling the kernel
Note: It seems that the friendly arm of the kernel source directory in the Uimage target annotated, the direct makeuimage will prompt no uimage target. Zimage is a armlinux commonly used compressed image file, Uimage is a u-boot dedicated image file, it is before zimage with a length of 0x40 "header", indicating the type of the image file, loading location, generation time, size and other information. In other words, zimage and uimage are not any different if executed directly from the 0x40 position of the uimage. In addition, the Linux2.4 kernel does not support the uimage,linux2.6 kernel to add a lot of support for embedded systems, but the uimage generation also needs to be set up.
Here, I directly copy the U-boot root directory under the/tools Mkimage tool into the/usr/bin directory of the host, you can directly execute in the kernel root directory
#make Uimagearch=arm cross_compile=arm-linux-
Wait a minute, kernel compilation is complete.
6. Making the RAMDisk root file system (actually building the root filesystem)
This process is the core step of making the RAMDisk root file system, as follows:
A) Create the root file system directory:
#cd转入到你的工作目录.
#mkdir Rootfs
#cd Rootfs
#mkdir bin Dev etclib proc sbin sys usr MNT tmp var
#mkdir usr/binusr/lib Usr/sbin Lib/modules
b) Create the most basic device files:
#cd Dev
#mknod-M 666console C 5 1
#mknod-M 666 NULLC 1 3
#cd:
c) Install/etc configuration file:
I am using the country embedded with the ETC configuration file, without modification, directly extracted into the root file system.
The operation is as follows:
#tar ETC.TAR.GZ-C/XXX/ROOTWHJ
XXX indicates the path where you want the root directory to be created.
d) Compile the kernel module:
Enter the Linux kernel source root directory
#make Modulesarch=arm cross_compile=arm-linux-
e) Install the kernel module:
#makemodules_install arch=arm install_mod_path=/xxx/rootwhj//Embedded kernel modules are in the file system
XXX Indicates the directory where you want to make the rootfs.
f) Configuration BusyBox
Go to BusyBox directory to execute #make menuconfig
Enter Busyboxsettings-Build Options, "build Busyboxas a static binary", or static link, eliminating the copying of a large number of library files.
Installationoptions, select "Don t use/usr" to prevent BusyBox accidentally being installed in the appropriate directory of the host system, destroying the host system.
Busyboxinstallation Prefix (/XXX/ROOTWHJ), modify this option to indicate that the compiled BusyBox will be installed to that location.
g) Compile and install BusyBox
#make Arch=arm cross_compile=arm-linux-
A few minutes after the compilation is complete
#make Install
Installed in the Busyboxinstallation Prefix (/XXX/ROOTWHJ) settings directory. Currently the root file system directory (/XXX/ROOTWHJ) that I want to make.
Complete creation of the root file system
h) Make RAMDisk root file system image
Here's how:
On the http://genext2fs.sourceforge.net/ download can easily make RAMDisk file System tool GENEXT2FS, so that you do not like most of the internet said the tedious production ramdisk image, Currently the latest version is genext2fs-1.4.1.tar.gz.
Compile and build the tool genext2fs and put it into the/sbin/directory of the host for easy use.
Jump to the top-level directory of the rootfs you want to make
#genext2fs-B 8192-d rootfs RAMDisk
-B refers to the size of the RAMDisk made of 8MB
-D refers to the root file system directory to be made into RAMDisk
The last RAMDisk is the name of the RAMDisk, and of course it can be renamed.
#gzip-9-F RAMDisk
The RAMDisk is optimally compressed to ramdisk.gz
Booting Linux successfully from RAMDisk root file system