• Masahiro Yamada's avatar
    Build: support pre-tool image processing · 2da522bb
    Masahiro Yamada authored
    
    
    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, <FILTER_NAME>_RULE and <FILTER_NAME>_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------------------------
    
    <IMAGE_NAME>_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: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    2da522bb
build_macros.mk 12.8 KB