LoginSignup
3
6

More than 5 years have passed since last update.

自前でビルドしたAndroidソースをNexusに焼く

Posted at

Nexusシリーズ(最近はPixelですね)は公式にBootloaderをアンロックして、自前で改造したAndroidのソースをビルドして焼きこむことができるので、それのコマンドメモ。
基本的には公式サイトの抜粋です。
なお、焼き込みターゲットはNexus 9です。
※Bootloaderをアンロックするとメーカーの保証等は受けられなくなります。

環境

Ubuntu 16.04 LTS
メモリ 16GB
CPU Intel® Core™ i5-4570 CPU @ 3.20GHz × 4
HDD 500GB
※HDDが公式で250GBも必要らしいので注意して下さい

AOSPソースのビルド

bash
#JDKが入ってることを確認(1.8.0_131が入ってた)
java -version

#作業用ディレクトリ作成
mkdir androidAllBuild
cd androidAllBuild/

#もろもろインストール
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip

#Repoをインストール
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

#ソースDL(時間かかる)
mkdir nexus9_1
cd nexus9_1/
#目的のブランチを指定(今回はandroid-7.1.1_r53)
repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.1_r53
repo sync

#ソースを編集
#OSを改造したり、調査用のログを入れたり…

#ビルド(時間かかる)
make clobber
source build/envsetup.sh
#ターゲット端末を指定(今回はaosp_flounder-userdebug)
lunch
make -j4

焼きこみ

こちらを参考にブートローダーをアンロックする。
ちなみに当方の環境ではfastbootはsudoで実行する必要があったので↓のように実行

bash
sudo XXXXXX/androidAllBuild/nexus9_1/out/host/linux-x86/bin/fastboot oem unlock

次に実際に端末に焼きこむ。

bash
env | grep ANDROID_PRODUCT_OUT
sudo -E XXXXXX/androidAllBuild/nexus9_1/out/host/linux-x86/bin/fastboot flashall -w

以上で自分でビルドしたROMで検証等が可能となる。

公式イメージへの戻し方

公式サイトに工場出荷時のイメージが置いてあるのでそちらへの戻し方。
公式サイトからNexus9のイメージを落としてきてflash-all.shの中身を参考に↓のコマンドを実行。
※基本的にflash-all.shの中身をsudoで実行してるだけ。

bash
adb reboot bootloader
sudo XXXXXX/androidAllBuild/nexus9_1/out/host/linux-x86/bin/fastboot flash bootloader bootloader-flounder-3.50.0.0143.img
sudo XXXXXX/androidAllBuild/nexus9_1/out/host/linux-x86/bin/fastboot reboot-bootloader
sudo XXXXXX/androidAllBuild/nexus9_1/out/host/linux-x86/bin/fastboot -w update image-volantis-n9f27m.zip
3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6