Add rule to build U-Boot.
Bug: 204895048
Change-Id: Ifd3f14b07010c998dbcc03a2c344e4dbbd40e136
diff --git a/Makefile b/Makefile
index a0535d7..d6bf367 100644
--- a/Makefile
+++ b/Makefile
@@ -84,7 +84,7 @@
default: kvm-unit-tests linux
.PHONY: clean
-clean: buildroot_clean kvm-unit-tests_clean linux_clean kselftest_clean
+clean: bl33_clean buildroot_clean kvm-unit-tests_clean linux_clean kselftest_clean
.PHONY: distclean
distclean:
@@ -100,6 +100,7 @@
@echo 'Generic Targets:'
@echo ' default - builds all generic targets except for buildroot'
@echo ' all - builds all generic targets'
+ @echo ' bl33 - U-Boot as BL33'
@echo ' buildroot - the buildroot rootfs image as well as the host qemu'
@echo ' kvm-unit-tests - the kvm-unit-tests'
@echo ' linux - the Linux kernel'
@@ -108,6 +109,7 @@
@echo 'Clean Targets:'
@echo ' clean - cleans all, but keeps the prebuilts'
@echo ' distclean - distclean for all targets'
+ @echo ' bl33_clean - the U-Boot BL33'
@echo ' buildroot_clean - the buildroot rootfs image as well as the host qemu'
@echo ' kvm-unit-tests_clean - the kvm-unit-tests'
@echo ' linux_clean - the Linux kernel'
@@ -157,6 +159,46 @@
buildroot_clean:
+ $(BR_MAKE) clean
+##
+## U-Boot
+##
+UBOOT_SRC := $(ROOT_DIR)/u-boot
+UBOOT_OUT := $(OUT_DIR)/u-boot
+BL_DIR := $(OUT_DIR)/bl
+BL33_BIN := $(BL_DIR)/bl33.bin
+UBOOT_DEFCONFIG ?= qemu_arm64_defconfig
+UBOOT_CONFIG := $(UBOOT_OUT)/.config
+UBOOT_TOOLCHAIN ?= gcc-9.2
+UBOOT_VERBOSE ?= $(VERBOSE)
+$(eval $(call define_toolchain,$(UBOOT_TOOLCHAIN),UBOOT_))
+UBOOT_MAKE := \
+ PATH=$(UBOOT_TOOLCHAIN_BIN):$(PATH) \
+ CROSS_COMPILE=aarch64-linux-gnu- \
+ $(MAKE) \
+ V=$(UBOOT_VERBOSE) \
+ -C $(UBOOT_SRC) \
+ O=$(UBOOT_OUT)
+
+.PHONY: bl33
+bl33: $(BL33_BIN)
+
+$(UBOOT_CONFIG): $(UBOOT_SRC)/configs/$(UBOOT_DEFCONFIG)
+ + $(UBOOT_MAKE) $(UBOOT_DEFCONFIG)
+ $(LINUX_SRC)/scripts/config --file $(UBOOT_CONFIG) --set-val CONFIG_BOOTDELAY 0
+ $(LINUX_SRC)/scripts/config --file $(UBOOT_CONFIG) --set-str CONFIG_BOOTCOMMAND \
+ "qfw load 0x40000000 0x50000000 ; booti 0x40000000 - $$\{fdtcontroladdr\}"
+
+$(UBOOT_OUT)/u-boot.bin: $(UBOOT_CONFIG) FORCE
+ + $(UBOOT_MAKE)
+
+$(BL33_BIN): $(UBOOT_OUT)/u-boot.bin
+ mkdir -p $(@D)
+ cp $< $@
+
+.PHONY: bl33_clean
+bl33_clean:
+ + $(UBOOT_MAKE) distclean
+ rm -f $(BL33_BIN)
##
## kvm-unit-tests