The following two articles are very good articles on the RAMDisk file system in the ARM9 forum
Today did a test, let Linux2.6.29.4 from the RAMDisk root file system to start a successful, summed up.
It involves more content, a lot of things no longer detailed, for further study please consult the relevant information (Baidu or Google a lot).
Development environment: Fedora 9
Cross-compilation toolchain: ARM-LINUX-GCC 4.3.2 with EABI
Embedded Linux kernel version: 2.6.29.4-friendlyarm. When I wrote the Post yesterday, I did not know the details, today to start the Development Board with Uname-r Check, is called 2.6.29.4-friendlyarm, the posts have been changed. This article is based on the 2.6.29.4-friendlyarm version of the friendly arm of the kernel. Other versions should also be similar, for informational purposes only.
Development Board: mini2440-128m Nand Flash
bootloader:u-boot-2009.11
The steps are as follows:
1. Unzip the kernel source tree
Extracting the linux-2.6.29-mini2440-20090708.tgz into your working directory will generate a friendly arm of the kernel source directory linux-2.6.29 that has been modified and has several mini2440 default profiles. Specific steps refer to the friendly arm mini2440 Development Board User manual, specifically not detailed.
2. Modify Kernel configuration options
Enter the kernel source directory linux-2.6.29 directory
#cp config_mini2440_t35. config
#make Menuconfig Arch=arm
Open the Configuration menu and modify the two configuration items, respectively:
A): General setup--> Select Initial RAM filesystem and RAM disk ... Item
b): Device drivers-->block devices--> Select RAM Block Device Support Item
And check if optimize for size is selected, if not selected, this key optimizes the kernel size and configures as needed.
Modify (8192) the Default RAM disk size Kbytes option for
(4096) Default RAM disk size Kbytes, the reason for this modification is that the RAMDisk I made later is 4096KB in size. Of course, if you want to make 8192KB size RAMDisk, here is the corresponding 8192, and so on. But the smallest system, is not so big ramdisk. The default configuration for this item is (4096), which I had previously changed, so it was (8192). If this size does not match the ramdisk you do, the kernel panic kernel panic will still appear on startup, prompting the RAMDisk format is not correct and the RAMDisk is not mounted.
It is then 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 go to the file Systems menu when make Menuconfig arch=arm, and select <*> Second extended FS support. To provide kernel support for the ext2 file system. I have previously added the ext2 file system, so there is no explanation at the beginning, here in order to explain why some people follow my method, but still kernel panic, especially this step is added.
Then save the configuration to exit.
This adds the RAMDisk startup function and RAMDisk driver support to the kernel.
3. Modify Kernel boot parameters
There are two methods:
A): Modify the No. 310 line of the. config and modify the definition of config_cmdline= ""
Modified to Config_cmdline= "initrd=0x31000000,0x200000 root=/dev/ram rw init=/linuxrc console=ttysac0 Mem=64M"
Save.
Starting from RAMDisk, RAMDisk compresses the file start address at the memory address 0x31000000, and the file size is 0x200000.
This parameter can also be entered in the Boot Options menu when make Menuconfig 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,0x200000 root=/dev/ram rw init=/linuxrc console=ttysac0 Mem=64M
and saveenv save u-boot environment variable
Above a), B) The effect is the same.
4. Compiling the kernel
#make zimage Arch=arm cross_compile=arm-linux-
Then there was a wait of about 20 minutes.
The Zimage kernel image appears in the current directory when the compilation is complete.
As if the friendly arm of the kernel source directory in the Uimage target to comment, previously seen in the forum has been said that the direct make uimage as if prompted not uimage goal. So I first make zimage, and then use the U-boot mkimage tool to convert to Uimage. In fact Uimage is in the beginning of Zimage added a 64-byte kernel image description. Note: Zimage is a commonly used arm Linux 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.
5. Making Uimage kernel image
Since I am using the bootloader is U-boot, so to convert Zimage to Uimage, the method is as follows:
#mkimage-A arm-o linux-t kernel-c none-a 0x30008000-e 0x30008000-n "Linux kernel Image"-D zimage Uimage-ramdisk
Description: The Mkimage tool is a u-boot format uimage kernel image authoring tool. If U-boot is compiled successfully, it will be under the Tools directory under the U-boot source tree. It is recommended that you copy it to the host's/sbin/directory for ease of use. Mkimage use of the specific parameters are no longer detailed, not clear please check their own.
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, the method is as follows:
A) Create the root file system directory:
#cd转入到你的工作目录.
#mkdir Rootfs
#cd Rootfs
#mkdir bin Dev etc lib proc sbin sys usr MNT tmp var
#mkdir usr/bin usr/lib Usr/sbin lib/modules
b) Create the most basic device files:
#cd Dev
#mknod-M 666 console C 5 1
#mknod-M 666 null C 1 3
#cd:
c) Install/etc configuration file:
Here can directly the friendly arm of the Root_qtopia in a few basic configuration files, copy only the necessary, and the contents of the deletion, because I do not include the RAMDisk Qtopia, all copies come and no use.
I was looking for the smallest system from the Internet etc profile extracted directly into the root file system I made, and do reference to the friendly arm of the Root_qtopia added some content, see the final description.
The operation is as follows:
#tar etc.tar.gz-c/xxx/rootfs
XXX Indicates the directory where you want to make the rootfs.
d) Compile the kernel module:
The method is as follows:
Enter the Linux kernel source directory (linux-2.6.29)
#make Modules Arch=arm cross_compile=arm-linux-
e) Install the kernel module:
#make modules_install arch=arm install_mod_path=/xxx/rootfs//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 "Build BusyBox as a static binary" in BusyBox Settings, build Options, which is a static link, eliminating the copying of a large number of library files.
Installation options, "Don t use/usr", to prevent BusyBox accidentally installed in the host system in the appropriate directory, destroy the host system.
Busybox installation Prefix (/XXX/ROOTFS), 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 BusyBox installation Prefix (/XXX/ROOTFS) settings directory. Currently the root file system directory (/XXX/ROOTFS) 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 4096-d rootfs RAMDisk
-B refers to the RAMDisk size of 4096K bytes made
-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
7. Download the kernel image and RAMDisk image
Start U-boot, pause u-boot Auto-start, and on the u-boot command line, type the following command to download the kernel and RAMDisk image:
[[Email protected]]# tftp 0x32000000 Uimage-ramdisk
dm9000 I/o: 0x20000300, Id:0x90000a46
Dm9000:running in + bit mode
Mac:08:08:11:18:12:27
Operating at 100M full duplex mode
Using dm9000 Device
TFTP from server 192.168.31.117; Our IP address is 192.168.31.230
Filename ' Uimage-ramdisk '.
Load address:0x32000000
Loading:t T #################################################################
#################################################################
#
Done
Bytes transferred = 1917752 (1d4338 hex)
[[Email protected]]# tftp 0x31000000 ramdisk.gz
dm9000 I/o: 0x20000300, Id:0x90000a46
Dm9000:running in + bit mode
Mac:08:08:11:18:12:27
Operating at 100M full duplex mode
Using dm9000 Device
TFTP from server 192.168.31.117; Our IP address is 192.168.31.230
Filename ' ramdisk.gz '.
Load address:0x31000000
Loading:t T #################################################################
####
Done
Bytes transferred = 1002594 (f4c62 hex)
8) Boot the kernel using the RAMDisk root file system
Start the system by typing the following command at the u-boot command line:
Bootm 0x32000000
# # booting kernel from Legacy Image at 32000000 ...
Image Name:linux-2.6.29.4-friendlyarm
created:2010-04-09 15:13:52 UTC
Image Type:arm Linux Kernel image (uncompressed)
Data size:1917688 Bytes = 1.8 MB
Load address:30008000
Entry point:30008000
Verifying Checksum ... Ok
Loading Kernel Image ... Ok
Ok
Starting kernel ...
Uncompressing Linux ... ..... ... ..... ... ..... ..... ..... ..... ..... ..... ..... ..... ....... .........
...... .... done, booting T, ... done, .... Done, ... done, and .... done, and .... done, and .... Done.-----No, no, no, ..... done.
He kernel.
Linux version 2.6.29.4-friendlyarm ([email protected]Ldomain) (gcc version 4.3
.2 (Sourcery g++ Lite 2008q3-72)) #3 Fri Apr 9 23:13:36 CST 2010
cpu:arm920t [41129200] revision 0 (ARMV4T), cr=c0007177
CPU:VIVT data cache, VIVT instruction cache
Machine:friendlyarm Mini2440 Development Board
Memory POLICY:ECC Disabled, Data cache writeback
...... The content of the middle too long is omitted here ...
Ramdisk:compressed image found at block 0
vfs:mounted Root (ext2 filesystem) on device 1:0.
Freeing Init memory:136k
Eth0:link down
Processing/etc/profile ... Done
# Eth0:link up, 100Mbps, Full-duplex, LPA 0x45e1
The system started successfully.
----------------------------------------------------------------------------------
PostScript:Because of the friendly arm mini2440 the default configuration file is to compile the driver into the kernel directly, and does not use kernel modules. So the 6th step in making the root file system D) compilation and e) installation of kernel modules can be done without the steps. I did not compile the kernel module. Because the Root_qtopia root file system, referring to the friendly arm, found that/lib/modules/' uname-r ' had nothing at all. and used to use the friendly arm of the CONFIG_MINI2440_T35 default configuration when compiling kernel modules. Discover friendliness only made a hello_modules sample of kernel modules. We do not need to use this hello_modules here, so these two steps are slightly past.
Description:Because the ETC profile in the smallest system does not write the script to automatically start the NIC, I do not start the RAMDisk automatically start the network card. Later, the script can be started automatically by referring to the script in the Root_qtopia root file system of the friendly arm to make the following changes.
Modify the following:
Modify the/etc/init.d/rcs file under Rootfs of the RAMDisk root file system to be made
Add the following two lines of command at the bottom to automatically start the network card:
/sbin/ifconfig Lo 127.0.0.1
/sbin/ifconfig eth0 192.168.31.230 netmask 255.255.255.0 up
This method is discovered by analyzing the startup process of the Root_qtopia root file system of the friendly arm.
We can also find more content by analyzing the Root_qtopia root filesystem of the friendly arm. Not in detail here.
Exercise your ability to analyze and solve problems. Oh.
Using Initramfs to start Linux success, summed up the day before yesterday did a RAMDisk root file system to start the Linux experiment, wrote a post. By the total moderator Kasim Hero's carry, learned that now Linux-based distribution is usually used Initramfs instead of INITRD, the architecture is simpler, the application is more flexible. It's all right tonight. Use Initramfs to start Linux, write a post to summarize.
This post does not detail each step, just the difference between it and the steps required to start the system with RAMDisk. In fact, I was the day before yesterday. Configure the build kernel to use the RAMDisk boot system based on the steps to change. The main differences and some problems encountered in using INITRAMFS and using RAMDisk to configure kernel options are summarized here.
Refer to my other post, "Starting Linux from the RAMDisk root file system success, summing up"
Http://www.arm9home.net/read.php?tid-5610.html
Development environment: Fedora 9
Cross-compilation toolchain: ARM-LINUX-GCC 4.3.2 with EABI
Embedded Linux kernel version: 2.6.29.4-friendlyarm. This article is based on the 2.6.29.4-friendlyarm version of the friendly arm of the Config_mini2440_t35 kernel. Other versions should also be similar, for informational purposes only.
Development Board: mini2440-128m Nand Flash
bootloader:u-boot-2009.11
The main differences:
Step 2: Modify kernel configuration options
Enter the kernel source directory linux-2.6.29 directory
#cp config_mini2440_t35. config
#make Menuconfig Arch=arm
Open the Configuration menu and configure the two options required to start the system using RAMDisk.
only one configuration item needs to be configured here:
General setup--> Select Initial RAM filesystem and RAM disk ... Items
The reason is simple, we're using Initramfs instead of RAMDisk, so we don't have to configure the RAMDisk driver support device Drivers-->block Devices-->ram Block device supports Item The corresponding default configuration options, such as the After (4096) default RAM disk size Kbytes, will no longer appear.
Another important difference between INITRAMFS technology and RAMDisk technology is that INITRAMFS does not emulate a disk in memory, so it does not require the EXT2 driver support required for RAMDisk. Therefore, the Ext2 file system support < > Second Extended FS supports option can be canceled under the Files Systems menu.
In this step
Another important difference is the need for general Setup-->initial RAM filesystem and RAM disk ... Item (/WORK/ROOTFS) Initramfs source file (s) fill in the root filesystem directory you want to create in INITRAMFS formatThe directory where I'm going to do the root file system is/work/rootfs.
Step 6: Make Initramfs root file system
h) Make Initramfs root file system image
The steps to make a minimal system root file system are basically consistent with the previous steps to make the RAMDisk root file system, which only shows how the last step is different.
Because the first program that executes when the INITRAMFS root file system starts is init, not LINUXRC, so here we make the root filesystem that needs
Add an init file, the corresponding LINUXRC file is no longer needed.
Modify the root file system as follows
#cd/work/rootfs
#ln-S Bin/busybox Init
This is theBusyBox created a soft link init, which is the init file we want to create.
In addition, we are using the GENEXT2FS tool when we make the RAMDisk root file system image, we do not need additional steps when making the Initramfs root file system image, but it is generated automatically when you compile the Linux kernel.
The automatically generated Initramfs root file system is mirrored in the USR directory of the Linux source tree. Name is initramfs_data.cpio.gz ., it is a zip file in gz format.
So there is a problem in
when compiling a kernel that can be started with INITRAMFS, its configuration options have a dependency, which is to fill in the root filesystem directory you want to make in INITRAMFS format in (/work/rootfs) Initramfs source file (s). This requires us to compile the kernel, first of all the root file system to do a good job. It is important to note that the kernel image that we made in this way is actually a lot larger than the original, because when we do this, we actually merge the Initramfs root filesystem directly into the kernel image. In this way, a single image will no longer need to burn a separate root file system image, corresponding to the boot kernel parameters do not need to add initrd= ... To specify the location of the Initramfs. Of course if you don't want to merge Initramfs into the kernel, you can start the system directly with the RAMDisk kernel, but then you have to use initrd= ... To specify the location of the Initramfs, and the second parameter Initramfs the size of the root file system image must be specified as the actual size, otherwise the image checksum error will not start the system.
There is no difference between the others.
-------------------------------------------------------------------
All the work done, Uimage and initramfs_data.cpio.gz have been compiled.
Download the kernel image and Initramfs root file system image with U-boot, start the system at this time, the final kernel panic kernel panic boot failed.
The last line in HyperTerminal shows the following error:
Unpacking Initramfs...<0>kernel Panic-not Syncing:bad gzip Magic Numbers
Internet access to the relevant errors, the solution is as follows:
"This problem has been solved;
Because, I passed to the kernel in the U-boot initrd=bufptr,size;
Size is larger than the actual INITRAMFS size in this parameter;
Cause unpack_to_rootfs in the call Gunzip to Initramfs compression package decompression, Gunzip can not determine the INITRAMFS compressed packet end address, repeated decompression caused; (Gunzip this east is not smart Ah, hehe)
The size setting is the same as that of the Initramfs compressed package;
The system starts successfully. Note that the device node under Dev is generated, otherwise the card dies
Starting Linux successfully from the RAMDisk root file system and booting Linux with Initramfs