我的nexus 6是美版的也就是 xt1103
按照http://source.android.com/source/initializing.html的流程,初始化环境,下载代码,编译。
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo
$ repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.0_r7
$ repo sync
$ source build/envsetup.sh
$ lunch shamu-userdebug
$ make -j32
经过漫长的等待后编译完成 通过$ fastboot flashall -w刷机运行。
机器到达logo界面后便重启,无法启动。根据现象分析,kernel已经启动了,幸运的是可以打印出log
01-01 00:18:45.655 304 304 I SurfaceFlinger: SurfaceFlinger's main thread ready to run. Initializing graphics H/W...
01-01 00:18:45.656 304 304 F libEGL : couldn't find an OpenGL ES implementation
01-01 00:18:45.656 304 304 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 304 (surfaceflinger)
01-01 00:18:45.657 275 275 W : debuggerd: handling request: pid=304 uid=1000 gid=1003 tid=304
01-01 00:18:45.663 308 308 E : debuggerd: Unable to connect to activity manager (connect failed: No such file or directory)
01-01 00:18:45.713 308 308 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-01 00:18:45.713 308 308 F DEBUG : Build fingerprint: 'Android/aosp_shamu/shamu:7.1/NDE63X/ruby12072307:userdebug/test-keys'
01-01 00:18:45.713 308 308 F DEBUG : Revision: '0'
01-01 00:18:45.713 308 308 F DEBUG : ABI: 'arm'
01-01 00:18:45.713 308 308 F DEBUG : pid: 304, tid: 304, name: surfaceflinger >>> /system/bin/surfaceflinger <<<
01-01 00:18:45.713 308 308 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
01-01 00:18:45.717 308 308 F DEBUG : Abort message: 'couldn't find an OpenGL ES implementation'
01-01 00:18:45.717 308 308 F DEBUG : r0 00000000 r1 00000130 r2 00000006 r3 00000008
01-01 00:18:45.717 308 308 F DEBUG : r4 ac6e158c r5 00000006 r6 ac6e1534 r7 0000010c
01-01 00:18:45.717 308 308 F DEBUG : r8 00000000 r9 00000000 sl 00000000 fp be8c2b9c
01-01 00:18:45.717 308 308 F DEBUG : ip 00000002 sp be8c25a8 lr ac332537 pc ac334da0 cpsr 600d0010
01-01 00:18:45.729 308 308 F DEBUG :
01-01 00:18:45.729 308 308 F DEBUG : backtrace:
01-01 00:18:45.729 308 308 F DEBUG : #00 pc 00049da0 /system/lib/libc.so (tgkill+12)
01-01 00:18:45.729 308 308 F DEBUG : #01 pc 00047533 /system/lib/libc.so (pthread_kill+34)
01-01 00:18:45.729 308 308 F DEBUG : #02 pc 0001d635 /system/lib/libc.so (raise+10)
01-01 00:18:45.729 308 308 F DEBUG : #03 pc 00019181 /system/lib/libc.so (__libc_android_abort+34)
01-01 00:18:45.729 308 308 F DEBUG : #04 pc 00017048 /system/lib/libc.so (abort+4)
01-01 00:18:45.729 308 308 F DEBUG : #05 pc 0000c313 /system/lib/libcutils.so (__android_log_assert+114)
01-01 00:18:45.729 308 308 F DEBUG : #06 pc 0000f871 /system/lib/libEGL.so
01-01 00:18:45.730 308 308 F DEBUG : #07 pc 0000bf0f /system/lib/libEGL.so
01-01 00:18:45.730 308 308 F DEBUG : #08 pc 0000c0f5 /system/lib/libEGL.so (eglGetDisplay+20)
01-01 00:18:45.730 308 308 F DEBUG : #09 pc 00027467 /system/lib/libsurfaceflinger.so (_ZN7android14SurfaceFlinger4initEv+50)
01-01 00:18:45.730 308 308 F DEBUG : #10 pc 0000101d /system/bin/surfaceflinger
01-01 00:18:45.730 308 308 F DEBUG : #11 pc 00016c61 /system/lib/libc.so (__libc_init+48)
01-01 00:18:45.730 308 308 F DEBUG : #12 pc 00000ec8 /system/bin/surfaceflinger
01-01 00:18:45.797 275 275 W : debuggerd: resuming target 304
01-01 00:18:45.798 275 275 E : debuggerd: failed to send signal 18 to target: No such process
通过log可以看到SurfaceFlinger在运行过程中调用OpenEGL的库,但是没有相应的库,由此可发现是少了厂商闭源的一些模块库。
从网站下载与编译的库(不仅限于openGL ES的,还有别的库)
https://developers.google.com/android/drivers --->Nexus 6 (Mobile) binaries for Android 7.0.0 (NBD91U)
有三个压缩包分别是博通,摩托,高通提供的私有lib,将他们下载下来后解压缩到安卓源码目录,运行shell脚本,脚本将lib解压缩到vendor目录中。
然后重新编译,刷机,运行成功。
编译内核:
1.下载内核代码
$ git clone https://android.googlesource.com/kernel/msm.git
2.checkout 代码
$ git checkout android-msm-shamu-3.10-n-preview-5
3.设置环境
export PATH=$PATH:../../prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin
export ARCH=arm
export CROSS_COMPILE=arm-eabi-
此处只能用arm-eabi-工具链,我用arm-linux-androideabi-工具链生成的img无法启动。
4.编译
$ make
将生成的arch/arm/boot/zImage-dtb copy到../../device/moto/shamu-kernel/
$ make bootimage
5.刷入bootimage
$ fastboot flash boot boot.img