Skip to content
Snippets Groups Projects
Commit f37a7014 authored by Matt Ma's avatar Matt Ma
Browse files

qemu_v8: add First build script for QEMU ARMv8-A


QEMU and OP-TEE on ARMv8 is working

Reviewed-by: default avatarVictor Chong <victor.chong@linaro.org>
Reviewed-by: default avatarJoakim Bech <joakim.bech@linaro.org>
Signed-off-by: default avatarMatt Ma <matt.ma@linaro.org>
parent eebcdbe4
No related branches found
No related tags found
No related merge requests found
......@@ -2,3 +2,5 @@ Makefile
*.swp
/serial0.log
/serial1.log
.gdb_history
gdb
################################################################################
# Following variables defines how the NS_USER (Non Secure User - Client
# Application), NS_KERNEL (Non Secure Kernel), S_KERNEL (Secure Kernel) and
# S_USER (Secure User - TA) are compiled
################################################################################
override COMPILE_NS_USER := 64
override COMPILE_NS_KERNEL := 64
override COMPILE_S_USER := 64
override COMPILE_S_KERNEL := 64
-include common.mk
################################################################################
# Paths to git projects and various binaries
################################################################################
ARM_TF_PATH ?= $(ROOT)/arm-trusted-firmware
EDK2_PATH ?= $(ROOT)/edk2
EDK2_BIN ?= $(EDK2_PATH)/QEMU_EFI.fd
QEMU_PATH ?= $(ROOT)/qemu
SOC_TERM_PATH ?= $(ROOT)/soc_term
STRACE_PATH ?= $(ROOT)/strace
DEBUG = 1
################################################################################
# Targets
################################################################################
all: arm-tf qemu soc-term linux strace update_rootfs
all-clean: arm-tf-clean busybox-clean linux-clean \
optee-os-clean optee-client-clean qemu-clean \
soc-term-clean check-clean strace-clean
-include toolchain.mk
################################################################################
# ARM Trusted Firmware
################################################################################
ARM_TF_EXPORTS ?= \
CFLAGS="-O0 -gdwarf-2" \
CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)"
ARM_TF_FLAGS ?= \
BL32=$(OPTEE_OS_BIN) \
BL33=$(EDK2_BIN) \
ARM_TSP_RAM_LOCATION=tdram \
PLAT=qemu \
DEBUG=0 \
LOG_LEVEL=50 \
ERROR_DEPRECATED=1 \
BL32_RAM_LOCATION=tdram \
SPD=opteed
arm-tf: optee-os edk2
$(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) all fip
arm-tf-clean:
$(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) clean
# FIXME: This is just too rough, we should build this just as we're doing for
# FVP.
edk2: optee-os
ifeq ("$(wildcard $(EDK2_BIN))","")
mkdir -p $(EDK2_PATH)
wget -O $(EDK2_BIN) \
http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/989/QEMU-KERNEL-AARCH64/RELEASE_GCC49/QEMU_EFI.fd
endif
mkdir -p $(ARM_TF_PATH)/build/qemu/release
ln -sf $(OPTEE_OS_BIN) $(ARM_TF_PATH)/build/qemu/release/bl32.bin
ln -sf $(EDK2_BIN) $(ARM_TF_PATH)/build/qemu/release/bl33.bin
################################################################################
# QEMU
################################################################################
qemu:
cd $(QEMU_PATH); ./configure --target-list=aarch64-softmmu --cc="$(CCACHE)gcc" --extra-cflags="-Wno-error"
$(MAKE) -C $(QEMU_PATH)
qemu-clean:
$(MAKE) -C $(QEMU_PATH) distclean
################################################################################
# Busybox
################################################################################
BUSYBOX_COMMON_TARGET = fvp
BUSYBOX_CLEAN_COMMON_TARGET = fvp clean
BUSYBOX_COMMON_CCDIR = $(AARCH64_PATH)
busybox: busybox-common
busybox-clean: busybox-clean-common
busybox-cleaner: busybox-cleaner-common
################################################################################
# Linux kernel
################################################################################
LINUX_DEFCONFIG_COMMON_ARCH := arm64
LINUX_DEFCONFIG_COMMON_FILES := \
$(LINUX_PATH)/arch/arm64/configs/defconfig \
$(CURDIR)/kconfigs/qemu.conf
linux-defconfig: $(LINUX_PATH)/.config
LINUX_COMMON_FLAGS += ARCH=arm64
linux: linux-common
linux-defconfig-clean: linux-defconfig-clean-common
LINUX_CLEAN_COMMON_FLAGS += ARCH=arm64
linux-clean: linux-clean-common
LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64
linux-cleaner: linux-cleaner-common
################################################################################
# OP-TEE
################################################################################
OPTEE_OS_COMMON_FLAGS += PLATFORM=vexpress-qemu_armv8a CFG_ARM64_core=y \
DEBUG=0 CFG_PM_DEBUG=0 CFG_TEE_CORE_LOG_LEVEL=3
optee-os: optee-os-common
OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=vexpress-qemu_armv8a
optee-os-clean: optee-os-clean-common
optee-client: optee-client-common
optee-client-clean: optee-client-clean-common
################################################################################
# Soc-term
################################################################################
soc-term:
$(MAKE) -C $(SOC_TERM_PATH)
soc-term-clean:
$(MAKE) -C $(SOC_TERM_PATH) clean
################################################################################
# xtest / optee_test
################################################################################
xtest: xtest-common
xtest-clean: xtest-clean-common
xtest-patch: xtest-patch-common
################################################################################
# strace
################################################################################
strace:
ifneq ("$(wildcard $(STRACE_PATH))","")
cd $(STRACE_PATH) && \
./bootstrap && \
./configure --host=aarch64-linux-gnu CC=$(CROSS_COMPILE_NS_USER)gcc && \
CC=$(CROSS_COMPILE_NS_USER)gcc $(MAKE)
endif
strace-clean:
ifneq ("$(wildcard $(STRACE_PATH))","")
CC=$(CROSS_COMPILE_NS_USER)gcc \
$(MAKE) -C $(STRACE_PATH) clean && \
rm -f $(STRACE_PATH)/Makefile $(STRACE_PATH)/configure
endif
################################################################################
# Root FS
################################################################################
.PHONY: filelist-tee
filelist-tee: xtest
@echo "# xtest / optee_test" > $(GEN_ROOTFS_FILELIST)
@find $(OPTEE_TEST_OUT_PATH) -type f -name "xtest" | sed 's/\(.*\)/file \/bin\/xtest \1 755 0 0/g' >> $(GEN_ROOTFS_FILELIST)
@echo "# TAs" >> $(GEN_ROOTFS_FILELIST)
@echo "dir /lib/optee_armtz 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@find $(OPTEE_TEST_OUT_PATH) -name "*.ta" | \
sed 's/\(.*\)\/\(.*\)/file \/lib\/optee_armtz\/\2 \1\/\2 444 0 0/g' >> $(GEN_ROOTFS_FILELIST)
@echo "# Secure storage dir" >> $(GEN_ROOTFS_FILELIST)
@echo "dir /data 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "dir /data/tee 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@if [ -e $(OPTEE_GENDRV_MODULE) ]; then \
echo "# OP-TEE device" >> $(GEN_ROOTFS_FILELIST); \
echo "dir /lib/modules 755 0 0" >> $(GEN_ROOTFS_FILELIST); \
echo "dir /lib/modules/$(call KERNEL_VERSION) 755 0 0" >> $(GEN_ROOTFS_FILELIST); \
echo "file /lib/modules/$(call KERNEL_VERSION)/optee.ko $(OPTEE_GENDRV_MODULE) 755 0 0" >> $(GEN_ROOTFS_FILELIST); \
fi
@echo "# OP-TEE Client" >> $(GEN_ROOTFS_FILELIST)
@echo "file /bin/tee-supplicant $(OPTEE_CLIENT_EXPORT)/bin/tee-supplicant 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "file /lib/libteec.so.1.0 $(OPTEE_CLIENT_EXPORT)/lib/libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "slink /lib/libteec.so.1 libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST)
@echo "slink /lib/libteec.so libteec.so.1 755 0 0" >> $(GEN_ROOTFS_FILELIST)
ifneq ("$(wildcard $(STRACE_PATH)/strace)","")
@echo "file /bin/strace $(STRACE_PATH)/strace 755 0 0" >> $(GEN_ROOTFS_FILELIST)
endif
update_rootfs: busybox optee-client filelist-tee
cat $(GEN_ROOTFS_PATH)/filelist-final.txt $(GEN_ROOTFS_PATH)/filelist-tee.txt > $(GEN_ROOTFS_PATH)/filelist.tmp
cd $(GEN_ROOTFS_PATH); \
$(LINUX_PATH)/usr/gen_init_cpio $(GEN_ROOTFS_PATH)/filelist.tmp | gzip > $(GEN_ROOTFS_PATH)/filesystem.cpio.gz
################################################################################
# Run targets
################################################################################
define run-help
@echo "Run QEMU"
@echo QEMU is now waiting to start the execution
@echo Start execution with either a \'c\' followed by \<enter\> in the QEMU console or
@echo attach a debugger and continue from there.
@echo
@echo To run xtest paste the following on the serial 0 prompt
@echo tee-supplicant\&
@echo sleep 0.1
@echo xtest
@echo
@echo To run a single test case replace the xtest command with for instance
@echo xtest 2001
endef
define launch-terminal
@nc -z 127.0.0.1 $(1) || \
xterm -title $(2) -e $(BASH) -c "$(SOC_TERM_PATH)/soc_term $(1)" &
endef
define wait-for-ports
@while ! nc -z 127.0.0.1 $(1) || ! nc -z 127.0.0.1 $(2); do sleep 1; done
endef
.PHONY: run
# This target enforces updating root fs etc
run: all
$(MAKE) run-only
.PHONY: run-only
run-only:
$(call run-help)
$(call launch-terminal,54320,"Normal World")
$(call launch-terminal,54321,"Secure World")
$(call wait-for-ports,54320,54321)
cd $(ARM_TF_PATH)/build/qemu/release && \
$(QEMU_PATH)/aarch64-softmmu/qemu-system-aarch64 \
-nographic \
-serial tcp:localhost:54320 -serial tcp:localhost:54321 \
-machine virt,secure=on -cpu cortex-a57 -m 1057 -bios $(ARM_TF_PATH)/build/qemu/release/bl1.bin \
-semihosting -d unimp \
-initrd $(GEN_ROOTFS_PATH)/filesystem.cpio.gz \
-kernel $(LINUX_PATH)/arch/arm64/boot/Image \
-append 'console=ttyAMA0,38400 keep_bootcon root=/dev/vda2'
ifneq ($(filter check,$(MAKECMDGOALS)),)
CHECK_DEPS := all
endif
ifneq ($(TIMEOUT),)
check-args := --timeout $(TIMEOUT)
endif
check: $(CHECK_DEPS)
expect qemu-check.exp -- $(check-args) || \
(if [ "$(DUMP_LOGS_ON_ERROR)" ]; then \
echo "== $$PWD/serial0.log:"; \
cat serial0.log; \
echo "== end of $$PWD/serial0.log:"; \
echo "== $$PWD/serial1.log:"; \
cat serial1.log; \
echo "== end of $$PWD/serial1.log:"; \
fi; false)
check-only: check
check-clean:
rm -f serial0.log serial1.log
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment