xref: /rk3399_ARM-atf/make_helpers/tbbr/tbbr_tools.mk (revision 82cb2c1ad9897473743f08437d0a3995bed561b9)
173c99d4eSJuan Castillo#
273c99d4eSJuan Castillo# Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
373c99d4eSJuan Castillo#
4*82cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause
573c99d4eSJuan Castillo#
673c99d4eSJuan Castillo
773c99d4eSJuan Castillo# This file defines the keys and certificates that must be created to establish
873c99d4eSJuan Castillo# a Chain of Trust following the TBBR document. These definitions include the
9819281eeSdp-arm# command line options passed to the cert_create and fiptool commands.
1073c99d4eSJuan Castillo#
1173c99d4eSJuan Castillo# Expected environment:
1273c99d4eSJuan Castillo#
1373c99d4eSJuan Castillo#   BUILD_PLAT: output directory
14d178637dSJuan Castillo#   NEED_BL32: indicates whether BL32 is needed by the platform
1573c99d4eSJuan Castillo#   BL2: image filename (optional). Default is IMG_BIN(2) (see macro IMG_BIN)
16f59821d5SJuan Castillo#   SCP_BL2: image filename (optional). Default is IMG_BIN(30)
1773c99d4eSJuan Castillo#   BL31: image filename (optional). Default is IMG_BIN(31)
1873c99d4eSJuan Castillo#   BL32: image filename (optional). Default is IMG_BIN(32)
1973c99d4eSJuan Castillo#   BL33: image filename (optional). Default is IMG_BIN(33)
2073c99d4eSJuan Castillo#
2173c99d4eSJuan Castillo# Build options added by this file:
2273c99d4eSJuan Castillo#
2373c99d4eSJuan Castillo#   KEY_ALG
2473c99d4eSJuan Castillo#   ROT_KEY
2573c99d4eSJuan Castillo#   TRUSTED_WORLD_KEY
2673c99d4eSJuan Castillo#   NON_TRUSTED_WORLD_KEY
27f59821d5SJuan Castillo#   SCP_BL2_KEY
2873c99d4eSJuan Castillo#   BL31_KEY
2973c99d4eSJuan Castillo#   BL32_KEY
3073c99d4eSJuan Castillo#   BL33_KEY
3173c99d4eSJuan Castillo#
3273c99d4eSJuan Castillo
3373c99d4eSJuan Castillo# Certificate generation tool default parameters
3473c99d4eSJuan CastilloTRUSTED_KEY_CERT	:=	${BUILD_PLAT}/trusted_key.crt
350191262dSYatharth KocharFWU_CERT		:=	${BUILD_PLAT}/fwu_cert.crt
3673c99d4eSJuan Castillo
3796103d5aSJuan Castillo# Default non-volatile counter values (overridable by the platform)
3896103d5aSJuan CastilloTFW_NVCTR_VAL		?=	0
3996103d5aSJuan CastilloNTFW_NVCTR_VAL		?=	0
4096103d5aSJuan Castillo
4196103d5aSJuan Castillo# Pass the non-volatile counters to the cert_create tool
4296103d5aSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr))
4396103d5aSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${NTFW_NVCTR_VAL},--ntfw-nvctr))
4496103d5aSJuan Castillo
45819281eeSdp-arm# Add Trusted Key certificate to the fiptool and cert_create command line options
4673c99d4eSJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert))
4773c99d4eSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_KEY_CERT},--trusted-key-cert))
4873c99d4eSJuan Castillo
49819281eeSdp-arm# Add fwu certificate to the fiptool and cert_create command line options
500191262dSYatharth Kochar$(eval $(call FWU_FIP_ADD_PAYLOAD,${FWU_CERT},--fwu-cert))
510191262dSYatharth Kochar$(eval $(call FWU_CERT_ADD_CMD_OPT,${FWU_CERT},--fwu-cert))
520191262dSYatharth Kochar
5373c99d4eSJuan Castillo# Add the keys to the cert_create command line options (private keys are NOT
5473c99d4eSJuan Castillo# packed in the FIP). Developers can use their own keys by specifying the proper
5573c99d4eSJuan Castillo# build option in the command line when building the Trusted Firmware
5673c99d4eSJuan Castillo$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg)))
5773c99d4eSJuan Castillo$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key)))
580191262dSYatharth Kochar$(if ${ROT_KEY},$(eval $(call FWU_CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key)))
5973c99d4eSJuan Castillo$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key)))
6073c99d4eSJuan Castillo$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key)))
6173c99d4eSJuan Castillo
6273c99d4eSJuan Castillo# Add the BL2 CoT (image cert + image)
63516beb58SJuan Castillo$(if ${BL2},$(eval $(call CERT_ADD_CMD_OPT,${BL2},--tb-fw,true)),\
64516beb58SJuan Castillo            $(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,2),--tb-fw,true)))
65516beb58SJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert))
66516beb58SJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert))
6773c99d4eSJuan Castillo
68f59821d5SJuan Castillo# Add the SCP_BL2 CoT (key cert + img cert + image)
69f59821d5SJuan Castilloifneq (${SCP_BL2},)
70f59821d5SJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${SCP_BL2},--scp-fw,true))
71f59821d5SJuan Castillo    $(if ${SCP_BL2_KEY},$(eval $(call CERT_ADD_CMD_OPT,${SCP_BL2_KEY},--scp-fw-key)))
72516beb58SJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/scp_fw_content.crt,--scp-fw-cert))
73516beb58SJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/scp_fw_key.crt,--scp-fw-key-cert))
74516beb58SJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_content.crt,--scp-fw-cert))
75516beb58SJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_key.crt,--scp-fw-key-cert))
7673c99d4eSJuan Castilloendif
7773c99d4eSJuan Castillo
7873c99d4eSJuan Castillo# Add the BL31 CoT (key cert + img cert + image)
79516beb58SJuan Castillo$(if ${BL31},$(eval $(call CERT_ADD_CMD_OPT,${BL31},--soc-fw,true)),\
80516beb58SJuan Castillo             $(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,31),--soc-fw,true)))
81516beb58SJuan Castillo$(if ${BL31_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL31_KEY},--soc-fw-key)))
82516beb58SJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/soc_fw_content.crt,--soc-fw-cert))
83516beb58SJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/soc_fw_key.crt,--soc-fw-key-cert))
84516beb58SJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_content.crt,--soc-fw-cert))
85516beb58SJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_key.crt,--soc-fw-key-cert))
8673c99d4eSJuan Castillo
8773c99d4eSJuan Castillo# Add the BL32 CoT (key cert + img cert + image)
8873c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
89516beb58SJuan Castillo    $(if ${BL32},$(eval $(call CERT_ADD_CMD_OPT,${BL32},--tos-fw,true)),\
90516beb58SJuan Castillo                 $(if ${BL32_SOURCES},$(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,32),--tos-fw,true))))
91516beb58SJuan Castillo    $(if ${BL32_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL32_KEY},--tos-fw-key)))
92516beb58SJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/tos_fw_content.crt,--tos-fw-cert))
93516beb58SJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/tos_fw_key.crt,--tos-fw-key-cert))
94516beb58SJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_content.crt,--tos-fw-cert))
95516beb58SJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_key.crt,--tos-fw-key-cert))
9673c99d4eSJuan Castilloendif
9773c99d4eSJuan Castillo
9873c99d4eSJuan Castillo# Add the BL33 CoT (key cert + img cert + image)
9973c99d4eSJuan Castilloifneq (${BL33},)
100516beb58SJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BL33},--nt-fw,true))
101516beb58SJuan Castillo    $(if ${BL33_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL33_KEY},--nt-fw-key)))
102516beb58SJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/nt_fw_content.crt,--nt-fw-cert))
103516beb58SJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/nt_fw_key.crt,--nt-fw-key-cert))
104516beb58SJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_content.crt,--nt-fw-cert))
105516beb58SJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_key.crt,--nt-fw-key-cert))
10673c99d4eSJuan Castilloendif
1079003fa0bSYatharth Kochar
1089003fa0bSYatharth Kochar# Add the BL2U image
109516beb58SJuan Castillo$(if ${BL2U},$(eval $(call FWU_CERT_ADD_CMD_OPT,${BL2U},--ap-fwu-cfg,true)),\
110516beb58SJuan Castillo     $(eval $(call FWU_CERT_ADD_CMD_OPT,$(call IMG_BIN,2u),--ap-fwu-cfg,true)))
1110191262dSYatharth Kochar
1120191262dSYatharth Kochar# Add the SCP_BL2U image
1130191262dSYatharth Kocharifneq (${SCP_BL2U},)
114516beb58SJuan Castillo    $(eval $(call FWU_CERT_ADD_CMD_OPT,${SCP_BL2U},--scp-fwu-cfg,true))
1150191262dSYatharth Kocharendif
1160191262dSYatharth Kochar
1170191262dSYatharth Kochar# Add the NS_BL2U image
1180191262dSYatharth Kocharifneq (${NS_BL2U},)
119516beb58SJuan Castillo    $(eval $(call FWU_CERT_ADD_CMD_OPT,${NS_BL2U},--fwu,true))
1209003fa0bSYatharth Kocharendif
121