aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2019-01-18 15:49:37 +0900
committerAnup Patel <anup@brainfault.org>2019-01-21 09:58:33 +0530
commit0df82694776d4497ca3bcfb662a68fd817698e89 (patch)
treea0524cf1d8c2df483adb241c53bb3885c2503230 /Makefile
parentf4373731e386a3b410f3e8acf6620111fb339abc (diff)
downloadopensbi-0df82694776d4497ca3bcfb662a68fd817698e89.zip
opensbi-0df82694776d4497ca3bcfb662a68fd817698e89.tar.gz
opensbi-0df82694776d4497ca3bcfb662a68fd817698e89.tar.bz2
Makefile: Add support for device tree compilation
Add rules to compile dts files into dtb files using the device tree compiler (dtc). A platform can specify the DTS file to compile using the platform-dtb-y variable. The flattened device tree binary file to be used for building the final polatform firmware can be specified using the new FW_PAYLOAD_FDT firmware configuration option to point to the automatically compiled FDT file. Using the existing FW_PAYLOAD_FDT_PATH configuration option is still possible and will take precedence over the FW_PAYLOAD_FDT definition. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile11
1 files changed, 11 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 11e1634..6ff0b2c 100644
--- a/Makefile
+++ b/Makefile
@@ -79,6 +79,7 @@ include $(firmware-object-mks)
lib-objs-path-y=$(foreach obj,$(lib-objs-y),$(build_dir)/lib/$(obj))
ifdef PLATFORM
platform-objs-path-y=$(foreach obj,$(platform-objs-y),$(build_dir)/$(platform_subdir)/$(obj))
+platform-dtb-path-y=$(foreach obj,$(platform-dtb-y),$(build_dir)/$(platform_subdir)/$(obj))
platform-common-objs-path-y=$(foreach obj,$(platform-common-objs-y),$(build_dir)/platform/common/$(obj))
firmware-bins-path-y=$(foreach bin,$(firmware-bins-y),$(build_dir)/$(platform_subdir)/firmware/$(bin))
endif
@@ -154,6 +155,9 @@ else
OBJCOPY ?= objcopy
endif
+DTC = dtc
+DTCFLAGS = -O dtb
+
# Setup functions for compilation
define dynamic_flags
-I$(shell dirname $(2)) -D__OBJNAME__=$(subst -,_,$(shell basename $(1) .o))
@@ -212,10 +216,14 @@ compile_ar = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
compile_objcopy = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
echo " OBJCOPY $(subst $(build_dir)/,,$(1))"; \
$(OBJCOPY) -S -O binary $(2) $(1)
+compile_dts = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
+ echo " DTC $(subst $(build_dir)/,,$(1))"; \
+ $(DTC) $(DTCFLAGS) -o $(1) $(2)
targets-y = $(build_dir)/lib/libsbi.a
ifdef PLATFORM
targets-y += $(build_dir)/$(platform_subdir)/lib/libplatsbi.a
+targets-y += $(platform-dtb-path-y)
endif
targets-y += $(firmware-bins-path-y)
@@ -265,6 +273,9 @@ $(build_dir)/$(platform_subdir)/%.dep: $(src_dir)/%.S
$(build_dir)/$(platform_subdir)/%.o: $(src_dir)/%.S
$(call compile_as,$@,$<)
+$(build_dir)/%.dtb: $(src_dir)/%.dts
+ $(call compile_dts,$@,$<)
+
# Rule for "make docs"
$(build_dir)/docs/latex/refman.pdf: $(build_dir)/docs/latex/refman.tex
$(CMD_PREFIX)mkdir -p $(build_dir)/docs