add IPL
This commit is contained in:
346
IPL/Customer/Mobis/ca76_loader/Makefile
Normal file
346
IPL/Customer/Mobis/ca76_loader/Makefile
Normal file
@@ -0,0 +1,346 @@
|
||||
#
|
||||
# Copyright (c) 2020 Renesas Electronics Corporation. All rights reserved.
|
||||
#
|
||||
define add_define
|
||||
DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
|
||||
endef
|
||||
|
||||
V=@
|
||||
|
||||
# LSI setting common define
|
||||
RCAR_S4:=0
|
||||
RCAR_V4H:=1
|
||||
RCAR_V4M:=2
|
||||
NORMAL:=0
|
||||
SECURE:=1
|
||||
HS400:=0
|
||||
HS200:=1
|
||||
HIGH_SPEED:=2
|
||||
NO_HIGH_SPEED:=3
|
||||
$(eval $(call add_define,RCAR_S4))
|
||||
$(eval $(call add_define,RCAR_V4H))
|
||||
$(eval $(call add_define,RCAR_V4M))
|
||||
$(eval $(call add_define,NORMAL))
|
||||
$(eval $(call add_define,SECURE))
|
||||
$(eval $(call add_define,HS400))
|
||||
$(eval $(call add_define,HS200))
|
||||
$(eval $(call add_define,HIGH_SPEED))
|
||||
$(eval $(call add_define,NO_HIGH_SPEED))
|
||||
ifneq ("$(FORCE_115200)", "")
|
||||
$(eval $(call add_define,FORCE_115200))
|
||||
endif
|
||||
$(eval $(call add_define,MOBIS_PRK3))
|
||||
|
||||
#/* Select LSI("S4" or "V4H" or "V4M")***********************
|
||||
ifeq ("$(LSI)", "")
|
||||
LSI = V4H
|
||||
endif
|
||||
|
||||
ifeq (${LSI},V4H)
|
||||
RCAR_LSI:=${RCAR_V4H}
|
||||
else
|
||||
$(error "Error: ${LSI} is not supported.")
|
||||
endif
|
||||
$(eval $(call add_define,RCAR_LSI))
|
||||
|
||||
ifndef BOOT_MODE
|
||||
BOOT_MODE:=${NORMAL}
|
||||
else
|
||||
ifeq (${BOOT_MODE},NORMAL)
|
||||
BOOT_MODE:=${NORMAL}
|
||||
else ifeq (${BOOT_MODE},SECURE)
|
||||
BOOT_MODE:=${SECURE}
|
||||
ifeq (${LSI},V4H)
|
||||
$(eval $(call add_define,TARGET_CORTEX_A))
|
||||
$(eval $(call add_define,TARGET_DEVICE_V4H))
|
||||
endif
|
||||
else
|
||||
$(error "Error: ${BOOT_MODE} is not supported.")
|
||||
endif
|
||||
$(eval $(call add_define,BOOT_MODE))
|
||||
endif
|
||||
$(eval $(call add_define,AARCH64))
|
||||
|
||||
ifndef EMMC_TRANS_MODE
|
||||
EMMC_TRANS_MODE:=${HS400}
|
||||
else
|
||||
ifeq (${EMMC_TRANS_MODE},HS400)
|
||||
EMMC_TRANS_MODE:=${HS400}
|
||||
else ifeq (${EMMC_TRANS_MODE},HS200)
|
||||
EMMC_TRANS_MODE:=${HS200}
|
||||
else ifeq (${EMMC_TRANS_MODE},HIGH_SPEED)
|
||||
EMMC_TRANS_MODE:=${HIGH_SPEED}
|
||||
else ifeq (${EMMC_TRANS_MODE},NO_HIGH_SPEED)
|
||||
EMMC_TRANS_MODE:=${NO_HIGH_SPEED}
|
||||
else
|
||||
$(error "Error: ${EMMC_TRANS_MODE} is not supported.")
|
||||
endif
|
||||
$(eval $(call add_define,EMMC_TRANS_MODE))
|
||||
endif
|
||||
|
||||
RTOS_LOAD_NUM := 1
|
||||
$(eval $(call add_define,RTOS_LOAD_NUM))
|
||||
|
||||
BOOT = ICUMXA
|
||||
AArch = 64
|
||||
CPU = -march=armv8-a
|
||||
AS_NEON =
|
||||
CC_NEON = # -mgeneral-regs-only
|
||||
ALIGN = -mstrict-align
|
||||
|
||||
AArch32_64 = AArch64
|
||||
BOOTDIR = AArch64_boot
|
||||
OUTPUT_DIR = build/release
|
||||
OBJECT_DIR = build/obj
|
||||
CROSS_COMPILE ?= aarch64-elf-
|
||||
|
||||
MEMORY_DEF = memory_cx_ipl.def
|
||||
FILE_NAME = $(OUTPUT_DIR)/ca76_loader
|
||||
|
||||
INCLUDE_DIR = -I$(BOOTDIR) -I./include -I../V4H_Cx_Loader/include
|
||||
|
||||
OUTPUT_FILE = $(FILE_NAME).axf
|
||||
|
||||
#Object file
|
||||
OBJ_FILE_BOOT = \
|
||||
$(OBJECT_DIR)/boot_mon.o \
|
||||
$(OBJECT_DIR)/stack.o
|
||||
|
||||
SRC_FILE := \
|
||||
main.c \
|
||||
common/string.c \
|
||||
common/log/log.c \
|
||||
common/log/scif.c \
|
||||
common/timer/generic_timer.c \
|
||||
loader/loader_main_common.c \
|
||||
image_load/image_load.c
|
||||
|
||||
SRC_FILE += \
|
||||
ip/emmc/emmc_boot.c \
|
||||
ip/emmc/emmc_cmd.c \
|
||||
ip/emmc/emmc_init.c \
|
||||
ip/emmc/emmc_interrupt.c \
|
||||
ip/emmc/emmc_mount.c \
|
||||
ip/emmc/emmc_multiboot.c \
|
||||
ip/emmc/emmc_read.c \
|
||||
ip/emmc/emmc_utility.c
|
||||
|
||||
ifeq (${BOOT_MODE},SECURE)
|
||||
SRC_FILE += secure/secure_boot.c \
|
||||
secure/src/comm_drv/icum_d_comm_pe.c \
|
||||
secure/src/icumif_lib/r_icumif.c \
|
||||
secure/shared/src/mem_info_def.c \
|
||||
secure/user_api/user_icumif_api.c
|
||||
|
||||
INCLUDE_DIR += -Isecure/src/comm_drv -Isecure/src/icumif_lib \
|
||||
-Isecure/icumif -Isecure/include -Isecure/user_api \
|
||||
-Isecure/shared/src
|
||||
endif
|
||||
|
||||
ifeq ("$(DCACHE)", "1")
|
||||
OBJ_FILE_BOOT += $(OBJECT_DIR)/d_armasm.o
|
||||
SRC_FILE += vmsatable.c
|
||||
endif
|
||||
|
||||
ifeq ("$(BOOT)", "WRITER_WITH_CERT")
|
||||
SRC_FILE += cert_param.c
|
||||
endif
|
||||
|
||||
###################################################
|
||||
# Process access protection flag
|
||||
# 0:Disable 1:Enable
|
||||
ifndef ACC_PROT_ENABLE
|
||||
ACC_PROT_ENABLE := 0
|
||||
$(eval $(call add_define,ACC_PROT_ENABLE))
|
||||
else
|
||||
ifeq (${ACC_PROT_ENABLE},0)
|
||||
$(eval $(call add_define,ACC_PROT_ENABLE))
|
||||
else ifeq (${ACC_PROT_ENABLE},1)
|
||||
$(eval $(call add_define,ACC_PROT_ENABLE))
|
||||
else
|
||||
$(error "Error:ACC_PROT_ENABLE=${ACC_PROT_ENABLE} is not supported.")
|
||||
endif
|
||||
endif
|
||||
|
||||
# Debug build
|
||||
DEBUG:=0
|
||||
|
||||
# Process DEBUG flag
|
||||
$(eval $(call assert_boolean,DEBUG))
|
||||
$(eval $(call add_define,DEBUG))
|
||||
ifeq (${DEBUG},0)
|
||||
$(eval $(call add_define,NDEBUG))
|
||||
CFLAGS += -Os
|
||||
else
|
||||
CFLAGS += -g
|
||||
endif
|
||||
|
||||
# timing measurement
|
||||
ifeq ("$(MEASURE_TIME)", "")
|
||||
MEASURE_TIME = 0
|
||||
else
|
||||
$(eval $(call add_define,MEASURE_TIME))
|
||||
# Set log level to Error, so we dont waste time with unnecessary prints
|
||||
LOG_LEVEL := 1
|
||||
SRC_FILE += \
|
||||
common/scmt_checkpoint.c \
|
||||
common/timer/scmt.c
|
||||
endif
|
||||
|
||||
ifneq ("$(BE_QUIET)", "")
|
||||
$(eval $(call add_define,BE_QUIET))
|
||||
endif
|
||||
|
||||
# Process OPTEE_LOAD_ENABLE flag
|
||||
ifeq ($(filter ${LSI},V4H V4M),${LSI})
|
||||
ifndef OPTEE_LOAD_ENABLE
|
||||
OPTEE_LOAD_ENABLE := 1
|
||||
$(eval $(call add_define,OPTEE_LOAD_ENABLE))
|
||||
else
|
||||
ifeq (${OPTEE_LOAD_ENABLE},0)
|
||||
$(eval $(call add_define,OPTEE_LOAD_ENABLE))
|
||||
else ifeq (${OPTEE_LOAD_ENABLE},1)
|
||||
$(eval $(call add_define,OPTEE_LOAD_ENABLE))
|
||||
else
|
||||
$(error "Error:OPTEE_LOAD_ENABLE=${OPTEE_LOAD_ENABLE} is not supported.")
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Process BL2_LOAD_ENABLE flag
|
||||
ifeq (${LSI},V4H)
|
||||
ifndef BL2_LOAD_ENABLE
|
||||
BL2_LOAD_ENABLE := 1
|
||||
$(eval $(call add_define,BL2_LOAD_ENABLE))
|
||||
else
|
||||
ifeq (${BL2_LOAD_ENABLE},0)
|
||||
$(eval $(call add_define,BL2_LOAD_ENABLE))
|
||||
else ifeq (${BL2_LOAD_ENABLE},1)
|
||||
$(eval $(call add_define,BL2_LOAD_ENABLE))
|
||||
else
|
||||
$(error "Error:BL2_LOAD_ENABLE=${BL2_LOAD_ENABLE} is not supported.")
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Process QNX_OS_LOAD_ENABLE flag
|
||||
ifeq (${LSI},V4H)
|
||||
ifndef QNX_OS_LOAD_ENABLE
|
||||
QNX_OS_LOAD_ENABLE := 1
|
||||
$(eval $(call add_define,QNX_OS_LOAD_ENABLE))
|
||||
else
|
||||
ifeq (${QNX_OS_LOAD_ENABLE},0)
|
||||
$(eval $(call add_define,QNX_OS_LOAD_ENABLE))
|
||||
else ifeq (${QNX_OS_LOAD_ENABLE},1)
|
||||
$(eval $(call add_define,QNX_OS_LOAD_ENABLE))
|
||||
else
|
||||
$(error "Error:QNX_OS_LOAD_ENABLE=${QNX_OS_LOAD_ENABLE} is not supported.")
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Process LOG_LEVEL
|
||||
ifndef LOG_LEVEL
|
||||
LOG_LEVEL := 2
|
||||
endif
|
||||
$(eval $(call add_define,LOG_LEVEL))
|
||||
|
||||
###################################################
|
||||
#C compiler
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
#Assembler
|
||||
AS = $(CROSS_COMPILE)as
|
||||
#Linker
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
#Liblary
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
#Object dump
|
||||
OBJDMP = $(CROSS_COMPILE)objdump
|
||||
#Object copy
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
#clean
|
||||
CL = rm -rf
|
||||
|
||||
OBJ_FILE := $(addprefix $(OBJECT_DIR)/,$(patsubst %.c,%.o,$(SRC_FILE)))
|
||||
|
||||
#Dependency File
|
||||
DEPEND_FILE = $(patsubst %.lib, ,$(OBJ_FILE:%.o=%.d))
|
||||
|
||||
CFLAGS += -ffreestanding -Wall \
|
||||
-Wmissing-include-dirs \
|
||||
-std=c99 -c \
|
||||
-D__CX_IPL__ \
|
||||
$(DEFINES)
|
||||
|
||||
LDFLAGS = --fatal-warnings -O1 -lm
|
||||
|
||||
BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
|
||||
|
||||
LIBS = -L$(subst libc.a, ,$(shell $(CC) -print-file-name=libc.a 2> /dev/null)) -lc
|
||||
LIBS += -L$(subst libgcc.a, ,$(shell $(CC) -print-libgcc-file-name 2> /dev/null)) -lgcc
|
||||
|
||||
###################################################
|
||||
# Suffixes
|
||||
.SUFFIXES : .s .c .o
|
||||
|
||||
###################################################
|
||||
# Command
|
||||
|
||||
.PHONY: all
|
||||
all: $(OBJECT_DIR) $(OUTPUT_DIR) $(OBJ_FILE_BOOT) $(OBJ_FILE) $(OUTPUT_FILE)
|
||||
|
||||
#------------------------------------------
|
||||
# Make Directory
|
||||
#------------------------------------------
|
||||
$(OBJECT_DIR):
|
||||
-mkdir -p "$(OBJECT_DIR)"
|
||||
|
||||
$(OUTPUT_DIR):
|
||||
-mkdir -p "$(OUTPUT_DIR)"
|
||||
|
||||
#------------------------------------------
|
||||
# Compile
|
||||
#------------------------------------------
|
||||
$(OBJECT_DIR)/%.o:$(BOOTDIR)/%.s
|
||||
$(V)$(AS) -g $(AS_NEON) --MD $(patsubst %.o,%.d,$@) \
|
||||
$(INCLUDE_DIR) $< -o $@ --defsym $(AArch32_64)=0
|
||||
|
||||
$(OBJECT_DIR)/%.o:%.c
|
||||
@if [ ! -e `dirname $@` ]; then mkdir -p `dirname $@`; fi
|
||||
$(V)$(CC) $(ALIGN) $(CPU) $(CC_NEON) -MMD -MP -c \
|
||||
$(INCLUDE_DIR) $< -o $@ -D$(AArch32_64)=0 $(DEFINES) $(CFLAGS)
|
||||
|
||||
#------------------------------------------
|
||||
# Linker
|
||||
#------------------------------------------
|
||||
$(OUTPUT_FILE): $(OBJ_FILE_BOOT) $(OBJ_FILE) $(MEMORY_DEF)
|
||||
@echo 'const char build_message[] = "Built : "$(BUILD_MESSAGE_TIMESTAMP);' | \
|
||||
$(CC) $(CFLAGS) -xc - -o $(OBJECT_DIR)/build_message.o
|
||||
|
||||
$(V)$(LD) $(OBJ_FILE_BOOT) $(OBJ_FILE) $(OBJECT_DIR)/build_message.o \
|
||||
-T '$(MEMORY_DEF)' \
|
||||
-o '$(OUTPUT_FILE)' \
|
||||
$(LDFLAGS) \
|
||||
-Map '$(FILE_NAME).map' \
|
||||
-static \
|
||||
$(LIBS)
|
||||
|
||||
$(V)$(OBJCOPY) -O srec --srec-forceS3 "$(OUTPUT_FILE)" "$(FILE_NAME).srec"
|
||||
$(V)$(OBJCOPY) -O binary "$(OUTPUT_FILE)" "$(FILE_NAME).bin"
|
||||
$(V)$(OBJDMP) -d -S "$(OUTPUT_FILE)" > "$(FILE_NAME)_disasm.txt"
|
||||
@chmod 644 $(FILE_NAME).*
|
||||
|
||||
ifneq ("$(V)", "")
|
||||
@echo "Build complete: $(OUTPUT_FILE)"
|
||||
@echo "Output files:"
|
||||
@echo " - $(FILE_NAME).srec"
|
||||
endif
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(CL) $(OBJECT_DIR)/* $(OUTPUT_DIR)/*
|
||||
|
||||
distclean: clean
|
||||
@$(CL) build
|
||||
|
||||
-include $(DEPEND_FILE)
|
||||
Reference in New Issue
Block a user