Busybox1.13.3 create a yaffs2 root file system (static and dynamic)

Source: Internet
Author: User

Busybox1.13.3 create a yaffs2 root file system (static and dynamic)15:09:34

Category: Linux

Preparation tool 1: mkyaffs2image

Purpose: Create a target file system image.

Tool 2: busybox

Purpose: generate the target file system. I have an introduction to it on the Internet.

The above tools are from the friendly arm http://www.busybox.net/downloads /. Cross-compilation tool arm-linux-gcc4.3.2. (We sincerely thank the resource and information providers)

Production process:

Select the busybox-1.13.3.tgz version and compile it statically, that is, the generated busybox runs without the support of the shared library. In this way, we do not need to deploy the library. The disadvantage is that the self-written arm-Linux program cannot run in this root file system because it lacks support for shared libraries. But don't worry. Mount the library file of the arm-Linux-GCC compiler on the host machine to/lib on the target machine by mounting NFS, we can run our own program perfectly.

Now, create the root file system of the static Link Library.

1. Prepare the root file system

Create a rootfs folder on the machine

# Mkdir rootfs

Create a typical folder in Linux in rootfs

# Cd rootfs

# Mkdir root home bin sbin etc Dev USR lib tmp mnt sys proc

# Mkdir usr/lib usr/bin

# Pwd

/Home/SU/rootfs

2. decompress the source code package.

# Tar xzvf busybox-1.13.3.tgz

# Cd busybox-1.13.3

3. Modify makefile,

# Vi makefile

In makefile

Cross_compile? =

Change

Cross_compile? = Arm-Linux-

4. Custom busybox

Select All executable programs in busybox

# Make defconfig

Enter configuration options

# Make menuconfig

Set static compilation Mode

Busybox settings ---> build options ---> [*] Build busybox as a static binary (no shared libs)

In busybox settings ---> install options --->, enter the path of the file that creates the root file system/home/rootfs.

Other default values.

Make sure that [*] Build busybox as a static binary (no shared libs) is selected, save and exit

5. Execute make Compilation

# Make

After compilation, busybox is generated and then executed

# Make install

Busybox is installed to/home/rootfs in the specified path. At this time, we can find that there is a liunxrc file in rootfs, and many files are added in BIN and sbin. Use the LS-l command to view a file. You can find that it is a connector linked to busybox. Therefore, most of the commands we run on the target machine will call the file busybox.

If you forget to specify the path, it is generated to the temporary directory busybox-1.13.3/_ install by default.

6. Write the initialization program under configuration/etc (which can be omitted)

The simplest way is to copy all the files under busybox-1.9.2/examples/bootfloppy/etc to the etc directory of the target file

# Cd/home/SU/busybox-1.9.2/examples/bootfloppy/etc

# Cp-RF */home/SU/rootfs/etc

You can also write these files by yourself.

7. Make rootfs an image

#./Mkyaffs2image 2 rootfs. yaffs2

8. Burn rootfs. yaffs2 to the target machine.

9. Run the target machine

An error message is displayed:

Can't open tty2

Can't open tty3

Can't open tty4

Solution: Delete the third line "tty2: askfirst:-bin/sh" of the/rootfs/etc/inittab file.

Return to Step 1 for redo.

10. Other operations

1) Use chmod 777 linuxrc to change the linuxrc attribute, otherwise it may not be executed.

2) The prompt "Warning: Unable to open an initial console" is displayed during running.

The original problem is that after devfs is canceled, the device will not be automatically generated, and no null or console will be available, so the device cannot be started. Solution:

Under rootfs/dev:

Mknod-M 660 null C 1 3

Mknod-M 660 console C 5 1

OK.

Bytes ------------------------------------------------------------------------------------------

In reality, The dynamic compilation method is more suitable for engineering needs, so it is generally used to compile the root file system dynamically. If you choose the dynamic compilation method, the general method is the same, there are some differences:

1 of the differences is:

Enter configuration options

# Make menuconfig

Select dynamic mode

Busybox settings ---> build options ---> [*] build shared libbusybox

2 of the differences is (the biggest difference ):

After compilation, enter the Lib in the rootfs directory and add some library files to it.

# Cd/home/SU/rootfs/lib

This is a little troublesome. How do I know what library file support is needed?

The simplest way is to copy the entire lib Library Under ARM-Linux-GCC 3.3.2, which is simple and easy to use. But there is a problem with this. The root file system is very large.

Another method is:

# Cd/home/SU/rootfs/bin

# Arm-Linux-readelf-DBusybox | grepSHared

This will display the library files required for the system to run, and then copy the corresponding library files to/home/SU/rootfs/lib. In general, the system library uses two: dynamic linker ld-linux.so and C function library glibc, glibc includes:

LD-Linux: Dynamic Link Library, required

Libc: Standard C function library, required

Libm: Math Library, generally required

Libdl: Used to dynamically load shared libraries, rarely used

Libcrypt: used to encrypt additional libraries. It is rarely used by programs requiring authentication.

Libpthread: POSIX thread library, which is generally required

If you need a function library, we can copy these libraries and the corresponding symbolic links to the/lib directory of the target root file system. For simplicity, use-DOption or-You can retain the complete symbolic link information.

Example:

# Cp-A libc. so.6/home/SU/rootfs/lib/

To reduce the size of the Runtime Library, we should use the Strip tool of the arm-Linux-GCC version to process the library files of the root file system, delete the symbol table and debugging information contained in the binary file.

Example:

# Arm-Linux-strip/home/SU/rootfs/lib/*. So

Where can I find the Lib of the Cross Compiler 4.3.2 ??

Previously, under usr/local/ARM/4.3.2/ARM-non-Linux-gnueabi/libc/lib *. the so file is copied to rootfs/lib/. After the result is downloaded, "kernel panic-not syncing: attempted to kill Init!" is returned!" Error message. Later, I finally thought that there may be a problem with the Library Link. Copy usr/local/ARM/4.3.2/ARM-non-Linux-gnueabi/libc/again/Armv4t/Lib file. The problem is solved!

Note: It has been plagued by the problem of dynamically compiling library files for a long time. I hope this article will be helpful to you. This article is originated from a netizen article and its own practice. I have not provided some references here. Sorry.

Address: http://hi.baidu.com/pingall/blog/item/d0ad750f3004dde7aa645768.htmlHttp://hi.baidu.com/pingall/blog/item/d0ad750f3004dde7aa645768.html

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.