Init makefiles

Change-Id: I404b13c7d3e5035f28cc8297ee64179c15eadedd
diff --git a/AndroidBoard.mk b/AndroidBoard.mk
new file mode 100644
index 0000000..3f62092
--- /dev/null
+++ b/AndroidBoard.mk
@@ -0,0 +1,20 @@
+#
+# 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/freescale/picoimx/kernel-fsl.mk
+
diff --git a/BoardConfig.mk b/BoardConfig.mk
new file mode 100644
index 0000000..7b0f862
--- /dev/null
+++ b/BoardConfig.mk
@@ -0,0 +1,43 @@
+#
+# 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.
+#
+
+# Select the SoC
+$(call set_soc, freescale, imx6ul)
+
+# ARM32 device.
+TARGET_ARCH := arm
+TARGET_ARCH_VARIANT := armv7-a
+TARGET_CPU_VARIANT := generic
+TARGET_CPU_ABI := armeabi-v7a
+TARGET_CPU_ABI2 := armeabi
+
+TARGET_NO_BOOTLOADER := false
+TARGET_NO_KERNEL := false
+
+TARGET_KERNEL_DTB := imx6ul-14x14-evk.dtb
+BOARD_KERNEL_BASE := 0x82800000
+
+BOARD_KERNEL_CMDLINE := console=ttymxc0,115200 init=/init androidboot.console=ttymxc0 consoleblank=0 androidboot.hardware=freescale
+
+TARGET_USERIMAGES_USE_EXT4 := true
+
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+
+BOARD_FLASH_BLOCK_SIZE := 131072
+
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 268435456
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 134217728
+BOARD_CACHEIMAGE_PARTITION_SIZE := 268435456
diff --git a/base_product/AndroidProducts.mk b/base_product/AndroidProducts.mk
new file mode 100644
index 0000000..a39ae40
--- /dev/null
+++ b/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)/picoimx.mk
diff --git a/base_product/picoimx.mk b/base_product/picoimx.mk
new file mode 100755
index 0000000..b67241f
--- /dev/null
+++ b/base_product/picoimx.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.
+#
+
+$(call inherit-product, device/generic/brillo/brillo_base.mk)
+
+PRODUCT_NAME := picoimx
+PRODUCT_BRAND := Brillo
+PRODUCT_DEVICE := picoimx
diff --git a/kernel-fsl.mk b/kernel-fsl.mk
new file mode 100755
index 0000000..0356094
--- /dev/null
+++ b/kernel-fsl.mk
@@ -0,0 +1,111 @@
+#
+# 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.
+#
+
+# Targets for builing kernels
+# The following must be set before including this file.
+# TARGET_KERNEL_SRC must be set the base of a kernel tree.
+# TARGET_KERNEL_DEFCONFIG must name a base kernel config.
+# TARGET_KERNEL_ARCH must be set to match kernel arch.
+
+# The following maybe set.
+# TARGET_KERNEL_CROSS_COMPILE_PREFIX to override toolchain
+# TARGET_PREBUILT_KERNEL to use a pre-built kernel
+
+# Only build kernel if caller has not defined a prebuild
+ifeq ($(TARGET_PREBUILT_KERNEL),)
+
+ifeq ($(TARGET_KERNEL_SRC),)
+$(error TARGET_KERNEL_SRC not defined)
+endif
+
+ifeq ($(TARGET_KERNEL_DEFCONFIG),)
+$(error TARGET_KERNEL_DEFCONFIG not defined)
+endif
+
+ifeq ($(TARGET_KERNEL_ARCH),)
+$(error TARGET_KERNEL_ARCH not defined)
+endif
+
+# Check target arch.
+KERNEL_TOOLCHAIN_ABS := $(shell readlink -f $(TARGET_TOOLCHAIN_ROOT)/bin)
+TARGET_KERNEL_ARCH := $(strip $(TARGET_KERNEL_ARCH))
+KERNEL_ARCH := $(TARGET_KERNEL_ARCH)
+HOST_PROCESSOR := $(shell cat /proc/cpuinfo | grep processor | wc -l)
+
+ifeq ($(TARGET_KERNEL_ARCH), arm)
+KERNEL_CROSS_COMPILE := $(KERNEL_TOOLCHAIN_ABS)/arm-linux-androideabi-
+ifdef TARGET_KERNEL_DTB
+KERNEL_NAME := zImage
+else
+KERNEL_NAME := zImage-dtb
+endif
+else ifeq ($(TARGET_KERNEL_ARCH), arm64)
+KERNEL_CROSS_COMPILE := $(KERNEL_TOOLCHAIN_ABS)/aarch64-linux-android-
+KERNEL_NAME := Image
+else
+$(error kernel arch not supported at present)
+endif
+
+# Allow caller to override toolchain.
+TARGET_KERNEL_CROSS_COMPILE_PREFIX := $(strip $(TARGET_KERNEL_CROSS_COMPILE_PREFIX))
+ifneq ($(TARGET_KERNEL_CROSS_COMPILE_PREFIX),)
+KERNEL_CROSS_COMPILE := $(TARGET_KERNEL_CROSS_COMPILE_PREFIX)
+endif
+
+KERNEL_GCC_NOANDROID_CHK := $(shell (echo "int main() {return 0;}" | $(KERNEL_CROSS_COMPILE)gcc -E -mno-android - > /dev/null 2>&1 ; echo $$?))
+ifeq ($(strip $(KERNEL_GCC_NOANDROID_CHK)),0)
+KERNEL_CFLAGS := KCFLAGS=-mno-android
+endif
+
+ifeq ($(TARGET_KERNEL_DTB),)
+$(error TARGET_KERNEL_DTB not defined)
+endif
+
+# Set the output for the kernel build products.
+KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
+
+KERNEL_CONFIG := $(KERNEL_OUT)/.config
+
+KERNEL_BIN := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(KERNEL_NAME)
+
+KERNEL_MERGE_CONFIG := device/generic/brillo/mergeconfig.sh
+
+KERNEL_ZIMAGE := $(TARGET_KERNEL_SRC)/arch/$(KERNEL_ARCH)/boot/zImage
+KERNEL_DTB_FILE := $(TARGET_KERNEL_SRC)/arch/$(KERNEL_ARCH)/boot/dts/$(TARGET_KERNEL_DTB)
+BOARD_MKBOOTIMG_ARGS += --second $(PRODUCT_OUT)/$(TARGET_KERNEL_DTB)
+
+$(KERNEL_OUT):
+	mkdir -p $(KERNEL_OUT)
+
+# Build the kernel config
+#$(KERNEL_CONFIG): $(KERNEL_OUT)
+#	$(KERNEL_MERGE_CONFIG) $(TARGET_KERNEL_SRC) `readlink -f $(KERNEL_OUT)` $(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) arch/$(KERNEL_ARCH)/configs/$(TARGET_KERNEL_DEFCONFIG) $(TARGET_KERNEL_CONFIGS)
+
+KERNEL_ENV := ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(KERNEL_CFLAGS)
+
+.PHONY: kernelimage
+kernelimage:
+	$(hide) echo " Building kernel... "
+	$(hide) rm -rf $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/dts
+	$(MAKE) $(TARGET_KERNEL_DEFCONFIG) -C $(TARGET_KERNEL_SRC) $(KERNEL_ENV)
+	$(MAKE) -j$(HOST_PROCESSOR) -C $(TARGET_KERNEL_SRC)  $(KERNEL_ENV)
+
+$(PRODUCT_OUT)/kernel: kernelimage
+	install -D $(KERNEL_ZIMAGE)  $(PRODUCT_OUT)/kernel
+	install -D $(KERNEL_DTB_FILE) $(PRODUCT_OUT)/$(TARGET_KERNEL_DTB)
+
+endif
+
diff --git a/provision-device b/provision-device
new file mode 100755
index 0000000..c418e8e
--- /dev/null
+++ b/provision-device
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+fastboot \
+  flash boot_a ${ANDROID_PRODUCT_OUT}/boot.img \
+  flash system_a ${ANDROID_PRODUCT_OUT}/system.img \
+  flash boot_b ${ANDROID_PRODUCT_OUT}/boot.img \
+  flash system_b ${ANDROID_PRODUCT_OUT}/system.img \
+  flash misc ${ANDROID_PRODUCT_OUT}/misc.img \
+  flash recovery ${ANDROID_PRODUCT_OUT}/recovery.img "$@"