summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlistair Strachan2018-10-16 17:24:16 -0500
committerAlistair Strachan2018-10-16 19:57:55 -0500
commit848da4f1318cc12619512f4e66c6b281155c5f8a (patch)
tree1cbf7c027d75626768954d55f8079ab41d2697d0
parent351e67763631286964f41e000f6bfc95bbd3c49d (diff)
downloaddevice-ti-beagle-x15-848da4f1318cc12619512f4e66c6b281155c5f8a.tar.gz
device-ti-beagle-x15-848da4f1318cc12619512f4e66c6b281155c5f8a.tar.xz
device-ti-beagle-x15-848da4f1318cc12619512f4e66c6b281155c5f8a.zip
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 @@
1#
2# Copyright 2018 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17include 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 += \
59 device/ti/beagle_x15/sepolicy 59 device/ti/beagle_x15/sepolicy
60 60
61BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true 61BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
62
63# U-Boot configuration.
64TARGET_UBOOT_ARCH := $(TARGET_ARCH)
65TARGET_UBOOT_SRC := external/u-boot
66TARGET_UBOOT_DEFCONFIG := am57xx_evm_defconfig
67TARGET_UBOOT_CONFIGS += device/ti/beagle_x15/beagle_x15_uboot.conf
68TARGET_UBOOT_MAKE_TARGET := u-boot-img.bin
69TARGET_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 @@
1#
2# Copyright (C) 2016 The Android Open-Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# Put options here which are needed for a particular configuration of
18# Android but which might not be suitable to upstream
19
20# Override the 'recommended.config' back, otherwise U-Boot fails to link
21CONFIG_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 @@
1#!/bin/bash
2
3#
4# Copyright 2015 The Android Open Source Project
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18args=( "$@" )
19confs=( )
20
21KERNEL_PATH=${args[0]}
22OUTPUT=${args[1]}
23TARGET_ARCH=${args[2]}
24TARGET_CROSS_COMPILE=${args[3]}
25
26unset "args[0]"
27unset "args[1]"
28unset "args[2]"
29unset "args[3]"
30
31curdir=$(pwd)
32
33# Explicitly record the list of config files used to build .config, and
34# canonicalize the path since we have to have our current directory in
35# the kernel source tree.
36for conf in ${args[*]} ; do
37 fullpath=$conf
38 if [ ${fullpath:0:1} != "/" ] ; then
39 fullpath=$curdir/$fullpath
40 fi
41 confs+=($fullpath)
42 echo $conf
43done > $OUTPUT/config.list
44
45cd $KERNEL_PATH
46
47ARCH=$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 @@
1#
2# Copyright 2015 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# Targets for building U-Boot
18#
19# The following must be set before including this file:
20# TARGET_UBOOT_SRC must be set the base of a U-Boot tree.
21# TARGET_UBOOT_DEFCONFIG must name a base U-Boot config.
22# TARGET_UBOOT_ARCH must be set to match U-Boot arch.
23#
24# The following may be set:
25# TARGET_UBOOT_CROSS_COMPILE_PREFIX to override toolchain.
26# TARGET_UBOOT_CONFIGS to specify a set of additional U-Boot config files.
27# TARGET_UBOOT_ENV to specify an environment to be compiled into uboot.env.
28# TARGET_UBOOT_ENV_SIZE to specify the size reserved in U-Boot for the env.
29
30ifeq ($(TARGET_UBOOT_SRC),)
31$(error TARGET_UBOOT_SRC not defined but uboot.mk included)
32endif
33
34ifeq ($(TARGET_UBOOT_DEFCONFIG),)
35$(error TARGET_UBOOT_DEFCONFIG not defined)
36endif
37
38ifeq ($(TARGET_UBOOT_ARCH),)
39$(error TARGET_UBOOT_ARCH not defined)
40endif
41
42ifeq ($(TARGET_UBOOT_ENV_SIZE),)
43ifneq ($(TARGET_UBOOT_ENV),)
44$(error If TARGET_UBOOT_ENV is set TARGET_UBOOT_ENV_SIZE must also be set. See\
45 CONFIG_ENV_SIZE in the selected U-Boot board config file.)
46endif
47endif
48
49# These may be assigned in target BoardConfig.mk.
50TARGET_UBOOT_MAKE_TARGET ?= u-boot.bin
51TARGET_UBOOT_COPY_TARGETS ?= $(TARGET_UBOOT_MAKE_TARGET)
52
53# Check target arch.
54TARGET_UBOOT_ARCH := $(strip $(TARGET_UBOOT_ARCH))
55UBOOT_ARCH := $(TARGET_UBOOT_ARCH)
56UBOOT_CC_WRAPPER := $(CC_WRAPPER)
57UBOOT_AFLAGS :=
58UBOOT_DTC := $(HOST_OUT_EXECUTABLES)/dtc
59UBOOT_DTC_ABS := $(abspath $(UBOOT_DTC))
60
61ifeq ($(TARGET_UBOOT_ARCH), arm)
62UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.9/bin)
63UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/arm-linux-androidkernel-
64UBOOT_SRC_ARCH := arm
65UBOOT_CFLAGS :=
66else ifeq ($(TARGET_UBOOT_ARCH), arm64)
67UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/aarch64/aarch64-linux-android-4.9/bin)
68UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/aarch64-linux-androidkernel-
69UBOOT_SRC_ARCH := arm64
70UBOOT_CFLAGS :=
71else ifeq ($(TARGET_UBOOT_ARCH), i386)
72UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-4.9/bin)
73UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/x86_64-linux-androidkernel-
74UBOOT_SRC_ARCH := x86
75UBOOT_CFLAGS := -mstack-protector-guard=tls
76else ifeq ($(TARGET_UBOOT_ARCH), x86_64)
77UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-4.9/bin)
78UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/x86_64-linux-androidkernel-
79UBOOT_SRC_ARCH := x86
80UBOOT_CFLAGS := -mstack-protector-guard=tls
81else ifeq ($(TARGET_UBOOT_ARCH), mips)
82UBOOT_TOOLCHAIN_ABS := $(realpath prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mips64el-linux-android-4.9/bin)
83UBOOT_CROSS_COMPILE := $(UBOOT_TOOLCHAIN_ABS)/mips64el-linux-androidkernel-
84UBOOT_SRC_ARCH := mips
85UBOOT_CFLAGS :=
86else
87$(error U-Boot arch not supported at present)
88endif
89
90# Allow caller to override toolchain.
91TARGET_UBOOT_CROSS_COMPILE_PREFIX := $(strip $(TARGET_UBOOT_CROSS_COMPILE_PREFIX))
92ifneq ($(TARGET_UBOOT_CROSS_COMPILE_PREFIX),)
93UBOOT_CROSS_COMPILE := $(TARGET_UBOOT_CROSS_COMPILE_PREFIX)
94endif
95
96# Use ccache if requested by USE_CCACHE variable
97UBOOT_CROSS_COMPILE_WRAPPER := $(realpath $(UBOOT_CC_WRAPPER)) $(UBOOT_CROSS_COMPILE)
98
99UBOOT_GCC_NOANDROID_CHK := $(shell (echo "int main() {return 0;}" | $(UBOOT_CROSS_COMPILE)gcc -E -mno-android - > /dev/null 2>&1 ; echo $$?))
100ifeq ($(strip $(UBOOT_GCC_NOANDROID_CHK)),0)
101UBOOT_CFLAGS += -mno-android
102UBOOT_AFLAGS += -mno-android
103endif
104
105# Set the output for the U-Boot build products.
106UBOOT_OUT := $(TARGET_OUT_INTERMEDIATES)/UBOOT_OBJ
107UBOOT_ENV_OUT := $(PRODUCT_OUT)/uboot.env
108
109# Merge all U-Boot config file sources.
110UBOOT_CONFIG_DIR := device/ti/beagle_x15/uboot_config
111UBOOT_CONFIG_DEFAULT := $(TARGET_UBOOT_SRC)/configs/$(TARGET_UBOOT_DEFCONFIG)
112UBOOT_CONFIG_RECOMMENDED := $(UBOOT_CONFIG_DIR)/recommended.config
113UBOOT_CONFIG_REQUIRED_SRC := $(UBOOT_CONFIG_DIR)/common.config
114UBOOT_CONFIG_REQUIRED := $(UBOOT_OUT)/.config.required
115UBOOT_CONFIG_SRC := $(UBOOT_CONFIG_DEFAULT) \
116 $(UBOOT_CONFIG_RECOMMENDED) \
117 $(TARGET_UBOOT_CONFIGS) \
118 $(UBOOT_CONFIG_REQUIRED)
119UBOOT_CONFIG := $(UBOOT_OUT)/.config
120UBOOT_MERGE_CONFIG := device/ti/beagle_x15/mergeconfig.sh
121# List of all the Kconfig files from the source code. Changing the Kconfig files
122# requires to reassemble the .config, so we add them as dependencies.
123UBOOT_SRC_KCONFIGS := \
124 $(call find-files-in-subdirs,.,Kconfig,$(TARGET_UBOOT_SRC))
125
126$(UBOOT_OUT):
127 mkdir -p $@
128
129define build_uboot
130 # We don't support bundling a device tree with U-Boot yet.
131 CCACHE_NODIRECT="true" PATH=$$(cd device/ti/beagle_x15/hostcc; pwd):$$PATH \
132 BISON_PKGDATADIR=$$(cd prebuilts/build-tools/common/bison; pwd) \
133 $(MAKE) -C $(TARGET_UBOOT_SRC) \
134 O=$(realpath $(UBOOT_OUT)) \
135 CROSS_COMPILE="$(UBOOT_CROSS_COMPILE_WRAPPER)" \
136 DTC="$(UBOOT_DTC_ABS)" \
137 KCFLAGS="$(UBOOT_CFLAGS)" \
138 KAFLAGS="$(UBOOT_AFLAGS)" \
139 SOURCE_DATE_EPOCH="$(BUILD_DATETIME_FROM_FILE)" \
140 $(1)
141endef
142
143# Merge the required U-Boot config elements into a single file.
144$(UBOOT_CONFIG_REQUIRED): $(UBOOT_CONFIG_REQUIRED_SRC) | $(UBOOT_OUT)
145 $(hide) cat $^ > $@
146
147# Merge the final target U-Boot config.
148$(UBOOT_CONFIG): $(UBOOT_CONFIG_SRC) $(UBOOT_SRC_KCONFIGS) | $(UBOOT_OUT)
149 $(hide) echo Merging U-Boot config
150 $(call build_uboot,mrproper)
151 PATH=$$(cd device/ti/beagle_x15/hostcc; pwd):$$PATH \
152 BISON_PKGDATADIR=$$(cd prebuilts/build-tools/common/bison; pwd) \
153 $(UBOOT_MERGE_CONFIG) \
154 $(TARGET_UBOOT_SRC) $(realpath $(UBOOT_OUT)) \
155 $(UBOOT_ARCH) $(UBOOT_CROSS_COMPILE) \
156 $(UBOOT_CONFIG_SRC)
157
158$(UBOOT_OUT)/$(TARGET_UBOOT_MAKE_TARGET): $(UBOOT_CONFIG) | $(UBOOT_OUT) $(UBOOT_DTC)
159 $(hide) echo "Building $(UBOOT_ARCH) U-Boot ..."
160 $(call build_uboot,$(TARGET_UBOOT_MAKE_TARGET))
161
162$(addprefix $(UBOOT_OUT)/,$(TARGET_UBOOT_COPY_TARGETS)): $(UBOOT_OUT)/$(TARGET_UBOOT_MAKE_TARGET)
163
164ifneq ($(TARGET_UBOOT_ENV),)
165$(UBOOT_ENV_OUT): $(TARGET_UBOOT_ENV) | $(addprefix $(UBOOT_OUT)/,$(TARGET_UBOOT_COPY_TARGETS))
166 $(UBOOT_OUT)/tools/mkenvimage -s $(TARGET_UBOOT_ENV_SIZE) -o $@ $<
167endif
168
169ALL_DEFAULT_INSTALLED_MODULES += $(addprefix $(PRODUCT_OUT)/,$(TARGET_UBOOT_COPY_TARGETS))
170
171# Produces the actual U-Boot image!
172define copy_uboot
173$$(PRODUCT_OUT)/$(1): $$(UBOOT_OUT)/$(1) | $$(ACP)
174 $$(ACP) -fp $$< $$@
175endef
176$(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 @@
1#
2# Copyright (C) 2016 The Android Open-Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17#
18# The following are the U-Boot configurations that are required for all builds.
19# These cannot be overridden in the board.
20#
21
22CONFIG_AUTOBOOT=y
23
24# Add support for Android Images.
25CONFIG_ANDROID_BOOT_IMAGE=y
26CONFIG_CMD_LOAD_ANDROID=y
27
28# Support for Android Bootloader is required.
29CONFIG_ANDROID_BOOTLOADER=y
30CONFIG_CMD_BOOT_ANDROID=y
31
32# Support for selecting the A/B slot.
33CONFIG_ANDROID_AB=y
34CONFIG_CMD_ANDROID_AB_SELECT=y
35
36# Fastboot and Android image support should be enabled.
37CONFIG_FASTBOOT=y
38CONFIG_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 @@
1#
2# Copyright (C) 2016 The Android Open-Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17#
18# The following are the U-Boot configurations that are recommended (though not
19# strictly required) for all builds. These can be overridden by setting
20# TARGET_UBOOT_CONFIGS.
21#
22
23# Disable most other ways of booting by default.
24# CONFIG_NET is not set