Production of the yaffs2 root file system

Source: Internet
Author: User

 

Production of the yaffs2 root file system

 

Environment:

 

Cross-compilation environment: 4.3.3 (provided by tianyintech, storage path/opt/embedsky/4.3.3)

 

Development Platform: tq2440

 

 

1. Compile busybox

 

Busyboxsource code busybox-1.17.2.tar (http://www.busybox.net/downloads)

 

Put in directory/opt/embed

 

# Tar jxvf busybox-1.17.2.tar.bz2

 

# Cd busybox-1.17.2

 

# Vim makefile

 

Change row 164 to cross_compile = arm-Linux-change row 190 to arch = arm

 

Save and go to the configuration menu

 

# Make Men onfig is saved using the default configuration.

 

# Make

 

# Make install

 

A _ install directory appears under the root directory of the busybox-1.17.2, where there are three directory files bin sbin USR and a link file linuxrc.

 

2. Create necessary directories for the root file system

 

Go back to the/opt/embed directory and create the necessary directory for the root file system.

 

# Mkdir root_fs

 

# Cd root_fs

 

Upload the three generated directories bin sbin USR and a link file linuxrc to the directory root_fs.

 

# Cp-RF ../busybox-1.17.2/_ install /*./

 

# Mkdir Dev etc home lib MNT opt proc root sys TMP VaR

 

Create several necessary level-2 Directories

 

# Mkdir usr/lib usr/share

 

# Mkdir etc/rc. d

 

# Mkdir var/lib var/lock var/run var/tmp

 

3. create necessary files

 

 

(1), get the library file (my cross-compilation tool chain is put under the directory/opt/embedsky)

 

# Cp-RF/opt/embedsky/4.3.3/ARM-None-Linux-GN? I/libc/armv4t/lib/* So * Lib-

 

(2) copy the passwd, group, and shadow files under the etc directory of the host to the root_fs/etc directory.

 

# Cp-F/etc/passwd/etc/group/etc/shadow etc

 

Copy all files under the/opt/embed/busybox-1.17.2/examples/bootfloppy/etc directory

 

Root_fs/etc. This directory contains three files: fstab, inittab, profile, and init. d,

 

In the init. d directory, there is a file RC.

 

# Cp-RF ../busybox-1.17.2/examples/bootfloppy/etc/* etc

 

Create the mdev. conf file under the etc directory. What is mdev? A simplified version of V. You can use the mdev. conf file to customize the names or links of some device nodes to meet specific requirements, but leave it blank here.

 

# To H etc/mdev. conf

 

(3) create two Device Files DEV/console DEV/null.

 

In the Linux kernel source code file init/Main. C, you can open the device file DEV/console as follows:

 

Static noinline int init_post (void)

 

_ Releases (kernel_lock)

 

{

 

....................................

 

If (sys_open (const char _ User *) "/dev/console", o_rdwr, 0) <0)

 

Printk (kern_warning "Warning: Unable to open an initial console. \ n ");

 

....................................

 

}

 

When the kernel is started and executed here, mdev has not yet built the dev directory. If no device file DEV/console is created, the warning: Unable to open an initial console will be printed.

 

When the kernel is started, an empty device DEV/null is required to discard some junk information.

 

# Mknod DEV/console C 5 1

 

# Mknod DEV/null C 1 3

 

4. modify several necessary files

 

During the startup process, bootloader will pass the init =/linuxrc parameter to the main () function of the kernel. Therefore, after the file system is mounted, the first program to be run is linuxrc, linuxrc is a link file pointing to/bin/busybox. That is to say, the first program running after the file system is Hung is busybox. Busybox first parses the file/etc/inittab, which stores the system configuration information, which specifies the programs to be started next.

 

(1) modify the ETC/inittab file as follows:

 

: Sysinit:/etc/init. d/RCS

 

Tq2440_serial0: askfirst:-/bin/sh

 

: Ctrlaltdel:/sbin/reboot

 

: Shutdown:/bin/umount-a-r

 

Each entry in the/etc/inittab file is used to define a sub-process and determine its startup method. The format is as follows:

<ID >:< runlevels >:< action >:< process>

 

<ID>: indicates the console (standard input, standard output, and standard error device) to be used by the process ). If this parameter is omitted, the console is the same as the INIT process.

<Runlevels>: For the busybox INIT program, this field slide meaning can be omitted.

<Action>: indicates how the INIT program controls this sub-process,

<Process>: the program to be executed. It can be an executable program or a script.

 

 

The configuration entries in the ETC/inittab file are described as follows:

 

: Sysinit:/etc/init. d/RCS

 

Start the system initialization file/etc/init. d/RCS. The sysinit field indicates that the file/etc/init. d/RCS is executed first after the system is started, and only once, the INIT process continues to execute other actions until it ends.

 

(Generally, the script file name is RC, And the suffix "S" indicates the script running level for a single user)

 

Tq2440_serial0: askfirst:-/bin/sh

 

Start the shell of the askfirst action on the serial port tq2440_serial0. The serial port name of S3C2410 is s3c2410_serialx under/dev. At this time, you have not transplanted your own kernel. The serial port name is tq2440_serial0 because the kernel of tianyined technology is used. Askfirst indicates that the INIT process outputs "Please press enter to actvie this console" and starts-/bin/sh only after you enter the Enter key.

 

: Ctrlaltdel:/sbin/reboot

 

When you press CTRL + ALT + Delete, init restarts the program. The field ctrlaltdel indicates that the process is executed when CTRL + ALT + Delete is pressed.

 

: Shutdown:/bin/umount-a-r

 

Tell init to run the umount command to uninstall all file systems when it is shut down. If the unmount fails, try to remount the file system in read-only mode. The shutdown field indicates that the corresponding process is executed when the system command is restarted and shut down.

 

(2) After the ETC/inittab file is parsed, these processes will be started. The first thing to execute is the startup script etc/init. d/RCS.

 

Modify the etc/init. d/RCS file as follows:

 

#! /Bin/sh

 

Path =/sbin:/bin:/usr/sbin:/usr/bin

 

Runlevel = s

 

Prevlevel = N

 

Umask 022

 

Export path runlevel prevlevel

 

/Bin/hostname cyembed

 

Echo "---------- mount all ----------"

 

/Bin/Mount-

 

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

 

Mdev-S

 

Echo "**************************************"

 

Echo "**************************************"

 

Echo "kernel version: linux-2.6.30.4"

 

Echo "Date: 2010.09.16"

 

Echo "**************************************"

 

Description:

 

#! /Bin/sh use the shell of busybox

 

Path =/sbin:/bin:/usr/sbin:/usr/bin // search path of the shell command

 

Runlevel = S // run in Single User Mode

 

Prevlevel = N // the previous level is N, indicating that no previous level exists.

 

Umask 022 // permission mask

 

Export path runlevel prevlevel // export the set variables to the environment

 

/Bin/hostname cyembed // host name, cyembed will appear in the shell prompt [root @ cyembed/] #

 

/Bin/Mount-A // mount the file system specified in the file etc/fstab to the corresponding mount point

 

Echo/sbin/mdev>/proc/sys/kernel/hotplug // use mdev to handle kernel hot swapping events.

 

When a hot swapping event occurs, the kernel calls the mdev in the/sbin directory. At this time, mdev uses the action and devpath in the environment variable (these two variables are included in the system) to determine the action of the hot swapping event and the directory in/sys. Check whether the "Dev" attribute file exists in the directory. If yes, use this information to create a device node file for the device under/dev.

 

 

 

Mdev-S // create the dev directory. Call mdev written in the/sbin directory with '-S' as the parameter (in fact, it is a link to pass the parameter to the busybox program in the/bin directory and call it ), mdev scans all the class device directories in/sys/class and/sys/block. If the directory contains a file named "Dev" and the file contains a device number, then mdev uses this information to create a node file for the device under/dev. Generally, "mdev-s" is executed only once at startup ".

 

(3) modify the file etc/fstab as follows:

 

# Device Mount-point type option dump fsck order

 

Proc/proc defaults 0 0

 

None/tmp ramfs defaults 0 0

 

Sysfs/sys sysfs defaults 0 0

 

Mdev/dev ramfs defaults 0 0

 

Run the mount command/bin/Mount-A in the system startup initialization file/etc/init. d/RCs, which is

 

Mount the file system specified in the file etc/fstab to the corresponding mount point. The mounting of these file systems is execution.

 

The premise that the mdev-s command establishes the dev directory.

 

(4) After the startup script etc/init. d/RCS is executed, a shell is started at the serial port tq2440_serial0. During shell startup, the login environment is configured according to the file/etc/profile.

 

Modify the/etc/profile file as follows:

 

User = "'id-UN '"

 

LOGNAME = $ user

 

PS1 = '[\ U @ \ H \ W] #'

 

Path = $ path

 

Hostname = '/bin/hostname'

 

Export user LOGNAME PS1 path

 

Details:

 

User = "ID-UN" // get the username ID-UN has the same function as the whoami command

PS1 = '[\ U @ \ H \ W] #' // PS1 specifies the sh prompt format. In this environment, it will be [root @ cyembed/] #

 

Export user LOGNAME PS1 path to export these variables to the environment.

 

(5) When a user logs on, the user will search for the three files passwd, shadow, and group in/etc to match the relevant information.

 

These three files are modified as follows:

 

/Etc/passwd

 

Root: X: 0: 0: Root:/root:/bin/bash

 

Bin: X: 1: 1: Bin:/bin:/sbin/nologin

 

Daemon: X: 2: 2: daemon:/sbin/nologin

 

FTP: X: 14: 50: FTP user:/var/ftp:/sbin/nologin

 

Nobody: X: 99: 99: Nobody: // sbin/nologin

 

/Etc/group

 

Root: X: 0: Root

 

Bin: X: 1: Root, bin, daemon

 

Daemon: X: 2: Root, bin, daemon

 

FTP: X: 50:

 

Nobody: X: 99:

 

/Etc/shadow

 

Root: $6 $ hnswptgxzfazhlll $ wmmv0av6o6c4ra4pwpvsgcksiurhulp5dxf3/keys/: 14819: 0: 99999: 7 :::

 

Bin: *: 14715: 0: 99999: 7 :::

 

Daemon: *: 14715: 0: 99999: 7 :::

 

FTP: *: 14715: 0: 99999: 7 :::

 

Nobody: *: 14715: 0: 99999: 7 :::

 

5. Create a yaffs2 root file system image

 

Use the yaffs2 file system image creation tool mkyaffs2image provided by tianyintech to create the root file system image.

 

#./Mkyaffs2image root_fs root_fs.bin

 

6. Download the root file system image to NAND Flash and start

 

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.