I started a Linux experiment from the ramdisk root file system the day before yesterday and wrote a post. With the help of Kasim, the general moderator, I learned that Linux-based releases usually use initramfs instead of initrd. The architecture is simpler and the applications are more flexible. Just this evening, I just started Linux using initramfs and wrote a post to summarize it.
This post does not detail every step, but only describes the difference between it and the steps required to start the system using ramdisk. In fact, I also changed it based on the steps of configuring and compiling the kernel to start the system using ramdisk the day before yesterday. Here, we will only summarize the main differences between using initramfs and using ramdisk to configure kernel options and some problems encountered.
Refer to my other post titled "LINUX started successfully from the ramdisk root file system. To sum up,"
Http://www.arm9home.net/read.php? Tid-5610.html
Development Environment: fedora 9
Tool chain for cross-Compilation: Arm-Linux-GCC 4.3.2 with Eabi
Embedded Linux kernel version: 2.6.29.4-friendlyarm. This article is based on the config_mini2440_t35 kernel of 2.6.29.4-friendlyarm. Other versions should be similar for reference only.
Development Board: mini2440-128M NAND Flash
Bootloader: u-boot-2009.11
Main differences:
Step 2. Modify Kernel configuration options
Go to the kernel source code directory linux-2.6.29 directory
# Cp config_mini2440_t35. config
# Make menuconfig arch = arm
Open the configuration menu and set two options when you use ramdisk to start the system. Here you only need to configure one configuration item:
General setup --> select initial Ram filesystem and RAM disk...
The reason is very simple. We use initramfs instead of ramdisk, so we do not need to configure the ramdisk driver support item device drivers --> Block devices --> ram block device support item. Corresponding (4096) default RAM disk size Kbytes and other related default configuration options will not appear again.
Another important difference between initramfs and ramdisk is that initramfs does not model a disk in the memory, so it does not require the ext2 driver support required by ramdisk. Therefore, the <> second extended FS Support option can be canceled for the ext2 File System under the file systems menu.
Another important difference in this step is the need to go to General setup --> initial Ram filesystem and RAM disk ......
In the/work/rootfs initramfs source file (s), enter the root file system directory in the initramfs format, here, the root file system directory I want to do is/work/rootfs.
Step 6. Create the initramfs root file system
H) Create an initramfs root file system image
The steps for creating the minimum system root file system are basically the same as those for creating the ramdisk root file system. Here, we only show what is the difference in the last step.
Because the first program executed during initramfs root file system startup is INIT, rather than linuxrc, we need to add an init file to the root file system, the corresponding linuxrc file is no longer needed.
Modify the root file system as follows
# Cd/work/rootfs
# Ln-s bin/busybox init
In this way, a soft link init is created for busybox, which is the init file to be created.
In addition, we used the genext2fs tool when making the ramdisk root file system image. Here, we do not need to take any additional steps to make the initramfs root file system image, instead, it is automatically generated when you compile the Linux kernel. The automatically generated initramfs root file system image is in the USR directory of the Linux source code tree. The name is initramfs_data.cpio.gz, which is a compressed file in the GZ format.
In this way, there is a problem. When compiling a kernel that can be started using initramfs, There is a related item in its configuration options, that is, in (/work/rootfs) initramfs
In source file (s), enter the root file system directory in initramfs format. This requires that the root file system be ready first when compiling the kernel. It is worth noting that the kernel image we have produced based on this method is actually much larger than the original one, because we are doing this step, in fact, the initramfs root file system is directly merged into the kernel image. In this way, you no longer need to separately burn the root file system image for the merged image. Correspondingly, you do not need to add initrd = ...... To specify the initramfs location. Of course, if you do not want to merge initramfs into the kernel, you can directly use the kernel configured with ramdisk to start the system. However, you must use initrd = ...... To specify the initramfs location, and the size of the second initramfs root file system image must be specified as the actual size. Otherwise, an image verification error is prompted and the system cannot be started.
There is no difference between others.
-------------------------------------------------------------------
Uimageand initramfs_data.cpio.gz have been compiled.
Use U-boot to download the kernel image and the initramfs root file system image. When the system is started, the kernel crashes and the kernel panic fails to be started.
The following error is displayed on the last line of the Super Terminal:
Unpacking initramfs... <0> kernel panic-not syncing: Bad gzip magic numbers
Check related errors online. The solution is as follows:
"This problem has been solved;
It is because the initrd = bufptr, size that I pass to the kernel in U-boot;
In the size parameter, the size is larger than the actual initramfs;
As a result, when unpack_to_rootfs calls gunzip to decompress the initramfs package, gunzip cannot determine the end address of the initramfs package. This is caused by repeated decompressing. (gunzip is really not intelligent, haha)
Set the size to be the same as the size of the initramfs compressed package. "The system is started successfully.
Additional:
If the LCD driver is transplanted to the kernel, if u-boot is not specified
Bootargs = initrd = 0x31000000, 0xf2c4c root =/dev/Ram RW init =/linuxrc console = ttysac0 mem = 64 m
In addition, config_cmdline = "" is not set in Kernel configuration ""
The default console is the LCD output that is connected to the Development Board. The default terminal device is tty1.
The conclusion above is that we forgot to add
Bootargs = initrd = 0x31000000, 0xf2c4c root =/dev/Ram RW init =/linuxrc console = ttysac0 mem = 64 m
It is found that a large amount of startup information is displayed on the LCD.
[U-boot @ mini2440] # bootm 0x32000000
# Booting kernel from legacy image at 32000000...
Image name: Linux-2.6.29.4-FriendlyARM
Created: 2010-04-11 13:53:44 UTC
Image Type: ARM Linux kernel image (uncompressed)
Data size: 2881480 bytes = 2.7 MB
Load address: 30008000
Entry Point: 30008000
Verifying checksum... OK
Loading kernel image... OK
OK
Starting kernel...
Uncompressing
Linux ....................................... ......................
........................................ ........................................
...... Done, booting the kernel.
The Super Terminal stops when it is displayed. It is estimated that the control is handed over to the console tty1 displayed by the LCD.
I do not know if the analysis is correct. Please correct me.
Answer: tty1 is the LCD framebuffer.
Console. It registers itself as one of the kernel's consoles during initialization, just like the UART driver of S3C2440. When the kernel is started without a console specified, it is basically used as the console.
This blog reposted from: http://www.arm9home.net/read.php? Tid-5645-fpage-0-toread--page-1.html Technology Forum, it seems that there are many masters in this forum.