Merge pull request #1104 from nmenon/dtb_build-v2
Makefile: Add ability to build dtb (v2)
This commit is contained in:
commit
842c00eb44
17
Makefile
17
Makefile
|
@ -125,6 +125,7 @@ OC := ${CROSS_COMPILE}objcopy
|
||||||
OD := ${CROSS_COMPILE}objdump
|
OD := ${CROSS_COMPILE}objdump
|
||||||
NM := ${CROSS_COMPILE}nm
|
NM := ${CROSS_COMPILE}nm
|
||||||
PP := ${CROSS_COMPILE}gcc -E
|
PP := ${CROSS_COMPILE}gcc -E
|
||||||
|
DTC ?= dtc
|
||||||
|
|
||||||
ifeq (${ARM_ARCH_MAJOR},7)
|
ifeq (${ARM_ARCH_MAJOR},7)
|
||||||
target32-directive = -target arm-none-eabi
|
target32-directive = -target arm-none-eabi
|
||||||
|
@ -163,6 +164,8 @@ TF_LDFLAGS += --fatal-warnings -O1
|
||||||
TF_LDFLAGS += --gc-sections
|
TF_LDFLAGS += --gc-sections
|
||||||
TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
|
TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
|
||||||
|
|
||||||
|
DTC_FLAGS += -I dts -O dtb
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Common sources and include directories
|
# Common sources and include directories
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -451,6 +454,10 @@ include bl31/bl31.mk
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef FDT_SOURCES
|
||||||
|
NEED_FDT := yes
|
||||||
|
endif
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Build options checks
|
# Build options checks
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -551,7 +558,7 @@ endif
|
||||||
# Build targets
|
# Build targets
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip fwu_fip certtool
|
.PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool fip fwu_fip certtool dtbs
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
|
||||||
all: msg_start
|
all: msg_start
|
||||||
|
@ -604,6 +611,13 @@ $(if ${BL2U}, ,$(eval $(call MAKE_BL,2u)))
|
||||||
$(eval $(call FWU_FIP_ADD_PAYLOAD,${BL2U_PATH},--ap-fwu-cfg))
|
$(eval $(call FWU_FIP_ADD_PAYLOAD,${BL2U_PATH},--ap-fwu-cfg))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Expand build macros for the different images
|
||||||
|
ifeq (${NEED_FDT},yes)
|
||||||
|
$(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
|
||||||
|
$(eval $(call MAKE_FDT))
|
||||||
|
dtbs: $(DTBS)
|
||||||
|
endif
|
||||||
|
|
||||||
locate-checkpatch:
|
locate-checkpatch:
|
||||||
ifndef CHECKPATCH
|
ifndef CHECKPATCH
|
||||||
$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
|
$(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
|
||||||
|
@ -731,6 +745,7 @@ help:
|
||||||
@echo " distclean Remove all build artifacts for all platforms"
|
@echo " distclean Remove all build artifacts for all platforms"
|
||||||
@echo " certtool Build the Certificate generation tool"
|
@echo " certtool Build the Certificate generation tool"
|
||||||
@echo " fiptool Build the Firmware Image Package (FIP) creation tool"
|
@echo " fiptool Build the Firmware Image Package (FIP) creation tool"
|
||||||
|
@echo " dtbs Build the Flattened device tree (if required for the platform)"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Note: most build targets require PLAT to be set to a specific platform."
|
@echo "Note: most build targets require PLAT to be set to a specific platform."
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|
|
@ -336,3 +336,49 @@ $(eval $(call MAKE_TOOL_ARGS,$(1),$(BIN),$(2)))
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
define SOURCES_TO_DTBS
|
||||||
|
$(notdir $(patsubst %.dts,%.dtb,$(filter %.dts,$(1))))
|
||||||
|
endef
|
||||||
|
|
||||||
|
# MAKE_FDT macro defines the targets and options to build each FDT binary
|
||||||
|
# Arguments: (none)
|
||||||
|
define MAKE_FDT
|
||||||
|
$(eval DTB_BUILD_DIR := ${BUILD_PLAT}/fdts)
|
||||||
|
$(eval DTBS := $(addprefix $(DTB_BUILD_DIR)/,$(call SOURCES_TO_DTBS,$(FDT_SOURCES))))
|
||||||
|
$(eval TEMP_DTB_DIRS := $(sort $(dir ${DTBS})))
|
||||||
|
# The $(dir ) function leaves a trailing / on the directory names
|
||||||
|
# Rip off the / to match directory names with make rule targets.
|
||||||
|
$(eval DTB_DIRS := $(patsubst %/,%,$(TEMP_DTB_DIRS)))
|
||||||
|
|
||||||
|
$(eval $(foreach objd,${DTB_DIRS},$(call MAKE_PREREQ_DIR,${objd},${BUILD_DIR})))
|
||||||
|
|
||||||
|
fdt_dirs: ${DTB_DIRS}
|
||||||
|
|
||||||
|
endef
|
||||||
|
|
||||||
|
# MAKE_DTB generate the Flattened device tree binary (device tree binary)
|
||||||
|
# $(1) = output directory
|
||||||
|
# $(2) = input dts
|
||||||
|
define MAKE_DTB
|
||||||
|
|
||||||
|
$(eval DOBJ := $(1)/$(patsubst %.dts,%.dtb,$(notdir $(2))))
|
||||||
|
$(eval DEP := $(patsubst %.dtb,%.d,$(DOBJ)))
|
||||||
|
|
||||||
|
$(DOBJ): $(2) | fdt_dirs
|
||||||
|
@echo " DTC $$<"
|
||||||
|
$$(Q)$$(DTC) $$(DTC_FLAGS) -d $(DEP) -o $$@ $$<
|
||||||
|
|
||||||
|
-include $(DEP)
|
||||||
|
|
||||||
|
endef
|
||||||
|
|
||||||
|
# MAKE_DTBS builds flattened device tree sources
|
||||||
|
# $(1) = output directory
|
||||||
|
# $(2) = list of flattened device tree source files
|
||||||
|
define MAKE_DTBS
|
||||||
|
$(eval DOBJS := $(filter %.dts,$(2)))
|
||||||
|
$(eval REMAIN := $(filter-out %.dts,$(2)))
|
||||||
|
$(eval $(foreach obj,$(DOBJS),$(call MAKE_DTB,$(1),$(obj))))
|
||||||
|
|
||||||
|
$(and $(REMAIN),$(error Unexpected s present: $(REMAIN)))
|
||||||
|
endef
|
||||||
|
|
Loading…
Reference in New Issue