Embedded Root file system

Source: Internet
Author: User

Root file system

The previous section explains the Linux kernel porting, which describes how to construct the root file system.

Tools and source code in path: F:\ Vedon \cd1_ main disc \system.

JFFS2 Authoring Tool Path: F:\ Vedon \cd1_ main disc \gui\xwindow\x\deps

Concrete steps See: http://www.cnblogs.com/pigeon84/articles/2234214.html

Tar xjf busybox-1.7.0.tar.bz2//Unzip

CD busybox-1.7.0//Enter directory

Make Menuconfig//Enter the configuration menu

One is to choose the dynamic Library compilation in the compilation option, of course you can also choose static, but then build the root file system than the dynamic compilation of the larger.

->busybox Settings

->buildoptions

->buildshared Libbusybox (selected)

The second is to select the tab completion function in the Performance tuning option.

->busybox Settings

->busyboxlibrary Tuning

->commandline Editing (selected)

->tabcompletion (selected)

The rest is a few command configurations, and if you want to make your root filesystem command, choose that command. I choose the default configuration, general basic commands to help you choose.

2) Compiling BusyBox

Modify makefile, modify "arch?= arm" and "cross_compile?= arm-linux-", and then compile with the Make command. The following error occurred during the compilation process:

.. /ARM-NONE-LINUX-GNUEABI/LIBC/USR/INCLUDE/LINUX/NETFILTER.H:44:

Error:field ' in ' have incomplete type

Workaround:

Modifying the Arm-linux cross-compilation tool chain

Add missing header files at the beginning of the Usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include/linux/netfilter.h header file: #include < Netinet/in.h>

3) Install BusyBox

Here we first create a new first_fs to build the root filesystem,/share/first_fs is the directory where BusyBox is installed.

Then use the command [email protected]:/share/busybox-1.7.0# make config_prefix=/share/first_fs install for busybox installation. So below the/SHARE/FIRST_FS appears the following directories and files, you can see that LINUXRC is a link to busybox.

[Email protected] first_fs]# ls-l

Total 12

Drwxr-xr-x 2 root root 4096 Oct 05:41bin

lrwxrwxrwx 1 root root one Oct 11:17 LINUXRC-Bin/busybox

Drwxr-xr-x 2 root root 4096 Oct 18:43sbin

Drwxr-xr-x 4 root root 4096 Oct 16:52usr

Entering the bin directory, you can see that these files are all links to BusyBox (except the BusyBox itself).

[Email protected]_fs]# ls bin-l

Total 0

lrwxrwxrwx 1 root root 7 Oct 11:17addgroup-BusyBox

lrwxrwxrwx 1 root root 7 Oct 11:17adduser-BusyBox

lrwxrwxrwx 1 root root 7 Oct 11:17ash-BusyBox

-rwxr-xr-x 1 root root 0 Oct 13:20busybox

lrwxrwxrwx 1 root root 7 Oct 11:17cat-BusyBox

lrwxrwxrwx 1 root root 7 Oct 11:17catv-BusyBox

2. Install the GLIBC library.

Create a new Lib directory under First_fs mkdir lib, and then copy the Lib file under the arm-linux-cross-compilation chain to the Lib directory under our first_fs. I use

cp/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/* first_fs/lib/*-DF using the-D option means that the linked file is copied in the original link. Otherwise the linked file is copied over to a copy.

3. Building the/etc,/dev,proc Directory

/etc and/dev are required for a root file system. The/etc file should contain the configuration file Inittab required to start the init process. The dev directory contains the two device files required for INIT process startup and NULL. Proc directory to come in to mount the virtual proc file system of the kernel. This makes some commands for the process, such as PS, effective.

1) perform mkdir etc Dev proc in the First_fs directory

2) Create a new file under etc Inittab

Format of configuration information in Inittab I have explained it in my previous article, "Linux Transplant (iii)". We write two lines of configuration information inside.

:: Sysinit:/etc/init.d/rcs

:: askfirst:-/bin/sh

The first line is used to start the script file RCS, because we can use this file to boot the system to do a job for us, such as mount the file system or launch some other applications.

The second one is to start the shell interpreter sh

3) Configure the script file RCS (the script is executed first when the file system is loaded)

Create a new INIT.D directory mkdir INIT.D under etc, and then create a new RCS file in the INIT.D directory,

Add the RCS file with executable permission chmod +x RCS.

Write in the RCS directory

#!bin/sh

#mount –a

MOUNT-T proc None/proc

The Mount–a command is executed in RCS, so the command will mount the corresponding directory according to the ETC fstab file.

4) Configure the Fstab file

Create a new Fstab file in the ETC directory and write it in the file (to write shelf)

# device Mount-point type options dump fsck order

PROC/PROC proc Defaults 0 0

The first parameter is the device, the second one is the mount point, and the third is the setting. The rest of the write two a 0.

5) Build the device files under the Dev directory.

Because the console and null devices are required for the INIT process to start, the two device files are created, enter the Dev directory, and then execute

Mknod Console C 5 1

Mknod NULL C 1 3

If these two device files are not manually mknod created, an error occurs when the kernel boots:

Warning:unable to open an initialconsole.

Note that the two device files must be created under Dev. I was confused in the ETC directory to create the two files, the majority of talent to find the reason. Also in the CD etc or CD dev do not in the etc and Dev in front of the slanting slash, I was the hand of the cheap, hit the slash, the results entered the Linux system on the PC etc directory deleted some files, causing the system crashes.

Complete the above steps, the root file system made into a YAFFS2 image burning to flash can be started normally.

5. Configure the Mdev to support hot swapping (there is a problem with the experiment)

BusyBox uses a mdev in the Sbin directory to support hot-swappable, what is called hot-swappable? is when you plug in a device when your Linux system starts, Mdev will automatically create the device file for you in the dev directory.

In the/busybox source code in the Mdev.txt have introduced. I intercept the sections below

Mdev has a primary uses:initialpopulation and dynamic updates. Both

Require SYSFS support in the kernel andhave it mounted at/sys. For dynamic

Updates, you also need to havehotplugging enabled in your kernel.

Here's a typical code snippet from Theinit script:

[1] mount-t Sysfs Sysfs/sys

[2] Echo/bin/mdev >/proc/sys/kernel/hotplug

[3] Mdev-s

Of course, a more ' full ' setupwould entail executing this before the previous

Code snippet:

[4] mount-t Tmpfs Mdev/dev

[5] Mkdir/dev/pts

[6] mount-t devpts devpts/dev/pts

The simple explanation, here is, [1]you need to have/sys mounted before

Executing Mdev. Then you [2] instruct the kernel to Execute/bin/mdev whenever

A device is added, or removed so, thedevice node can be created or

Destroyed. Then you [3] Seed/dev with all the devicenodes that were created

While the system was booting.

For the ' full ' setup, you wantto [4] Make Sure/dev is a TMPFS filesystem

(Assumingyou ' re running out of Flash). Then you want to [5] Create the

/dev/pts mount point and finally [6]mount the devpts filesystem on it.

When we use it in flash, we only need the front [1][2][3] step. That

[1] mount-t Sysfs Sysfs/sys

[2] Echo/bin/mdev >/proc/sys/kernel/hotplug

[3] Mdev-s

So we changed the Etc/init.d/rcs file to

Mount–a

Echo/bin/mdev >/proc/sys/kernel/hotplug

Mdev-s

Change the Ect/fstab file to

# device Mount-point type options dump fsck order

PROC/PROC proc Defaults 0 0

Sysfs/sys Sysfs Defaults 0 0

Then create a new sys directory under FIRST_FS mkdir sys.

So we make a YAFFS2 image can support the automatic creation of device files, note that the built-in console and null device files cannot be deleted, because they have been used before mdev work.

6. Perfect the root file system.

1) Add the Inittab under the ETC directory

:: Ctrlaltdel:/sbin/reboot

:: Shutdown:/bin/umount-a-R

:: Restart:/sbin/init

To specify additional work done by the system when performing Special operations commands (Shultdown, restart, Ctrlaltdel).

2) Create a new MNT, TMP, and root directory under FIRST_FS

7. Make YAFFS2 image

Copy directory: F:\ Vedon \cd1_ main disc \system tools

yaffs_source_util_larger_small_page_nand.tar.bz2 to/share directory, and Unzip

Enter the \DEVELOPMENT_UTIL_OK\YAFFS2 directory, execute the make command to generate the Mkyaffs2image tool, and copy it to the/usr/local/bin directory.

Cp Mkyaffs2image/usr/local/bin

Chmod +x/usr/local/bin/mkyaffs2image

Return to the/share directory and make the FIRST_FS in the share directory into a YAFFS2 file system.

Execute command mkyaffs2image first_fs FIRST_FS.YAFFS2

Download FIRST_FS.YAFFS2 via U-boot.

The following issues may be encountered during the migration of the root file system:

When the Linux kernel boots the root filesystem, the card is stuck here, and the solution looks as described in the kernel porting.

Block 535 is bad

Block 809 is bad

Block 937 is bad

Block 1898 is bad

vfs:mounted Root (yaffs filesystem).

Freeing Init memory:136k

Embedded Root file system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.