LoginSignup
2
3

More than 5 years have passed since last update.

Android Open Source Project(AOSP)最新環境をビルドし、リファレンスボード:Hikey960で動かす

Last updated at Posted at 2018-09-15

Android Open Source Project(AOSP)のmasterブランチ環境を、リファレンスボードであるHiKey960向けにビルドして書き込み・動作を行う

基本的には、AOSPサイト及びビルド環境のdevice/linaro/hikey/hikey960/READMEの手順通り

用意するもの

  • Hikey960
    • 電源
    • USBケーブル (ビルドPCと接続。Hikey960側はType-C)
    • HDMIディスプレイ、ケーブル
    • USBマウス
  • ビルドPC
    • CPUコアは多いほど良い
      ただし第一世代Ryzenの初期ロットは、ランダムにビルドがコケる場合あり
      Ryzen SEGV問題
    • ストレージはビルド環境 & 生成物で200GB近く食うのでそれ以上
    • OSはUbuntu16.04が無難。AOSPサイトには14.04推奨とは書いてあるけど古い感

ビルドPCのセットアップ

ビルドに必要となるパッケージをインストール

AOSPサイト記載のUbuntu14.04向けのパッケージ一式でビルド確認済
JDKは、ビルド環境に含まれるので、個別にインストールする必要がない模様

$ 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 \
libgl1-mesa-dev libxml2-utils xsltproc unzip

Repoコマンドのインストール

ビルド環境のGitレポジトリ一式をまとめてダウンロードするツールをインストール

$ mkdir ~/bin
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

※~/binはログインし直せば勝手にPATHが通るはず

adb/fastbootアクセスの設定

Android SDKを入れてadb/fastbootが使えるようにしておく
# aptでandroid-tools-adb, android-tools-fastbootを入れてもいいかもしれないが古そう?

また、ユーザ権限でアクセスできるようにするために、udevルールファイルを作成しておく

/etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"

AOSPビルド環境取得

$ repo init -u https://android.googlesource.com/platform/manifest -b master
$ repo sync -c -j24

repo init の-b指定は、masterなら省略できる
repo sync の-cは、カレントブランチのみ取得の指定。多少早くなる

ローカルにmirrorを作成して利用する方法についてはこちらの記事を参照

ビルド実行

$ . ./build/envsetup.sh
$ lunch hikey960-userdebug
$ make -j16

-j指定は、色々と試した経験上、物理コア数x2(HTT/SMT対応CPUなら論理コア数x1)くらいが丁度よい感
Ryzen2700X / メモリ32GB / NVMe SSDの環境でビルド時間は80分程度

イメージ書き込み

まずはfastbootモードでHikey960を起動させておくこと
HiKey960上のスイッチ1,3をONにして起動するか、adb reboot bootloaderを実行

flash-all.shによりパーティションテーブル含めて一括更新が可能

$ cd device/linaro/hikey/installer/hikey960
$ ./flash-all.sh
android out dir:./../../../../..//out/target/product/hikey960
Sending 'xloader' (151 KB)                         OKAY [  0.010s]
Writing 'xloader'                                  FAILED (remote: 'flash write back vrl failure')
Finished. Total time: 0.116s
Sending 'ptable' (196 KB)                          OKAY [  0.011s]
Writing 'ptable'                                   OKAY [  0.023s]
Finished. Total time: 0.047s
・・・

xloaderパーティションの更新でエラーが出るが、device/linaro/hikey/installer/hikey960/READMEには気にするなとの記載あり
nvmeパーティションの更新以降でエラーとなる場合は、直前にwaitを入れておくと良さげ

device/linaro/hikey/installer/hikey960/flash-all.sh
diff --git a/installer/hikey960/flash-all.sh b/installer/hikey960/flash-all.sh
index 2888020..c123577 100755
--- a/installer/hikey960/flash-all.sh
+++ b/installer/hikey960/flash-all.sh
@@ -19,6 +19,7 @@ fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
 fastboot flash ptable "${INSTALLER_DIR}"/hisi-ptable.img
 fastboot flash fastboot "${INSTALLER_DIR}"/hisi-fastboot.img
 fastboot reboot-bootloader
+sleep 5s
 fastboot flash nvme "${INSTALLER_DIR}"/hisi-nvme.img
 fastboot flash fw_lpm3   "${INSTALLER_DIR}"/hisi-lpm3.img
 fastboot flash trustfirmware   "${INSTALLER_DIR}"/hisi-bl31.bin

起動

HiKey960上のスイッチを弄っていた場合は、スイッチ3をOFFに戻してから起動
繋いだHDMIディスプレイに、起動画面(androidロゴ)、続いてホーム画面が表示されればOK

2
3
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
2
3