summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTina Zhang <tina.zhang@intel.com>2015-10-08 16:20:11 +0800
committerGaurav Shah <gauravsh@google.com>2015-10-23 15:56:58 -0700
commitf99492f8737ae991759928760b2391653f34825d (patch)
tree88b4c283afd4a8942265c201fb8b7bd3279cdddd
parentdbff98408c234cc3ae4d6e0e12523fddd31127aa (diff)
downloadbrillo-f99492f8737ae991759928760b2391653f34825d.tar.gz
Enable IA emulator
This patch is used to enable building IA image. With this patch, one can generate the IA image and boot the emulator to shell. Build steps to generate system image are as follow: . build/envsetup.sh lunch brilloemulator_x86-eng make -jX To boot the system, please use brilloemulator-x86 or brilloemulator-x86_64 under base_product/qemu/ folder. To use adb feature, you need to download the patch: https://android-review.googlesource.com/#/c/175598/ Change-Id: I36360ed616c41af0f440c7767721ba0fcb50ff44 Signed-off-by: Bruce Beare <bruce.j.beare@intel.com> Signed-off-by: Tina Zhang <tina.zhang@intel.com> Signed-off-by: Lizhe Liu <lizhe.liu@intel.com> Signed-off-by: Jason Hu <jia-cheng.hu@intel.com> Signed-off-by: Yu Ning <yu.ning@intel.com> Original Author: Lizhe Liu <lizhe.liu@intel.com>
-rw-r--r--brilloemulator_x86/AndroidBoard.mk19
-rw-r--r--brilloemulator_x86/BoardConfig.mk38
-rw-r--r--brilloemulator_x86/base_product/AndroidProducts.mk21
-rw-r--r--brilloemulator_x86/base_product/brilloemulator_x86.mk29
-rw-r--r--brilloemulator_x86/base_product/devicesetup.sh17
-rw-r--r--brilloemulator_x86/base_product/qemu/Android.mk21
-rwxr-xr-xbrilloemulator_x86/base_product/qemu/brilloemulator-x8653
-rw-r--r--brilloemulator_x86/base_product/weaved.conf79
-rw-r--r--brilloemulator_x86/bsp/brillo.kconf23
-rw-r--r--brilloemulator_x86/bsp/init.qemu.rc26
-rw-r--r--brilloemulator_x86/bsp/initnetwork.sh11
-rw-r--r--brilloemulator_x86/bsp/qemu_x86.mk42
-rw-r--r--brilloemulator_x86/bsp/sepolicy/brillo_setup.te3
-rw-r--r--brilloemulator_x86/bsp/sepolicy/file_contexts1
-rw-r--r--brilloemulator_x86/fstab.device2
-rw-r--r--brilloemulator_x86_64/AndroidBoard.mk19
-rw-r--r--brilloemulator_x86_64/BoardConfig.mk38
-rw-r--r--brilloemulator_x86_64/base_product/AndroidProducts.mk21
-rw-r--r--brilloemulator_x86_64/base_product/brilloemulator_x86_64.mk29
-rw-r--r--brilloemulator_x86_64/base_product/devicesetup.sh17
-rw-r--r--brilloemulator_x86_64/base_product/qemu/Android.mk21
-rwxr-xr-xbrilloemulator_x86_64/base_product/qemu/brilloemulator-x86_6453
-rw-r--r--brilloemulator_x86_64/base_product/weaved.conf79
-rw-r--r--brilloemulator_x86_64/bsp/brillo.kconf23
-rw-r--r--brilloemulator_x86_64/bsp/init.qemu.rc26
-rw-r--r--brilloemulator_x86_64/bsp/initnetwork.sh11
-rw-r--r--brilloemulator_x86_64/bsp/qemu_x86_64.mk51
-rw-r--r--brilloemulator_x86_64/bsp/sepolicy/brillo_setup.te3
-rw-r--r--brilloemulator_x86_64/bsp/sepolicy/file_contexts1
-rw-r--r--brilloemulator_x86_64/fstab.device2
30 files changed, 779 insertions, 0 deletions
diff --git a/brilloemulator_x86/AndroidBoard.mk b/brilloemulator_x86/AndroidBoard.mk
new file mode 100644
index 0000000..ddfeb1c
--- /dev/null
+++ b/brilloemulator_x86/AndroidBoard.mk
@@ -0,0 +1,19 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This has to live here for now as the variables it requires are
+# not read when BoardConfig.mk is parsed.
+include device/generic/brillo/kernel.mk
diff --git a/brilloemulator_x86/BoardConfig.mk b/brilloemulator_x86/BoardConfig.mk
new file mode 100644
index 0000000..0db52ca
--- /dev/null
+++ b/brilloemulator_x86/BoardConfig.mk
@@ -0,0 +1,38 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Standard devices would usally define an SoC. As the emulator
+# has no SoC defnition we pull in a local qemu BSP.
+include device/generic/brillo/brilloemulator_x86/bsp/qemu_x86.mk
+
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 786432000
+# No ramdisk.
+BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
+
+# No ramdisk.
+BOARD_USES_FULL_RECOVERY_IMAGE := true
+
+TARGET_RECOVERY_FSTAB = device/generic/brillo/brilloemulator_x86/fstab.device
+
+# This is an emulator build.
+TARGET_SKIP_OTA_PACKAGE := true
+
+# Use clang.
+USE_CLANG_PLATFORM_BUILD := true
+
+PRODUCT_COPY_FILES += \
+ device/generic/brillo/brilloemulator_x86/fstab.device:root/fstab.device
diff --git a/brilloemulator_x86/base_product/AndroidProducts.mk b/brilloemulator_x86/base_product/AndroidProducts.mk
new file mode 100644
index 0000000..32965cf
--- /dev/null
+++ b/brilloemulator_x86/base_product/AndroidProducts.mk
@@ -0,0 +1,21 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This file is found by the build system.
+# It defines the base product definition for device bring up.
+
+PRODUCT_MAKEFILES := \
+ $(LOCAL_DIR)/brilloemulator_x86.mk
diff --git a/brilloemulator_x86/base_product/brilloemulator_x86.mk b/brilloemulator_x86/base_product/brilloemulator_x86.mk
new file mode 100644
index 0000000..5474637
--- /dev/null
+++ b/brilloemulator_x86/base_product/brilloemulator_x86.mk
@@ -0,0 +1,29 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+$(call inherit-product, device/generic/brillo/brillo_base.mk)
+
+PRODUCT_NAME := brilloemulator_x86
+PRODUCT_BRAND := Brillo
+
+PRODUCT_DEVICE := brilloemulator_x86
+
+# Install emulator-specific config file for weaved.
+PRODUCT_COPY_FILES += \
+ device/generic/brillo/brilloemulator_x86/base_product/weaved.conf:system/etc/weaved/weaved.conf
+
+PRODUCT_PACKAGES += \
+ brilloemulator-x86
diff --git a/brilloemulator_x86/base_product/devicesetup.sh b/brilloemulator_x86/base_product/devicesetup.sh
new file mode 100644
index 0000000..ee80aa2
--- /dev/null
+++ b/brilloemulator_x86/base_product/devicesetup.sh
@@ -0,0 +1,17 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+add_lunch_combo brilloemulator_x86-eng
diff --git a/brilloemulator_x86/base_product/qemu/Android.mk b/brilloemulator_x86/base_product/qemu/Android.mk
new file mode 100644
index 0000000..098329c
--- /dev/null
+++ b/brilloemulator_x86/base_product/qemu/Android.mk
@@ -0,0 +1,21 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := optional
+LOCAL_PREBUILT_EXECUTABLES := brilloemulator-x86
+include $(BUILD_HOST_PREBUILT)
diff --git a/brilloemulator_x86/base_product/qemu/brilloemulator-x86 b/brilloemulator_x86/base_product/qemu/brilloemulator-x86
new file mode 100755
index 0000000..d14a247
--- /dev/null
+++ b/brilloemulator_x86/base_product/qemu/brilloemulator-x86
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+function PrintUsage() {
+ echo "$0 -m <mem>"
+ echo -e "\t-m <mem>\tSet memory size in MB"
+ exit 1
+}
+
+MEM=1024
+ARGS=$(getopt -o hm: -- "$@")
+eval set -- "$ARGS"
+while true ; do
+ case "$1" in
+ -m)
+ case "$2" in
+ *) MEM=$2; shift 2;;
+ esac ;;
+ -h) PrintUsage ;;
+ --) shift; break ;;
+ esac
+done
+
+echo Starting Emulator with ${MEM}MB Memory
+${ANDROID_BUILD_TOP}/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-i386 \
+ -m ${MEM}M \
+ -kernel ${ANDROID_BUILD_TOP}/out/target/product/brilloemulator_x86/kernel \
+ -append "console=ttyS0 root=/dev/vda androidboot.hardware=qemu qemu=1 rootwait noinitrd init=/init androidboot.selinux=enforcing"\
+ -nographic \
+ -device virtio-blk-pci,drive=system\
+ -drive file="${ANDROID_BUILD_TOP}/out/target/product/brilloemulator_x86/system.img,if=none,id=system,format=raw" \
+ -device virtio-blk-pci,drive=userdata \
+ -drive file="${ANDROID_BUILD_TOP}/out/target/product/brilloemulator_x86/userdata.img,if=none,id=userdata,format=raw" \
+ -netdev user,id=mynet -device virtio-net-pci,netdev=mynet \
+ -redir tcp:5555::5555 \
+ -vga none \
+ -L ${ANDROID_BUILD_TOP}/prebuilts/android-emulator/linux-x86_64/lib/pc-bios
diff --git a/brilloemulator_x86/base_product/weaved.conf b/brilloemulator_x86/base_product/weaved.conf
new file mode 100644
index 0000000..0d3b76f
--- /dev/null
+++ b/brilloemulator_x86/base_product/weaved.conf
@@ -0,0 +1,79 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# OAuth 2.0 client id.
+client_id=58855907228.apps.googleusercontent.com
+
+# OAuth 2.0 client secret.
+client_secret=eHSAREAHrIqPsHBxCE9zPPBi
+
+# OAuth 2.0 API key.
+api_key=AIzaSyDSq46gG-AxUnC3zoqD9COIPrjolFsMfMA
+
+# Human readable name of the device.
+name=Starter Board
+
+# Human readable description of the device.
+# Defaults to empty string"
+description=X86 Emulator
+
+# Location of the device.
+# location=
+
+# Manufacturer of the device.
+oem_name=Brillo
+
+# Model of the device.
+# Defaults to Brillo.
+model_name=Emulator
+
+# Five character code assigned by the cloud registry of device models.
+# Defaults to "AAAAA" (Unregistered model).
+model_id=AAAAA
+
+# Maximum role for local anonymous user.
+# local_anonymous_access_role=viewer
+
+# If true, allows local pairing using Privet API.
+# local_pairing_enabled=true
+
+# If true, allows local discovery using mDns.
+# local_discovery_enabled=true
+
+# GCD service polling interval in milliseconds.
+# polling_period_ms=7000
+
+# GCD service backup polling interval in milliseconds.
+# backup_polling_period_ms=1800000
+
+# Automatic mode causes buffet to automatically bring up a SoftAP for
+# bootstrapping when it loses network connectivity for long enough,
+# and on first boot.
+# wifi_auto_setup_enabled=true
+
+# List of pairing modes supported by device.
+# Values can be one of pinCode, embeddedCode, ultrasound32, audible32.
+# Defaults to pinCode if embedded_code_path is empty, or embeddedCode otherwise.
+pairing_modes=embeddedCode
+
+# Absolute path to file specifying an embedded pairing code. The file at
+# embedded_code_path should be a file in key value format, with a key
+# embedded_code.
+# Defaults to empty path.
+embedded_code_path=/etc/weaved/weaved.conf
+
+# Embedded code.
+embedded_code=hello
diff --git a/brilloemulator_x86/bsp/brillo.kconf b/brilloemulator_x86/bsp/brillo.kconf
new file mode 100644
index 0000000..3e52596
--- /dev/null
+++ b/brilloemulator_x86/bsp/brillo.kconf
@@ -0,0 +1,23 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+CONFIG_GOLDFISH=y
+CONFIG_GOLDFISH_PIPE=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_NET_9P=y
+CONFIG_NET_9P_VIRTIO=y
+CONFIG_DEBUG_INFO=y
diff --git a/brilloemulator_x86/bsp/init.qemu.rc b/brilloemulator_x86/bsp/init.qemu.rc
new file mode 100644
index 0000000..2a9002c
--- /dev/null
+++ b/brilloemulator_x86/bsp/init.qemu.rc
@@ -0,0 +1,26 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+on fs
+ mount_all /fstab.device
+
+on boot
+ start initnetwork
+
+service initnetwork /system/bin/initnetwork.sh
+ user root
+ group root
+ oneshot
diff --git a/brilloemulator_x86/bsp/initnetwork.sh b/brilloemulator_x86/bsp/initnetwork.sh
new file mode 100644
index 0000000..d2f8ca7
--- /dev/null
+++ b/brilloemulator_x86/bsp/initnetwork.sh
@@ -0,0 +1,11 @@
+#!/system/bin/sh
+
+# Setup networking when boot starts
+ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up
+route add default gw 10.0.2.2
+# Open up port 5555 for adb
+iptables -I INPUT -p tcp --dport 5555 -j ACCEPT -w
+# Run dnsmasq so we can access hosts on the Internet. This is needed since
+# Bionic hard-wires DNS requests to go to 0.0.0.0, so this acts as a DNS proxy.
+dnsmasq --no-hosts --listen-address=127.0.0.1 --no-resolv --server=8.8.8.8 \
+ --pid-file < /dev/null
diff --git a/brilloemulator_x86/bsp/qemu_x86.mk b/brilloemulator_x86/bsp/qemu_x86.mk
new file mode 100644
index 0000000..def4c01
--- /dev/null
+++ b/brilloemulator_x86/bsp/qemu_x86.mk
@@ -0,0 +1,42 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# TODO(leecam): Make this automatic.
+LOCAL_PATH := device/generic/brillo/brilloemulator_x86/bsp
+
+TARGET_ARCH := x86
+TARGET_CPU_ABI := x86
+TARGET_KERNEL_ARCH := i386
+
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := false
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/init.qemu.rc:root/init.qemu.rc \
+ $(LOCAL_PATH)/initnetwork.sh:system/bin/initnetwork.sh \
+ system/core/rootdir/init.usb.rc:root/init.usb.rc \
+ system/core/rootdir/ueventd.rc:root/ueventd.rc \
+
+# Set up the local kernel.
+TARGET_KERNEL_SRC := hardware/bsp/kernel/common/android-3.18
+TARGET_KERNEL_DEFCONFIG := i386_defconfig
+TARGET_KERNEL_CONFIGS := $(realpath $(LOCAL_PATH)/brillo.kconf)
+
+BOARD_SEPOLICY_DIRS := $(BOARD_SEPOLICY_DIRS) $(LOCAL_PATH)/sepolicy
diff --git a/brilloemulator_x86/bsp/sepolicy/brillo_setup.te b/brilloemulator_x86/bsp/sepolicy/brillo_setup.te
new file mode 100644
index 0000000..5834064
--- /dev/null
+++ b/brilloemulator_x86/bsp/sepolicy/brillo_setup.te
@@ -0,0 +1,3 @@
+# Needed for dnsmasq (run from initnetwork.sh).
+allow brillo_setup dnsmasq_exec:file { execute execute_no_trans getattr open read };
+allow brillo_setup self:capability { net_bind_service setgid setuid };
diff --git a/brilloemulator_x86/bsp/sepolicy/file_contexts b/brilloemulator_x86/bsp/sepolicy/file_contexts
new file mode 100644
index 0000000..e5910f5
--- /dev/null
+++ b/brilloemulator_x86/bsp/sepolicy/file_contexts
@@ -0,0 +1 @@
+/system/bin/initnetwork.sh u:object_r:brillo_setup_exec:s0 \ No newline at end of file
diff --git a/brilloemulator_x86/fstab.device b/brilloemulator_x86/fstab.device
new file mode 100644
index 0000000..362b854
--- /dev/null
+++ b/brilloemulator_x86/fstab.device
@@ -0,0 +1,2 @@
+/dev/block/vda / ext4 ro wait
+/dev/block/vdb /data ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
diff --git a/brilloemulator_x86_64/AndroidBoard.mk b/brilloemulator_x86_64/AndroidBoard.mk
new file mode 100644
index 0000000..ddfeb1c
--- /dev/null
+++ b/brilloemulator_x86_64/AndroidBoard.mk
@@ -0,0 +1,19 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This has to live here for now as the variables it requires are
+# not read when BoardConfig.mk is parsed.
+include device/generic/brillo/kernel.mk
diff --git a/brilloemulator_x86_64/BoardConfig.mk b/brilloemulator_x86_64/BoardConfig.mk
new file mode 100644
index 0000000..aceb3d7
--- /dev/null
+++ b/brilloemulator_x86_64/BoardConfig.mk
@@ -0,0 +1,38 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Standard devices would usally define an SoC. As the emulator
+# has no SoC defnition we pull in a local qemu BSP.
+include device/generic/brillo/brilloemulator_x86_64/bsp/qemu_x86_64.mk
+
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 786432000
+# No ramdisk.
+BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
+
+# No ramdisk.
+BOARD_USES_FULL_RECOVERY_IMAGE := true
+
+TARGET_RECOVERY_FSTAB = device/generic/brillo/brilloemulator_x86_64/fstab.device
+
+# This is an emulator build.
+TARGET_SKIP_OTA_PACKAGE := true
+
+# Use clang.
+USE_CLANG_PLATFORM_BUILD := false
+
+PRODUCT_COPY_FILES += \
+ device/generic/brillo/brilloemulator_x86_64/fstab.device:root/fstab.device
diff --git a/brilloemulator_x86_64/base_product/AndroidProducts.mk b/brilloemulator_x86_64/base_product/AndroidProducts.mk
new file mode 100644
index 0000000..2d8f422
--- /dev/null
+++ b/brilloemulator_x86_64/base_product/AndroidProducts.mk
@@ -0,0 +1,21 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This file is found by the build system.
+# It defines the base product definition for device bring up.
+
+PRODUCT_MAKEFILES := \
+ $(LOCAL_DIR)/brilloemulator_x86_64.mk
diff --git a/brilloemulator_x86_64/base_product/brilloemulator_x86_64.mk b/brilloemulator_x86_64/base_product/brilloemulator_x86_64.mk
new file mode 100644
index 0000000..1dfaec9
--- /dev/null
+++ b/brilloemulator_x86_64/base_product/brilloemulator_x86_64.mk
@@ -0,0 +1,29 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+$(call inherit-product, device/generic/brillo/brillo_base.mk)
+
+PRODUCT_NAME := brilloemulator_x86_64
+PRODUCT_BRAND := Brillo
+
+PRODUCT_DEVICE := brilloemulator_x86_64
+
+# Install emulator-specific config file for weaved.
+PRODUCT_COPY_FILES += \
+ device/generic/brillo/brilloemulator_x86_64/base_product/weaved.conf:system/etc/weaved/weaved.conf
+
+PRODUCT_PACKAGES += \
+ brilloemulator-x86_64
diff --git a/brilloemulator_x86_64/base_product/devicesetup.sh b/brilloemulator_x86_64/base_product/devicesetup.sh
new file mode 100644
index 0000000..d75a90c
--- /dev/null
+++ b/brilloemulator_x86_64/base_product/devicesetup.sh
@@ -0,0 +1,17 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+add_lunch_combo brilloemulator_x86_64-eng
diff --git a/brilloemulator_x86_64/base_product/qemu/Android.mk b/brilloemulator_x86_64/base_product/qemu/Android.mk
new file mode 100644
index 0000000..7b2dea8
--- /dev/null
+++ b/brilloemulator_x86_64/base_product/qemu/Android.mk
@@ -0,0 +1,21 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := optional
+LOCAL_PREBUILT_EXECUTABLES := brilloemulator-x86_64
+include $(BUILD_HOST_PREBUILT)
diff --git a/brilloemulator_x86_64/base_product/qemu/brilloemulator-x86_64 b/brilloemulator_x86_64/base_product/qemu/brilloemulator-x86_64
new file mode 100755
index 0000000..6456e95
--- /dev/null
+++ b/brilloemulator_x86_64/base_product/qemu/brilloemulator-x86_64
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+function PrintUsage() {
+ echo "$0 -m <mem>"
+ echo -e "\t-m <mem>\tSet memory size in MB"
+ exit 1
+}
+
+MEM=1024
+ARGS=$(getopt -o hm: -- "$@")
+eval set -- "$ARGS"
+while true ; do
+ case "$1" in
+ -m)
+ case "$2" in
+ *) MEM=$2; shift 2;;
+ esac ;;
+ -h) PrintUsage ;;
+ --) shift; break ;;
+ esac
+done
+
+echo Starting Emulator with ${MEM}MB Memory
+${ANDROID_BUILD_TOP}/prebuilts/android-emulator/linux-x86_64/qemu/linux-x86_64/qemu-system-x86_64 \
+ -m ${MEM}M \
+ -kernel ${ANDROID_BUILD_TOP}/out/target/product/brilloemulator_x86_64/kernel \
+ -append "console=ttyS0 root=/dev/vda androidboot.hardware=qemu qemu=1 rootwait noinitrd init=/init androidboot.selinux=enforcing"\
+ -nographic \
+ -device virtio-blk-pci,drive=system\
+ -drive file="${ANDROID_BUILD_TOP}/out/target/product/brilloemulator_x86_64/system.img,if=none,id=system,format=raw" \
+ -device virtio-blk-pci,drive=userdata \
+ -drive file="${ANDROID_BUILD_TOP}/out/target/product/brilloemulator_x86_64/userdata.img,if=none,id=userdata,format=raw" \
+ -netdev user,id=mynet -device virtio-net-pci,netdev=mynet \
+ -redir tcp:5555::5555 \
+ -vga none \
+ -L ${ANDROID_BUILD_TOP}/prebuilts/android-emulator/linux-x86_64/lib/pc-bios
diff --git a/brilloemulator_x86_64/base_product/weaved.conf b/brilloemulator_x86_64/base_product/weaved.conf
new file mode 100644
index 0000000..9ae1ad7
--- /dev/null
+++ b/brilloemulator_x86_64/base_product/weaved.conf
@@ -0,0 +1,79 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# OAuth 2.0 client id.
+client_id=58855907228.apps.googleusercontent.com
+
+# OAuth 2.0 client secret.
+client_secret=eHSAREAHrIqPsHBxCE9zPPBi
+
+# OAuth 2.0 API key.
+api_key=AIzaSyDSq46gG-AxUnC3zoqD9COIPrjolFsMfMA
+
+# Human readable name of the device.
+name=Starter Board
+
+# Human readable description of the device.
+# Defaults to empty string"
+description=X86_64 Emulator
+
+# Location of the device.
+# location=
+
+# Manufacturer of the device.
+oem_name=Brillo
+
+# Model of the device.
+# Defaults to Brillo.
+model_name=Emulator
+
+# Five character code assigned by the cloud registry of device models.
+# Defaults to "AAAAA" (Unregistered model).
+model_id=AAAAA
+
+# Maximum role for local anonymous user.
+# local_anonymous_access_role=viewer
+
+# If true, allows local pairing using Privet API.
+# local_pairing_enabled=true
+
+# If true, allows local discovery using mDns.
+# local_discovery_enabled=true
+
+# GCD service polling interval in milliseconds.
+# polling_period_ms=7000
+
+# GCD service backup polling interval in milliseconds.
+# backup_polling_period_ms=1800000
+
+# Automatic mode causes buffet to automatically bring up a SoftAP for
+# bootstrapping when it loses network connectivity for long enough,
+# and on first boot.
+# wifi_auto_setup_enabled=true
+
+# List of pairing modes supported by device.
+# Values can be one of pinCode, embeddedCode, ultrasound32, audible32.
+# Defaults to pinCode if embedded_code_path is empty, or embeddedCode otherwise.
+pairing_modes=embeddedCode
+
+# Absolute path to file specifying an embedded pairing code. The file at
+# embedded_code_path should be a file in key value format, with a key
+# embedded_code.
+# Defaults to empty path.
+embedded_code_path=/etc/weaved/weaved.conf
+
+# Embedded code.
+embedded_code=hello
diff --git a/brilloemulator_x86_64/bsp/brillo.kconf b/brilloemulator_x86_64/bsp/brillo.kconf
new file mode 100644
index 0000000..a0b2eee
--- /dev/null
+++ b/brilloemulator_x86_64/bsp/brillo.kconf
@@ -0,0 +1,23 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+CONFIG_GOLDFISH=y
+CONFIG_GOLDFISH_PIPE=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_NET_9P=y
+CONFIG_NET_9P_VIRTIO=y
+CONFIG_DEBUG_INFO=y \ No newline at end of file
diff --git a/brilloemulator_x86_64/bsp/init.qemu.rc b/brilloemulator_x86_64/bsp/init.qemu.rc
new file mode 100644
index 0000000..2a9002c
--- /dev/null
+++ b/brilloemulator_x86_64/bsp/init.qemu.rc
@@ -0,0 +1,26 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+on fs
+ mount_all /fstab.device
+
+on boot
+ start initnetwork
+
+service initnetwork /system/bin/initnetwork.sh
+ user root
+ group root
+ oneshot
diff --git a/brilloemulator_x86_64/bsp/initnetwork.sh b/brilloemulator_x86_64/bsp/initnetwork.sh
new file mode 100644
index 0000000..d2f8ca7
--- /dev/null
+++ b/brilloemulator_x86_64/bsp/initnetwork.sh
@@ -0,0 +1,11 @@
+#!/system/bin/sh
+
+# Setup networking when boot starts
+ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up
+route add default gw 10.0.2.2
+# Open up port 5555 for adb
+iptables -I INPUT -p tcp --dport 5555 -j ACCEPT -w
+# Run dnsmasq so we can access hosts on the Internet. This is needed since
+# Bionic hard-wires DNS requests to go to 0.0.0.0, so this acts as a DNS proxy.
+dnsmasq --no-hosts --listen-address=127.0.0.1 --no-resolv --server=8.8.8.8 \
+ --pid-file < /dev/null
diff --git a/brilloemulator_x86_64/bsp/qemu_x86_64.mk b/brilloemulator_x86_64/bsp/qemu_x86_64.mk
new file mode 100644
index 0000000..b3bfd9c
--- /dev/null
+++ b/brilloemulator_x86_64/bsp/qemu_x86_64.mk
@@ -0,0 +1,51 @@
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# TODO(leecam): Make this automatic.
+LOCAL_PATH := device/generic/brillo/brilloemulator_x86_64/bsp
+
+# X86_64 device.
+TARGET_ARCH := x86_64
+TARGET_ARCH_VARIANT := x86_64
+TARGET_CPU_ABI := x86_64
+
+TARGET_2ND_CPU_ABI := x86
+TARGET_2ND_ARCH := x86
+TARGET_2ND_ARCH_VARIANT := x86
+
+TARGET_USES_64_BIT_BINDER := true
+
+TARGET_KERNEL_ARCH := $(TARGET_ARCH)
+
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := false
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/init.qemu.rc:root/init.qemu.rc \
+ $(LOCAL_PATH)/initnetwork.sh:system/bin/initnetwork.sh \
+ system/core/rootdir/init.usb.rc:root/init.usb.rc \
+ system/core/rootdir/ueventd.rc:root/ueventd.rc \
+
+# Set up the local kernel.
+TARGET_KERNEL_SRC := hardware/bsp/kernel/common/android-3.18
+TARGET_KERNEL_DEFCONFIG := x86_64_defconfig
+TARGET_KERNEL_CONFIGS := $(realpath $(LOCAL_PATH)/brillo.kconf)
+
+BOARD_SEPOLICY_DIRS := $(BOARD_SEPOLICY_DIRS) $(LOCAL_PATH)/sepolicy
diff --git a/brilloemulator_x86_64/bsp/sepolicy/brillo_setup.te b/brilloemulator_x86_64/bsp/sepolicy/brillo_setup.te
new file mode 100644
index 0000000..5834064
--- /dev/null
+++ b/brilloemulator_x86_64/bsp/sepolicy/brillo_setup.te
@@ -0,0 +1,3 @@
+# Needed for dnsmasq (run from initnetwork.sh).
+allow brillo_setup dnsmasq_exec:file { execute execute_no_trans getattr open read };
+allow brillo_setup self:capability { net_bind_service setgid setuid };
diff --git a/brilloemulator_x86_64/bsp/sepolicy/file_contexts b/brilloemulator_x86_64/bsp/sepolicy/file_contexts
new file mode 100644
index 0000000..e5910f5
--- /dev/null
+++ b/brilloemulator_x86_64/bsp/sepolicy/file_contexts
@@ -0,0 +1 @@
+/system/bin/initnetwork.sh u:object_r:brillo_setup_exec:s0 \ No newline at end of file
diff --git a/brilloemulator_x86_64/fstab.device b/brilloemulator_x86_64/fstab.device
new file mode 100644
index 0000000..362b854
--- /dev/null
+++ b/brilloemulator_x86_64/fstab.device
@@ -0,0 +1,2 @@
+/dev/block/vda / ext4 ro wait
+/dev/block/vdb /data ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check