nxp: make file for loading additional ddr image

- NXP SoC lx2160a needs additional ddr_fip.bin.

- There are three types of ddr image that can be created:
  -- ddr_fip.mk for creating fip_ddr.bin image for normal boot.
  -- ddr_fip_sb.mk for creating fip_ddr_sec.bin image for NXP CSF based
     CoT/secure boot.
  -- ddr_fip_tbbr.mk for creating fip_ddr_sec.bin image for MBEDTLS
     CoT/secure boot.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Change-Id: I24bff8d489f72da99f64cb79b2114faa9423ce8c
This commit is contained in:
Pankaj Gupta 2020-12-09 14:02:41 +05:30
parent 87056d3193
commit 18498657f0
3 changed files with 235 additions and 0 deletions

View File

@ -0,0 +1,97 @@
#
# Copyright 2020 NXP
#
# SPDX-License-Identifier: BSD-3-Clause
#
DDR_PHY_BIN_PATH ?= ./ddr-phy-binary/lx2160a
ifeq (${DDR_IMEM_UDIMM_1D},)
DDR_IMEM_UDIMM_1D := ${DDR_PHY_BIN_PATH}/ddr4_pmu_train_imem.bin
endif
ifeq (${DDR_IMEM_UDIMM_2D},)
DDR_IMEM_UDIMM_2D := ${DDR_PHY_BIN_PATH}/ddr4_2d_pmu_train_imem.bin
endif
ifeq (${DDR_DMEM_UDIMM_1D},)
DDR_DMEM_UDIMM_1D := ${DDR_PHY_BIN_PATH}/ddr4_pmu_train_dmem.bin
endif
ifeq (${DDR_DMEM_UDIMM_2D},)
DDR_DMEM_UDIMM_2D := ${DDR_PHY_BIN_PATH}/ddr4_2d_pmu_train_dmem.bin
endif
ifeq (${DDR_IMEM_RDIMM_1D},)
DDR_IMEM_RDIMM_1D := ${DDR_PHY_BIN_PATH}/ddr4_rdimm_pmu_train_imem.bin
endif
ifeq (${DDR_IMEM_RDIMM_2D},)
DDR_IMEM_RDIMM_2D := ${DDR_PHY_BIN_PATH}/ddr4_rdimm2d_pmu_train_imem.bin
endif
ifeq (${DDR_DMEM_RDIMM_1D},)
DDR_DMEM_RDIMM_1D := ${DDR_PHY_BIN_PATH}/ddr4_rdimm_pmu_train_dmem.bin
endif
ifeq (${DDR_DMEM_RDIMM_2D},)
DDR_DMEM_RDIMM_2D := ${DDR_PHY_BIN_PATH}/ddr4_rdimm2d_pmu_train_dmem.bin
endif
$(shell mkdir -p '${BUILD_PLAT}')
ifeq (${DDR_FIP_NAME},)
ifeq (${TRUSTED_BOARD_BOOT},1)
DDR_FIP_NAME := ddr_fip_sec.bin
else
DDR_FIP_NAME := ddr_fip.bin
endif
endif
ifneq (${TRUSTED_BOARD_BOOT},1)
DDR_FIP_ARGS += --ddr-immem-udimm-1d ${DDR_IMEM_UDIMM_1D} \
--ddr-immem-udimm-2d ${DDR_IMEM_UDIMM_2D} \
--ddr-dmmem-udimm-1d ${DDR_DMEM_UDIMM_1D} \
--ddr-dmmem-udimm-2d ${DDR_DMEM_UDIMM_2D} \
--ddr-immem-rdimm-1d ${DDR_IMEM_RDIMM_1D} \
--ddr-immem-rdimm-2d ${DDR_IMEM_RDIMM_2D} \
--ddr-dmmem-rdimm-1d ${DDR_DMEM_RDIMM_1D} \
--ddr-dmmem-rdimm-2d ${DDR_DMEM_RDIMM_2D}
endif
ifeq (${TRUSTED_BOARD_BOOT},1)
ifeq (${MBEDTLS_DIR},)
include plat/nxp/soc-lx2160a/ddr_sb.mk
else
include plat/nxp/soc-lx2160a/ddr_tbbr.mk
# Variables for use with Certificate Generation Tool
CRTTOOLPATH ?= tools/cert_create
CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
ifneq (${GENERATE_COT},0)
ddr_certificates: ${DDR_CRT_DEPS} ${CRTTOOL}
${Q}${CRTTOOL} ${DDR_CRT_ARGS}
@${ECHO_BLANK_LINE}
@echo "Built $@ successfully"
@echo "DDR certificates can be found in ${BUILD_PLAT}"
@${ECHO_BLANK_LINE}
endif
endif
endif
# Variables for use with Firmware Image Package
FIPTOOLPATH ?= tools/fiptool
FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
${BUILD_PLAT}/${DDR_FIP_NAME}: ${DDR_FIP_DEPS} ${FIPTOOL}
$(eval ${CHECK_DDR_FIP_CMD})
${Q}${FIPTOOL} create ${DDR_FIP_ARGS} $@
${Q}${FIPTOOL} info $@
@${ECHO_BLANK_LINE}
@echo "Built $@ successfully"
@${ECHO_BLANK_LINE}
fip_ddr: ${BUILD_PLAT}/${DDR_FIP_NAME}

View File

@ -0,0 +1,43 @@
#
# Copyright 2021 NXP
#
# SPDX-License-Identifier: BSD-3-Clause
#
ifneq (${TRUSTED_BOARD_BOOT},0)
ifeq (${GENERATE_COT},0)
DDR_FIP_ARGS += --ddr-immem-udimm-1d ${DDR_IMEM_UDIMM_1D}.sb \
--ddr-immem-udimm-2d ${DDR_IMEM_UDIMM_2D}.sb \
--ddr-dmmem-udimm-1d ${DDR_DMEM_UDIMM_1D}.sb \
--ddr-dmmem-udimm-2d ${DDR_DMEM_UDIMM_2D}.sb \
--ddr-immem-rdimm-1d ${DDR_IMEM_RDIMM_1D}.sb \
--ddr-immem-rdimm-2d ${DDR_IMEM_RDIMM_2D}.sb \
--ddr-dmmem-rdimm-1d ${DDR_DMEM_RDIMM_1D}.sb \
--ddr-dmmem-rdimm-2d ${DDR_DMEM_RDIMM_2D}.sb
endif
UDIMM_DEPS = ${DDR_IMEM_UDIMM_1D}.sb ${DDR_IMEM_UDIMM_2D}.sb ${DDR_DMEM_UDIMM_1D}.sb ${DDR_DMEM_UDIMM_2D}.sb
RDIMM_DEPS = ${DDR_IMEM_RDIMM_1D}.sb ${DDR_IMEM_RDIMM_2D}.sb ${DDR_DMEM_RDIMM_1D}.sb ${DDR_DMEM_RDIMM_2D}.sb
DDR_FIP_DEPS += ${UDIMM_DEPS}
DDR_FIP_DEPS += ${RDIMM_DEPS}
# Max Size of CSF header (CSF_HDR_SZ = 0x3000).
# Image will be appended at this offset of the header.
# Path to CST directory is required to generate the CSF header,
# and prepend it to image before fip image gets generated
ifeq (${CST_DIR},)
$(error Error: CST_DIR not set)
endif
ifeq (${DDR_INPUT_FILE},)
DDR_INPUT_FILE:= drivers/nxp/auth/csf_hdr_parser/${CSF_FILE}
endif
%.sb: %
@echo " Generating CSF Header for $@ $<"
$(CST_DIR)/create_hdr_esbc --in $< --out $@ --app_off ${CSF_HDR_SZ} \
--app $< ${DDR_INPUT_FILE}
endif

View File

@ -0,0 +1,95 @@
#
# Copyright 2021 NXP
#
# SPDX-License-Identifier: BSD-3-Clause
#
# This file defines the keys and certificates that must be created to establish
# a Chain of Trust for the DDR FW. These definitions include the
# command line options passed to the cert_create and fiptool commands for DDR FW.
# A DDR FW key is used for signing the DDR Firmware. The DDR key is authenticated
# by the Trusted World Key. Two content certificates are created:
# For DDR RDIMM Images [ signed by DDR FW Key]
# For DDR UDIMM Images [ signed by DDR FW Key]
#
# Expected environment:
#
# BUILD_PLAT: output directory
#
# Build options added by this file:
#
# KEY_ALG
# KEY_SIZE
# TRUSTED_WORLD_KEY
# NON_TRUSTED_WORLD_KEY
#
# Copy the tbbr.mk from PLAT_TOOL_PATH/cert_create_helper
# to the ${PLAT_DIR}. So that cert_create is enabled
# to create certificates for DDR
$(shell cp ${PLAT_TOOL_PATH}/cert_create_helper/cert_create_tbbr.mk ${PLAT_DIR})
# Certificate generation tool default parameters
DDR_FW_CERT := ${BUILD_PLAT}/ddr_fw_key_cert.crt
# Default non-volatile counter values (overridable by the platform)
TFW_NVCTR_VAL ?= 0
NTFW_NVCTR_VAL ?= 0
# Pass the non-volatile counters to the cert_create tool
$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr,DDR_))
$(shell mkdir -p '${BUILD_PLAT}')
ifeq (${DDR_KEY},)
DDR_KEY=${BUILD_PLAT}/ddr.pem
endif
ifeq (${TRUSTED_KEY_CERT},)
$(info Generating: Trusted key certificate as part of DDR cert creation)
TRUSTED_KEY_CERT := ${BUILD_PLAT}/trusted_key.crt
$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert,))
$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert,,DDR_))
else
$(info Using: Trusted key certificate as part of DDR cert creation)
DDR_FIP_ARGS += --trusted-key-cert ${TRUSTED_KEY_CERT}
endif
# Add the keys to the cert_create command line options (private keys are NOT
# packed in the FIP). Developers can use their own keys by specifying the proper
# build option in the command line when building the Trusted Firmware
$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg,DDR_)))
$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size,DDR_)))
$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg,DDR_)))
$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key,DDR_)))
$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key,DDR_)))
$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key, DDR_)))
# Add the DDR CoT (key cert + img cert)
$(if ${DDR_KEY},$(eval $(call CERT_ADD_CMD_OPT,${DDR_KEY},--ddr-fw-key,DDR_)))
$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_fw_key.crt,--ddr-fw-key-cert,,DDR_))
$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_udimm_fw_content.crt,--ddr-udimm-fw-cert,,DDR_))
$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_rdimm_fw_content.crt,--ddr-rdimm-fw-cert,,DDR_))
$(eval $(call TOOL_ADD_IMG,DDR_IMEM_UDIMM_1D,--ddr-immem-udimm-1d,DDR_))
$(eval $(call TOOL_ADD_IMG,DDR_IMEM_UDIMM_2D,--ddr-immem-udimm-2d,DDR_))
$(eval $(call TOOL_ADD_IMG,DDR_DMEM_UDIMM_1D,--ddr-dmmem-udimm-1d,DDR_))
$(eval $(call TOOL_ADD_IMG,DDR_DMEM_UDIMM_2D,--ddr-dmmem-udimm-2d,DDR_))
$(eval $(call TOOL_ADD_IMG,DDR_IMEM_RDIMM_1D,--ddr-immem-rdimm-1d,DDR_))
$(eval $(call TOOL_ADD_IMG,DDR_IMEM_RDIMM_2D,--ddr-immem-rdimm-2d,DDR_))
$(eval $(call TOOL_ADD_IMG,DDR_DMEM_RDIMM_1D,--ddr-dmmem-rdimm-1d,DDR_))
$(eval $(call TOOL_ADD_IMG,DDR_DMEM_RDIMM_2D,--ddr-dmmem-rdimm-2d,DDR_))
DDR_FIP_DEPS += ddr_certificates
# Process TBB related flags
ifneq (${GENERATE_COT},0)
# Common cert_create options
ifneq (${CREATE_KEYS},0)
$(eval DDR_CRT_ARGS += -n)
ifneq (${SAVE_KEYS},0)
$(eval DDR_CRT_ARGS += -k)
endif
endif
endif