编译android-4.3.1_r源代码并刷到自己的Galaxy Nexus I9250真机上

编译android-4.3.1_r源代码并刷到自己的Galaxy Nexus I9250真机上
作者:雨水  日期:2014-04-30

编译源码的目的还是为了自己改动源码,然后还可以执行在相应的手机上,仅仅有这样才有意义.  我手上有一部三星的Galaxy Nexus I9250, 代号为maguro。可是在眼下google的官方未提供针对android4.4.2版本号所相应的硬件驱动,最新仅仅提供到Android4.3,详细可以在 https://developers.google.com/android/nexus/drivers这里查看。 
我在网上看有基于4.4源代码+4.3驱动编译成功并能执行的,但我尝试了,非常多错误到眼下为止还没解决(已于2014-5-4已搞定),因此先尝试了4.3的源代码+4.3的驱动。以下就是整个过程:

注:关于编译环境设置等细节參考我的前一篇< 基于Ubuntu 14.04 LTS编译Android4.4.2源码>.
第一步:获取android-4.3.1_r1的源代码
$mkdir android-4.3.1_r1
$cd android-4.3.1_r1
$repo init -u https://android.googlesource.com/platform/manifest -b android-4.3.1_r1
$repo sync
第二步:编译android-4.3.1_r1的源代码
dennis@dubuntu1404:~/devenv/android-4.3.1_r1$ . build/envsetup.sh
including device/asus/deb/vendorsetup.sh
including device/asus/flo/vendorsetup.sh
including device/asus/tilapia/vendorsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/mips/vendorsetup.sh
including device/generic/x86/vendorsetup.sh
including device/lge/mako/vendorsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/manta/vendorsetup.sh
including device/samsung_slsi/arndale/vendorsetup.sh
including device/samsung/toroplus/vendorsetup.sh
including device/samsung/toro/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash
dennis@dubuntu1404:~/devenv/android-4.3.1_r1$ lunch
You're building on Linux
Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_x86-eng
     3. aosp_mips-eng
     4. vbox_x86-eng
     5. aosp_deb-userdebug
     6. aosp_flo-userdebug
     7. full_tilapia-userdebug
     8. mini_armv7a_neon-userdebug
     9. mini_mips-userdebug
     10. mini_x86-userdebug
     11. full_mako-userdebug
     12. full_maguro-userdebug
     13. full_manta-userdebug
     14. full_arndale-userdebug
     15. full_toroplus-userdebug
     16. full_toro-userdebug
     17. full_panda-userdebug
Which would you like? [aosp_arm-eng] 12
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.3.1
TARGET_PRODUCT=full_maguro
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a9
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=JLS36I
OUT_DIR=out
============================================
dennis@dubuntu1404:~/devenv/android-4.3.1_r1$ make -j4
注1:假设这一步直接刷机,会出现提示flash成功,可是重新启动之后出现google的logo之后就黑屏,无法启动。原因就是由于驱动没有加进来,必须完毕第三步之后再開始刷机。
注2:编译过程中可能会出现例如以下错误:
Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
解决的方法:
$sudo apt-get install libswitch-perl
第三步:下载i9250(maguro)的官方驱动并又一次编译
(1) 下载驱动:进入 https://developers.google.com/android/nexus/drivers#magurojwr66y,将Wi-Fi等6个驱动一次下载下来,然后解压,会生成6个.sh文件。将这些文件放入源码的根文件夹就可以。
(2) 运行.sh文件提取驱动程序: 通过运行"chmod +x *.sh"为它们添加可运行权限,然后依次运行这6个sh文件,每一个文件会让你输入"I ACCEPT"来接受协议。接受之后会将提取后的驱动放入名为vendor的文件夹中。此时,vendor文件夹应该位于源码的根文件夹之下,即android-4.3.1_r1之下。
然后再次依次运行例如以下命令又一次编译,本次编译时间会比較短。
$. build/envsetup.sh
$lunch 12
$make -j4
第四步 将编译好的img刷到i9250手机上
(1) 改动~/.bashrc中的环境变量ANDROID_PRODUCT_OUT为:
export ANDROID_PRODUCT_OUT=/home/dennis/devenv/android-4.3.1_r1/out/target/product/maguro
(2) 又一次进入命令行,然后開始刷机
$ adb reboot bootloader
$ fastboot flashall -w
刷好之后,系统会自己主动重新启动,假设没什么其它问题,你能够看到你的劳动成果了!

作者:雨水 转载请注明出处: http://blog.csdn.net/gobitan/article/details/24792589
參考资料:
1.   http://blog.csdn.net/gobitan/article/details/24367439 基于Ubuntu 14.04 LTS编译Android4.4.2源码
2.   http://blog.csdn.net/zjmdp/article/details/7737802 Android 4.1 (Jelly Bean) 源代码编译过程总结

你可能感兴趣的:(android)