blob: a098a026a11fa45e75e5d6bf083e41e238102793 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001LK_ENV_PATH := $(call my-dir)
2LK_ROOT_DIR := $(PWD)
3HOST_OS ?= $(shell uname | tr '[A-Z]' '[a-z]')
4
5# BL2 and BL33 LK common tool and directories setting
6LK_DIR := $(LK_ENV_PATH)
7DRAMK_DIR := $(LK_ENV_PATH)/../dramk_2712
8LK_EXT_DIR := $(LK_ENV_PATH)/../lk_ext_mod
9LK_DTS_DIR := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/security/lk_dts
10DUMMY_IMG_DIR := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/security/dummy_img
11DEV_INFO_DIR := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/security/dev_info
12UBOOT_MKIMG_TOOL := $(LK_ROOT_DIR)/prebuilts/u-boot/host/x86_64-linux/usr/bin/uboot-mkimage
13BL2_BUILDROOT := $(LK_ROOT_DIR)/$(PRODUCT_OUT)/bl2_out
14BL33_BUILDROOT := $(LK_ROOT_DIR)/$(PRODUCT_OUT)/bl33_out
15LK_BLOB_INC := $(BL2_BUILDROOT)
16BL33_BLOB_INC := $(BL33_BUILDROOT)
17
18#userdebug/eng setting DEBUG=1, user load setting it to 0
19ifeq ($(TARGET_BUILD_VARIANT), user)
20 DEBUG = 0
21else
22 DEBUG = 1
23endif
24
25COMMON_PROJ_OPTION = \
26 SECURE_BOOT_ENABLE \
27 AB_OTA_UPDATER
28
29BL2_PROJ_OPTION = \
30 MTK_CLK32K_EXT_REMOVAL_SUPPORT
31
32define convertOpt
33 $(eval result := $(empty)) \
34 $(foreach opt, $(strip $(1)), $(eval result += $(opt)=$($(opt)))) \
35 $(patsubst %=false,%=no,$(patsubst %=true,%=yes,$(result)))
36endef
37
38CONVERTED_COMMON_PROJ_OPTION := $(strip $(call convertOpt,$(COMMON_PROJ_OPTION)))
39CONVERTED_BL2_PROJ_OPTION := $(strip $(call convertOpt,$(BL2_PROJ_OPTION)))
40
41# LK/BL33 make option
42LOCAL_COMMON_MAKE_OPTION := $(if $(SHOW_COMMANDS),NOECHO=) $(if $(LK_CROSS_COMPILE),ARCH_arm64_TOOLCHAIN_PREFIX=$(LK_CROSS_COMPILE)) \
43 CFLAGS= DEBUG=$(DEBUG) CLANGBUILD=$(LK_CLANGBUILD) CLANG_BINDIR=$(LK_CLANG_BINDIR) \
44 $(CONVERTED_COMMON_PROJ_OPTION) \
45 SECURE_BOOT_TYPE=$(SECURE_BOOT_TYPE) \
46 ANDROID_2712=yes
47
48# BL2 LK specific
49ifeq ($(wildcard $(TARGET_PREBUILT_LK)),)
50TARGET_LK_OUT ?= $(TARGET_OUT_INTERMEDIATES)/BOOTLOADER_OBJ
51BUILT_LK_TARGET := $(TARGET_LK_OUT)/build-$(LK_PROJECT)/lk.bin
52LK_FIT_PACK_SCRIPT := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/mk_lk_img.sh
53LK_MAKE_OPTION := PROJECT=$(LK_PROJECT) \
54 $(CONVERTED_BL2_PROJ_OPTION)
55BL2_OFF_DT_STRINGS=`fdtdump ${BL2_BUILDROOT}/lk.dtb | grep off_dt_strings | sed "s,^\/\/.*:\s*0x,,"`
56BL2_SIZE_DT_STRINGS=`fdtdump ${BL2_BUILDROOT}/lk.dtb | grep size_dt_strings | sed "s,^\/\/.*:\s*0x,,"`
57endif
58
59# BL33 LK specific
60ifeq ($(wildcard $(TARGET_PREBUILT_BL33)),)
61TARGET_BL33_OUT ?= $(TARGET_OUT_INTERMEDIATES)/BL33_OBJ
62BUILT_BL33_TARGET := $(TARGET_BL33_OUT)/build-$(BL33_PROJECT)/bl33.bin
63BL33_FIT_PACK_SCRIPT := $(LK_ROOT_DIR)/device/mediatek/common/tools/bootloader/mk_bl33_img.sh
64BL33_MAKE_OPTION := MTK_MRDUMP_SUPPORT=$(MTK_MRDUMP_SUPPORT) \
65 MTK_KEDUMP_MINI_SUPPORT=$(MTK_KEDUMP_MINI_SUPPORT) \
66 PROJECT=$(BL33_PROJECT) \
67 MTK_BOOT_REASON_SUPPORT=$(MTK_BOOT_REASON_SUPPORT)
68BL33_OFF_DT_STRINGS=`fdtdump ${BL33_BUILDROOT}/lk.dtb | grep off_dt_strings | sed "s,^\/\/.*:\s*0x,,"`
69BL33_SIZE_DT_STRINGS=`fdtdump ${BL33_BUILDROOT}/lk.dtb | grep size_dt_strings | sed "s,^\/\/.*:\s*0x,,"`
70endif