db845c: Update userland build to use dragonboard-kernel project and build boot.img

This patch updates the userland build to built a boot.img
from prebuilt kernel/modules in the dragonboard-kernel project.

At the moment, there is nothing in the dragonboard-kernel
project, but once we do add the prebuilt files, we'll want
this change.

Change-Id: I6b9ce745c378ea50e176e9c8ed67336953766fa2
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/db845c.mk b/db845c.mk
index 3d44eb3..721a9ad 100644
--- a/db845c.mk
+++ b/db845c.mk
@@ -1,3 +1,8 @@
+ifndef TARGET_KERNEL_USE
+TARGET_KERNEL_USE := mainline
+endif
+DB845C_KERNEL_DIR := device/linaro/dragonboard-kernel/android-$(TARGET_KERNEL_USE)
+
 # Inherit the full_base and device configurations
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
 $(call inherit-product, device/linaro/dragonboard/db845c/device.mk)
@@ -9,10 +14,12 @@
 PRODUCT_DEVICE := db845c
 PRODUCT_BRAND := Android
 
-ifneq ($(DB845C_USES_GKI),)
-# The path here need to be finalized (ideally in the dragonboard-kernel dir)
-DB845C_MOD_DIR := device/linaro/dragonboard/db845c-mods/
-DB845C_MODS := $(wildcard $(DB845C_MOD_DIR)/*.ko)
+ifndef DB845C_USES_GKI
+DB845C_USES_GKI := true
+endif
+
+ifeq ($(DB845C_USES_GKI), true)
+DB845C_MODS := $(wildcard $(DB845C_KERNEL_DIR)/*.ko)
 ifneq ($(DB845C_MODS),)
   BOARD_VENDOR_KERNEL_MODULES += $(DB845C_MODS)
   BOARD_VENDOR_RAMDISK_KERNEL_MODULES += $(DB845C_MODS)
diff --git a/db845c/BoardConfig.mk b/db845c/BoardConfig.mk
index ffc6047..0af0aaf 100644
--- a/db845c/BoardConfig.mk
+++ b/db845c/BoardConfig.mk
@@ -4,6 +4,15 @@
 TARGET_BOOTLOADER_BOARD_NAME := db845c
 TARGET_BOARD_PLATFORM := db845c
 
+TARGET_NO_KERNEL := false
+BOARD_INCLUDE_DTB_IN_BOOTIMG := true
+BOARD_BOOT_HEADER_VERSION := 2
+BOARD_MKBOOTIMG_ARGS := --header_version $(BOARD_BOOT_HEADER_VERSION)
+BOARD_KERNEL_BASE := 0x80000000
+BOARD_KERNEL_PAGESIZE := 2048
+BOARD_KERNEL_CMDLINE := firmware_class.path=/vendor/firmware/ androidboot.hardware=db845c
+BOARD_KERNEL_CMDLINE += init=/init androidboot.boot_devices=soc/1d84000.ufshc printk.devkmsg=on
+
 # Image Configuration
 BOARD_BOOTIMAGE_PARTITION_SIZE := 67108864 #64M
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 21474836480 #20G
diff --git a/db845c/device.mk b/db845c/device.mk
index d15e188..be50f51 100644
--- a/db845c/device.mk
+++ b/db845c/device.mk
@@ -18,6 +18,8 @@
 $(call inherit-product, frameworks/native/build/tablet-10in-xhdpi-2048-dalvik-heap.mk)
 
 PRODUCT_COPY_FILES := \
+    $(DB845C_KERNEL_DIR)/Image.gz:kernel \
+    $(DB845C_KERNEL_DIR)/sdm845-db845c.dtb:dtb.img \
     device/linaro/dragonboard/fstab.ramdisk.common:$(TARGET_COPY_OUT_RAMDISK)/fstab.db845c \
     device/linaro/dragonboard/fstab.ramdisk.common:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.db845c \
     device/linaro/dragonboard/fstab.common:$(TARGET_COPY_OUT_VENDOR)/etc/init/fstab.db845c \
diff --git a/installer/db845c/flash-all-aosp.sh b/installer/db845c/flash-all-aosp.sh
index 57391f8..575870f 100755
--- a/installer/db845c/flash-all-aosp.sh
+++ b/installer/db845c/flash-all-aosp.sh
@@ -36,31 +36,11 @@
 # Slot _a is already marked as active by bootloader but just in case..
 echo "FLASH-ALL-AOSP: Mark _a slot as active"
 fastboot set_active a
+echo "FLASH-ALL-AOSP: Flash boot img"
+fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img
 echo "FLASH-ALL-AOSP: Flash super/dynamic image"
 fastboot flash super "${ANDROID_PRODUCT_OUT}"/super.img
 echo "FLASH-ALL-AOSP: Flash userdata image"
 fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img
 
-if [ "$1" != "" ]; then
-    if [ "$2" = "" ]; then
-        echo "FLASH-ALL-AOSP: Trying to build boot.img? Pass corresponding dtb as well"
-        echo "                Usage: flash-all-aosp.sh Image.gz sdm845-db845c.dtb"
-        exit
-    fi
 
-    ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../
-    ANDROID_OUT_HOST_BIN="${ANDROID_BUILD_TOP}/out/host/linux-x86/bin"
-
-    if [ ! -d "${ANDROID_OUT_HOST_BIN}" ]; then
-        echo "FLASH-ALL-AOSP: error in locating out/host/ directory for mkbootimg, check if it exist"
-        echo "FLASH-ALL-AOSP: can't build boot image with user provided kernel image and dtb"
-        exit
-    fi
-
-    echo "FLASH-ALL-AOSP: Building boot image with user provided ${1} kernel image and ${2} dtb"
-    ${ANDROID_OUT_HOST_BIN}/mkbootimg --kernel ${1} --dtb ${2} --ramdisk ${ANDROID_PRODUCT_OUT}/ramdisk.img --header_version 2 --base 0x80000000 --pagesize 2048 --cmdline "firmware_class.path=/vendor/firmware/ androidboot.hardware=db845c init=/init androidboot.boot_devices=soc/1d84000.ufshc printk.devkmsg=on buildvariant=userdebug" --output ${ANDROID_PRODUCT_OUT}/boot.img
-
-    echo "FLASH-ALL-AOSP: Flash boot image"
-    fastboot flash boot ${ANDROID_PRODUCT_OUT}/boot.img
-    fastboot reboot
-fi