How To Port CyanogenMod Android To Your Own Device

怎样把cyanogenmod移植到你自己的设备

Note:

If you came

to this page by searching for information about porting Android, and you're not

sure what CyanogenMod is,.

注意:

如果你通过搜索关于安卓移植的信息来到这里,而且你不知道cyanogenmod是什么,点击这里了解更多。

Some

tips on porting CyanogenMod to your own device

一些关于移植cyanogenmod到你自己设备的建议

So you may come across a phone or tablet or

whatever that does not yet have CyanogenMod available.

你可能会碰到一些手机或者平板电脑,他们没有可获得的cyanogenmod版本ROM。

You've previouslyon your computer for another device or two, and you feel comfortable

with the process. In fact, you've still got thestanding by and are ready to tackle a big project.

你可能之前已经在你的电脑上为其他的设备编译过了Cyanogenmod,而且你对于这个过程很享受。事实上,你已经得到了源代码并且准备去处理一个大工程。

Looks like this is your opportunity to shine!

似乎你发光的机会到了。

Note:

For the

purposes of this tutorial, all references to directories will assume you are in

the root of the source code (ie, where you did the), and folder names will be relative to there. If you

followed the, the root of the source code is at

注意:

在这个指导教程里面,所有对目录的提及都是假定你是在源代码的根目录(例如在你做repo init的地方),而且目录名会和那个地方有关。如果你遵循构建指导,源代码的根目录是在~/android/system。

Prerequisites

预先需要的东西

Porting CyanogenMod to a new device can be

ridiculously easy or ridiculously difficult, depending on the device itself,

whether it currently runs a recent version of Android or not, and of course

your skills as a developer matter too.

把Cyanogenmod移植到一个新设备上可能是异常容易的或者异常困难的,这取决于设备本身,它是否运行着较新版本的安卓,当然你作为一个开发者的技术也是很重要的。

It would be pretty hard to do a port without

having built CyanogenMod (and) previously for another device. So if you haven't done a, give it a shot.

如果之前没有为其他设备构建过Cyanogenmod,做一个移植可能会非常难。所以如果你没有做过构建,尽量试试吧。

Helpful

Tip

If you found

this page other than via the CyanogenMod Learning Center, head over tofor much more information.

有用的建议

如果你不是通过Cyanogenmod学习中心发现这个网页的,点击这里去了解开发的更多信息。

Additionally, you should familiarize yourself with the. You should expect that, barring some rare exceptions, nearly everything

you need to do will be in the/device/[vendor]/[codename],/vendor/[vendor]/[codename], and/kernel/[vendor]/[codename]directories

(which you will need to create).

另外你应该对于Cyanogenmod源代码非常熟悉。你应该知道,不包括一些罕见的例外,你需要做的几乎一切都是在/device/制造商/开发代号,/制造商/制造商/开发代号,和/kernel/制造商/开发代号目录(你将要创建它们)。

Helpful

Tip

For a

more-detailed overview of what's where in the CyanogenMod source folders, see. In fact, you really should read this if you plan on

doing a port.

有用的建议

对于一个关于在Cyanogenmod源代码文件夹中哪些地方是什么东西的更详细的概述,点击这里。事实上,如果你计划做移植你真的应该读一读这个。

Collect information about your device

搜集你设备的信息

Before you begin your port, you will want to

collect as much information about your device as you can. Go toor XDA-Developers Wiki and identify the product name,,,(i.e.), memory

size, internal storage size, and platform architecture. Put this information in

a file for easy retrieval. Try to learn as much about the device, including any

similarities it may have to other devices (common elements, i.e chip, motherboard,...).

在你开始移植之前,你应该尽可能多的搜集关于你的设备的信息。去维基百科或XDA维基网站确认产品名,开发代号,生产商名,处理器架构(例如ARMv7架构),内存大小,内置存储器大小,和平台结构。为了方便检索把这些信息放在一个文件里面。努力去了解更多关于这个设备的东西,包括它和其他设备的任何相似的地方(芯片组相同的元素,例如,芯片,主板,GPU等等)。

Helpful

Tip

Many devices

are architecturally similar to other devices that are already on the market and

have existing CM ports. When a new device comes out, see if you can find out if

it may be identical to another device or have the same processor (i.e.processor ormotherboard) only with a different sized screen or more

memory or some other minor difference. If you find an "ancestor" or

"sibling" of your device, much of the work may already be done for

you!

有用的建议

许多设备和其他上市的已经有CM移植包的设备结构上相似。当一个新设备面世的时候,看看它是否是和其他设备相同或者有同样的处理器(例如ARM处理器或者MTK主板),只是有不同尺寸的屏幕或跟大的内存或一些其他小的差别。如果你能发现一个你的设备的祖先或者兄弟,那么许多工作都已经为你做好了。

Much of the information you need may be

available online, but assuming the device is already running a non-CyanogenMod

version Android, you may also get some of that information from the device

itself. To view the files containing this information, sometimes the device may

need to be. However, sometimes you can find aupdate package online, and can view the files

from the.ziparchive

file.

你可以在网上获得许多信息,但是假设这个设备已经运行了一个非Cyanogenmod版本的安卓,你可以从设备本身得到一些信息。有时设备可能需要ROOT,这样才能看到包含这个信息的文件。然而,有时你可能在网上发现一个固件更新包,而且能从zip归档文件查看文件。

Look

at the device's current/system/build.prop

查看设备目前的/system/build.prop文件

Assuming the device is already running a

version of Android, there should be a file,, on the device which may contain useful information that will come into

play as you do your port. This file contains definitions for various parameters

and settings used by Android.

假设设备已经运行了一个版本的安卓,那就应该有这个文件/system/build.prop。在你做移植的时候会有作用。这个文件包被安卓使用的各种参数和设置信息。

So, if you have previously installedonto your

computer, you can use the following command tothis file to

your computer:

所以,如果你之前已经在电脑上安装了adb,你可以用下面的命令把这个文件推到你的电脑上。

adb pull

/system/build.prop

If you receive an error relating to

permissions, the device may need to beto gain access to this file. However, as said, there are

other ways to locate this file. For example, it may be included in any stock

firmware "upgrade" package online.

如果你收到了一个关于权限的错误,这个设备可能需要被ROOT才能获得这个文件。然而,也有其他的方法获得这个文件。例如,这个文件会包含在任何网上的固件更新包里面。

You can also useandfrom(is a prerequisite to use them).

你也可以用Build Prop

Editor和Build Prop Editor,点击这里(root是使用它们的前提)。

Once you have the file...

当你有了这个文件

·Write down the value of

thero.product.manufacturerparameter. This will be yourvendorname. The[vendor]is the name of the manufacturer/vendor

of the device. CM has established naming conventions for most major vendors,

such assamsung,htc,lge, etc. Note

that in these directory names, the vendor is alwayslowercase and contains no spaces.

写下ro.product.manufacturer参数的值。这将是你的vender的值。Vender是设备的生产商或者销售商的值。CM已经为大多数主流生厂商建立了命名协定,比如samsung,htc,lge等等。注意在这些目录名中,生厂商名小写而且没有空格的。

·Write down the value of

thero.product.deviceparameter. This will be your devicecodename. The[codename]corresponds to the project code name

of the device itself. This is almostneverthe sales name of the device. If you

have built CM before (and again, you better have!), you should be familiar with

the concept of a code name for each device. Like the vendor name, the codename

is always lowercase and contains no spaces.

写下ro.product.device参数的值。这是你的设备的开发代号。这个开发代号对应设备自己的项目代号名。这几乎绝不会是设备的销售名。如果你之前已经编译过CM(再一次说,你最好已经做过了),你应该对每个设备的开发代号名这个概念很熟悉。和生产商名一样,开发代号也是小写无空格的。

Note:

Sometimes a

device is identified in other parameters such asro.product.board

注意

有时一个设备用其他的参数来确定,例如ro.product.board

Keep thebuild.propfile handy, as you may refer to it later.

留着build.prop文件,因为你后来可能用到它。

Examineboot.imgandrecovery.img

检查boot.img和recovery.Img

As stated, when doing your port, you may wish

to use an existing pre-builtkernelthat you know works instead ofone from. Depending on your device, you may need to extract this

kernel file from the device. The kernel may exist as a single file (as it does

on many OMAP devices) or may be wrapped up along with the ramdisk in a boot or

recovery partition.

就像之前说的,当做移植的时候,你可能希望用一个存在的之前编译好的内核,你知道它工作,而不是根据源代码编译一个新的。依靠你的设备,你可能需要从设备解压内核文件。内核可能存在作为一个单独的文件(在许多OMAP设备上就这样),或者可能连同内存盘被打包放进一个boot或recovery分区。

Similarly, the contents of the stockramdiskmay be extremely helpful and can often

be extracted and reviewed. It may be the case that a device requires specific

files from the stock ramdisk in order to boot properly, load a module, etc. In

most cases you can view files in the ramdisk from the device itself, but it you

may prefer to look at the full directory.

相似地,内存盘的内容可能非常有帮助,而且常常能被提取和检查。为了正常的开机,载入模块等,设备可能要求内存盘的特定的文件。在大多数情况下你可能要检查来自设备本身的内存盘,但是你可能更喜欢看整个目录。

Note:

The ramdisk

is a tiny group of files and directories that are loaded into memory along with

the kernel. The kernel then runs one of the files in the ramdisk calledinit, which then runs a script (init.rc,init.[codename].rc, etc.) that

in turns loads the rest of Android. The ramdisk and kernel can be packaged

together in a number of different ways using tools with names likemkbootimg,, and other methods.

提示

内存盘是一小群文件和目录,连同内核被载入内存。内核然后运行内存盘的一个叫做init的文件,init然后运行一个脚本(init.rc,init.开发代号.rc等等),接着依次载入安卓的剩余部分。内存盘和内核能够以许多种不同的方式打包在一起,通过使用像mkbootimg,mkimage等这样的工具。

You can frequently extract the boot and

recovery images (to a file you nameboot.imgandrecovery.img) on a rooted Android

device using.

你可以经常使用dd命令在已经ROOT的安卓设备上提取boot和recovery镜像。

Or, if you have access to an.zipfile from

the vendor (that could call it firmware), you can often find those files

within.

或者,如果你从生厂商那里获得了一个update.zip文件(常常被他们成为固件),你能在里面发现这些文件。

Collect

any available existing source code

搜集任何可获得的,存在的源代码

The manufacturer or vender of any device

using Android will minimally need to make the source code available for allcomponents

upon request, including (and especially) the kernel. You definitely want to

request a copy of the kernel source and keep it handy.

任何使用安卓的设备生厂商或者销售商会最小地让源代码可获得,由于遵循GPL协议的组件,包括(特别是)内核。你确实可以要求一份内核源代码并且留在手里。

Determine

the partition scheme

决定分区表

The primary long-term storage portion of your

mobile device-- usually an "emmc" (embedded)-- is much like a computer hard drive in that it is

prepared in a la particular way to identify and isolate different areas of

data. These unique areas are calledand they can have any kind of data stored there. Some

partitions contain--,s,s, etc. More often, a partition is formatted to use a

particularthat the kernel will recognize so that

individual files and directories can be read and written there.

你的移动设备主要的长期存储部分,通常是一个“emmc”芯片,更像一个电脑的硬盘驱动器,因为它在一种特殊的方式下被准备好,能识别和隔离不同的数据区域。这些独立的区域被叫做分区,他们能让任何种类的数据存储在那里。一些分区包含原始数据,固件,内核,内存盘等等。更加经常的是,一个分区被格式化来使用一个特定的内核识别的文件系统,所以单独的文件和目录能在那里被读和写。

Before you can replace the stock operating

system with CyanogenMod, it is therefore important to ascertain theof the device. The recovery image you build

will need this information to know where to find the various Android

directories. Particularly, you want to know which partitions are assigned to/system,/data,/cache, and/sdcard.

在你用Cyanogenmod代替原来的操作系统之前,确定设备的分区表是相当重要的。你构建的Recovery镜像将需要这些信息来知道在哪里发现各种安卓目录。特别是你想知道哪些分区被安排为/system, /data, /cache和/sdcard。

You want to know which partitions exist, on

what device, how they are mounted, as well as the size of the partitions. This

information may be transferred later to theBoardConfig.mkfile in your/vendordirectory.

你想知道哪个分区存在在哪个设备上,它们怎么被挂载,以及分区的大小。这个信息后来可能被转移到你的/vender目录的BoardConfig.mk文件。

If you're lucky, arecovery.fstabfile can be

located in arecovery.imgfile, speeding up the process of figuring out what goes

where. Also, theinit.[codename].rcfile in themay have the information. Look for the lines near the top

where the partitions aremounted.

如果你幸运,会发现一个recovery.fstab文件在recovery.img文件中,加快弄清楚什么东西去哪里的过程。这个在内存盘中的init.开发代号.rc文件可能有这个信息。在文件靠近头部的几行分区被挂载。

Also, the command:

这个命令是

$ cat /proc/partitions

from a running device can also help you

identify the partitions. Also see/proc/emmc,/proc/mountsor/proc/mtd. You

may also get some information from the commandmount(run as).

从一个运行的设备也能帮你识别这个分区。也可以看看/proc/emmc, /proc/mounts或者/proc/mtd目录。你也可以用命令mount(root权限)得到一些信息。

Also check/cache/recovery.logor/tmp/recovery.log.

也可以检查一下/cache/recovery.log或者/tmp/recovery.log文件

Finally, if you have source code to the(such as theused by many-based devices), you will likely find the information

there as well.

最后,如果你有bootloader的源代码(比如被许多基于OMAP设备使用的u-boot),你也很可能在那里发现这些信息。

Note:

Be aware

that in some rare cases, such as the, an abstractedis used.

注意:

要知道在一些很罕见的情况下,例如HP Touchpad,一种VFS虚拟文件系统被使用。

Set up three new directories

建立三个新的目录

Now that you've gathered information about

your device, it's time to generate the folders for your device configuration,

located in the following directories, relative to the code source directory.

现在你已经收集的你的设备的信息,是时候为你的设备配置建立文件夹了。这些配置信息在下列文件夹里,和代码资源有关。

·device/[vendor]/[codename]/-- this is

where the installation files specific to your device will go. Thedevice/directory

contain 99-100% of the configuration settings and other code for particular

devices. You'll get to know this directory pretty well. As mentioned, when

starting the folder for this device, it may be a good idea to adapt a directory

for an existing device that is architecturally similar to the one you wish to

port. Look for a device that is based on the same platform, asorchipset, for example.

·这是和你的特定的设备有关的安装文件要去的地方。这个device文件夹包含99%到100%的设置配置信息和其他针对特殊设备的代码。你将逐渐了解这个文件夹。就像之前说的一样,在为这个设备建立文件夹时,比较好的做法可能是去修改一个已存在的设备的文件夹,这个已存在的设备是和你希望移植的设备在架构上相似。寻找基于同一个平台的设备,例如使用ARMv7或MTK芯片组。

·vendor/[vendor]/[codename]/-- Thevendor/directory

contains proprietary, binary "blobs" that are backed up from the

original device (or provided by the vendor, such as in the case of Google Nexus

devices and some TI graphics blobs).

·这vendor文件夹包含生产商专有的,从原始设备打包的二进制块文件(或者是被生产商提供的,例如Google Nexus设备和一些德州仪器的图像处理块文件)。

·kernel/[vendor]/[codename]/-- the

kernel source goes here. When you first start your porting effort, you may wish

to simplify things by using a pre-built kernel (such as the one that came with

the stock installation) rather than building the kernel from scratch. The trick

to that will be extracting the kernel out of the stock system from whatever

format it may be in, and then re-packaging it, along with a new ramdisk, into a

form that your device can use. This can vary from device-to-device, so it may

again be helpful to look at similar devices to yours that use a similar

architecture. Building the kernel from source is not strictly necessary for

every device, but in the spirit of open source, it is the preferred practice

for CyanogenMod. Seefor a detailed discussion about how CyanogenMod builds

the kernel source from scratch.

·内核源代码在这里。在你第一次开始移植的努力的时候,你可能希望使用一个预先编译好的啮合来简化工作(例如来自一个固件安装包的内核),而不是从头开始。那样做的技巧就是从一个无论内核是什么格式的原来的系统中提取内核,然后加上一个新的内存盘来重新打包,用一个你的设备可以使用的格式。这种活可能不同的设备有不同的方式,所以再一次说明找一个有相似架构的设备是很有帮助的。用源代码重新构建内核不是对每个设备都是必要的,但是本着开源的精神,重新编译对于Cyanogenmod更好。

There are at least three methods to generate

these directories:

至少有三种建立这些文件夹的方式。

Method

1: Usemkvendor.shto generate skeleton files

方法一:用mkvendor.sh建立框架文件

Use themkvendor.shscript inbuild/tools/device/to automatically generate the directories.

用在build/tools/device/的mkvendor.sh脚本自动建立这些文件夹

Note:

Themkvendorscript only works with devices that use a

standardboot.imgfile, using

the standard Android conventions and headers. It won't work for devices that

deviate from this standard (Nook Color, Touchpad, etc.).

注意:

Mkvendor脚本只和使用标准boot.img文件的设备工作,它使用标准的安卓协定和文件头。它不会和偏离这个标准的设备工作(例如Nook Color和Touchpad等等)。

This script accepts three parameters:vendor,codename, and aboot.imgfile.

这个脚本接受三个参数,vendor,codename和一个boot.img文件

Example usage:

示例用法:

$ ./build/tools/device/mkvendor.sh samsung i9300 ~/Desktop/i9300boot.img

In the above example,samsungrepresents thevendor,i9300represents thecodenameand the last parameter is the path to

theboot.imgfile that was extracted from the boot

partition withddor provided

by the vendor in an update .zip as discussed above.

在上面的例子中,samsung代表生厂商,i9300代表开发代号名,最后一个参数是到boot.img文件的路径,像上面讨论的一样,这个文件用dd命令从boot分区解压出来或者被生产商提供在一个update .zip里。

The command above should create a/device/samsung/i9300/folder

within your CyanogenMod source repo structure. And inside the folder, the filesAndroidBoard.mk,AndroidProducts.mk,BoardConfig.mk,cm.mk,device_[codename].mk,kernel(the binary),recovery.fstab, etc.

上面的命令会创建一个/device/samsung/i9300/文件夹,在你的Cyanogenmod源代码repo结构里。这个文件夹里面有AndroidBoard.mk,AndroidProducts.mk,,BoardConfig.mk,cm.mk,,device_[codename].mk,,kernel (二进制的),recovery.fstab等等文件。

This will not build thekernel/directory. You will need to do that later,

when you are ready to build the kernel.

这样不会建立内核文件夹。在你准备去构建内核的时候,你将会去建立这个文件夹。

Note:

If it

returns the message "unpackbootimg not found. Is your android build

environment set up and have the host tools been built?" please be sure

that you run the following command during setting up the developer environment:

$ make -j4 otatools

注意:

如果它返回这个信息“unpackbootimg没有发现。你的安卓编译环境建立了吗?而且host工具被构建了吗?”请确定你在建立开发环境的时候运行了下列的命令。

Method

2: Fork a similar device's git repository

方法二:复制一个相似设备的git仓库

If you've got aaccount, you might want to start byanother, similar device, and then rename it for your

device. See thefor a discussion on how to name your

repository.

如果你有一个git账号,你可能想通过复制另一个相似的设备的文件夹然后重命名为你的设备来开始。可以看看这个section on setting up github关于怎样命名你的仓库的讨论。

Always be sure you're compliant with the

license of any repository you fork.

当然要确定你符合任何你复制的仓库的许可证。

Method

3: create the directories and files manually

手动创建文件夹和文件

You can always start with an empty directory

and start creating the files by hand. This is the least recommended and perhaps

the most tedious method, but it may be the most instructive. You can look at

other devices for reference on what files you need.

你总是可以以一个空文件夹开始来手动创建文件。这是最不推荐的和或许最冗长乏味的方法,但也可能是最有益的方法。你可以可以参考其他的设备来决定你需要什么文件。

Customize the files

定制这些文件

There are many files in thedevice/folders. We will start by focusing on four

filesBoardConfig.mk,device_[codename].mk,cm.mk,recovery.fstab, andkernelto get

recovery working for your device.

在device文件夹里有很多文件。我们会通过致力于四个文件BoardConfig.mk,device_[codename].mk,cm.mk,recovery.fstab来开始,kernel文件是为了得到recovery为你的设备工作。

Helpful

Tip– Start with the recovery!

The first

major step is to get a working recovery image for your device so that testing

subsequent update.zips is easy. A working recovery will also assist you in

doing backups if necessary.

Since having

a working recovery is so critical for doing your port, these next steps will

focus more on getting a working recovery than getting CM itself to work. Once

the recovery is built and operating safely, the work you've done will apply

directly to the CM part as well.

有用的建议,以recovery开始

第一个主要的步骤是为你的设备得到一个工作的recovery镜像,所以测试接下来的update.zip是容易的。一个工作的recovery镜像将会帮助你在必要的时候备份。

因为一个工作的recovery对做你的移植是如此至关重要,这些接下来的步骤将会更加致力于得到一个工作的recovery,和让CM它自己去工作相比。一旦recovery被构建和安全地运行,你已经做的工作也将会直接应用到CM的部分。

Lets examine each of these files:

让我们检查这些文件的每一个。

BoardConfig.mk

This file contains vital architectual and

build information about the architecture of your device's motherboard, CPU, and

other hardware. Getting this file right is essential.

这个文件包含必不可少的关于你的设备的主板架构,CPU,和其他硬件的架构的和构建信息。让这个文件正确是至关重要的。

To get a basic recovery booting, a few

parameters need to be set in this file.

为了得到一个基本的recovery镜像,几个参数需要在这个文件里设置。

The following parameters must be set properly

inBoardConfigto compile a working recovery image:

接下来的几个参数必须在BoardConfig中被合适地设置,为了编译一个工作的recovery镜像。

·TARGET_ARCH: this is the architecture of the device it is usually

something likearmoromap3.

·这是这个设备的架构,通常像arm或omap3.

·BOARD_KERNEL_CMDLINE: not all devices pass boot parameters however if your

device does thismustbe filled out properly in order to

boot successfully. You can find this information in theramdisk.img. (You

can learn more about configuring the integrated kernel build-from-source.)

·不是所有的设备都传递开机参数。但是如果你的设备确实这样,那为了正确地开机这个参数必须被合适地填写。

·BOARD_KERNEL_PAGESIZE: the pagesize of the stockboot.imgand must be

set properly in order to boot. Typical values for this are2048and4096and this information can be extracted

from the stock kernel.

·这是boot.img的页大小。为了开机必须被合适地设置。典型的值是2048或者4096,而且这个信息可以从原来的内核中提取。

·BOARD_BOOTIMAGE_PARTITION_SIZE: the number of bytes allocated to the kernel image

partition.

·分配给内核镜像分区的字节数。

·BOARD_RECOVERYIMAGE_PARTITION_SIZE: the number of bytes allocated to the recovery image

partition.

·分配给recovery分区的字节数。

·BOARD_SYSTEMIMAGE_PARTITION_SIZE: the number of bytes allocated to the Android system

filesystem partition.

·分配给安卓system文件系统的字节数。

·BOARD_USERDATAIMAGE_PARTITION_SIZE: the number of bytes allocated to the Android data

filesystem partition.

·分配给安卓data文件系统分区的字节数。

Note:

The above

information can be obtained by multiplying the size from/proc/partitionsor/proc/mtdby the block size, typically1024.

注意:

这上面的信息可以通过把来自/proc/partitions或/proc/mtd的大小和块大小相乘得到,典型的是1024。

·BOARD_HAS_NO_SELECT_BUTTON: (optional), use this if your device needs to use itsPowerbutton to confirm selections in

recovery.

·(可选的),如果你的设备需要在recovery中用电源键去确认选择,你要使用这个。

·BOARD_FORCE_RAMDISK_ADDRESS

/ BOARD_MKBOOTIMG_ARGS:

(optional), use these to force a specific address for the ramdisk. This is

usually needed on larger partitions in order for the ramdisk to be loaded

properly where it's expected to exist. This value can be obtained from the

stock kernel. The former is deprecated as of Android 4.2.x and the latter will

now be used in 4.2.x and beyond.

·(可选的)用这个去强制为内存盘指定一个特定的地址。这通常在分区很大的时候被需要。为了让内存盘在它应该在的地方被合适地载入。这个值能从原来的内核得到。安卓4.2.x之前是不推荐的,但之后版本这个东西被使用。

device_[codename].mk

Thedevice_codename.mkcontains instructions about which Android packages to, and where

to copy specific files and packages, or specific properties to set during your.

这个device_codename.mk的make文件包含一些指导说明,说明要编译哪些安卓包,复制特定的文件和包到哪里,或特定的在你编译的时候设定的资源。

This file can be used to copy vital files

into theat compilation time.

这个文件可以被使用在编译的时候复制必不可少的文件到内存盘。

·PRODUCT_COPY_FILES: used to copy files during compilation into the ramdisk,

which will be located at$OUT/recovery/root.

这个变量被使用在编译的时候把一些文件复制到内存盘,这些文件将会位于$OUT/recovery/root。

Example:例子:

$(LOCAL_PATH)/sbin/offmode_charging:recovery/root/sbin/offmode_charging \

This will copy the file offmode_charging

binary into thefolder within the ramdisk.

这将会把offmode_charging这个二进制文件复制到内存盘里的sbin文件夹。

·PRODUCT_NAME

/ PRODUCT_DEVICE: used for setting the

value of your codename. This is the name of the device you load with.

·被用来设置你的开发代号的值。这是你用lunch载入的设备的名称。

Kernel内核

This is simply the prebuilt kernel image or a

kernel you built yourself used to boot the device. The format of the kernel may

be in aor, depending on the requirements of theof your device.

这就是预编译的内核或你自己编译用来启动设备的内核。内核的格式可能是zImage或者uImage,取决于你的设备架构的要求。

cm.mk

You'll need to make a few changes to this

file to integrate with the,, andcommands, so that your device shows up on the list and

builds properly. You'll also set some variables (see other devices) to indicate

what size splash animation should be used, whether this is a tablet or phone,

etc.

为了集成lunch,brunch和breakfast命令你将需要对这个文件做一些改变,这样你的设备将会出现在列表上和正确的编译。你也会设置一些变量(看看别的设备)来说明什么尺寸的开机动画应该被使用,这是一个手机还是平板,等等。

Some of these settings aren't used for building

just the recovery, but you may as well set them now because once recovery is

done and working, the settings here will be important.

这些设置中的一些不会被构建CM使用,只是为了recovery,但是你也应该现在设置它们,因为一旦recovery做好而且工作,这些设置将会变得非常重要。

Again, take a look at a similar device to yours

to get an idea of what the settings here should be. It's fairly intuitive.

在说一次,看一看相似的设备来了解这里的设置应该是什么样的。这是相当靠直觉的事。

recovery.fstab

defines the,, andfor each of the partitions in your device. It works

almost exactly likein a standard Linux operating system.

recovery.fstab定义了你设备的文件系统,挂载点,文件系统类型和每个分区对应的块设备名。它就像标准linux操作系统的/etc/fstab一样工作。

Example:例子:

/system           ext4        /dev/block/mmcblk0p32

This sets the block device atmmcblk0p32to be mounted on/systemas filesystem typeext4

这句话设置在mmcblk0p32的块设备挂载在/system文件夹,以ext4的文件系统类型。

All mountpoints should exist in this file and

it iscrucialthis information be correct or else

very bad things can happen, such as a recovery flash writing to the wrong

location.

所有的挂载点都应该存在在这个文件,保持这个信息正确是至关重要的,否则非常坏的事情可能发生,比如一个recovery烧写了错误的区域。

Note:注意:

The filesystem

typedatamediacan be used for internal sdcards as well as

setting the block device to/dev/null.

看不懂了

vendorsetup.sh

vendorsetup.shis called whensetupenv.shis run. It is used to add non-standardlunchcombos to thelunchmenu.

setupenv.sh运行时需要vendorsetup.sh这个脚本。它被使用来添加非标准的lunch套餐到lunch菜单。

To add your device to the lunch menu:

把你的设备添加到这个lunch菜单:

add_lunch_combo cm_-userdebug

Then build a test recovery image

然后编译一个测试的recovery镜像

To build only the recovery, set uplunchas with a regular build, and say.

为了只编译一个recovery,用一个一般的构建来建立lunch然后输入make

recoveryimage。

If things break (and they will break), have a

look at these tips for.

如果事情出错了(而且这几乎是必然的),看看这些关于如何处理编译错误的建议。

Helpful

Tip

If you have, you

can try it to install the recovery image to the. There are other methods for installing the recovery,

such as usingfrom a rooted system to flash it into place.

有帮助的建议:

如果你有fastboot,你可以试着安装recovery镜像到recovery分区。也有其他方法安装recovery,比如在一个root的系统用dd命令烧录。

Not much needs to be said here, but make sure

the recovery is working before you move on to getting CyanogenMod working. A

100%-working and reliableis absolutely necessary before you start

testing experimental Android builds.

不是非常有必要在这里说,但是在你继续让Cyanogenmod工作之前应该保证这个recovery工作。一个百分之百工作和可靠的recovery在你开始测试实验性的安卓编译之前是绝对有必要的。

Adjustrecovery_ui.cppif necessary

在必要的时候修改recovery_ui.cpp文件

You may discover that although the recovery

image runs, some of the hardware buttons, such as the volume buttons or power

buttons, which would normally be used to scroll through the options, don't

work.

你可能会发现即使recovery镜像工作,一些硬件按键,比如通常用来滚动选项的音量键或电源键,不工作。

You may need to adjust thevalues to get

the buttons to be recognized. Similarly, you may wish to include/exclude

options or modify other UI elements.

你可能需要调整GPIO(General Purpose Input Output(通用输入/输出)简称为GPIO,译者注)的值来让按键被识别。同样地,你可能会希望包括或去除一些选项或修改其他UI元素。

To do this, you may wish to create and edit

the/device/[vendor]/[codename]/recovery/recovery_ui.cpp. You can find ample examples of this file, the

associatedfile that builds it, and how it is used.

为了这样做,你可能会希望创建和编辑/device/[vendor]/[codename]/recovery/recovery_ui.cpp这个文件。你可以发现这个文件的大量的例子,相关的编译它的recovery/Android.mk文件和它是怎样被使用的。

Helpful

Tip

The GPIO

values for your device may be found in the.

有帮助的建议

你的设备的GPIO的值能在内核源代码中找到。

Put your device folder in github, and

use a local manifest to automatically sync it with repo sync

把你的设备文件夹放到git上去,用repo sync命令,使用一个本地清单来自动同步它

Once you've started your device folder,

create your ownaccount and. This is a great

opportunity to learn about, and also

your source can be accessible to others who can collaborate with you.

一旦你建立你的设备文件夹,你就应该创建你自己的账户并且建立你的文件夹作为一个公共的GitHub仓库。这是学习git的一个很好的机会,而且你的源代码也可以被那些能协助你的人获得。

When naming your repository, use the formatandroid_device_VENDOR_CODENAME,

where VENDOR and CODENAME use the new device's values. So, let's say your

GitHub account name is "fat-tire" and your device codename is "", manufactured by Barnes and Noble. You should call your repositoryandroid_device_bn_encore. It

would be accessible at. Similarly, the kernel repository would be called android_kernel_bn_encore.

It would be accessible at.

在命名你的仓库的时候,使用这样的格式android_device_VENDOR_CODENAME,vendor和codename用新设备的值。所以,假如说你的GitHub账户名是fat-tire而且你的设备开发代号是encore,被Barnes and Noble制造。你应该把你的仓库叫做android_device_bn_encore。这个可以在https://github.com/fat-tire/android_device_bn_encore获得。类似的,内核仓库将会被叫做android_kernel_bn_encore。这个也可以在https://github.com/fat-tire/android_kernel_bn_encore获得。

The last thing to do is create afor other people to use to automatically download and

their keep up-to-date with your changes. Here's an example, using the above

scenario:

最后一件事是创建一个本地文件清单,方便其他人用它自动下载代码和于你的改动保持一致。这里有一个例子,使用了上面的情景。

Note:

Therevisionattribute is optional. If it is

omitted,repo syncwill use the

revision specified by thetag in the.

注意:

这个revision属性是可选的。如果它被省略,repo sync会用在默认manifest标记的revision。

Once you've tested that thefile works, you can pass it on to others, who can then

try out your work. At that point you can continue to push your changes to

GitHub, and even give other users commit access so that you can work on the

device together.

一旦你测试了这个本地文件清单工作,你就可以把它传递给别人,这些人可以协助你的工作。那个时候你也可以继续把你的修改推送到GitHub,甚至可以给别的用户委托权限,这样你们就可以一起开发这个设备。

Helpful

Tip– Using other repositories

If you find

that for some reason you need to replace or supplement other repositories

provided by CyanogenMod, you can add additional repositories using the. Once you've got everything working, you can useto submit stuff found in those repositories back upstream

to CyanogenMod.

有帮助的建议——使用其他的仓库

如果你发现,由于某些原因你需要代替或补充由Cyanogenmod提供的其他仓库,你可以使用本地文件清单添加附加的仓库。一旦你让一切工作,你可以用Gerrit来反过来向Cyanogenmod提交在这些仓库中发现的组件。

Add the blobs to thevendor/directory

把块文件添加到vendor文件夹

Once you have a working recovery, it's now

time to get CyanogenMod building and working.

一旦你有一个工作的recovery,是时候来编译Cyanogenmod和让它工作了。

The first thing you may do is to get all the

proprietary, binaryinto thevendor/folder,

along with afile that will include them in the final build.

你要做的第一件事就是把所有的专有的文件,二进制块文件放进vendor文件夹,连同在最后编译的时候会把它们包含进来的.mk文件。

This requires three steps:

这需要三步:

1.Createands to pull those blob files from the device usingand put them in the rightdirectory. There are plenty of examples available for

other devices.

创建一个extract-files.sh和setup-makefiles.sh脚本来用adb把这些块文件从设备拉出来,然后把它们放进vendor目录。其他的设备有足够多可获得的例子。

2.Create an.mkMakefile to copy those files to thefolder during the build process and put them in the right

place. Again, use other devices as a guide for what this Makefile should look

like. An example filename might be

创建一个.mk的makefile文件来在编译的过程中把这些文件复制到$OUT文件夹并且把它们放在正确的地方。再说一次,用其他的设备指导自己,这个makefile文件应该看起来怎么样。一个示例文件名可以是BoardConfigVendor.mk。

3.Make sure that the Makefile you just created is included

from your mainBoardConfig.mkvia a command such as-include

vendor/[vendor]/[codename]/BoardConfigVendor.mk. Again, existing devices can illustrate how this is done.

保证你刚刚创建的makefile文件被你的主要的BoardConfig.mk包含,用一个像-include

vendor/[vendor]/[codename]/BoardConfigVendor.mk这样的命令。再一次说,存在的设备可以说明这个是怎么工作的。

An alternative is use the blob-free and free

code.

一个可以选择的是使用blob-free和自由代码项目Replicant。

Now revise thedevice/directory

现在修改一下这个device目录

Since you have a working recovery, go back

and start modifying the files in the. As always, use other similar devices as a reference.

一旦你有了一个工作的recovery,回去开始修改device文件夹里的文件。总是要记住,使用相似的设备作为参考。

You now have a easy means to do backups and

test your builds. So start tweaking the device folder itself, and see if you

get it to boot... Once you do, from there its a matter of building and supporting

the various parts and peripherals, one-by-one.

你现在有一个容易的方法来备份和测试你的系统。所以开始拉扯设备文件夹它本身,看看你是否能让她开机。一旦你成功了,就可以一个接一个地编译和支持这个设备的各个部分和外围组件。

Getting help from the manufacturers

& vendors

从生产商和销售商那里获得帮助

Many of thes (s) who make the underlying platform used by your device

frequently provide wikis, documentation, and sample code that can assist you in

completing your port. You'll find that some companies are more friendly to the

development community than others. Here are some of the more common OEMs and

vendors, along with web sites and repositories that may help.

许多制造你的设备使用的基础平台的OEM(原始设备制造商)经常提供维基、文档和示例代码,这能帮助你完成你的移植。你将会发现一些公司比另一些公司对开发社区更加友好。这里有一些更加普遍的OEM和销售商,以及可能会有帮助的网站和仓库。

(This list is incomplete. Please help add to

it)

这个列表是不完全的。请帮助添加。

Sometimes if you have questions you can even

reach out to the developers via email or the support forums.

有时如果你有问题你可以致邮件给开发者或者支持的论坛。

Adding XML Overlays

添加XML覆盖文件

It's very likely in yourdevice_[codename].mkfile,

there's a line that looks like this:

在你的device_[codename].mk文件里,可能有一行看起来这样的:

DEVICE_PACKAGE_OVERLAYS := \

device/[vendor]/[codename]/overlay

What this does is set thefolder to allow you to override any XML file used bys or apps, just for this device. To do so,

create a directory structure which mirrors the path leading to an XML file,

starting from the root of your source. Then replace the file you want to

overlay.

这段话做的工作是设置这个overlay文件夹来允许你为你的这台设备抛弃任何被安卓框架或者apps使用的XML文件。为了能够这样做,创建一个对应到一个XML文件的文件夹结构,从你的源代码的根目录开始。然后取代你想去抛弃的文件。

Example: Let's say you want to override some

standard Android settings. Look at the file inframeworks/base/core/res/res/values/config.xml. Then copy it todevice/[vendor]/[codename]/overlay/frameworks/base/core/res/res/values/config.xml. Now YOUR version will be used instead of the other one.

You only need to include the settings you wish to override-- not all of them,

so you can pare down the file to those few that change from the default.

例子:假设你想抛弃一些标准安卓设置。找到这个文件frameworks/base/core/res/res/values/config.xml。然后把它复制到device/[vendor]/[codename]/overlay/frameworks/base/core/res/res/values/config.xml。现在你的版本的文件将会被使用。你只需要包含你想要抛弃的设置,没必要是全部。所以你能让这些文件与默认的改变得更少。

You can overlay any XML file, affecting

layouts, settings, preferences, translations, and more.

你可以覆盖任何XML文件,这可以影响布局、设置、偏好、翻译等等。

Make the kernel and kernel modules

build from source

从源码编译内核和内核模块

If you have previously used a pre-built

kernel, you may at some point want to start building the kernel from scratch.

如果你之前已经使用了一个预编译的内核,你可能想去从头开始编译内核。

See the instructions for how to change theBoardConfig.mkfile to make

CyanogenMod.

看看这个关于怎么改变BoardConfig.mk文件来使CM自动编译内核和任何要求的内核模块的介绍。

Conclusion

结论

There's no way a single wiki page will tell

you everything you need to know to do a port from beginning to end. However,

hopefully you now have an understanding of how things are set up and the steps

you need to take. You can always ask for help on theor on. Others

with the same device, chipset or platform (i.e. samechip) may

jump in to help too.

没有一个单独的网页能告诉你需要知道的一切,来从头到尾完成一次移植。然而有希望的是你现在已经对事情是怎么建立的和你需要采取的步骤有了一个理解。你总是可以在CM论坛或者IRC上寻求帮助。其他有同样设备、芯片组或者平台的人会跳出来帮助你。

Hopefully you'll find the process rewarding

and educational. And it'll get you some street cred as well.

有希望的是你会发现这个过程是让你受益匪浅的和受教育的。而且它也会让你得到许多宝贵的能力。

When you're all done, and your port works

better than stock... when it's stable and shiny and marvelous and wonderful and

includes improvements, free code or commons grounds for different devices...

在你完成时,你的移植包工作得比官方的更好……在它是稳定的和闪耀的和令人惊异的和很棒的和包含了很多改进的时候,

You may want to contribute your work

upstream.for how to do just that.

你可能想要反向的贡献你的代码。这里有一些怎么做的建议。

Good luck!

idea overlays文件夹_怎样把cyanogenmod移植到你自己的设备相关推荐

  1. idea overlays文件夹_使用IDEA加载maven项目没有出现overlays目录的解决方法

    使用IDEA加载maven项目没有出现overlays目录的解决方法 欢迎使用Markdown编辑器 你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页.如果你想学习如何使用Markdo ...

  2. python爬虫保存图片到指定文件夹_李亚涛:python抓取某房源户型图并自动保存到文件夹...

    大家好,今天来给大家分享一下如何抓取某房产网站房源户型图的所有图片,而且自动以房源名称命名一个文件夹,把所有图片放到文件夹中. 大概的思路是: 1.获取网页源代码 2.获取图片地址与房源名称 3.在当 ...

  3. du -sh 如何找到最大的文件夹_小白必看!手把手教你如何在linux上安装redis数据库...

    首先我们要清楚redis是什么? redis是一种非关系型数据库,它与MySQL的这种关系型数据库不同,MySQL是将数据存储在磁盘中,而redis是储存在内存中.一般很多公司都是使用MySQL+re ...

  4. scripts文件夹_常用Scripts整理

    常用scripts整理--2020.05.13 平时在进行数据处理时,经常会用到一些脚本文件,可以提高效率,我把自己常用到的进行整理总结,希望可以有所帮助 1.批量修改图片名字 #coding=utf ...

  5. 服务器上无法重命名文件夹,linux如何重命名文件和文件夹_网站服务器运行维护...

    win10显示网络电缆被拔出怎么办_网站服务器运行维护 win10显示网络电缆被拔出的解决方法是:1.打开[设备管理器],展开[网络适配器]选项:2.打开网卡属性窗口,切换到[电源管理]选项,并取消勾 ...

  6. mkdir 创建随机序号文件夹_使用PowerShell批量新建文件夹的方法

    系统推荐:[GHOST WIN10 X64] 现在很多的电脑都是使用Win10,如果我们在整理文档需要新建多个文件夹进行归类,不如使用Win10系统中自带的PowerShell,来批量新建文件夹,具体 ...

  7. sh脚本每天创建一个文件夹_我每天创建一个月的视频。 这就是发生的事

    sh脚本每天创建一个文件夹 At the end of 2019 I promised that 2020 would be all about my YouTube channel. So that ...

  8. python读取多个文件夹_在python中如何从不同的文件夹读取多个文件

    我在不同的文件夹中有年度数据文件.每个文件包含从1月1日到12月31日的每日数据.数据文件名类似于AS060419.67,其中最后四位代表年份,即1967年,0604是文件夹名.在 我试图使用下面的代 ...

  9. 电脑字体在哪个文件夹_电脑键盘使用方法

    对于刚使用电脑的电脑新手而言,首先要做的就是熟悉键盘.不过,小编发现有许多的童鞋都怕文字过于繁多看的自己眼花,别担心,小编这有电脑键盘的示意图,能让大家一目了然. 对于经常需要使用电脑的人而言,键盘那 ...

  10. python自动整理文件夹_计算机文件和文件夹的Python自动管理,自动化,电脑,及

    目录 一.输出目录所在的文件以及文件夹 import os print(os.getcwd())#获得当前文件的地址 print(os.path.join('MyProjects','AI'))#让P ...

最新文章

  1. R语言将dataframe数据从宽表(wide)变为长表(long)实战:tidyr包的gather函数、cdata包的unpivot_to_blocks函数、data.table使用melt函数
  2. java 多线程数量_java多线程之计算数量
  3. Asp.net禁用site.Mobile.Master
  4. 在此之前的软件系统做开发—需求的研究框架
  5. grunt安装与运行
  6. Python的类成员函数、静态函数和成员的函数的比较
  7. WEP密码破解BT3-spoonwep2教程及下…
  8. 小米笔记本pro充电测试软件,小米笔记本 Pro 评测:高端已成,性价比不变
  9. html文字段落i排版,i排版怎么修改字体?i排版字体排版详细介绍
  10. Latex 只在首页添加页眉页脚 修改局部字体大小
  11. 安全模式解除android,手机安全模式怎么解除
  12. linux读取文件头错误,Linux系统grub常见错误问题解决
  13. Zend_Cache
  14. 家用汽车维修3:基于OBDII的故障分析
  15. python画venn图
  16. 求方程ax^2+bx+c=0的实数根
  17. 【C++】C++PrimerPlus(第6版)中文版 第9章 内存模型和名称空间 编程练习 参考答案
  18. 一位卖家对淘宝查杀虚假交易痛讼!
  19. 【MATLAB】机器学习:决策树算法实验
  20. 朴实无华的取证 (数字取证)

热门文章

  1. 商务办公软件应用与实践【8】
  2. 怎么把PPT幻灯片里背景图片拿出来
  3. UE4----GC(垃圾回收)
  4. Google云存储服务GDrive再度浮出水面
  5. 《思考的技巧》- 学习总结
  6. 如何判断channel是否已经关闭
  7. ntdll.dll处引发的异常: 0xC0000005: 写入位置 0x00000004 时发生访问冲突
  8. 【html】css样式
  9. 爬虫 -- 简单封装
  10. win7设置定时开关机