Build Linux root file system with BusyBox (reprint)

Source: Internet
Author: User
Tags bz2 parse error

Note: This article reproduces the Linux root file system built from http://blog.sina.com.cn/u/2478597014 with BusyBox (2015-07-05 14:25:02)  VMS: Virtual Box4.2.6 and VMware Workstation6.5.2 (both virtual machines have been successfully implemented) development environment: Linux version 2.6.32 with UBUNTU10.04ARM-LINUX-GCC version: 3.4.1BusyBox version: 1.7.0Development Board: Infineon Embedded s3c2440Development Board Linux kernel version: linux2.6.28 First, the concept:
Linux is not like Windows has the C, D, E, F and other drive letter concept, it is a fast tree management of all directories and files, the other partitions are hooked up to a directory, this directory is called Mount Contact, you can then access the files on this partition through this directory. The root file system is hooked up to the root directory "/" and there is a root file system directory under the root directory. Similar to Windows C drive, Linux needs to store system boot-up files (such as kernel image files, the first program that runs after kernel boot (init), shell, application-dependent libraries, etc.) on a partition, and these must be files that are called root file system,It's stored in a partition. . Linux starts by hooking up this partition first, called hooking up the root file systemSecond, installation configuration BusyBoxFirst you need to install and configure BusyBox, which uses busybox-1.7.0.tar.bz2,Put it in the virtual machine/home/book Directory decompression: Input decompression command: Tar xjf busybox-1.7.0.tar.bz2,Then go to the Unpacked folder ,Found it INSTALLThis file ,and copy to the shared folder:
Open the file through the software under Windows and write the steps to install BusyBox:
1. First go back to BusyBox extract directory, make Menuconfig

Then come out a configuration busybox Options window, similar to configuring the kernel window
Here mainly in accordance with Vedon video and books inside the configuration, mainly add a tab to complement the full key function, the general default BusyBox wood has this function, configuration of this function will bring great convenience to the embedded development research
Then need to modify the BusyBox inside the makefile file, vi makefile after the cross-compiler modified to arm-linux-
2. Then perform the second step: make, the result is 2 error
Find answers by Baidu: (1) Miscutils/taskset.c:17:error:parse error before ' * ' token   miscutils/taskset.c:18: Warning:function declaration isn ' t a prototype   miscutils/taskset.c:in function ' __from_cpuset ':    miscutils/taskset.c:22:error: ' Cpu_setsize ' undeclared (first use of this function)  miscutils/ Taskset.c:22:error: (Each undeclared identifier are reported only once   miscutils/taskset.c:22:error:for each function it appears in.)    miscutils/taskset.c:26:warning:implicit declaration of function ' Cpu_isset '   miscutils /taskset.c:26:error: ' Mask ' undeclared (first use of this function)   miscutils/taskset.c:in function ' Taskset _main ':    miscutils/taskset.c:47:error: ' cpu_set_t ' undeclared (first use with this function)    miscutils/taskset.c:47:error:parse error Before "Mask"    miscutils/taskset.c:68:warning: Implicit declaration of function ' Cpu_zero'   miscutils/taskset.c:68:error: ' New_mask ' undeclared (first use of this function)   miscutils/ Taskset.c:69:error: ' Cpu_setsize ' undeclared (first use of this function)   miscutils/taskset.c:71:warning:i Mplicit declaration of function ' Cpu_set '   miscutils/taskset.c:78:error: ' Mask ' undeclared function) Make[1]: * * * [MISCUTILS/TASKSET.O] Error 1   make: * * * [miscutils] Error 2      Workaround: Make Menuconfig Find [Miscellaneous Utilities], remove [task set](2) solve the problem (1) and make another problem (2)
Again Baidu learned the answer:
and then make on the success!!! 3. Next is make install, but cannot be executed directly under this directory, it will cause confusion, and a separate file system directory should be built mkdir-p/home/book/firstfs,And then execute Make config_prefix=/home/book/firstfs install,After the install is entered into the directory, a root file system is built in the directory. building the root file systemSome root file system directories have been built using BusyBox, but the device files, application execution files, libraries, and configuration files have not yet been generated, so these files need to be built below. 1. Creating/dev/console and/dev/nullView the two device number information in/etc in the virtual machine's Linux root directory and mknod the two devices under the new root file system
2. Create/etc/inittabUnder the root file system directory, create InittabFile, first mkdir etcAnd then VI etc/inittab, enter the following:
View Inittab file Contents: 3. Build C libraryThe Linux version under the virtual machine differs from the C library location, which is first established under the Firstfs root file system directory. Libdirectory, and then place the virtual machine under the Linux system as shown in the library file ( files with the. so extension) to the Lib directory under the new root file system, where the library file contains. So is what we need. Dynamic Library FilesNote: For the general Virtual machine Linux system, such C library is in the corresponding version of the cross-compiler in the Lib library, such as my flight Development Board for the general Ubuntu system is/usr/local/arm/3.4.1/arm-linux/lib
4. Set up the minimum root file systemWe have established the minimum root file system in the/home/book/firstfs directory under the virtual Machine Linux environment, as shown in the above operation.
Iv. making yaffs image files, burning to the Development Board 1. Install the command that generates the YAFFS2 image fileHere, using the yaffs_source_util_larger_small_page_nand.tar.bz2 file provided by JZ2440, is a yaffs version containing a large page of small-page flash, which goes into the directory and extracts tar xjf yaffs_source_util_larger_small_page_nand.tar.bz2Get DEVELOPMENT_UTIL_OKFile:
Enter the directory under the YAFFS2Catalogue, re-entry UtilsDirectory, and then execute it in this directory Make
Generated mkyaffs2image and mkyaffsimage two execution files, because my FL2440 NAND falsh is large page (like JZ2440 NAND flash), so just use the Mkyaffs2imageFile:
2. Making yaffs image FilesThe generated mkyaffs2image file is CP to the virtual machine Linux system root directory under the/usr/local/bin directory, and Plus executable Permissions, and then go back to the/home/book directory, ready to generate an image file for the entire FIRSTFS root file system directory:
Input command Mkyaffs2image, you can see that the command's usage (usage) appears below, that is, there are at least 2 arguments behind the command, and the first parameter is root File system directory, the second parameter is the generated image file name。 Enter the full command again based on the usage: mkyaffs2image FIRSTFS/FIRSTFS.YAFFS2
Then the image file for the minimum root file system is generated. FIRSTFS.YAFFS2
Then launch the Development Board, the image file via USB on the U-boot Interface Command menu FIRSTFS.YAFFS2Write to the Development Board corresponding to the file system partition Fs_kernel, and then restart the development Linux system, successfully entered the command line interface, so that the minimum root file system migration succeeded:
v. Further perfecting the root file systemAlthough the minimum root file system successfully migrated successfully, but is the smallest root file system, like the microcontroller minimum system, many applications are not added, including the simplest PS CommandCan not be used, and has not been added udev mechanism, so that the drive device cannot be added automatically, which requires further refinement of the file system. 1. Hooking up the virtual file systemVery good for application commands (such as PS), or Mdev( a simple version of the udev mechanism) All need to hook up the corresponding virtual file system (VFS) to implement, of course, we can in the Development Board shell command Line input: MOUNT-T proc None/proc to implement in the directory/proc hook proc file system. But for more file systems to manually add more trouble, we can also add mount commands to the Linux boot script, so that the Development Board Linux boot automatically hooked up those virtual file system. establishment of the 2.MDEV mechanismThere is a mdev mechanism in BusyBox, it is a simple version of the udev mechanism, we can go to the BusyBox installation folder to find its information, we can find Mdev.txt, after Windows opened, its basic usage (basic use) has 6:


We add these 6 dots separately to the /etc/fstabAnd /etc/init.d/rcsfile that is not established can be first mkdirAnd VI(Some files need to add permissions), including virtual file system directories that need to be mounted /proc,/sys,/tmpsuch as

We can add some mount commands under boot script/etc/init.d/rcs (this directory can be mkdir first, then VI RcS):
Where the mount-a command is to call the contents of the/etc/fstab file to hook up the system, it is also necessary to create a fstab file, Vi/etc/fstab, and add a virtual file system that needs to be hooked up, such as:
And for/etc/init.d/rcs scripts to be added to the /etc/inittabTo start the file:
Then go back to the/home/book directory, and once again make the root file system image file burned to the development Board, namely: mkyaffs2image FIRSTFS/FIRSTFS.YAFFS2
Such a more complete root file system is successfully transplanted!!!

Build Linux root file system with BusyBox (reprint)

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.