blob: 10306afd1db15ea03205c1a2651d8f22fedc9555 [file] [log] [blame]
Victor Chongbadc7922015-12-08 17:23:20 +00001################################################################################
2# User-defined variables
3# Edit so these match your target
4################################################################################
5# Non-secure user mode (root fs binaries): 32 or 64-bit [default 64]
Victor Chong24475982015-12-02 07:18:13 +00006NSU ?= 64
Victor Chongbadc7922015-12-08 17:23:20 +00007# Secure kernel (OP-TEE OS): 32 or 64-bit [default 64]
Victor Chong24475982015-12-02 07:18:13 +00008SK ?= 64
Victor Chongbadc7922015-12-08 17:23:20 +00009# Secure user mode (Trusted Apps): 32 or 64-bit [default 32, requires SK=64 for 64]
10SU ?= 32
Victor Chong24475982015-12-02 07:18:13 +000011
Victor Chongbadc7922015-12-08 17:23:20 +000012################################################################################
13# Includes
14################################################################################
Pascal Brandd6536da2015-09-01 10:38:43 +020015-include common.mk
16
17################################################################################
18# Mandatory definition to use common.mk
19################################################################################
Victor Chongbadc7922015-12-08 17:23:20 +000020ifeq ($(SK),32)
21ifeq ($(SU),64)
22$(error 64-bit secure user mode requires 64-bit secure kernel, i.e. SK=64)
23endif
24endif
25
Victor Chong24475982015-12-02 07:18:13 +000026ifeq ($(NSU),64)
Pascal Brandd6536da2015-09-01 10:38:43 +020027CROSS_COMPILE_NS_USER ?= "$(CCACHE)$(AARCH64_CROSS_COMPILE)"
Victor Chong24475982015-12-02 07:18:13 +000028MULTIARCH := aarch64-linux-gnu
29else
30CROSS_COMPILE_NS_USER ?= "$(CCACHE)$(AARCH32_CROSS_COMPILE)"
31MULTIARCH := arm-linux-gnueabihf
32endif
Pascal Brandd6536da2015-09-01 10:38:43 +020033CROSS_COMPILE_NS_KERNEL ?= "$(CCACHE)$(AARCH64_CROSS_COMPILE)"
Victor Chong24475982015-12-02 07:18:13 +000034ifeq ($(SU),64)
35CROSS_COMPILE_S_USER ?= "$(CCACHE)$(AARCH64_CROSS_COMPILE)"
36else
Pascal Brandd6536da2015-09-01 10:38:43 +020037CROSS_COMPILE_S_USER ?= "$(CCACHE)$(AARCH32_CROSS_COMPILE)"
Victor Chong24475982015-12-02 07:18:13 +000038endif
39ifeq ($(SK),64)
Pascal Brandd6536da2015-09-01 10:38:43 +020040CROSS_COMPILE_S_KERNEL ?= "$(CCACHE)$(AARCH64_CROSS_COMPILE)"
Victor Chong24475982015-12-02 07:18:13 +000041else
42CROSS_COMPILE_S_KERNEL ?= "$(CCACHE)$(AARCH32_CROSS_COMPILE)"
43endif
Pascal Brandd6536da2015-09-01 10:38:43 +020044OPTEE_OS_BIN ?= $(OPTEE_OS_PATH)/out/arm-plat-hikey/core/tee.bin
Victor Chongbadc7922015-12-08 17:23:20 +000045OPTEE_OS_TA_DEV_KIT_DIR ?= $(OPTEE_OS_PATH)/out/arm-plat-hikey/export-ta_arm$(SU)
Pascal Brandd6536da2015-09-01 10:38:43 +020046
Joakim Bech427dd632015-05-04 15:52:33 +020047################################################################################
48# Paths to git projects and various binaries
49################################################################################
50ARM_TF_PATH ?= $(ROOT)/arm-trusted-firmware
51ifeq ($(DEBUG),1)
52ARM_TF_BUILD ?= debug
53else
54ARM_TF_BUILD ?= release
Joakim Bech427dd632015-05-04 15:52:33 +020055endif
56
57EDK2_PATH ?= $(ROOT)/edk2
58ifeq ($(DEBUG),1)
59EDK2_BIN ?= $(EDK2_PATH)/Build/HiKey/DEBUG_GCC49/FV/BL33_AP_UEFI.fd
60EDK2_BUILD ?= DEBUG
61else
62EDK2_BIN ?= $(EDK2_PATH)/Build/HiKey/RELEASE_GCC49/FV/BL33_AP_UEFI.fd
63EDK2_BUILD ?= RELEASE
64endif
65
Victor Chong24475982015-12-02 07:18:13 +000066MCUIMAGE_BIN ?=$(EDK2_PATH)/HisiPkg/HiKeyPkg/NonFree/mcuimage.bin
Joakim Bech427dd632015-05-04 15:52:33 +020067STRACE_PATH ?=$(ROOT)/strace
68BOOT_IMG ?=$(ROOT)/out/boot-fat.uefi.img
69LLOADER_PATH ?=$(ROOT)/l-loader
Joakim Bech7f43b922015-10-01 07:24:00 -070070NVME_IMG ?=$(ROOT)/out/nvme.img
Victor Chong24475982015-12-02 07:18:13 +000071OUT_PATH ?=$(ROOT)/out
72GRUB_PATH ?=$(ROOT)/grub
73PATCHES_PATH ?=$(ROOT)/patches_hikey
74AESPERF_PATH ?=$(ROOT)/aes-perf
75SHAPERF_PATH ?=$(ROOT)/sha-perf
Joakim Bech427dd632015-05-04 15:52:33 +020076
77################################################################################
Joakim Bech427dd632015-05-04 15:52:33 +020078# Targets
79################################################################################
Victor Chong24475982015-12-02 07:18:13 +000080all: prepare arm-tf boot-img lloader nvme
Joakim Bech427dd632015-05-04 15:52:33 +020081
Victor Chong24475982015-12-02 07:18:13 +000082clean: arm-tf-clean busybox-clean edk2-clean linux-clean optee-os-clean optee-client-clean optee-linuxdriver-clean xtest-clean strace-clean update_rootfs-clean boot-img-clean lloader-clean aes-perf-clean sha-perf-clean grub-clean
Joakim Bech427dd632015-05-04 15:52:33 +020083
Victor Chong24475982015-12-02 07:18:13 +000084cleaner: clean prepare-cleaner busybox-cleaner linux-cleaner strace-cleaner nvme-cleaner grub-cleaner
Joakim Bech427dd632015-05-04 15:52:33 +020085
86-include toolchain.mk
87
Victor Chong24475982015-12-02 07:18:13 +000088prepare:
89 @if [ ! -d $(ROOT)/out ]; then mkdir $(ROOT)/out; fi
Joakim Bech427dd632015-05-04 15:52:33 +020090
Victor Chong24475982015-12-02 07:18:13 +000091.PHONY: prepare-cleaner
92prepare-cleaner:
93 rm -rf $(ROOT)/out
Joakim Bech427dd632015-05-04 15:52:33 +020094
95################################################################################
96# ARM Trusted Firmware
97################################################################################
Pascal Brandb130ea22015-10-13 13:18:36 +020098ARM_TF_EXPORTS ?= \
Joakim Bech427dd632015-05-04 15:52:33 +020099 CFLAGS="-O0 -gdwarf-2" \
Pascal Brandb130ea22015-10-13 13:18:36 +0200100 CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)"
101
102ARM_TF_FLAGS ?= \
Joakim Bech427dd632015-05-04 15:52:33 +0200103 BL32=$(OPTEE_OS_BIN) \
104 BL33=$(EDK2_BIN) \
Joakim Bech427dd632015-05-04 15:52:33 +0200105 BL30=$(MCUIMAGE_BIN) \
Pascal Brandb130ea22015-10-13 13:18:36 +0200106 DEBUG=$(DEBUG) \
107 PLAT=hikey \
108 SPD=opteed
Joakim Bech427dd632015-05-04 15:52:33 +0200109
Victor Chong24475982015-12-02 07:18:13 +0000110arm-tf: optee-os edk2
Pascal Brandb130ea22015-10-13 13:18:36 +0200111 $(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) all fip
112
Victor Chong24475982015-12-02 07:18:13 +0000113.PHONY: arm-tf-clean
Joakim Bech427dd632015-05-04 15:52:33 +0200114arm-tf-clean:
Pascal Brandb130ea22015-10-13 13:18:36 +0200115 $(ARM_TF_EXPORTS) $(MAKE) -C $(ARM_TF_PATH) $(ARM_TF_FLAGS) clean
Joakim Bech427dd632015-05-04 15:52:33 +0200116
117################################################################################
118# Busybox
Victor Chong24475982015-12-02 07:18:13 +0000119################################################################################
Pascal Brand440ef9c2015-09-08 16:01:58 +0200120BUSYBOX_COMMON_TARGET = hikey nocpio
121BUSYBOX_CLEAN_COMMON_TARGET = hikey clean
Victor Chong24475982015-12-02 07:18:13 +0000122ifeq ($(NSU),64)
Pascal Brand440ef9c2015-09-08 16:01:58 +0200123BUSYBOX_COMMON_CCDIR = $(AARCH64_PATH)
Victor Chong24475982015-12-02 07:18:13 +0000124else
125BUSYBOX_COMMON_CCDIR = $(AARCH32_PATH)
126endif
Joakim Bech427dd632015-05-04 15:52:33 +0200127
Pascal Brand440ef9c2015-09-08 16:01:58 +0200128busybox: busybox-common
Joakim Bech427dd632015-05-04 15:52:33 +0200129
Joakim Bech7f43b922015-10-01 07:24:00 -0700130.PHONY: busybox-clean
Pascal Brand440ef9c2015-09-08 16:01:58 +0200131busybox-clean: busybox-clean-common
132
Joakim Bech7f43b922015-10-01 07:24:00 -0700133.PHONY: busybox-cleaner
Victor Chong24475982015-12-02 07:18:13 +0000134busybox-cleaner: busybox-clean-common busybox-cleaner-common
Joakim Bech427dd632015-05-04 15:52:33 +0200135
136################################################################################
137# EDK2 / Tianocore
138################################################################################
Pascal Brand9a0f50f2015-09-08 15:34:17 +0200139define edk2-call
Joakim Bech427dd632015-05-04 15:52:33 +0200140 GCC49_AARCH64_PREFIX=$(AARCH64_CROSS_COMPILE) \
Pascal Brand9a0f50f2015-09-08 15:34:17 +0200141 $(MAKE) -j1 -C $(EDK2_PATH) \
Joakim Bech427dd632015-05-04 15:52:33 +0200142 -f HisiPkg/HiKeyPkg/Makefile EDK2_ARCH=AARCH64 \
143 EDK2_DSC=HisiPkg/HiKeyPkg/HiKey.dsc \
144 EDK2_TOOLCHAIN=GCC49 EDK2_BUILD=$(EDK2_BUILD)
145endef
146
Pascal Brand9a0f50f2015-09-08 15:34:17 +0200147edk2: edk2-common
Joakim Bech427dd632015-05-04 15:52:33 +0200148
Joakim Bech7f43b922015-10-01 07:24:00 -0700149.PHONY: edk2-clean
Pascal Brand9a0f50f2015-09-08 15:34:17 +0200150edk2-clean: edk2-clean-common
Joakim Bech427dd632015-05-04 15:52:33 +0200151
152################################################################################
153# Linux kernel
154################################################################################
Jerome Forissiere1002382015-11-26 11:36:00 +0100155LINUX_DEFCONFIG_COMMON_ARCH ?= arm64
156LINUX_DEFCONFIG_COMMON_FILES ?= $(LINUX_PATH)/arch/arm64/configs/defconfig \
Victor Chong24475982015-12-02 07:18:13 +0000157 $(CURDIR)/kconfigs/hikey.conf \
158 $(PATCHES_PATH)/kernel_config/usb_net_dm9601.conf \
159 $(PATCHES_PATH)/kernel_config/ftrace.conf
Joakim Bech427dd632015-05-04 15:52:33 +0200160
161linux-defconfig: $(LINUX_PATH)/.config
162
163linux-gen_init_cpio: linux-defconfig
Victor Chong24475982015-12-02 07:18:13 +0000164 $(MAKE) -C $(LINUX_PATH)/usr \
Pascal Brande3d85982015-09-10 17:20:42 +0200165 CROSS_COMPILE=$(CROSS_COMPILE_NS_KERNEL) \
Joakim Bech427dd632015-05-04 15:52:33 +0200166 ARCH=arm64 \
167 LOCALVERSION= \
168 gen_init_cpio
169
Victor Chong24475982015-12-02 07:18:13 +0000170LINUX_COMMON_FLAGS += ARCH=arm64 Image modules
171UPSTREAM_KERNEL := $(if $(wildcard $(LINUX_PATH)/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts),1,0)
172ifeq ($(UPSTREAM_KERNEL),0)
173LINUX_COMMON_FLAGS += hi6220-hikey.dtb
174DTB = $(LINUX_PATH)/arch/arm64/boot/dts/hi6220-hikey.dtb
175else
176LINUX_COMMON_FLAGS += hisilicon/hi6220-hikey.dtb
177DTB = $(LINUX_PATH)/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dtb
178endif
Joakim Bech427dd632015-05-04 15:52:33 +0200179
Pascal Brande3d85982015-09-10 17:20:42 +0200180linux: linux-common
181
Joakim Bech7f43b922015-10-01 07:24:00 -0700182.PHONY: linux-defconfig-clean
Pascal Brande3d85982015-09-10 17:20:42 +0200183linux-defconfig-clean: linux-defconfig-clean-common
Joakim Bech427dd632015-05-04 15:52:33 +0200184
Pascal Brande3d85982015-09-10 17:20:42 +0200185LINUX_CLEAN_COMMON_FLAGS += ARCH=arm64
Joakim Bech427dd632015-05-04 15:52:33 +0200186
Joakim Bech7f43b922015-10-01 07:24:00 -0700187.PHONY: linux-clean
Pascal Brande3d85982015-09-10 17:20:42 +0200188linux-clean: linux-clean-common
189
190LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64
191
Joakim Bech7f43b922015-10-01 07:24:00 -0700192.PHONY: linux-cleaner
Pascal Brande3d85982015-09-10 17:20:42 +0200193linux-cleaner: linux-cleaner-common
Joakim Bech427dd632015-05-04 15:52:33 +0200194
195################################################################################
196# OP-TEE
197################################################################################
Victor Chong24475982015-12-02 07:18:13 +0000198OPTEE_OS_COMMON_FLAGS += PLATFORM=hikey CFG_TEE_TA_LOG_LEVEL=3
199OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=hikey CFG_TEE_TA_LOG_LEVEL=3
200ifeq ($(SK),64)
201OPTEE_OS_COMMON_FLAGS += CFG_ARM64_core=y
202OPTEE_OS_CLEAN_COMMON_FLAGS += CFG_ARM64_core=y
203endif
204
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200205optee-os: optee-os-common
Joakim Bech427dd632015-05-04 15:52:33 +0200206
Joakim Bech7f43b922015-10-01 07:24:00 -0700207.PHONY: optee-os-clean
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200208optee-os-clean: optee-os-clean-common
Joakim Bech427dd632015-05-04 15:52:33 +0200209
Pascal Brand070d9552015-09-01 15:33:22 +0200210optee-client: optee-client-common
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200211
Joakim Bech7f43b922015-10-01 07:24:00 -0700212.PHONY: optee-client-clean
Pascal Brand070d9552015-09-01 15:33:22 +0200213optee-client-clean: optee-client-clean-common
Jerome Forissierae45fbf2015-09-04 09:40:17 +0200214
215OPTEE_LINUXDRIVER_COMMON_FLAGS += ARCH=arm64
216optee-linuxdriver: optee-linuxdriver-common
217
218OPTEE_LINUXDRIVER_CLEAN_COMMON_FLAGS += ARCH=arm64
Joakim Bech7f43b922015-10-01 07:24:00 -0700219.PHONY: optee-linuxdriver-clean
Pascal Brand070d9552015-09-01 15:33:22 +0200220optee-linuxdriver-clean: optee-linuxdriver-clean-common
Joakim Bech427dd632015-05-04 15:52:33 +0200221
222################################################################################
223# xtest / optee_test
224################################################################################
Victor Chong24475982015-12-02 07:18:13 +0000225ifeq ($(NSU),32)
226XTEST_COMMON_FLAGS += CFG_ARM32=y
227XTEST_CLEAN_COMMON_FLAGS += CFG_ARM32=y
228endif
229
Pascal Brandd6536da2015-09-01 10:38:43 +0200230xtest: xtest-common
Joakim Bech7f43b922015-10-01 07:24:00 -0700231
Victor Chong24475982015-12-02 07:18:13 +0000232# FIXME:
233# "make clean" in xtest: fails if optee_os has been cleaned previously
Joakim Bech7f43b922015-10-01 07:24:00 -0700234.PHONY: xtest-clean
Pascal Brandd6536da2015-09-01 10:38:43 +0200235xtest-clean: xtest-clean-common
Victor Chong24475982015-12-02 07:18:13 +0000236 rm -rf $(OPTEE_TEST_OUT_PATH)
Joakim Bech7f43b922015-10-01 07:24:00 -0700237
238.PHONY: xtest-patch
Pascal Brandd6536da2015-09-01 10:38:43 +0200239xtest-patch: xtest-patch-common
Pascal Brand294bfdf2015-08-25 09:27:13 +0200240
Joakim Bech427dd632015-05-04 15:52:33 +0200241################################################################################
Victor Chong24475982015-12-02 07:18:13 +0000242# aes-pef
243################################################################################
244PERF_FLAGS := CROSS_COMPILE_HOST=$(CROSS_COMPILE_NS_USER) \
245 CROSS_COMPILE_TA=$(CROSS_COMPILE_S_USER) \
246 TA_DEV_KIT_DIR=$(OPTEE_OS_TA_DEV_KIT_DIR)
247
248aes-perf: optee-os optee-client
249 $(MAKE) -C $(AESPERF_PATH) $(PERF_FLAGS)
250
251.PHONY: aes-perf-clean
252aes-perf-clean:
253 rm -rf $(AESPERF_PATH)/out
254
255################################################################################
256# sha-perf
257################################################################################
258sha-perf: optee-os optee-client
259 $(MAKE) -C $(SHAPERF_PATH) $(PERF_FLAGS)
260
261.PHONY: sha-perf-clean
262sha-perf-clean:
263 rm -rf $(SHAPERF_PATH)/out
264
265################################################################################
Joakim Bech427dd632015-05-04 15:52:33 +0200266# strace
267################################################################################
268strace:
Victor Chong24475982015-12-02 07:18:13 +0000269 cd $(STRACE_PATH); \
270 ./bootstrap; \
271 set -e; \
272 ./configure --host=$(MULTIARCH) CC="$(CCACHE)$(AARCH64_CROSS_COMPILE)gcc" LD=$(AARCH64_CROSS_COMPILE)ld; \
273 CC="$(CCACHE)$(AARCH64_CROSS_COMPILE)gcc" LD=$(AARCH64_CROSS_COMPILE)ld $(MAKE) -C $(STRACE_PATH)
Joakim Bech427dd632015-05-04 15:52:33 +0200274
Joakim Bech7f43b922015-10-01 07:24:00 -0700275.PHONY: strace-clean
Joakim Bech427dd632015-05-04 15:52:33 +0200276strace-clean:
Victor Chong24475982015-12-02 07:18:13 +0000277 @if [ -e $(STRACE_PATH)/Makefile ]; then $(MAKE) -C $(STRACE_PATH) clean; fi
Joakim Bech427dd632015-05-04 15:52:33 +0200278
Joakim Bech7f43b922015-10-01 07:24:00 -0700279.PHONY: strace-cleaner
Victor Chong24475982015-12-02 07:18:13 +0000280strace-cleaner: strace-clean
Joakim Bech427dd632015-05-04 15:52:33 +0200281 rm -f $(STRACE_PATH)/Makefile $(STRACE_PATH)/configure
282
283################################################################################
284# Root FS
285################################################################################
Victor Chong24475982015-12-02 07:18:13 +0000286# Read stdin, expand ${VAR} environment variables, output to stdout
287# http://superuser.com/a/302847
288define expand-env-var
289awk '{while(match($$0,"[$$]{[^}]*}")) {var=substr($$0,RSTART+2,RLENGTH -3);gsub("[$$]{"var"}",ENVIRON[var])}}1'
290endef
Joakim Bech427dd632015-05-04 15:52:33 +0200291
Victor Chong24475982015-12-02 07:18:13 +0000292filelist-all: busybox
Joakim Bech427dd632015-05-04 15:52:33 +0200293 cat $(GEN_ROOTFS_PATH)/filelist-final.txt | sed '/fbtest/d' > $(GEN_ROOTFS_PATH)/filelist-all.txt
Victor Chong24475982015-12-02 07:18:13 +0000294 export KERNEL_VERSION=$(call KERNEL_VERSION); \
295 export TOP=$(ROOT); export MULTIARCH=$(MULTIARCH); \
296 $(expand-env-var) <$(PATCHES_PATH)/rootfs/initramfs-add-files.txt >> $(GEN_ROOTFS_PATH)/filelist-all.txt; \
297 find $(OPTEE_TEST_OUT_PATH) -type f -name "xtest" | sed 's/\(.*\)/file \/bin\/xtest \1 755 0 0/g' >> $(GEN_ROOTFS_PATH)/filelist-all.txt; \
298 find $(OPTEE_TEST_OUT_PATH) -name "*.ta" | \
299 sed 's/\(.*\)\/\(.*\)/file \/lib\/optee_armtz\/\2 \1\/\2 444 0 0/g' >> $(GEN_ROOTFS_PATH)/filelist-all.txt
Joakim Bech427dd632015-05-04 15:52:33 +0200300
Victor Chong24475982015-12-02 07:18:13 +0000301update_rootfs: optee-client optee-linuxdriver xtest aes-perf sha-perf strace filelist-all linux-gen_init_cpio
Joakim Bech427dd632015-05-04 15:52:33 +0200302 cd $(GEN_ROOTFS_PATH); \
Victor Chong24475982015-12-02 07:18:13 +0000303 $(LINUX_PATH)/usr/gen_init_cpio $(GEN_ROOTFS_PATH)/filelist-all.txt | gzip > $(GEN_ROOTFS_PATH)/filesystem.cpio.gz
304
305.PHONY: update_rootfs-clean
306update_rootfs-clean:
307 rm -f $(GEN_ROOTFS_PATH)/filesystem.cpio.gz $(GEN_ROOTFS_PATH)/filelist-all.txt $(GEN_ROOTFS_PATH)/filelist-tmp.txt
308
309################################################################################
310# grub
311################################################################################
312grub-flags := CC="$(CCACHE)gcc" \
313 TARGET_CC="$(AARCH64_CROSS_COMPILE)gcc" \
314 TARGET_OBJCOPY="$(AARCH64_CROSS_COMPILE)objcopy" \
315 TARGET_NM="$(AARCH64_CROSS_COMPILE)nm" \
316 TARGET_RANLIB="$(AARCH64_CROSS_COMPILE)ranlib" \
317 TARGET_STRIP="$(AARCH64_CROSS_COMPILE)strip"
318
319.PHONY: grub
320grub: prepare
321 cd $(GRUB_PATH); \
322 ./autogen.sh; \
323 ./configure --target=aarch64 --enable-boot-time $(grub-flags); \
324 $(MAKE) -C $(GRUB_PATH); \
325 ./grub-mkimage \
326 --verbose \
327 --output=$(OUT_PATH)/grubaa64.efi \
328 --config=$(PATCHES_PATH)/grub/grub.configfile \
329 --format=arm64-efi \
330 --directory=grub-core \
331 --prefix=/boot/grub \
332 boot chain configfile efinet ext2 fat gettext help linux loadenv lsefi normal part_gpt part_msdos read search search_fs_file search_fs_uuid search_label terminal terminfo tftp time
333
334.PHONY: grub-clean
335grub-clean:
336 @if [ -e $(GRUB_PATH)/Makefile ]; then $(MAKE) -C $(GRUB_PATH) clean; fi
337 rm -f $(OUT_PATH)/grubaa64.efi
338
339.PHONY: grub-cleaner
340grub-cleaner: grub-clean
341 @if [ -e $(GRUB_PATH)/Makefile ]; then $(MAKE) -C $(GRUB_PATH) distclean; fi
342 rm -f $(GRUB_PATH)/configure
Joakim Bech427dd632015-05-04 15:52:33 +0200343
344################################################################################
345# Boot Image
346################################################################################
Victor Chong24475982015-12-02 07:18:13 +0000347boot-img: linux update_rootfs edk2 grub
Joakim Bech427dd632015-05-04 15:52:33 +0200348 sudo -p "[sudo] Password:" true
349 if [ -d .tmpbootimg ] ; then sudo rm -rf .tmpbootimg ; fi
350 mkdir -p .tmpbootimg
351 dd if=/dev/zero of=$(BOOT_IMG) bs=512 count=131072 status=none
Victor Chong24475982015-12-02 07:18:13 +0000352 sudo mkfs.vfat -n "BOOT IMG" $(BOOT_IMG) >/dev/null
Joakim Bech427dd632015-05-04 15:52:33 +0200353 sudo mount -o loop,rw,sync $(BOOT_IMG) .tmpbootimg
Victor Chong24475982015-12-02 07:18:13 +0000354 sudo cp $(LINUX_PATH)/arch/arm64/boot/Image $(DTB) .tmpbootimg/
355 sudo mkdir -p .tmpbootimg/EFI/BOOT
356 sudo cp $(OUT_PATH)/grubaa64.efi $(PATCHES_PATH)/grub/grub_uart3.cfg .tmpbootimg/EFI/BOOT/
Joakim Bech427dd632015-05-04 15:52:33 +0200357 sudo cp $(GEN_ROOTFS_PATH)/filesystem.cpio.gz .tmpbootimg/initrd.img
Victor Chong24475982015-12-02 07:18:13 +0000358 sudo cp $(EDK2_PATH)/Build/HiKey/$(EDK2_BUILD)_GCC49/AARCH64/AndroidFastbootApp.efi .tmpbootimg/EFI/BOOT/fastboot.efi
Joakim Bech2a8ddf42015-11-12 14:12:43 +0100359 # We cannot figure out why we need the sleep here, but from time to time
360 # we can see that we get "device/resource busy" when trying to unmount
361 # .tmpbootimg below. A short sleep seems to solve the problem and has to
362 # be here until we figure out why this happens.
363 sleep 3
Joakim Bech427dd632015-05-04 15:52:33 +0200364 sudo umount .tmpbootimg
365 sudo rm -rf .tmpbootimg
366
Joakim Bech7f43b922015-10-01 07:24:00 -0700367.PHONY: boot-img-clean
Joakim Bech427dd632015-05-04 15:52:33 +0200368boot-img-clean:
369 rm -f $(BOOT_IMG)
370
371################################################################################
372# l-loader
373################################################################################
374lloader: arm-tf
Victor Chong24475982015-12-02 07:18:13 +0000375 $(MAKE) -C $(LLOADER_PATH) BL1=$(ARM_TF_PATH)/build/hikey/$(ARM_TF_BUILD)/bl1.bin CROSS_COMPILE="$(CCACHE)$(AARCH32_CROSS_COMPILE)" PTABLE_LST=linux-4g
Joakim Bech427dd632015-05-04 15:52:33 +0200376
Joakim Bech7f43b922015-10-01 07:24:00 -0700377.PHONY: lloader-clean
Joakim Bech427dd632015-05-04 15:52:33 +0200378lloader-clean:
Victor Chong24475982015-12-02 07:18:13 +0000379 $(MAKE) -C $(LLOADER_PATH) clean
Joakim Bech7f43b922015-10-01 07:24:00 -0700380
381################################################################################
382# nvme image
383################################################################################
384.PHONY: nvme
Victor Chong24475982015-12-02 07:18:13 +0000385nvme: prepare
Joakim Bech7f43b922015-10-01 07:24:00 -0700386 wget https://builds.96boards.org/releases/hikey/linaro/binaries/latest/nvme.img -O $(NVME_IMG)
387
388.PHONY: nvme-cleaner
389nvme-cleaner:
390 rm -f $(NVME_IMG)
391
392################################################################################
393# Flash
394################################################################################
395.PHONY: flash
396flash:
Victor Chong24475982015-12-02 07:18:13 +0000397 sudo python $(ROOT)/burn-boot/hisi-idt.py --img1=$(LLOADER_PATH)/l-loader.bin
398 fastboot flash ptable $(LLOADER_PATH)/ptable-linux-4g.img
399 fastboot flash fastboot $(ARM_TF_PATH)/build/hikey/$(ARM_TF_BUILD)/fip.bin
Joakim Bech7f43b922015-10-01 07:24:00 -0700400 fastboot flash nvme $(NVME_IMG)
401 fastboot flash boot $(BOOT_IMG)