Our focus on Android ROM porting is compiled from the source level, but it is not easy to compile a system from the AOSP source to run on your own phone from scratch, as Google offers too few supported models. However, we can use ready-made third-party ASOP open source projects to carry out our Android ROM porting, they have adapted a large number of third-party models, and have also done their own optimization. The most famous third party open source project is CyanogenMod, the domestic millet MIUI, is also based on the CM to develop.
First, we want to analyze what is ROM? Rom is meant to be read-only memory, and what we call ROM actually refers to the phone's firmware (firmware), which is the flashrom that writes a system program to a particular hardware system. The handset firmware is equivalent to the handset's system, the refresh firmware is equivalent to the brush system, namely we often say the brush ROM.
The following analysis of the Android device from the hardware to the system structure
The bottom is a variety of hardware devices, to the upper layer is bootloader, is a small section similar to the BIOS program. The most widely used bootloader is a program called Uboot, which supports a very large number of architectures. After compiling, Uboot generates a uboot.bin image, burns the image to a specific partition on the device, and can be used as a bootloader. Bootloader supports interactive boot, that is, we can let bootloader initialize the hardware, not immediately to start the OS, but stay in the current state, waiting for the user to enter a command to tell it what to do next. This boot module is called the FastBoot mode. The ADB reboot bootloader command allows it to be restarted and into FastBoot mode.
Typically, a ROM with an embedded device that starts normally can contain the following four partitions:
1. Bootloader partition, which is the partition that holds Uboot.bin
2. Bootloader the partition used to save environment variables
3. Kernel partition, which is the partition that holds the OS kernel
4. ROOTFS partition, which is the program that is stored in the system's first process init
For Android devices, when it's in fastboot mode, we can swipe a recovery.img image containing kernel and rootfs through the FastBoot tool into a partition called recovery on the device. This process is the brush recovery, it is also part of the brush ROM. Since the recovery partition contains kernel and ROOTFS, after the recovery.img is brushed into the device, we can allow the device to start up normally. This starting mode is called recovery mode. For Android devices, we can use the ADB reboot Recovery command to get it into recovery mode. What can we do when the device is in recovery mode? The answer depends on the program included in the Rootfs included in the recovery.img that was brushed in. Rather, it depends on what the INIT program in the ROOTFS image does.
When the user is using the Android device normally, the system is composed of two partitions, which are mainly included: System partition and boot partition. The system partition contains the Android runtime framework, System app, and preinstalled third-party apps, and the boot partition contains kernel and ROOTFS. The two mirrors that are brushed into the system partition and boot partition are called System.img and boot.img, and we typically package and compress them into a zip file, such as Update.zip, and upload it to the SDcard on Android devices. So when we go into recovery mode, we can use the recovery interface to update the system that the user used to use the Android device with the zip package we uploaded to SDcard. This process is usually called the brush ROM.
Therefore, a complete brush ROM process consists of the following two steps:
1. Put the device into FastBoot mode and swipe into a recovery.img image
2. Put the device into recovery mode, and swipe into a zip package containing the system.img image and boot.img image
Next analyze what files are included in the Update.zip compressed package that is being brushed in?
1. The boot.img file, which is the kernel image compiled by the kernel source code, is then created by the Mkbootimg tool together with the ramdisk.img compiled by the Android source.
2. Meta-inf directory, this directory is created by hand and is used primarily to store an upgrade script Update-script (the content of this script is very much related to the files contained in the system directory) and the signature of the APK file in several brush packs.
3. System directory, which is generated by compiling the Android platform source code.
Android source code after compiling, the out/target/product/generic generated under the three image text Pieces: Ramdisk.img,system.img,userdata.img and their corresponding directory tree Root,system,data. Ramdisk.img is the root file system, System.img includes the main package, library and other files, Userdata.img includes some user data, Android loaded these 3 image files, the system and UserData will be loaded separately into The system and data directories in the RAMDisk filesystem.
To create yourself to create your own ROM, we usually involve some of the following tasks:
1. Compile the kernel to generate kernel images.
2. Ramdisk.img's changes. Ramdisk.img is the root file system, which contains the startup configuration script.
3. Update-script's changes.
4. Changes to the system.
We have a general understanding of the structure of the Android ROM, and then we can compile and customize our own ROM via the CM source code. CM is officially supported by a number of models, see the List of Devices (http://wiki.cyanogenmod.org/w/Devices), the official release version is now divided into two types, nightly (usually updated every 24 hours of the experimental version) and snapshot ( Basic stable version). Of course, CM also provides the source code for the developer, which contains the source code of the device and kernel. The corresponding model of the source code after the download, to compile, you can get their own recovery and ROM. Specific compilation method CM also gives a more detailed description, to millet 2s For example, you can refer to (http://wiki.cyanogenmod.org/w/Build_for_aries)
Resources
1. Http://wiki.cyanogenmod.org/w/About
2. http://blog.csdn.net/luoshengyang/article/details/29688041
Android ROM Porting