Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 1 | DEBUG ?= 1 |
| 2 | |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 3 | ################################################################################ |
| 4 | # Following variables defines how the NS_USER (Non Secure User - Client |
| 5 | # Application), NS_KERNEL (Non Secure Kernel), S_KERNEL (Secure Kernel) and |
| 6 | # S_USER (Secure User - TA) are compiled |
| 7 | ################################################################################ |
Pascal Brand | efe5659 | 2016-03-03 10:46:52 +0100 | [diff] [blame] | 8 | COMPILE_NS_USER ?= 64 |
| 9 | override COMPILE_NS_KERNEL := 64 |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 10 | COMPILE_S_USER ?= 64 |
| 11 | COMPILE_S_KERNEL ?= 64 |
| 12 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 13 | -include common.mk |
| 14 | |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 15 | |
| 16 | ################################################################################ |
| 17 | # Paths to git projects and various binaries |
| 18 | ################################################################################ |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 19 | ARM_TF_PATH ?= $(ROOT)/arm-trusted-firmware |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 20 | EDK2_PATH ?= $(ROOT)/edk2 |
| 21 | EDK2_BIN ?= $(EDK2_PATH)/Build/ArmVExpress-FVP-AArch64/RELEASE_GCC49/FV/FVP_AARCH64_EFI.fd |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 22 | FOUNDATION_PATH ?= $(ROOT)/Foundation_Platformpkg |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 23 | ifeq ($(wildcard $(FOUNDATION_PATH)),) |
| 24 | $(error $(FOUNDATION_PATH) does not exist) |
| 25 | endif |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 26 | |
| 27 | ################################################################################ |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 28 | # Targets |
| 29 | ################################################################################ |
Jens Wiklander | fc2f012 | 2016-01-26 15:15:05 +0100 | [diff] [blame] | 30 | all: arm-tf edk2 linux optee-os optee-client xtest |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 31 | all-clean: arm-tf-clean busybox-clean edk2-clean optee-os-clean \ |
Jens Wiklander | fc2f012 | 2016-01-26 15:15:05 +0100 | [diff] [blame] | 32 | optee-client-clean |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 33 | |
| 34 | |
| 35 | -include toolchain.mk |
| 36 | |
| 37 | ################################################################################ |
| 38 | # ARM Trusted Firmware |
| 39 | ################################################################################ |
Pascal Brand | b130ea2 | 2015-10-13 13:18:36 +0200 | [diff] [blame] | 40 | ARM_TF_EXPORTS ?= \ |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 41 | CFLAGS="-O0 -gdwarf-2" \ |
Pascal Brand | b130ea2 | 2015-10-13 13:18:36 +0200 | [diff] [blame] | 42 | CROSS_COMPILE="$(CCACHE)$(AARCH64_NONE_CROSS_COMPILE)" |
| 43 | |
| 44 | ARM_TF_FLAGS ?= \ |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 45 | BL32=$(OPTEE_OS_BIN) \ |
| 46 | BL33=$(EDK2_BIN) \ |
Pascal Brand | b130ea2 | 2015-10-13 13:18:36 +0200 | [diff] [blame] | 47 | DEBUG=0 \ |
Jens Wiklander | 6d92394 | 2016-01-08 15:33:03 +0100 | [diff] [blame] | 48 | ARM_TSP_RAM_LOCATION=tdram \ |
Pascal Brand | b130ea2 | 2015-10-13 13:18:36 +0200 | [diff] [blame] | 49 | PLAT=fvp \ |
| 50 | SPD=opteed |
| 51 | |
| 52 | arm-tf: optee-os edk2 |
| 53 | $(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) all fip |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 54 | |
| 55 | arm-tf-clean: |
Pascal Brand | b130ea2 | 2015-10-13 13:18:36 +0200 | [diff] [blame] | 56 | $(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) clean |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 57 | |
| 58 | ################################################################################ |
| 59 | # Busybox |
| 60 | ################################################################################ |
Pascal Brand | efe5659 | 2016-03-03 10:46:52 +0100 | [diff] [blame] | 61 | BUSYBOX_COMMON_TARGET = fvp |
| 62 | BUSYBOX_CLEAN_COMMON_TARGET = fvp clean |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 63 | |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 64 | busybox: busybox-common |
| 65 | |
| 66 | busybox-clean: busybox-clean-common |
| 67 | |
| 68 | busybox-cleaner: busybox-cleaner-common |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 69 | |
| 70 | ################################################################################ |
| 71 | # EDK2 / Tianocore |
| 72 | ################################################################################ |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 73 | define edk2-call |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 74 | GCC49_AARCH64_PREFIX=$(AARCH64_NONE_CROSS_COMPILE) \ |
Pascal Brand | 1527169 | 2015-09-08 10:42:22 +0200 | [diff] [blame] | 75 | $(MAKE) -j1 -C $(EDK2_PATH) \ |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 76 | -f ArmPlatformPkg/Scripts/Makefile EDK2_ARCH=AARCH64 \ |
| 77 | EDK2_DSC=ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc \ |
| 78 | EDK2_TOOLCHAIN=GCC49 EDK2_BUILD=RELEASE \ |
Jens Wiklander | fc2f012 | 2016-01-26 15:15:05 +0100 | [diff] [blame] | 79 | EDK2_MACROS="-n 6 -D ARM_FOUNDATION_FVP=1 -D ARM_FVP_BOOT_ANDROID_FROM_SEMIHOSTING=1" |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 80 | endef |
| 81 | |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 82 | edk2: edk2-common |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 83 | |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 84 | edk2-clean: edk2-clean-common |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 85 | |
| 86 | ################################################################################ |
| 87 | # Linux kernel |
| 88 | ################################################################################ |
Jerome Forissier | e100238 | 2015-11-26 11:36:00 +0100 | [diff] [blame] | 89 | LINUX_DEFCONFIG_COMMON_ARCH := arm64 |
| 90 | LINUX_DEFCONFIG_COMMON_FILES := \ |
| 91 | $(LINUX_PATH)/arch/arm64/configs/defconfig \ |
| 92 | $(CURDIR)/kconfigs/fvp.conf |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 93 | |
| 94 | linux-defconfig: $(LINUX_PATH)/.config |
| 95 | |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 96 | LINUX_COMMON_FLAGS += ARCH=arm64 |
| 97 | |
| 98 | linux: linux-common |
| 99 | |
| 100 | linux-defconfig-clean: linux-defconfig-clean-common |
| 101 | |
| 102 | LINUX_CLEAN_COMMON_FLAGS += ARCH=arm64 |
| 103 | |
| 104 | linux-clean: linux-clean-common |
| 105 | |
| 106 | LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64 |
| 107 | |
| 108 | linux-cleaner: linux-cleaner-common |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 109 | |
| 110 | ################################################################################ |
| 111 | # OP-TEE |
| 112 | ################################################################################ |
Victor Chong | 9f0d120 | 2016-04-23 16:28:31 +0100 | [diff] [blame^] | 113 | OPTEE_OS_COMMON_FLAGS += PLATFORM=vexpress-fvp |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 114 | optee-os: optee-os-common |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 115 | |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 116 | OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=vexpress-fvp |
| 117 | optee-os-clean: optee-os-clean-common |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 118 | |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 119 | optee-client: optee-client-common |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 120 | |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 121 | optee-client-clean: optee-client-clean-common |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 122 | |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 123 | ################################################################################ |
| 124 | # xtest / optee_test |
| 125 | ################################################################################ |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 126 | xtest: xtest-common |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 127 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 128 | xtest-clean: xtest-clean-common |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 129 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 130 | xtest-patch: xtest-patch-common |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 131 | |
| 132 | ################################################################################ |
| 133 | # Root FS |
| 134 | ################################################################################ |
Pascal Brand | efe5659 | 2016-03-03 10:46:52 +0100 | [diff] [blame] | 135 | ifeq ($(COMPILE_NS_USER),32) |
| 136 | ROOTFS_LIBPATH ?= "/lib/arm-linux-gnueabihf" |
| 137 | endif |
| 138 | ifeq ($(COMPILE_NS_USER),64) |
| 139 | ROOTFS_LIBPATH ?= "/lib/aarch64-linux-gnu" |
| 140 | endif |
| 141 | |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 142 | .PHONY: filelist-tee |
| 143 | filelist-tee: |
| 144 | @echo "# xtest / optee_test" > $(GEN_ROOTFS_FILELIST) |
| 145 | @find $(OPTEE_TEST_OUT_PATH) -type f -name "xtest" | sed 's/\(.*\)/file \/bin\/xtest \1 755 0 0/g' >> $(GEN_ROOTFS_FILELIST) |
| 146 | @echo "# TAs" >> $(GEN_ROOTFS_FILELIST) |
| 147 | @echo "dir /lib/optee_armtz 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
| 148 | @find $(OPTEE_TEST_OUT_PATH) -name "*.ta" | \ |
| 149 | sed 's/\(.*\)\/\(.*\)/file \/lib\/optee_armtz\/\2 \1\/\2 444 0 0/g' >> $(GEN_ROOTFS_FILELIST) |
| 150 | @echo "# Secure storage dig" >> $(GEN_ROOTFS_FILELIST) |
| 151 | @echo "dir /data 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
| 152 | @echo "dir /data/tee 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
Victor Chong | 9f0d120 | 2016-04-23 16:28:31 +0100 | [diff] [blame^] | 153 | @if [ -e $(OPTEE_GENDRV_MODULE) ]; then |
| 154 | @echo "# OP-TEE device" >> $(GEN_ROOTFS_FILELIST) |
| 155 | @echo "dir /lib/modules 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
| 156 | @echo "dir /lib/modules/$(call KERNEL_VERSION) 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
| 157 | @echo "file /lib/modules/$(call KERNEL_VERSION)/optee.ko $(OPTEE_GENDRV_MODULE) 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
| 158 | @fi |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 159 | @echo "# OP-TEE Client" >> $(GEN_ROOTFS_FILELIST) |
| 160 | @echo "file /bin/tee-supplicant $(OPTEE_CLIENT_EXPORT)/bin/tee-supplicant 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
Pascal Brand | efe5659 | 2016-03-03 10:46:52 +0100 | [diff] [blame] | 161 | @echo "dir $(ROOTFS_LIBPATH) 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
| 162 | @echo "file $(ROOTFS_LIBPATH)/libteec.so.1.0 $(OPTEE_CLIENT_EXPORT)/lib/libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
| 163 | @echo "slink $(ROOTFS_LIBPATH)/libteec.so.1 libteec.so.1.0 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
| 164 | @echo "slink $(ROOTFS_LIBPATH)/libteec.so libteec.so.1 755 0 0" >> $(GEN_ROOTFS_FILELIST) |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 165 | |
Jens Wiklander | fc2f012 | 2016-01-26 15:15:05 +0100 | [diff] [blame] | 166 | update_rootfs: busybox optee-client xtest filelist-tee |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 167 | cat $(GEN_ROOTFS_PATH)/filelist-final.txt $(GEN_ROOTFS_PATH)/filelist-tee.txt > $(GEN_ROOTFS_PATH)/filelist.tmp |
| 168 | cd $(GEN_ROOTFS_PATH); \ |
| 169 | $(LINUX_PATH)/usr/gen_init_cpio $(GEN_ROOTFS_PATH)/filelist.tmp | gzip > $(GEN_ROOTFS_PATH)/filesystem.cpio.gz |
| 170 | |
| 171 | ################################################################################ |
| 172 | # Run targets |
| 173 | ################################################################################ |
| 174 | # This target enforces updating root fs etc |
Pascal Brand | 1527169 | 2015-09-08 10:42:22 +0200 | [diff] [blame] | 175 | run: all |
| 176 | $(MAKE) update_rootfs |
| 177 | $(MAKE) run-only |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 178 | |
| 179 | run-only: |
Jens Wiklander | fc2f012 | 2016-01-26 15:15:05 +0100 | [diff] [blame] | 180 | @ln -sf $(LINUX_PATH)/arch/arm64/boot/Image $(FOUNDATION_PATH)/kernel |
| 181 | @ln -sf $(GEN_ROOTFS_PATH)/filesystem.cpio.gz $(FOUNDATION_PATH)/ramdisk.img |
Pascal Brand | c520e12 | 2016-03-29 09:01:02 +0200 | [diff] [blame] | 182 | @ln -sf $(LINUX_PATH)/arch/arm64/boot/Image $(FOUNDATION_PATH)/Image |
| 183 | @ln -sf $(GEN_ROOTFS_PATH)/filesystem.cpio.gz $(FOUNDATION_PATH)/filesystem.cpio.gz |
Jens Wiklander | fc2f012 | 2016-01-26 15:15:05 +0100 | [diff] [blame] | 184 | @ln -sf $(LINUX_PATH)/arch/arm64/boot/dts/arm/foundation-v8.dtb $(FOUNDATION_PATH)/fdt.dtb |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 185 | @cd $(FOUNDATION_PATH); \ |
Jens Wiklander | 6d92394 | 2016-01-08 15:33:03 +0100 | [diff] [blame] | 186 | $(FOUNDATION_PATH)/models/Linux64_GCC-4.7/Foundation_Platform \ |
Joakim Bech | 427dd63 | 2015-05-04 15:52:33 +0200 | [diff] [blame] | 187 | --cores=4 \ |
| 188 | --secure-memory \ |
| 189 | --visualization \ |
| 190 | --gicv3 \ |
Pascal Brand | c520e12 | 2016-03-29 09:01:02 +0200 | [diff] [blame] | 191 | --data="$(ARM_TF_PATH)/build/fvp/release/bl1.bin"@0x0 \ |
| 192 | --data="$(ARM_TF_PATH)/build/fvp/release/fip.bin"@0x8000000 |
| 193 | |