From: Masahiro Yamada Date: Thu, 1 Feb 2018 07:31:09 +0000 (+0900) Subject: Build: support pre-tool image processing X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=2da522bb4ec3031ff7401c33614cb347122f4a7d;p=project%2Fbcm63xx%2Fatf.git Build: support pre-tool image processing There are cases where we want to process images before they are passed to cert_create / fiptool. My main motivation is data compression. By compressing images, we can save data storage, and possibly speed up loading images. The image verification will also get faster because certificates are generated based on compressed images. Other image transformation filters (for ex. encryption), and their combinations would be possible. So, our build system should support transformation filters in a generic manner. The choice of applied filters is up to platforms (so specified in platform.mk) To define a new filter, _RULE and _SUFFIX are needed. For example, the GZIP compression filter can be implemented as follows: ------------------------>8------------------------ define GZIP_RULE $(1): $(2) @echo " GZIP $$@" $(Q)gzip -n -f -9 $$< --stdout > $$@ endef GZIP_SUFFIX := .gz ------------------------>8------------------------ The _RULE defines how to create the target $(1) from the source $(2). The _SUFFIX defines the extension appended to the processed image path. The suffix is not so important because the file name information is not propagated to FIP, but adding a sensible suffix will be good to classify the data file. Platforms can specify which filter is applied to which BL image, like this: ------------------------>8------------------------ BL32_PRE_TOOL_FILTER := GZIP BL33_PRE_TOOL_FILTER := GZIP ------------------------>8------------------------ _PRE_TOOL_FILTER specifies per-image filter. With this, different images can be transformed differently. For the case above, only BL32 and BL33 are GZIP-compressed. Nothing is done for other images. Signed-off-by: Masahiro Yamada --- diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk index ef24f1d9..7ff1e154 100644 --- a/make_helpers/build_macros.mk +++ b/make_helpers/build_macros.mk @@ -112,6 +112,33 @@ define TOOL_ADD_PAYLOAD $(if $(3),$(4)CRT_DEPS += $(3)) endef +# TOOL_ADD_IMG_PAYLOAD works like TOOL_ADD_PAYLOAD, but applies image filters +# before passing them to host tools if BL*_PRE_TOOL_FILTER is defined. +# $(1) = image_type (scp_bl2, bl33, etc.) +# $(2) = payload filepath (ex. build/fvp/release/bl31.bin) +# $(3) = command line option for the specified payload (ex. --soc-fw) +# $(4) = tool target dependency (optional) (ex. build/fvp/release/bl31.bin) +# $(5) = FIP prefix (optional) (if FWU_, target is fwu_fip instead of fip) + +define TOOL_ADD_IMG_PAYLOAD + +$(eval PRE_TOOL_FILTER := $($(call uppercase,$(1))_PRE_TOOL_FILTER)) + +ifneq ($(PRE_TOOL_FILTER),) + +$(eval PROCESSED_PATH := $(BUILD_PLAT)/$(1).bin$($(PRE_TOOL_FILTER)_SUFFIX)) + +$(call $(PRE_TOOL_FILTER)_RULE,$(PROCESSED_PATH),$(2)) + +$(PROCESSED_PATH): $(4) + +$(call TOOL_ADD_PAYLOAD,$(PROCESSED_PATH),$(3),$(PROCESSED_PATH),$(5)) + +else +$(call TOOL_ADD_PAYLOAD,$(2),$(3),$(4),$(5)) +endif +endef + # CERT_ADD_CMD_OPT adds a new command line option to the cert_create invocation # $(1) = parameter filename # $(2) = cert_create command line option for the specified parameter @@ -135,7 +162,7 @@ define TOOL_ADD_IMG $(3)CRT_DEPS += check_$(1) $(3)FIP_DEPS += check_$(1) - $(call TOOL_ADD_PAYLOAD,$(value $(_V)),$(2),,$(3)) + $(call TOOL_ADD_IMG_PAYLOAD,$(1),$(value $(_V)),$(2),,$(3)) .PHONY: check_$(1) check_$(1): @@ -300,7 +327,7 @@ bl$(1): $(BIN) $(DUMP) all: bl$(1) -$(if $(2),$(call TOOL_ADD_PAYLOAD,$(BIN),--$(2),$(BIN),$(3))) +$(if $(2),$(call TOOL_ADD_IMG_PAYLOAD,bl$(1),$(BIN),--$(2),$(BIN),$(3))) endef