天天看点

Android系统源代码编译—[4]运行构建构建fastboot和adb引导到fastboot模式解锁bootloader选择一个设备进行构建Flash到一个设备

本文提供了在特定设备上运行构建的详细内容,同时也被设计扩充准备构建的信息。

构建fastboot和adb

如果你还没有fastboot和adb,你可以使用正规的构建系统构建他们。使用准备构建中的说明并使用下面命令来替换make命令:

$ make fastboot adb
           

引导到fastboot模式

在冷启动设备期间,使用下面的组合键引导进入fastboot模式,这个模式是一个用来flash设备的引导装载程序模式。

Device Keys
hikey Link pins 1 - 2 and 5 - 6 of J15
angler Press and hold Volume Down, then press and hold Power
bullhead Press and hold Volume Down, then press and hold Power
shamu Press and hold Volume Down, then press and hold Power
fugu Press and hold Power
volantis Press and hold Volume Down, then press and hold Power
hammerhead Press and hold both Volume Up and Volume Down, then press and hold Power
flo Press and hold Volume Down, then press and hold Power
deb Press and hold Volume Down, then press and hold Power
manta Press and hold both Volume Up and Volume Down, then press and hold Power
mako Press and hold Volume Down, then press and hold Power
grouper Press and hold Volume Down, then press and hold Power
tilapia Press and hold Volume Down, then press and hold Power
phantasm Power the device, cover it with one hand after the LEDs light up and until they turn red
maguro Press and hold both Volume Up and Volume Down, then press and hold Power
toro Press and hold both Volume Up and Volume Down, then press and hold Power
toroplus Press and hold both Volume Up and Volume Down, then press and hold Power
panda Press and hold Input, then press Power
wingray Press and hold Volume Down, then press and hold Power
crespo Press and hold Volume Up, then press and hold Power
crespo4g Press and hold Volume Up, then press and hold Power

不用组合键你也可以使用命令adb reboot bootloader 来重启直接进入引导装载程序。

解锁bootloader

只有手机的bootloader允许才能flash一个定制的系统,而且bootloader默认是锁定的。你可以解锁bootloader,但是需要意识到这样做会删除用户的隐私数据(解锁操作只需要运行一次)。解锁后,设备上的所有数据都会被擦除,i.e.应用的私有数据以及通过USB共享的数据,包括图片和电影。在解锁bootloader前请确保已备份了珍贵的文件。

当设备在fastboot模式下,使用下面命令来解锁bootloader:

$ fastboot oem unlock
           

在Nexus 10设备上,解锁bootloader后,内部存储是无格式的。你可以使用下面命令格式化设备:

$ fastboot format cache
$ fastboot format userdata
           

重新锁定bootloader,使用:

Note: 在Motoroal Xoom设备上重新锁定bootloader或擦除用户数据(包括USB共享的数据)。

选择一个设备进行构建

当运行无参数的lunch命令时,建议通过lunch菜单中选择可用的build。你可以从developers.google.com为Nexus设备下载factory inages 和 二进制文件:

  • Preview binaries (blobs)
  • Factory images for released devices
  • Support binaries (drivers) for release devices

参见获取专有二进制文件了解更详细的信息以及通过设备二进制文件要求了解其他资源。

Device Code name Build configuration
HiKey hikey hikey-userdebug
Nexus 6P angler aosp_angler-userdebug
Nexus 5X bullhead aosp_bullhead-userdebug
Nexus 6 shamu aosp_shamu-userdebug
Nexus Player fugu aosp_fugu-userdebug
Nexus 9 volantis (flounder) aosp_flounder-userdebug
Nexus 5 (GSM/LTE) hammerhead aosp_hammerhead-userdebug
Nexus 7 (Wi-Fi) razor (flo) aosp_flo-userdebug
Nexus 7 (Mobile) razorg (deb) aosp_deb-userdebug
Nexus 10 mantaray (manta) full_manta-userdebug
Nexus 4 occam (mako) full_mako-userdebug
Nexus 7 (Wi-Fi) nakasi (grouper) full_grouper-userdebug
Nexus 7 (Mobile) nakasig (tilapia) full_tilapia-userdebug
Galaxy Nexus (GSM/HSPA+) yakju (maguro) full_maguro-userdebug
Galaxy Nexus (Verizon) mysid (toro) aosp_toro-userdebug
Galaxy Nexus (Experimental) mysidspr (toroplus) aosp_toroplus-userdebug
PandaBoard (Archived) panda aosp_panda-userdebug
Motorola Xoom (U.S. Wi-Fi) wingray full_wingray-userdebug
Nexus S soju (crespo) full_crespo-userdebug
Nexus S 4G sojus (crespo4g) full_crespo4g-userdebug\

Flash到一个设备

你可以使用单一的命令来flash一个完整的Android系统到设备;这样做可以确定flash的系统和已经初始化的bootlodaer以及radio是兼容的,然后写入boot,还原,系统分区,然后重启系统。Flashing同样也会擦除所有用户数据,类似于fastboot oem unlock.

然设备进入fastboot模式既可以手动通过在boot过程中按组合键也可以通过下面的shell命令:

$ adb reboot bootloader
           

一旦设备处于fastboot模式,运行:

$ fastboot flashall -w
           

-w选项擦除了设备上的/data分区;当你第一次flash特定设备的时候是有用的但不是必须的。

Note: 通过在Motorola Xoom设备上 fastboot来创建的文件系统没有进行函数优化。我们建议通过recovery来re-creating 文件系统,使用$ adb reboot recovery.当在recovery这段时间里,打开菜单(按住 Power + Volume Up),清楚缓存分区,然后清楚数据。