---
title: "Port CyanogenMod to Mi2"
author: "fkpwolf"
date: "2013-01-23T10:40:04Z"
tags: []
categories: ["移动开发"]
slug: "port-cyanogenmod-to-mi2"
draft: false
lastmod: "2013-06-15T11:09:07Z"
id: 1774201
url: "https://fkpwolf.iteye.com/blog/1774201"
---

http://wiki.cyanogenmod.org/w/Build_for_mako 这个和m2用的一样的soc。


https://github.com/CyanogenMod/android_device_lge_mako/blob/cm-10.1/extract-files.sh

https://android.googlesource.com/device/lge/mako/+/master/proprietary-blobs.txt

对比m2，大多数的私有库是一样的。从这里看来，移植应该不难，至少基本的功能应该没问题。因为这些私有库是不需要编译的，而java编译的话问题会很少。

下一步先看看能否使用CM的recovery。

已经有CM 10 for m1：http://www.miui.com/thread-954095-1-1.html

如何[port CM](http://wiki.cyanogenmod.org/w/Doc:_porting_intro) 

https://github.com/fkpwolf/android_device_xiaomi_m2
device name本来想用aries（定义在/system/build.prop），不过[CM](https://github.com/CyanogenMod)上三星有个同名的。

取出recovery.fstab参考[这里](http://forum.xda-developers.com/showthread.php?t=633246)的“How to add new devices”章节。如果在linux上面，对于system.img，参考[这里](http://forum.xda-developers.com/showthread.php?t=1588461)使用mount，xiaomi的img文件先要转换成raw的img，然后才能用ext4 mount。而对于recovery.img，要用不同方法。参考[这里](http://forum.xda-developers.com/showthread.php?t=1590039)。

如何disbale一些功能做最小化编译：https://groups.google.com/d/msg/android-porting/u1rbpdEXqQw/92OUZiSf8wIJ

linux下使用adb连接device：看[这里](http://www.linuxidc.com/Linux/2013-01/77625.htm)和[这里](http://ubuntuforums.org/showthread.php?t=1918512)。我搞了半天才发现需要一个adb_usb.ini文件。
安装Recovery
做了个很粗糙的otg build，通过miui recovery安装到98%时失败。也不知道是何原因，因为看到log。于是猜想是recovery的原因，于是想自己Build cm recovery。但是即使使用xiaomi stock rom里面的kernel，启动到recovery时还是黑屏。
未知问题

android linux kernel: http://en.wikipedia.org/wiki/Android_version_history
最好linux的kenel和stock rom里面的一致，这样一些私有库可以直接使用，否则没有办法啊。好消息是[leg linux kernel](https://github.com/CyanogenMod/lge-kernel-mako/blob/jellybean/Makefile)用的也是3.4.0的版本，和小米2原生的一样，看来高通这个U用的版本都是一样的。

[一般手机](http://hackaday.com/2013/05/30/giving-the-nexus-4-a-serial-port/)都有uart接口，不过小米倒没有找到相关信息。

常用命令
1. Git. 在某个module目录下运行"git status"可以看到代码的check in状态。

编译错误
1. No rule to make target 

```java
make: *** No rule to make target `/home/fan/android/system/out/target/product/m2/obj/STATIC_LIBRARIES/libdumpstate.m2_intermediates/export_includes', needed by `/home/fan/android/system/out/target/product/m2/obj/EXECUTABLES/dumpstate_intermediates/import_includes'.  Stop.
```

这是因为libdumpstate.m2这个module没有定义。--->Modify device/xiaomi/m2/dumpstate/Android.mk

2.