Merge "Revert "v2p-aarch64: Use sdcard partition rather than emulated storage"" into linaro-jb
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 09af805..ff62461 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -4,53 +4,12 @@
 #
 
 TARGET_BOARD_PLATFORM := vexpress
-TARGET_NO_BOOTLOADER := true # Uses u-boot instead 
+TARGET_NO_BOOTLOADER := true # We use our own methods for building bootloaders
 TARGET_NO_KERNEL := false
 TARGET_HWPACK_CONFIG := device/linaro/vexpress/config
-ifeq ($(strip $(ANDROID_64)),true)
-KERNEL_TOOLS_PREFIX := aarch64-linux-android-
-KERNEL_CONFIG := vexpress-android_defconfig
-TARGET_USE_UBOOT := false
-CUSTOM_BOOTLOADER_MAKEFILE := device/linaro/vexpress/bootloader64.mk
-else
-#
-# Build IKS kernel depending on config.
-#
-ifneq ($(strip $(BUILD_IKS)),true)
-KERNEL_CONFIG := linaro/configs/linaro-base.conf \
-                 linaro/configs/android.conf \
-                 linaro/configs/big-LITTLE-MP.conf \
-                 linaro/configs/vexpress.conf
-ifeq ($(wildcard $(TOP)/boot-wrapper/bootwrapper.mk),)
-TARGET_USE_UBOOT := true
-UBOOT_CONFIG := vexpress_ca9x4_config
-UBOOT_FLAVOURS := vexpress_ca9x4:u-boot_v2p-ca9.bin vexpress_ca5x2:u-boot_v2p-ca5s.bin vexpress_ca15x2:u-boot_v2p-ca15-tc1.bin
-DEVICE_TREES := vexpress-v2p-ca5s:v2p-ca5s.dtb vexpress-v2p-ca9:v2p-ca9.dtb vexpress-v2p-ca15-tc1:v2p-ca15-tc1.dtb vexpress-v2p-ca15-tc2:v2p-ca15-tc2.dtb \
-		rtsm_ve-cortex_a9x2:rtsm/rtsm_ve-ca9x2.dtb \
-		rtsm_ve-cortex_a9x4:rtsm/rtsm_ve-ca9x4.dtb \
-		rtsm_ve-cortex_a15x1:rtsm/rtsm_ve-ca15x1.dtb \
-		rtsm_ve-cortex_a15x2:rtsm/rtsm_ve-ca15x2.dtb \
-		rtsm_ve-cortex_a15x4:rtsm/rtsm_ve-ca15x4.dtb \
-		rtsm_ve-v2p-ca15x1-ca7x1:rtsm/rtsm_ve-ca15x1-ca7x1.dtb \
-		rtsm_ve-v2p-ca15x4-ca7x4:rtsm/rtsm_ve-ca15x4-ca7x4.dtb
-CUSTOM_BOOTLOADER_MAKEFILE := device/linaro/vexpress/bootloader.mk
-INCLUDE_PERF := 0
-else
-TARGET_USE_UBOOT := false
-DEVICE_TREES := rtsm_ve-v2p-ca15x1-ca7x1:rtsm/rtsm_ve-ca15x1-ca7x1.dtb \
-		rtsm_ve-v2p-ca15x4-ca7x4:rtsm/rtsm_ve-ca15x4-ca7x4.dtb
-CUSTOM_BOOTLOADER_MAKEFILE := boot-wrapper/bootwrapper.mk
-endif
-else
-ifeq ($(KERNEL_CONFIG),)
-KERNEL_CONFIG := vexpress_bL_defconfig
-endif
-TARGET_USE_UBOOT := true
-UBOOT_CONFIG := vexpress_ca5x2
-DEVICE_TREES := vexpress-v2p-ca15-tc2:v2p-ca15-tc2.dtb
-endif
-endif
+
 TARGET_USE_XLOADER := false
+TARGET_USE_UBOOT := false
 TARGET_NO_RECOVERY := true
 TARGET_NO_RADIOIMAGE := true
 BOARD_USES_GENERIC_AUDIO := false
@@ -73,21 +32,60 @@
 TARGET_USERIMAGES_USE_EXT4 := true
 TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
 
-# bootargs
-BOARD_KERNEL_CMDLINE := mmci.fmax=4000000
-
-# Dual-Core Cortex A9
 TARGET_CPU_SMP := true
-#TARGET_EXTRA_CFLAGS += -mtune=cortex-a9 -mcpu=cortex-a9
 
 # ARMs gator (DS-5)
 TARGET_USE_GATOR:= true
 
+
 ifeq ($(strip $(ANDROID_64)),true)
-TARGET_BOOTLOADER_TYPE := none
+#
+# Juice
+#
+KERNEL_TOOLS_PREFIX := aarch64-linux-android-
+KERNEL_CONFIG := vexpress-android_defconfig
+CUSTOM_BOOTLOADER_MAKEFILE := device/linaro/vexpress/bootloader64.mk
+
+else ifeq ($(strip $(BUILD_IKS)),true)
+#
+# IKS
+#
+ifeq ($(KERNEL_CONFIG),)
+KERNEL_CONFIG := vexpress_bL_defconfig
+endif
+DEVICE_TREES := vexpress-v2p-ca15-tc2:v2p-ca15-tc2.dtb
+UBOOT_FLAVOURS := vexpress_ca5x2:u-boot.bin
+CUSTOM_BOOTLOADER_MAKEFILE := device/linaro/vexpress/bootloader-uboot-files.mk
+INSTALLED_KERNEL_TARGET_NAME := zImage
+INSTALLED_RAMDISK_TARGET_NAME := initrd
+
 else
-ifeq ($(wildcard $(TOP)/boot-wrapper/bootwrapper.mk),)
-# Build uImage and uInitrd instead of kernel and ramdisk.img
-TARGET_BOOTLOADER_TYPE := uboot
+#
+# MP
+#
+KERNEL_CONFIG := linaro/configs/linaro-base.conf \
+                 linaro/configs/android.conf \
+                 linaro/configs/big-LITTLE-MP.conf \
+                 linaro/configs/vexpress.conf
+DEVICE_TREES := vexpress-v2p-ca5s:v2p-ca5s.dtb \
+		vexpress-v2p-ca9:v2p-ca9.dtb \
+		vexpress-v2p-ca15-tc1:v2p-ca15-tc1.dtb \
+		vexpress-v2p-ca15-tc2:v2p-ca15-tc2.dtb \
+		rtsm_ve-cortex_a9x2:rtsm/rtsm_ve-ca9x2.dtb \
+		rtsm_ve-cortex_a9x4:rtsm/rtsm_ve-ca9x4.dtb \
+		rtsm_ve-cortex_a15x1:rtsm/rtsm_ve-ca15x1.dtb \
+		rtsm_ve-cortex_a15x2:rtsm/rtsm_ve-ca15x2.dtb \
+		rtsm_ve-cortex_a15x4:rtsm/rtsm_ve-ca15x4.dtb \
+		rtsm_ve-v2p-ca15x1-ca7x1:rtsm/rtsm_ve-ca15x1-ca7x1.dtb \
+		rtsm_ve-v2p-ca15x4-ca7x4:rtsm/rtsm_ve-ca15x4-ca7x4.dtb
+UBOOT_FLAVOURS := vexpress_ca9x4:u-boot_v2p-ca9.bin \
+		  vexpress_ca5x2:u-boot_v2p-ca5s.bin \
+		  vexpress_ca15x2:u-boot_v2p-ca15-tc1.bin
+CUSTOM_BOOTLOADER_MAKEFILE := device/linaro/vexpress/bootloader.mk
+INSTALLED_KERNEL_TARGET_NAME := zImage
+INSTALLED_RAMDISK_TARGET_NAME := initrd
+INCLUDE_PERF := 0
+
 endif
-endif
+
+
diff --git a/bootloader-uboot-files.mk b/bootloader-uboot-files.mk
new file mode 100644
index 0000000..f9aa504
--- /dev/null
+++ b/bootloader-uboot-files.mk
@@ -0,0 +1,14 @@
+#
+# Temporary (hopefully) ability to build uImage and uInitrd for
+# compatibility purposes during transition to zImage...
+#
+$(BOOTLOADER_OUT)/uImage : $(INSTALLED_KERNEL_TARGET)
+	$(eval UIMAGE_LOADADDR ?= 0x60008000)
+	mkimage -A arm -O linux -T kernel -n "Android Kernel" -C none -a $(UIMAGE_LOADADDR) -e $(UIMAGE_LOADADDR) -d $< $@
+
+BOOTLOADER_TARGETS += $(BOOTLOADER_OUT)/uImage
+
+$(BOOTLOADER_OUT)/uInitrd : $(INSTALLED_RAMDISK_TARGET)
+	mkimage -A arm -O linux -T ramdisk -n "Android Ramdisk Image" -d $< $@
+
+BOOTLOADER_TARGETS += $(BOOTLOADER_OUT)/uInitrd
diff --git a/bootloader.mk b/bootloader.mk
index 03f0ffa..d78c423 100644
--- a/bootloader.mk
+++ b/bootloader.mk
@@ -13,3 +13,6 @@
 	$(ACP) -fpt $(TOP)/boot-wrapper/linux-system-semi.axf $@
 
 BOOTLOADER_TARGETS += $(BOOTLOADER_OUT)/rtsm/linux-system-semi.axf
+
+
+include $(call my-dir)/bootloader-uboot-files.mk