Android Rom creation and Installation

Source: Internet
Author: User
Tags spl

After the android source code is compiled, three image files generated under out/target/product/generic: ramdisk. IMG, system. IMG, userdata. IMG and their corresponding directory tree root, system, and data. Ramdisk. IMG is the root file system, system. IMG includes the main packages, libraries, and other files, userdata. IMG includes some user data. After Android loads these three image files, it loads system and userdata to the system and Data Directories In the ramdisk file system respectively.

The generation relationship between the three image files and the three directory trees is the basis for Rom creation. The following describes in detail.

Ramdisk. img
Ramdisk images are packaged using cpio and compressed using gzip. Verify with file:

# File ramdisk. img

Output:

# Ramdisk. IMG: gzip compressed data, from UNIX

To facilitate troubleshooting, copy ramdisk. IMG to another directory and restore ramdisk. IMG to a directory tree by following these steps:

# Mv ramdisk. IMG ramdisk.img.gz

# Gunzip ramdisk.img.gz

# Mkdir ramdisk

# Cd ramdisk

# Cpio-I-f ../ramdisk. img

In this way, we can get a complete ramdisk directory. After comparing it with out/target/product/generic/root, we find that they are the same content.

By performing the following operations, we can generate a ramdisk image from the directory tree.

# Cd ramdisk

# Find. | cpio-o-h NEWC | gzip> ../ramdisk-new.img

System. IMG & userdata. img
Both images belong to the yaffs2 file format and are generated in the same way. Let's take system. IMG as an example.

System. img> system directory tree
Required tools unyaffs, http://code.google.com/p/unyaffs/downloads/list

# Mkdir System

# Cd System

# Unyaffs ../system. img

System directory tree> system. img

The required tool mkyaffs2image, Android source code compilation will generate this tool, in the out/host/linux-x86/bin directory.

Command Format:
Go to the directory where mkyaffs2image is located and set the execution permission chmod A + X./mkyaffs2image

#~ /Code/cbin/mkyaffs2image ~ /Code/system ~ /Code/system_new.img

The significance of understanding the above method is that we can modify and customize the image file image to meet our own needs.

How to Create Android Rom
There are many tutorials for creating Android ROM on the Internet. Here are some links:

Two articles written by Chen Yu of Beijing Institute of TechnologyArticleIt is the best tutorial I have found at the moment, which is very detailed.

Http://blog.chinaunix.net/u/26691/showart_2193396.html

Http://blog.chinaunix.net/u/26691/showart_2194274.html

These two articles refer to several classic tutorials on foreign forums:

Http://forum.xda-developers.com/showthread.php? T = 566235

Http://android-dls.com/wiki/index.php? Title = HOWTO: _ unpack % 2c_edit % 2c_and_re-pack_boot_images

Another article in China is well written. This article focuses more on creating Rom packages similar to patch.

Http://www.cnmsdn.com/html/201002/1267213800ID1030.html

Here, based on your own understanding and testing, we have summarized some methods and steps.

1. Start from available Rom
Android rompackets are usually called update.zippackets. You can download your. Zip package from www.hiapk.com. To learn how to create a rom package, we can start with a zip package. After the zip package is unwrapped, the following content is usually found:

Boot. img
File
This is to compile the kernelSource codeThe generated kernel image is then ramdisk compiled with the android source code. IMG was created through the mkbootimg tool together. Friends who save time can copy a usable image from other online refresh tools, which is almost the same.
META-INF
Directory
This directory is created manually and is mainly used to store an update-script (the content of this script is closely related to the files contained in the system directory) and a signature.
System
Directory
This directory is used to compile the Android platform source.CodeGenerated

To create a Rom, we usually involve the following tasks:

1. Compile the kernel to generate the kernel image. However, in general, we do not have to compile it by ourselves. We can simply extract one from the refresh box. For example, you need to create an upgrade package for Version 2.2. You can go to the Internet to find a refresh box that matches your own model and retrieve the corresponding kernel. IMG from it.

2. Modify ramdisk. IMG. Ramdisk. IMG is the root file system, which contains the startup configuration script.

3. Update-script modification.

4. modify the system.

Let's do a simple test to pave the way for more complex work. Test content: First unpack the ZIP file, then add a small file under the root directory of ramdisk and system, generate a new ROM, and verify whether the Rom is available.

For detailed steps, see http://blog.chinaunix.net/u/26691/showart_2194274.html. It should be noted that this article and many similar websites mentioned on the Internet all target HTC G1 or Nexus One. During the test, I used HTC G3 hero. One consequence of the above method is that the machine cannot be started normally and the ADB shell cannot be logged in after the package is repackaged. Later, I saw a description of the problem in a foreign blog. The root cause of the problem is very simple. From G3, the "-- base" parameter needs to be specified during packaging. For hero, the parameter is "-- Base 0x19200000", but for machines of other models, the value of "-- base" must be determined by referring to the implementation of the kernel code.

Unpackage two scripts are available to complete the unpack-bootimg.pl, repack-bootimg.pl. The mkbootimg tool used in the packaging script is in the out/host/linux-x86/bin directory. The unpack-bootimg.pl can directly build the boot. IMG kernel image boot. IMG-kernel and ramdisk directory tree boot. IMG-ramdisk. The repack-bootimg.pl can regenerate boot. IMG-kernel and boot. IMG-ramdisk.

After unpacking, add a test small file (such as mytest) under the ramdisk and System directories ). After completing the initial package, we will generate an update.zip file. At this point, our work is not completely completed, and there is still the last step-signature. The signature tool testsign. jar is used for signing. This is a Java 1.6-based tool. When compiling the android source code, we emphasize the use of Java 1.5. Here, we must switch to version 1.6. For the switchover method, see here.

2. Use a self-compiled image to generate a ROM
1) regenerate boot. img

Put the boot. IMG-ramdisk and the root directory tree under out/target/product/generic/after the source code is compiled in one directory, and then regenerate boot. IMG with the repack-bootimg.pl.

2) create a directory named myupdate and put the boot. IMG generated above into this directory.

3) After compiling Android, copy the system directory tree generated by out/target/product/generic/to the myupdate directory.

4) Create the update-Script script directory under the myupdate directory.

# Mkdir-P META-INF/COM/Google/android

5) Delete the "Symbolic Link" in the system/bin directory and create an update-Script script.

For the update-script syntax, refer to here. After studying the original Update-Script script, we can see that update-script is responsible for file deletion and copying, permission setting, and symbolic link creation. We can modify the original Update-script to get our own update-script. Here, we should note that to ensure that the link of update-script is successfully created, the link under/system/bin must be deleted. We can use a script to perform this task delsymlink. The modified script matches the self-compiled android2.2 system directory tree.

6) re-package and sign

7) An error is reported when downloading the self-made Rom.

During the experiment, I often encounter the following errors:

Can't open/sdcard/download/update. hiapk

Cause: When a command operation error occurs in update-script, the script stops and reports this error. The solution is to correct the script. You can refer to the prompt above this error to know which line of the script has an error.

3. Create a ROM for the patch Function
In many cases, you do not need to create a complete Rom package. All you need is to add, delete, or modify some features (for example, you only want to add an application, or you want to add the busybox tool ). We can refer to this for this purpose.

I will use a simple example to illustrate this process. In this example, add a mytest file under the system directory, and create a mylink that points to the file. The process is as follows:

1) Create the patch_update directory and execute

# Mkdir System

# Mkdir-P META-INF/COM/Google/android

2) generate the mytest file in the system directory

3) In META-INF/COM/Google/Android create the following update-script

Show_progress 0.1 0

Copy_dir package: System system:

Symlink mytest system: mylink

Set_perm 0 0 0755 system: mytest

4) package the signature

If you have mastered the previous three steps, you should be able to cope with your daily work. But to become a real rom guru, you still have a lot to cultivate. You need to understand the entire startup process, kernel compilation, Android source code compilation and configuration, file system and startup configuration...

Install android
An article on HTC's official website details the image package and machine burning methods. Two methods are usually used: recovery mode and fastboot mode. You can use some key combinations to enter the burning mode. Take HTC G3 hero as an example. If you press "Home + power" at the same time, you can enter the recovery mode and "back + power" can enter the fastboot mode.

The recovery mode is commonly used. It is equivalent to the download mode on the menu interface. Directly put the previously described update.zip file on the SD card, and then you can complete the installation by operating the control menu on the machine. Fastboot is a low-level download mode based on command lines. It can directly burn. imgfiles. The fastboot tool is also in the out/host/linux-x86/bin directory.

During my test, I found that the fastboot mode could not be burned. When I tried to burn system. IMG, the following error message was displayed:

# Fastboot flash system. img

# Writing 'system'... infosignature checking...

Failed (Remote: Signature verify fail)

After checking on the Internet, it is found that this is related to the signature. SPL needs to refresh it. The default value is SPL-on, which is to check the signature and change it to SPL-off, there will be no such problem, and there is no good way to solve it. Fortunately, the rediscovery mode can meet the requirements well. You can discard fastboot first.

If you find that the system cannot be started normally after using the recovery mode, recovery can still be used. In recovery mode, you can log on to the machine through the ADB shell. After you enter, you may find that the SD card is not mounted (you can view the mounting status by executing the mount command ). But the recovrypattern requires that update.zip be placed in the root directory of the SD card. What should I do? You can mount the SD card area by running "Mount-. If this is not the case, another trick is to manually mount the userdata partition to the sdcard Directory, which will lead to a rediscovery scam.

# Mount/dev/mtdblock5/sdcard

Then, you can use ADB pushto copy the new update.zip file to the sdcard directory and record it. Generally, before executing "Flash zip from sdcard", you must first perform the wipe operation to clear old user data.

How to update recovery?

Can reference http://bbs.gfan.com/viewthread.php? Tid = 66973, according to this strategy, update their G3 hero into a recovery-RA-hero-v1.6.2-blue.img. However, there are generally no special requirements and it is best not to update the recovery. After all, there is a certain risk, and it turns into a brick.

Other reference information:
Well-known Android forums:

Domestic: www.hiapk.com

Foreign: http://android-dls.com many domestic forum articles are reference or translation http://android-dls.com

A good blog in China: http://xy0811.spaces.live.com/, there are a lot of research topics on Android

A good foreign blog: http://blog.coralic.nl/category/android/, this blog helped me solve the problem of HTC G3 hero in the burning, hard to start after the ROM package burning

Android File System

Http://www.ibm.com/developerworks/cn/linux/l-k26initrd/

Http://developer.51cto.com/art/201001/180468.htm

Http://git.source.android.com /? P = kernel/common. Git; A = blob; F = documentation/filesystems/ramfs-rootfs-initramfs.txt

Http://dev.firnow.com/course/6_system/linux/Linuxjs/20090901/173312.html

Android init script syntax

Http://blog.chinaunix.net/u3/103613/showart.php? Id = 2237012

Http://www.kandroid.org/android_pdk/bring_up.html

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.