summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Strachan <astrachan@google.com>2018-10-16 15:24:16 -0700
committerAlistair Strachan <astrachan@google.com>2018-10-16 17:57:55 -0700
commit848da4f1318cc12619512f4e66c6b281155c5f8a (patch)
tree1cbf7c027d75626768954d55f8079ab41d2697d0
parent351e67763631286964f41e000f6bfc95bbd3c49d (diff)
downloadbeagle-x15-848da4f1318cc12619512f4e66c6b281155c5f8a.tar.gz
Build the x15 U-Boot binaries from source.
This change builds a config for U-Boot and then builds the MLO and u-boot.img files from the external/u-boot source tree. It uses symlinks to the host toolchain to preserve the Android build system's hermetic requirements. (The recommended configs were derived from the Things configs.) Bug: 110964307 Change-Id: I634c607ca5c07d24d46278aaf8215c70bc2e6aa0 Signed-off-by: Alistair Strachan <astrachan@google.com>
-rw-r--r--AndroidBoard.mk17
-rw-r--r--BoardConfig.mk8
-rw-r--r--beagle_x15_uboot.conf21
l---------hostcc/ar1
l---------hostcc/bison1
l---------hostcc/cc1
l---------hostcc/flex1
l---------hostcc/g++1
l---------hostcc/gcc1
l---------hostcc/ld1
l---------hostcc/ld.bfd1
l---------hostcc/strings1
-rwxr-xr-xmergeconfig.sh47
-rw-r--r--uboot.mk176
-rw-r--r--uboot_config/common.config38
-rw-r--r--uboot_config/recommended.config24
16 files changed, 340 insertions, 0 deletions
diff --git a/AndroidBoard.mk b/AndroidBoard.mk
new file mode 100644
index 0000000..03d3c7a
--- /dev/null
+++ b/AndroidBoard.mk
@@ -0,0 +1,17 @@
+#
+# Copyright 2018 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.
+#
+
+include device/ti/beagle_x15/uboot.mk
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 3b78403..d07a534 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -59,3 +59,11 @@ BOARD_SEPOLICY_DIRS += \
device/ti/beagle_x15/sepolicy
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
+
+# U-Boot configuration.
+TARGET_UBOOT_ARCH := $(TARGET_ARCH)
+TARGET_UBOOT_SRC := external/u-boot
+TARGET_UBOOT_DEFCONFIG := am57xx_evm_defconfig
+TARGET_UBOOT_CONFIGS += device/ti/beagle_x15/beagle_x15_uboot.conf
+TARGET_UBOOT_MAKE_TARGET := u-boot-img.bin
+TARGET_UBOOT_COPY_TARGETS := u-boot.img MLO
diff --git a/beagle_x15_uboot.conf b/beagle_x15_uboot.conf
new file mode 100644
index 0000000..29138b1
--- /dev/null
+++ b/beagle_x15_uboot.conf
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2016 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.
+#
+
+# Put options here which are needed for a particular configuration of
+# Android but which might not be suitable to upstream
+
+# Override the 'recommended.config' back, otherwise U-Boot fails to link
+CONFIG_NET=y
diff --git a/hostcc/ar b/hostcc/ar
new file mode 120000
index 0000000..9ba504b
--- /dev/null
+++ b/hostcc/ar
@@ -0,0 +1 @@
+../../../../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-ar \ No newline at end of file
diff --git a/hostcc/bison b/hostcc/bison
new file mode 120000
index 0000000..08c2205
--- /dev/null
+++ b/hostcc/bison
@@ -0,0 +1 @@
+../../../../prebuilts/build-tools/linux-x86/bin/bison \ No newline at end of file
diff --git a/hostcc/cc b/hostcc/cc
new file mode 120000
index 0000000..f026ff7
--- /dev/null
+++ b/hostcc/cc
@@ -0,0 +1 @@
+../../../../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-gcc \ No newline at end of file
diff --git a/hostcc/flex b/hostcc/flex
new file mode 120000
index 0000000..7c4992c
--- /dev/null
+++ b/hostcc/flex
@@ -0,0 +1 @@
+../../../../prebuilts/build-tools/linux-x86/bin/flex \ No newline at end of file
diff --git a/hostcc/g++ b/hostcc/g++
new file mode 120000
index 0000000..c9f9c01
--- /dev/null
+++ b/hostcc/g++
@@ -0,0 +1 @@
+../../../../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-g++ \ No newline at end of file
diff --git a/hostcc/gcc b/hostcc/gcc
new file mode 120000
index 0000000..f026ff7
--- /dev/null
+++ b/hostcc/gcc
@@ -0,0 +1 @@
+../../../../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-gcc \ No newline at end of file
diff --git a/hostcc/ld b/hostcc/ld
new file mode 120000
index 0000000..c3ae707
--- /dev/null
+++ b/hostcc/ld
@@ -0,0 +1 @@
+../../../../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-ld \ No newline at end of file
diff --git a/hostcc/ld.bfd b/hostcc/ld.bfd
new file mode 120000
index 0000000..c90dfd6
--- /dev/null
+++ b/hostcc/ld.bfd
@@ -0,0 +1 @@
+../../../../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-ld.bfd \ No newline at end of file
diff --git a/hostcc/strings b/hostcc/strings
new file mode 120000
index 0000000..1e62227
--- /dev/null
+++ b/hostcc/strings
@@ -0,0 +1 @@
+../../../../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-strings \ No newline at end of file
diff --git a/mergeconfig.sh b/mergeconfig.sh
new file mode 100755
index 0000000..70f0d1f
--- /dev/null
+++ b/mergeconfig.sh
@@ -0,0 +1,47 @@
+#!/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.
+
+args=( "$@" )
+confs=( )
+
+KERNEL_PATH=${args[0]}
+OUTPUT=${args[1]}
+TARGET_ARCH=${args[2]}
+TARGET_CROSS_COMPILE=${args[3]}
+
+unset "args[0]"
+unset "args[1]"
+unset "args[2]"
+unset "args[3]"
+
+curdir=$(pwd)
+
+# Explicitly record the list of config files used to build .config, and
+# canonicalize the path since we have to have our current directory in
+# the kernel source tree.
+for conf in ${args[*]} ; do
+ fullpath=$conf
+ if [ ${fullpath:0:1} != "/" ] ; then
+ fullpath=$curdir/$fullpath
+ fi
+ confs+=($fullpath)
+ echo $conf
+done > $OUTPUT/config.list
+
+cd $KERNEL_PATH
+
+ARCH=$TARGET_ARCH CROSS_COMPILE=$TARGET_CROSS_COMPILE ./scripts/kconfig/merge_config.sh -O $OUTPUT ${confs[*]} > $OUTPUT/merge_config.log
diff --git a/uboot.mk b/uboot.mk
new file mode 100644
index 0000000..d43cc60
--- /dev/null
+++ b/uboot.mk
@@ -0,0 +1,176 @@
+#
+# 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 building U-Boot
+#
+# The following must be set before including this file:
+# TARGET_UBOOT_SRC must be set the base of a U-Boot tree.
+# TARGET_UBOOT_DEFCONFIG must name a base U-Boot config.
+# TARGET_UBOOT_ARCH must be set to match U-Boot arch.
+#
+# The following may be set:
+# TARGET_UBOOT_CROSS_COMPILE_PREFIX to override toolchain.
+# TARGET_UBOOT_CONFIGS to specify a set of additional U-Boot config files.
+# TARGET_UBOOT_ENV to specify an environment to be compiled into uboot.env.
+# TARGET_UBOOT_ENV_SIZE to specify the size reserved in U-Boot for the env.
+
+ifeq ($(TARGET_UBOOT_SRC),)
+$(error TARGET_UBOOT_SRC not defined but uboot.mk included)
+endif
+
+ifeq ($(TARGET_UBOOT_DEFCONFIG),)
+$(error TARGET_UBOOT_DEFCONFIG not defined)
+endif
+
+ifeq ($(TARGET_UBOOT_ARCH),)
+$(error TARGET_UBOOT_ARCH not defined)
+endif
+
+ifeq ($(TARGET_UBOOT_ENV_SIZE),)
+ifneq ($(TARGET_UBOOT_ENV),)
+$(error If TARGET_UBOOT_ENV is set TARGET_UBOOT_ENV_SIZE must also be set. See\
+ CONFIG_ENV_SIZE in the selected U-Boot board config file.)
+endif
+endif
+
+# These may be assigned in target BoardConfig.mk.
+TARGET_UBOOT_MAKE_TARGET ?= u-boot.bin
+TARGET_UBOOT_COPY_TARGETS ?= $(TARGET_UBOOT_MAKE_TARGET)
+
+# Check target arch.
+TARGET_UBOOT_ARCH := $(strip $(TARGET_UBOOT_ARCH))
+UBOOT_ARCH := $(TARGET_UBOOT_ARCH)
+UBOOT_CC_WRAPPER := $(CC_WRAPPER)
+UBOOT_AFLAGS :=
+UBOOT_DTC := $(HOST_OUT_EXECUTABLES)/dtc
+UBOOT_DTC_ABS := $(abspath $(UBOOT_DTC))
+
+ifeq ($(TARGET_UBOOT_ARCH), arm)
+UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.9/bin)
+UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/arm-linux-androidkernel-
+UBOOT_SRC_ARCH := arm
+UBOOT_CFLAGS :=
+else ifeq ($(TARGET_UBOOT_ARCH), arm64)
+UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/aarch64/aarch64-linux-android-4.9/bin)
+UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/aarch64-linux-androidkernel-
+UBOOT_SRC_ARCH := arm64
+UBOOT_CFLAGS :=
+else ifeq ($(TARGET_UBOOT_ARCH), i386)
+UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-4.9/bin)
+UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/x86_64-linux-androidkernel-
+UBOOT_SRC_ARCH := x86
+UBOOT_CFLAGS := -mstack-protector-guard=tls
+else ifeq ($(TARGET_UBOOT_ARCH), x86_64)
+UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-4.9/bin)
+UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/x86_64-linux-androidkernel-
+UBOOT_SRC_ARCH := x86
+UBOOT_CFLAGS := -mstack-protector-guard=tls
+else ifeq ($(TARGET_UBOOT_ARCH), mips)
+UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mips64el-linux-android-4.9/bin)
+UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/mips64el-linux-androidkernel-
+UBOOT_SRC_ARCH := mips
+UBOOT_CFLAGS :=
+else
+$(error U-Boot arch not supported at present)
+endif
+
+# Allow caller to override toolchain.
+TARGET_UBOOT_CROSS_COMPILE_PREFIX := $(strip $(TARGET_UBOOT_CROSS_COMPILE_PREFIX))
+ifneq ($(TARGET_UBOOT_CROSS_COMPILE_PREFIX),)
+UBOOT_CROSS_COMPILE := $(TARGET_UBOOT_CROSS_COMPILE_PREFIX)
+endif
+
+# Use ccache if requested by USE_CCACHE variable
+UBOOT_CROSS_COMPILE_WRAPPER := $(realpath $(UBOOT_CC_WRAPPER)) $(UBOOT_CROSS_COMPILE)
+
+UBOOT_GCC_NOANDROID_CHK := $(shell (echo "int main() {return 0;}" | $(UBOOT_CROSS_COMPILE)gcc -E -mno-android - > /dev/null 2>&1 ; echo $$?))
+ifeq ($(strip $(UBOOT_GCC_NOANDROID_CHK)),0)
+UBOOT_CFLAGS += -mno-android
+UBOOT_AFLAGS += -mno-android
+endif
+
+# Set the output for the U-Boot build products.
+UBOOT_OUT := $(TARGET_OUT_INTERMEDIATES)/UBOOT_OBJ
+UBOOT_ENV_OUT := $(PRODUCT_OUT)/uboot.env
+
+# Merge all U-Boot config file sources.
+UBOOT_CONFIG_DIR := device/ti/beagle_x15/uboot_config
+UBOOT_CONFIG_DEFAULT := $(TARGET_UBOOT_SRC)/configs/$(TARGET_UBOOT_DEFCONFIG)
+UBOOT_CONFIG_RECOMMENDED := $(UBOOT_CONFIG_DIR)/recommended.config
+UBOOT_CONFIG_REQUIRED_SRC := $(UBOOT_CONFIG_DIR)/common.config
+UBOOT_CONFIG_REQUIRED := $(UBOOT_OUT)/.config.required
+UBOOT_CONFIG_SRC := $(UBOOT_CONFIG_DEFAULT) \
+ $(UBOOT_CONFIG_RECOMMENDED) \
+ $(TARGET_UBOOT_CONFIGS) \
+ $(UBOOT_CONFIG_REQUIRED)
+UBOOT_CONFIG := $(UBOOT_OUT)/.config
+UBOOT_MERGE_CONFIG := device/ti/beagle_x15/mergeconfig.sh
+# List of all the Kconfig files from the source code. Changing the Kconfig files
+# requires to reassemble the .config, so we add them as dependencies.
+UBOOT_SRC_KCONFIGS := \
+ $(call find-files-in-subdirs,.,Kconfig,$(TARGET_UBOOT_SRC))
+
+$(UBOOT_OUT):
+ mkdir -p $@
+
+define build_uboot
+ # We don't support bundling a device tree with U-Boot yet.
+ CCACHE_NODIRECT="true" PATH=$$(cd device/ti/beagle_x15/hostcc; pwd):$$PATH \
+ BISON_PKGDATADIR=$$(cd prebuilts/build-tools/common/bison; pwd) \
+ $(MAKE) -C $(TARGET_UBOOT_SRC) \
+ O=$(realpath $(UBOOT_OUT)) \
+ CROSS_COMPILE="$(UBOOT_CROSS_COMPILE_WRAPPER)" \
+ DTC="$(UBOOT_DTC_ABS)" \
+ KCFLAGS="$(UBOOT_CFLAGS)" \
+ KAFLAGS="$(UBOOT_AFLAGS)" \
+ SOURCE_DATE_EPOCH="$(BUILD_DATETIME_FROM_FILE)" \
+ $(1)
+endef
+
+# Merge the required U-Boot config elements into a single file.
+$(UBOOT_CONFIG_REQUIRED): $(UBOOT_CONFIG_REQUIRED_SRC) | $(UBOOT_OUT)
+ $(hide) cat $^ > $@
+
+# Merge the final target U-Boot config.
+$(UBOOT_CONFIG): $(UBOOT_CONFIG_SRC) $(UBOOT_SRC_KCONFIGS) | $(UBOOT_OUT)
+ $(hide) echo Merging U-Boot config
+ $(call build_uboot,mrproper)
+ PATH=$$(cd device/ti/beagle_x15/hostcc; pwd):$$PATH \
+ BISON_PKGDATADIR=$$(cd prebuilts/build-tools/common/bison; pwd) \
+ $(UBOOT_MERGE_CONFIG) \
+ $(TARGET_UBOOT_SRC) $(realpath $(UBOOT_OUT)) \
+ $(UBOOT_ARCH) $(UBOOT_CROSS_COMPILE) \
+ $(UBOOT_CONFIG_SRC)
+
+$(UBOOT_OUT)/$(TARGET_UBOOT_MAKE_TARGET): $(UBOOT_CONFIG) | $(UBOOT_OUT) $(UBOOT_DTC)
+ $(hide) echo "Building $(UBOOT_ARCH) U-Boot ..."
+ $(call build_uboot,$(TARGET_UBOOT_MAKE_TARGET))
+
+$(addprefix $(UBOOT_OUT)/,$(TARGET_UBOOT_COPY_TARGETS)): $(UBOOT_OUT)/$(TARGET_UBOOT_MAKE_TARGET)
+
+ifneq ($(TARGET_UBOOT_ENV),)
+$(UBOOT_ENV_OUT): $(TARGET_UBOOT_ENV) | $(addprefix $(UBOOT_OUT)/,$(TARGET_UBOOT_COPY_TARGETS))
+ $(UBOOT_OUT)/tools/mkenvimage -s $(TARGET_UBOOT_ENV_SIZE) -o $@ $<
+endif
+
+ALL_DEFAULT_INSTALLED_MODULES += $(addprefix $(PRODUCT_OUT)/,$(TARGET_UBOOT_COPY_TARGETS))
+
+# Produces the actual U-Boot image!
+define copy_uboot
+$$(PRODUCT_OUT)/$(1): $$(UBOOT_OUT)/$(1) | $$(ACP)
+ $$(ACP) -fp $$< $$@
+endef
+$(foreach _t,$(TARGET_UBOOT_COPY_TARGETS),$(eval $(call copy_uboot,$(_t))))
diff --git a/uboot_config/common.config b/uboot_config/common.config
new file mode 100644
index 0000000..60a2626
--- /dev/null
+++ b/uboot_config/common.config
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2016 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.
+#
+
+#
+# The following are the U-Boot configurations that are required for all builds.
+# These cannot be overridden in the board.
+#
+
+CONFIG_AUTOBOOT=y
+
+# Add support for Android Images.
+CONFIG_ANDROID_BOOT_IMAGE=y
+CONFIG_CMD_LOAD_ANDROID=y
+
+# Support for Android Bootloader is required.
+CONFIG_ANDROID_BOOTLOADER=y
+CONFIG_CMD_BOOT_ANDROID=y
+
+# Support for selecting the A/B slot.
+CONFIG_ANDROID_AB=y
+CONFIG_CMD_ANDROID_AB_SELECT=y
+
+# Fastboot and Android image support should be enabled.
+CONFIG_FASTBOOT=y
+CONFIG_CMD_FASTBOOT=y
diff --git a/uboot_config/recommended.config b/uboot_config/recommended.config
new file mode 100644
index 0000000..e5626bc
--- /dev/null
+++ b/uboot_config/recommended.config
@@ -0,0 +1,24 @@
+#
+# Copyright (C) 2016 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.
+#
+
+#
+# The following are the U-Boot configurations that are recommended (though not
+# strictly required) for all builds. These can be overridden by setting
+# TARGET_UBOOT_CONFIGS.
+#
+
+# Disable most other ways of booting by default.
+# CONFIG_NET is not set