Porting busybox Based on Android Kernel

Source: Internet
Author: User

First, compile the busybox source code and configure the following in menuconfig: busybox settings ---> build options ---> do not select static connections. to be dynamic, select the installation directory in Installation Options --->, and select [*] Don't use/usr. In this way, make install is not installed in/usr, but in the directory of your choice, here I select the self-created rootfs directory under the Code directory; then make; make install will be OK.

Go to the rootfs directory and create the following directory:

Mkdir dev;

Mkdir etc;

Mkdir sys;

Mkdir proc

Go to the dev directory,

Mknod console C 5 1;

Mknod null C1 3;

Return to the rootfs directory, CP/usr/local/ARM/4.2.2-Eabi/lib./-RD (the D parameter indicates that if the file is linked, copy the link ).

Mkdir etc/init. d;

Vim etc/init. d/RCs,

The content is as follows:

Vim etc/fstab:

After creating the smallest file system, package it into ramdisk. The command in the rootfs directory is as follows:

Find. | cpio-c-o> ../initrd_cpio.img

Find. | cpio-h newc-o> ../initrd_cpio.img
CD ../
Gzip initrd_cpio.img-F

Mkimage-A arm-O Linux-T ramdisk-C none-A 0x30800000-n "ramdisk"-D initrd_cpio.img.gz ramdisk_mmc.img

In this way, ramdisk is ready. Replace ramdisk_mmc.img in our update package, and modify the fuse file and uboot file because the generated ramdisk is large and has more than 6 MB, the ramdisk size will be checked during the update and uboot operations on ramdisk. If it is larger than 4 m, an error will be reported. Therefore, we need to increase the limit of 4 m to 8 m, modify framework/external/fuse/include/normal. size in H:

Modifying external/normal. C:

Also in uboot movi. h:

Check. C:

After the modification, compile and replace fuse and uboot in the update package. Then, modify the bootargs parameter in uboot, modify init =/linuxrc in policy_interface.c, and add the new parameter rdinit = linuxrc, otherwise, you will be prompted that the file system cannot be found. What is the specific cause? Check the init/main. C will know:

Therefore, if rdinit is not added, init will be used as the first application for execution, and the first program to be executed in busybox should be linuxrc. After the modification, compile the program, you can enter the control mode, but can't open/dev/tty2, can't open/dev/tty3, can't open/dev/tty4, the solution is to enter the init of busybox. in RC, comment out the following three lines:

The above uses ramdisk as the root file system. Here we will introduce the situation where no ramdisk is needed. Instead, we will directly place the busybox File System in the inand or sdcard partitions. For example, we will first use sdcard for mounting: first, we divide the sdcard partition in Linux. Here we divide two partitions. The first is the fat format (mmcblk1p1) and the second is the ext3 format (mmcblk1p2). Then we copy the busybox to the ext3 partition, then modify the uboot bootargs parameter: "setenv bootargs console = ttysac2, 115200 noinitrd
Root =/dev/mmcblk1p2 RW rootfstype = ext3 init =/linuxrc ", mainly root partitions and addition of noinitrd, it is best to put bootm. the ramdisk parameter passed to the kernel in C is also removed, so that the compilation and writing can be started to enter the console and check my successful log information:

In addition, the busybox file system is burned to inand. For example, it is very easy to replace the original Android system partition (mmcblk0p2, the difference from the previous sdcard production is that zip-r system_mmc.img system under busybox/rootfs, compress it, and replace system_mmc.img in update, note that you should put the busybox File System in a system folder and compress it. I didn't do this when I made the file system, and there was an empty system folder in the rootfs folder, the result is saved to the update package and the content in the empty system folder is written. As a result, the mmcblk0p2 partition is naturally blank and it takes a long time to find it, then the uboot
The bootargs parameter root = mmcblk0p2 is enough. Let's take a look at the created log:

Problem: after several days of re-writing and startup, I found that no partition can be mounted. The following message is displayed, because the run command is used in uboot. For example, run prg_kernel_sd. Otherwise, the mmc2 device cannot be found in the kernel, causing the mounting failure. The specific cause is not found yet!

Next we will introduce how to create and mount the cramfs file system as the root file system. The basic idea is to burn the cramfs compressed file package to an inand address, then it is automatically mounted to/dev/ram0 when the kernel is up. This is a bit like ramdisk mounting. First download the cramfs tool and run it in kernel rootfs/cramfs. IMG. Remember to use rootfs/instead of rootfs/*. Otherwise, an error is prompted. We here to burn write convenience, but also like ramdisk, Gzip compression and add uboot header file information, the last generation is the ramdisk-uboot.img (to burn write convenience, the name is the same, the content format is different from ramdisk), and then run in uboot
Prg_ramdisk_sd can be burned in. uboot also needs to be modified as follows: setenv bootargs console = ttysac2, 115200 root =/dev/ram0 RW ramdisk = 46080 rootfstype = cramfs init =/linuxrc

Because the file size is 8 Mb, you must increase the ramdisk size in the kernel. Otherwise, the system prompts "image too big" during mounting ", make menuconfig-> device drivers ---> [*] Block devices ---> default RAM disk size (Kbytes), change the value here to ramdisk, and then start it to enter the console, check my successful logs:

Related Article

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.