• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include $(MAIN_TOPDIR)/build/make_scripts/config.mk
2-include $(MAIN_TOPDIR)/$(MODULE_DIR)/srcs.mk
3include $(MAIN_TOPDIR)/$(MODULE_DIR)/module_config.mk
4
5override CCFLAGS = $(BOOT_CCFLAGS) $(BOOT_DEFINE) $(BOOT_INC)
6override ASFLAGS = $(BOOT_ASFLAGS) $(BOOT_DEFINE) $(BOOT_INC)
7
8LIBDIR = $(MAIN_TOPDIR)/$(LIB_PATH)/$(MODULE_DIR)
9OBJDIR = $(MAIN_TOPDIR)/$(OBJ_PATH)/loaderboot
10ID_CFG_FILE = $(MAIN_TOPDIR)/$(MODULE_DIR)/file_id.cfg
11
12LIB_NAME = lib$(LIB).a
13SRCS = $($(LIB)_srcs)
14LIBOUT = $(LIBDIR)/$(MODULE_DIR)/$(LIB_NAME)
15
16ifdef SRC_FILES
17OBJ_SRCS = $(filter %.c, $(SRC_FILES))
18ASM_SRCS = $(filter %.S, $(SRC_FILES))
19else
20OBJ_SRCS = $(foreach dir, $(SRCS), $(wildcard $(dir)/*.c))
21ASM_SRCS = $(foreach dir, $(SRCS), $(wildcard $(dir)/*.S ))
22OBJ_COMMON_SRCS = $(foreach dir, $($(LIB)_common_srcs), $(wildcard $(dir)/*.c))
23ASM_COMMON_SRCS = $(foreach dir, $($(LIB)_common_srcs), $(wildcard $(dir)/*.S ))
24endif
25OBJ_SRCS += $(MAIN_TOPDIR)/third_party/u-boot-v2019.07/u-boot-v2019.07/lib/crc32.c \
26            $(MAIN_TOPDIR)/third_party/u-boot-v2019.07/u-boot-v2019.07/lib/lzma/LzmaDec.c \
27            $(MAIN_TOPDIR)/third_party/u-boot-v2019.07/u-boot-v2019.07/lib/lzma/LzmaTools.c
28OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(OBJ_SRCS))
29ASM_OBJS = $(patsubst %.S, $(OBJDIR)/%.o, $(ASM_SRCS))
30COMMON_OBJS = $(patsubst ../%.c, $(OBJDIR)/%.o, $(OBJ_COMMON_SRCS))
31COMMON_ASM_OBJS = $(patsubst ../%.S, $(OBJDIR)/%.o, $(ASM_COMMON_SRCS))
32
33SIGN_TOOL = $(MAIN_TOPDIR)/tools/sign_tool/sign_tool
34ENCRYPT_KEY_PATH = $(MAIN_TOPDIR)/tools/sign_tool/aes_key.txt
35ifeq ($(CONFIG_TARGET_SIG_SHA256), y)
36    LINK_FILE = $(MAIN_TOPDIR)/build/link/loaderboot_sha256.lds
37else ifeq ($(CONFIG_TARGET_SIG_ECC), y)
38    LINK_FILE = $(MAIN_TOPDIR)/build/link/loaderboot_ecc.lds
39    ROOT_KEY_PATH = $(MAIN_TOPDIR)/tools/sign_tool/root_ecc.pem
40    SUB_KEY_PATH = $(MAIN_TOPDIR)/tools/sign_tool/sub_ecc.pem
41    SIGN_TYPE = 2
42else
43    LINK_FILE = $(MAIN_TOPDIR)/build/link/loaderboot_rsa.lds
44    ROOT_KEY_PATH = $(MAIN_TOPDIR)/tools/sign_tool/root_rsa.pem
45    SUB_KEY_PATH = $(MAIN_TOPDIR)/tools/sign_tool/sub_rsa.pem
46    ifeq ($(CONFIG_TARGET_SIG_RSA_V15), y)
47        SIGN_TYPE = 0
48    else ifeq ($(CONFIG_TARGET_SIG_RSA_PSS), y)
49        SIGN_TYPE = 1
50    endif
51endif
52
53LIBS := $(patsubst lib%.a, -l%, $(notdir $(wildcard $(MAIN_TOPDIR)/build/libs/boot_libs/*.a)))
54LIBPATH := -L$(MAIN_TOPDIR)/build/libs
55LIBPATH += -L$(MAIN_TOPDIR)/build/libs/boot_libs
56BOOT_ELF = $(MAIN_TOPDIR)/$(CACHE_PATH)/loader_boot.elf
57BOOT_BIN = $(MAIN_TOPDIR)/$(CACHE_PATH)/hi_loader_boot.bin
58BOOT_SIGNED_BIN = $(MAIN_TOPDIR)/$(BIN_PATH)/$(TARGET_CHIP)_loader_signed.bin
59
60all: $(OBJS) $(ASM_OBJS) $(COMMON_OBJS) $(COMMON_ASM_OBJS)
61	$(LINK) $(BOOT_LINK_FLAGS) -T $(LINK_FILE) $(LIBPATH) $(sort $^) -o $(BOOT_ELF) --start-group $(LIBS) --end-group
62	$(OBJCOPY) -Obinary -R .rom.text -R .rom.code.text -R .u_boot_cmd  -R .rom.data -R .rom.code.data -R .rom.bss -R .rom.code.bss -S $(BOOT_ELF) $(BOOT_BIN)
63ifeq ($(CONFIG_TARGET_SIG_SHA256), y)
64	$(SIGN_TOOL) -i $(BOOT_BIN) -o $(BOOT_SIGNED_BIN) -n
65else ifeq ($(CONFIG_BOOT_ENCRYPT), y)
66	$(SIGN_TOOL) -i $(BOOT_BIN) -o $(BOOT_SIGNED_BIN) -r$(ROOT_KEY_PATH) -s$(SUB_KEY_PATH) -v $(CONFIG_TARGET_BOOT_VER) -a $(SIGN_TYPE) -e$(ENCRYPT_KEY_PATH)
67else
68	$(SIGN_TOOL) -i $(BOOT_BIN) -o $(BOOT_SIGNED_BIN) -r$(ROOT_KEY_PATH) -s$(SUB_KEY_PATH) -v $(CONFIG_TARGET_BOOT_VER) -a $(SIGN_TYPE)
69endif
70	$(Q)echo [LOADER_BOOT] SUCCESS
71	$(RM) $(BOOT_ELF) $(BOOT_BIN)
72
73
74include $(MAIN_TOPDIR)/build/make_scripts/lib.mk
75$(COMMON_OBJS): $(OBJDIR)/%.o : ../%.c
76	$(Q)if [ ! -d $(dir $@) ]; then \
77	mkdir -p $(dir $@); \
78	fi;
79	$(Q) echo Compile $<;
80	$(Q)if [ -e $< ]; \
81	then $(CC) $(CCFLAGS) -c $< -o $@; \
82	if [ "$$?" != "0" ]; then \
83	exit 1;\
84	fi; \
85	fi;
86
87$(COMMON_ASM_OBJS): $(OBJDIR)/%.o : ../%.S
88	$(Q)echo Compile  $<;
89	$(Q)if [ ! -d $(dir $@) ]; \
90	then \
91	mkdir -p $(dir $@);\
92	fi;
93	$(Q)if [ -f $< ]; \
94	then \
95	$(CC) $(ASFLAGS)  -c $< -o $@ ; \
96	if [ "$$?" != "0" ]; then \
97	exit 1;\
98	fi;\
99	fi;
100