Brillo を Intel Edison 向けに build してみよう

# はじめに

[前回](http://qiita.com/hidenorly/items/d114993052bb44f486d1) は、Brilloをbuildしてemulatorで起動してみました。

次は実機で。。。というわけで、build stepに迫りましょう。

# bspのdownload

```
~/work/brillo/tools/bdk/brunch$ cat README.md 
Brunch CLI for Brillo development

Brunch is a CLI tool to manage Brillo product development
```

というわけで、brunchというコマンドで管理ができるようです.


```
~/work/brillo/tools/bdk/brunch$ ./brunch bsp -h
usage: brunch bsp [-h] {download,list,uninstall} ...

positional arguments:
  {download,list,uninstall}
    download            Download a BSP. The software that you are downloading
                        is the property of the software owner and is
                        distributed by the software owner. Google is providing
                        the download service as a convenience.
    list                List available BSPs, and their current installation
                        status.
    uninstall           Uninstall BSP

optional arguments:
  -h, --help            show this help message and exit
```

こんなコマンドを見つけたので実行してみましょう。

```
~/work/brillo/tools/bdk/brunch$ ./brunch bsp list
edison - Intel Edison - Not Installed
```

edisonが最初からあるじゃないですか。。。

```
~/work/brillo/tools/bdk/brunch$ ./brunch bsp download edison
Installing edison BSP.
Downloading package "Edison IFWI"...
Remote package "Edison IFWI" contains a license LICENSE.txt:
Copyright  2015, Intel Corporation.

This Intel Edison Firmware ("Software") is furnished under license and may
only be used or copied in accordance with the terms of that license. No
license, express or implied, by estoppel or otherwise, to any intellectual
property rights is granted by this document. The Software is subject
to change without notice, and should not be construed as a commitment
by Intel Corporation to market, license, sell or support any product or
technology. Unless otherwise provided for in the license under which this
Software is provided, the Software is provided AS IS, with no warranties
of any kind, express or implied. Except as expressly permitted by the
Software license, neither Intel Corporation nor its suppliers assumes
any responsibility or liability for any errors or inaccuracies that may
appear herein. Except as expressly permitted by the Software license,
no part of the Software may be reproduced, stored in a retrieval system,
transmitted in any form, or distributed by any means without the express
written consent of Intel Corporation.


Do you accept this license (Y/n)? 
```

もちろんYです。

```
Downloading package "Edison U-boot"...
Remote package "Edison U-boot" contains a license LICENSE.txt:
		    GNU GENERAL PUBLIC LICENSE
		       Version 2, June 1991
..snip..
Do you accept this license (Y/n)? 
```

もちろんYです。

```
Downloading package "Edison WLAN firmware"...
Remote package "Edison WLAN firmware" contains a license LICENCE.broadcom_bcm43xx:

..snip..

Downloading package "Edison BT firmware"...
Remote package "Edison BT firmware" contains a license LICENCE.broadcom_bcm43xx:

..snip..

Downloading package "Edison device code"...
Remote package "Edison device code" contains a license flash_tools/LICENSE.txt:
Copyright 2015 Intel Corporation

..snip..

Downloading package "Edison base hardware code"...
Remote package "Edison base hardware code" contains a license peripheral/libmraa/src/i2c/LICENSE:

..snip..

Remote package "Edison base hardware code" contains a license peripheral/libupm/LICENSE:
Copyright © 2014-2015 Intel Corporation
..snip..
..snip..
```

というわけで、何度Yしたかわかりませんが、最後に、

```
Successfully installed edison BSP.
```

と出れば成功です。

# config

```
~/work/brillo/tools/bdk/brunch$ ././brunch product create hidenorlyBrillo edison
Creating product "hidenorlyBrillo" . . .
```

# build

```
~/work/brillo/tools/bdk/brunch$ ./brunch product build -b eng -p hidenorlyBrillo
To help improve the quality of this product, we collect
anonymized data on how the BDK is used. You may choose to opt out
of this collection now (by choosing 'N' at the below prompt),
or at any point in the future by running the following command:
    brunch config metrics disable
Do you want to help improve the Project Brillo BDK?
(Y/n) 

~/work/brillo/tools/bdk/brunch$ ./brunch product build -b eng -p hidenorlyBrillo
Output will be placed in /home/hidenorly/work/brillo/tools/bdk/brunch/hidenorlyBrillo/out
Building a shadow BDK v7.5.0 . . .
including device/generic/brillo/vendorsetup.sh
including device/generic/brillo/brilloemulator_arm/base_product/devicesetup.sh
including device/generic/brillo/brilloemulator_arm64/base_product/devicesetup.sh
including device/generic/brillo/brilloemulator_x86/base_product/devicesetup.sh
including device/generic/brillo/brilloemulator_x86_64/base_product/devicesetup.sh
including device/intel/edison/base_product/devicesetup.sh
including device/generic/mini-emulator-arm64/vendorsetup.sh
including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
including product/google/common/brillo_gpios/vendorsetup.sh
including product/google/common/brillo_leds/vendorsetup.sh

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.60
TARGET_PRODUCT=hidenorlyBrillo
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=x86
TARGET_ARCH_VARIANT=silvermont
TARGET_CPU_VARIANT=
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-44-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_CROSS_OS=windows
HOST_BUILD_TYPE=release
BUILD_ID=MASTER
OUT_DIR=out
============================================

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.60
TARGET_PRODUCT=hidenorlyBrillo
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=x86
TARGET_ARCH_VARIANT=silvermont
TARGET_CPU_VARIANT=
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-44-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_CROSS_OS=windows
HOST_BUILD_TYPE=release
BUILD_ID=MASTER
OUT_DIR=/home/hidenorly/work/brillo/tools/bdk/brunch/hidenorlyBrillo/out/out-edison
============================================
```

というわけで、待ちましょう・・・。

追記.

```
build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/packagelistparser/packagelistparser.h'
build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/packagelistparser/packagelistparser.h'
Starting build with ninja
ninja: Entering directory `.'
ninja: error: 'out/target/common/obj/PACKAGING/public_api.txt', needed by 'out/target/common/obj/PACKAGING/checkpublicapi-last-timestamp', missing and no known rule to make it
make: *** [ninja_wrapper] エラー 1
```

あれ・・・。

一度走らせると、

~/work/brillo/tools/bdk/brunch/hidenorlyBrillo/out/.bdk
の下に、~/work/brillo相当のものが見えます.

```
~/work/brillo/tools/bdk/brunch/hidenorlyBrillo/out/.bdk$ ls
Android.bp  abi     bootable        build   external    hardware         out        product  tools
Makefile    bionic  bootstrap.bash  device  frameworks  libnativehelper  prebuilts  system   vendor
```

とりあえず、再度repo syncしてrebuildしてみます。。。


# fix error

```~/work/brillo/tools/bdk/brunch/hidenorlyBrillo/out/.bdk/build/core/tasks/apicheck.mk
..snip..
# skip api check for PDK buid
ifeq (,$(filter true, $(WITHOUT_CHECK_API) $(TARGET_BUILD_PDK)))
+.PHONY: checkapi
+.PHONY: check-public-api
+.PHONY: update-api
+else
.PHONY: checkapi
..snip..
```

すると、つぎは、

```
build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/packagelistparser/packagelistparser.h'
build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/packagelistparser/packagelistparser.h'
Starting build with ninja
ninja: Entering directory `.'
ninja: error: 'out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar', needed by 'out/target/common/obj/PACKAGING/boot-jars-package-check_intermediates/stamp', missing and no known rule to make it
make: *** [ninja_wrapper] エラー 1
```

boot-jarsは、java codeですが、AOSPにはまだなっていません。。。というわけで無理か?

```~/work/brillo/tools/bdk/brunch/hidenorlyBrillo/out/.bdk/build/core/tasks/boot_jars_package_check.mk
-ifneq ($(SKIP_BOOT_JARS_CHECK),true)
+ifeq ($(SKIP_BOOT_JARS_CHECK),true)
-ifneq ($(TARGET_BUILD_PDK),true)
+ifeq ($(TARGET_BUILD_PDK),true)
```

としても

```
ninja: error: 'out/target/product/generic/obj/STATIC_LIBRARIES/libpng_intermediates/export_includes', needed by 'out/target/product/generic/obj/EXECUTABLES/recovery_intermediates/import_includes', missing and no known rule to make it
make: *** [ninja_wrapper] エラー 1
```

たしかに、external/libpngはbrilloのmanifestにはないので、とりあえず、

```
$ ln -s /home/hidenorly/work/master/external/libpng /home/hidenorly/work/brillo/external/libpng
```
して再度試してみます。。。