xref: /rk3399_ARM-atf/plat/nxp/soc-lx2160a/ddr_tbbr.mk (revision 18498657f05b66e915a57496974f2a60f0ef02a2)
1*18498657SPankaj Gupta#
2*18498657SPankaj Gupta# Copyright 2021 NXP
3*18498657SPankaj Gupta#
4*18498657SPankaj Gupta# SPDX-License-Identifier: BSD-3-Clause
5*18498657SPankaj Gupta#
6*18498657SPankaj Gupta
7*18498657SPankaj Gupta# This file defines the keys and certificates that must be created to establish
8*18498657SPankaj Gupta# a Chain of Trust for the DDR FW. These definitions include the
9*18498657SPankaj Gupta# command line options passed to the cert_create and fiptool commands for DDR FW.
10*18498657SPankaj Gupta# A DDR FW key is used for signing the DDR Firmware. The DDR key is authenticated
11*18498657SPankaj Gupta# by the Trusted World Key. Two content certificates are created:
12*18498657SPankaj Gupta# For DDR RDIMM Images [ signed by DDR FW Key]
13*18498657SPankaj Gupta# For DDR UDIMM Images [ signed by DDR FW Key]
14*18498657SPankaj Gupta#
15*18498657SPankaj Gupta# Expected environment:
16*18498657SPankaj Gupta#
17*18498657SPankaj Gupta#   BUILD_PLAT: output directory
18*18498657SPankaj Gupta#
19*18498657SPankaj Gupta# Build options added by this file:
20*18498657SPankaj Gupta#
21*18498657SPankaj Gupta#   KEY_ALG
22*18498657SPankaj Gupta#   KEY_SIZE
23*18498657SPankaj Gupta#   TRUSTED_WORLD_KEY
24*18498657SPankaj Gupta#   NON_TRUSTED_WORLD_KEY
25*18498657SPankaj Gupta#
26*18498657SPankaj Gupta
27*18498657SPankaj Gupta# Copy the tbbr.mk from PLAT_TOOL_PATH/cert_create_helper
28*18498657SPankaj Gupta# to the ${PLAT_DIR}. So that cert_create is enabled
29*18498657SPankaj Gupta# to create certificates for DDR
30*18498657SPankaj Gupta$(shell cp ${PLAT_TOOL_PATH}/cert_create_helper/cert_create_tbbr.mk ${PLAT_DIR})
31*18498657SPankaj Gupta
32*18498657SPankaj Gupta# Certificate generation tool default parameters
33*18498657SPankaj GuptaDDR_FW_CERT		:=	${BUILD_PLAT}/ddr_fw_key_cert.crt
34*18498657SPankaj Gupta
35*18498657SPankaj Gupta# Default non-volatile counter values (overridable by the platform)
36*18498657SPankaj GuptaTFW_NVCTR_VAL		?=	0
37*18498657SPankaj GuptaNTFW_NVCTR_VAL		?=	0
38*18498657SPankaj Gupta
39*18498657SPankaj Gupta# Pass the non-volatile counters to the cert_create tool
40*18498657SPankaj Gupta$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr,DDR_))
41*18498657SPankaj Gupta
42*18498657SPankaj Gupta$(shell mkdir -p '${BUILD_PLAT}')
43*18498657SPankaj Gupta
44*18498657SPankaj Guptaifeq (${DDR_KEY},)
45*18498657SPankaj GuptaDDR_KEY=${BUILD_PLAT}/ddr.pem
46*18498657SPankaj Guptaendif
47*18498657SPankaj Gupta
48*18498657SPankaj Guptaifeq (${TRUSTED_KEY_CERT},)
49*18498657SPankaj Gupta$(info Generating: Trusted key certificate as part of DDR cert creation)
50*18498657SPankaj GuptaTRUSTED_KEY_CERT	:=	${BUILD_PLAT}/trusted_key.crt
51*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert,))
52*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert,,DDR_))
53*18498657SPankaj Guptaelse
54*18498657SPankaj Gupta$(info Using: Trusted key certificate as part of DDR cert creation)
55*18498657SPankaj GuptaDDR_FIP_ARGS += --trusted-key-cert ${TRUSTED_KEY_CERT}
56*18498657SPankaj Guptaendif
57*18498657SPankaj Gupta
58*18498657SPankaj Gupta# Add the keys to the cert_create command line options (private keys are NOT
59*18498657SPankaj Gupta# packed in the FIP). Developers can use their own keys by specifying the proper
60*18498657SPankaj Gupta# build option in the command line when building the Trusted Firmware
61*18498657SPankaj Gupta$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg,DDR_)))
62*18498657SPankaj Gupta$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size,DDR_)))
63*18498657SPankaj Gupta$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg,DDR_)))
64*18498657SPankaj Gupta$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key,DDR_)))
65*18498657SPankaj Gupta$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key,DDR_)))
66*18498657SPankaj Gupta$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key, DDR_)))
67*18498657SPankaj Gupta
68*18498657SPankaj Gupta# Add the DDR CoT (key cert + img cert)
69*18498657SPankaj Gupta$(if ${DDR_KEY},$(eval $(call CERT_ADD_CMD_OPT,${DDR_KEY},--ddr-fw-key,DDR_)))
70*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_fw_key.crt,--ddr-fw-key-cert,,DDR_))
71*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_udimm_fw_content.crt,--ddr-udimm-fw-cert,,DDR_))
72*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_rdimm_fw_content.crt,--ddr-rdimm-fw-cert,,DDR_))
73*18498657SPankaj Gupta
74*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_IMEM_UDIMM_1D,--ddr-immem-udimm-1d,DDR_))
75*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_IMEM_UDIMM_2D,--ddr-immem-udimm-2d,DDR_))
76*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_DMEM_UDIMM_1D,--ddr-dmmem-udimm-1d,DDR_))
77*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_DMEM_UDIMM_2D,--ddr-dmmem-udimm-2d,DDR_))
78*18498657SPankaj Gupta
79*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_IMEM_RDIMM_1D,--ddr-immem-rdimm-1d,DDR_))
80*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_IMEM_RDIMM_2D,--ddr-immem-rdimm-2d,DDR_))
81*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_DMEM_RDIMM_1D,--ddr-dmmem-rdimm-1d,DDR_))
82*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_DMEM_RDIMM_2D,--ddr-dmmem-rdimm-2d,DDR_))
83*18498657SPankaj Gupta
84*18498657SPankaj GuptaDDR_FIP_DEPS += ddr_certificates
85*18498657SPankaj Gupta
86*18498657SPankaj Gupta# Process TBB related flags
87*18498657SPankaj Guptaifneq (${GENERATE_COT},0)
88*18498657SPankaj Gupta        # Common cert_create options
89*18498657SPankaj Gupta        ifneq (${CREATE_KEYS},0)
90*18498657SPankaj Gupta                $(eval DDR_CRT_ARGS += -n)
91*18498657SPankaj Gupta                ifneq (${SAVE_KEYS},0)
92*18498657SPankaj Gupta                       $(eval DDR_CRT_ARGS += -k)
93*18498657SPankaj Gupta                endif
94*18498657SPankaj Gupta        endif
95*18498657SPankaj Guptaendif
96