195cfd4adSJuan Castillo# 2d51981e1SRyan Everett# Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. 395cfd4adSJuan Castillo# 482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause 595cfd4adSJuan Castillo# 695cfd4adSJuan Castillo 71a0a3f06SYatharth KocharPLAT_BL_COMMON_SOURCES += drivers/arm/pl011/${ARCH}/pl011_console.S \ 81a0a3f06SYatharth Kochar plat/arm/board/common/${ARCH}/board_arm_helpers.S 995cfd4adSJuan Castillo 10aa7877c4SAntonio Nino DiazBL1_SOURCES += drivers/cfi/v2m/v2m_flash.c 1195cfd4adSJuan Castillo 12aa7877c4SAntonio Nino DiazBL2_SOURCES += drivers/cfi/v2m/v2m_flash.c 1395cfd4adSJuan Castillo 1495cfd4adSJuan Castilloifneq (${TRUSTED_BOARD_BOOT},0) 1595302e4bSlaurenw-armARM_ROTPK_S = plat/arm/board/common/rotpk/arm_dev_rotpk.S 16d51981e1SRyan EverettARM_ROTPK = $(BUILD_PLAT)/arm_rotpk.bin 17d51981e1SRyan EverettARM_ROTPK_IS_HASH := 1 18d51981e1SRyan Everett$(eval $(call add_define_val,ARM_ROTPK,'"$(ARM_ROTPK)"')) 19b65dfe40SSandrine Bailleux 2095cfd4adSJuan Castillo# ROTPK hash location 2195cfd4adSJuan Castilloifeq (${ARM_ROTPK_LOCATION}, regs) 2295cfd4adSJuan Castillo ARM_ROTPK_LOCATION_ID = ARM_ROTPK_REGS_ID 23d51981e1SRyan Everettelse 24d51981e1SRyan Everett# The ROTPK is a development key 25d51981e1SRyan Everettifeq (${ARM_ROTPK_LOCATION}, devel_rsa) 26698e231dSMax Shvetsov CRYPTO_ALG=rsa 2795cfd4adSJuan Castillo ARM_ROTPK_LOCATION_ID = ARM_ROTPK_DEVEL_RSA_ID 28d51981e1SRyan Everett ROT_KEY ?= plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem 29a6ffddecSMax Shvetsov$(warning Development keys support for FVP is deprecated. Use `regs` \ 30a6ffddecSMax Shvetsovoption instead) 319db9c65aSQixiang Xuelse ifeq (${ARM_ROTPK_LOCATION}, devel_ecdsa) 32698e231dSMax Shvetsov CRYPTO_ALG=ec 339db9c65aSQixiang Xu ARM_ROTPK_LOCATION_ID = ARM_ROTPK_DEVEL_ECDSA_ID 34d51981e1SRyan Everett ROT_KEY ?= plat/arm/board/common/rotpk/arm_rotprivk_ecdsa.pem 35a6ffddecSMax Shvetsov$(warning Development keys support for FVP is deprecated. Use `regs` \ 36a6ffddecSMax Shvetsovoption instead) 375f899286Slaurenw-armelse ifeq (${ARM_ROTPK_LOCATION}, devel_full_dev_rsa_key) 385f899286Slaurenw-arm CRYPTO_ALG=rsa 395f899286Slaurenw-arm ARM_ROTPK_LOCATION_ID = ARM_ROTPK_DEVEL_FULL_DEV_RSA_KEY_ID 40d51981e1SRyan Everett ROT_KEY ?= plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem 41d51981e1SRyan Everett ARM_ROTPK_IS_HASH = 0 425f899286Slaurenw-arm$(warning Development keys support for FVP is deprecated. Use `regs` \ 435f899286Slaurenw-armoption instead) 44b8ae6890Slaurenw-armelse ifeq (${ARM_ROTPK_LOCATION}, devel_full_dev_ecdsa_key) 45b8ae6890Slaurenw-arm CRYPTO_ALG=ec 46b8ae6890Slaurenw-arm ARM_ROTPK_LOCATION_ID = ARM_ROTPK_DEVEL_FULL_DEV_ECDSA_KEY_ID 47d51981e1SRyan Everett ROT_KEY ?= plat/arm/board/common/rotpk/arm_rotprivk_ecdsa.pem 48d51981e1SRyan Everett ARM_ROTPK_IS_HASH = 0 49b8ae6890Slaurenw-arm$(warning Development keys support for FVP is deprecated. Use `regs` \ 50b8ae6890Slaurenw-armoption instead) 5195cfd4adSJuan Castilloelse 5295cfd4adSJuan Castillo$(error "Unsupported ARM_ROTPK_LOCATION value") 5395cfd4adSJuan Castilloendif 54d51981e1SRyan Everett$(BUILD_PLAT)/bl1/arm_dev_rotpk.o : $(ARM_ROTPK) 55d51981e1SRyan Everett$(BUILD_PLAT)/bl2/arm_dev_rotpk.o : $(ARM_ROTPK) 56d51981e1SRyan Everettendif 57a6ffddecSMax Shvetsov 5895cfd4adSJuan Castillo$(eval $(call add_define,ARM_ROTPK_LOCATION_ID)) 59d51981e1SRyan Everett$(eval $(call add_define,ARM_ROTPK_IS_HASH)) 6095cfd4adSJuan Castillo 61f2423792Slaurenw-armifeq (${ENABLE_RME}, 1) 62f2423792Slaurenw-armCOT := cca 63f2423792Slaurenw-armendif 64f2423792Slaurenw-arm 65d51981e1SRyan Everett# Force generation of the ROT public key if ROT_KEY is specified 66a6ffddecSMax Shvetsovifdef ROT_KEY 67d51981e1SRyan Everett PK_PREREQUISITES = $(ROT_KEY) FORCE 68a6ffddecSMax Shvetsovendif 69a6ffddecSMax Shvetsov 70d51981e1SRyan Everett$(ARM_ROTPK) : $(PK_PREREQUISITES) 71a6ffddecSMax Shvetsovifndef ROT_KEY 72d51981e1SRyan Everett $(error Cannot generate public key: no ROT_KEY defined) 73a6ffddecSMax Shvetsovendif 74d51981e1SRyan Everettifeq ($(ARM_ROTPK_IS_HASH), 1) 75e95abc4cSSalome Thirot ${OPENSSL_BIN_PATH}/openssl ${CRYPTO_ALG} -in $< -pubout -outform DER | \ 76d51981e1SRyan Everett ${OPENSSL_BIN_PATH}/openssl dgst -${HASH_ALG} -binary -out $@ 77d51981e1SRyan Everettelse 78d51981e1SRyan Everett ${OPENSSL_BIN_PATH}/openssl ${CRYPTO_ALG} -in $< -pubout -outform DER -out $@ 79d51981e1SRyan Everettendif 80a6ffddecSMax Shvetsov 8148279d52SJuan Castillo# Certificate NV-Counters. Use values corresponding to tied off values in 8248279d52SJuan Castillo# ARM development platforms 8348279d52SJuan CastilloTFW_NVCTR_VAL ?= 31 8448279d52SJuan CastilloNTFW_NVCTR_VAL ?= 223 8502552d45Slaurenw-arm# The CCA Non-Volatile Counter only exists on some Arm development platforms. 8602552d45Slaurenw-arm# On others, we mock it by aliasing it to the Trusted Firmware Non-Volatile counter, 8702552d45Slaurenw-arm# hence we set both counters to the same default value. 8802552d45Slaurenw-armCCAFW_NVCTR_VAL ?= 31 89b65dfe40SSandrine Bailleux 90a6ffddecSMax ShvetsovBL1_SOURCES += plat/arm/board/common/board_arm_trusted_boot.c \ 915f899286Slaurenw-arm ${ARM_ROTPK_S} 92a6ffddecSMax ShvetsovBL2_SOURCES += plat/arm/board/common/board_arm_trusted_boot.c \ 935f899286Slaurenw-arm ${ARM_ROTPK_S} 94a6ffddecSMax Shvetsov 95*da57b6e3SRyan Everettifeq ($(CRYPTO_ALG), ec) 96*da57b6e3SRyan Everettifeq ($(KEY_SIZE), 384) 97*da57b6e3SRyan EverettARM_PROT_KEY := plat/arm/board/common/protpk/arm_protprivk_ecdsa_secp384r1.pem 98*da57b6e3SRyan EverettARM_SWD_ROT_KEY := plat/arm/board/common/swd_rotpk/arm_swd_rotprivk_ecdsa_secp384r1.pem 99*da57b6e3SRyan Everettelse 100*da57b6e3SRyan EverettARM_PROT_KEY := plat/arm/board/common/protpk/arm_protprivk_ecdsa.pem 101*da57b6e3SRyan EverettARM_SWD_ROT_KEY := plat/arm/board/common/swd_rotpk/arm_swd_rotprivk_ecdsa.pem 102*da57b6e3SRyan Everettendif 103*da57b6e3SRyan Everettelse 104*da57b6e3SRyan EverettARM_PROT_KEY := plat/arm/board/common/protpk/arm_protprivk_rsa.pem 105*da57b6e3SRyan EverettARM_SWD_ROT_KEY := plat/arm/board/common/swd_rotpk/arm_swd_rotprivk_rsa.pem 106*da57b6e3SRyan Everettendif 107*da57b6e3SRyan Everett 1081035a706SSandrine Bailleux# Allows platform code to provide implementation variants depending on the 1091035a706SSandrine Bailleux# selected chain of trust. 1101035a706SSandrine Bailleux$(eval $(call add_define,ARM_COT_${COT})) 1111035a706SSandrine Bailleux 1121035a706SSandrine Bailleuxifeq (${COT},dualroot) 1131035a706SSandrine Bailleux# Platform Root of Trust key files. 114*da57b6e3SRyan EverettARM_PROTPK := $(BUILD_PLAT)/arm_protpk.bin 1151035a706SSandrine Bailleux 1161035a706SSandrine Bailleux# Provide the private key to cert_create tool. It needs it to sign the images. 1171035a706SSandrine BailleuxPROT_KEY := ${ARM_PROT_KEY} 1181035a706SSandrine Bailleux 119*da57b6e3SRyan Everett$(eval $(call add_define_val,ARM_PROTPK,'"$(ARM_PROTPK)"')) 1201035a706SSandrine Bailleux 1211035a706SSandrine BailleuxBL1_SOURCES += plat/arm/board/common/protpk/arm_dev_protpk.S 1221035a706SSandrine BailleuxBL2_SOURCES += plat/arm/board/common/protpk/arm_dev_protpk.S 1231035a706SSandrine Bailleux 124*da57b6e3SRyan Everett$(BUILD_PLAT)/bl1/arm_dev_protpk.o: $(ARM_PROTPK) 125*da57b6e3SRyan Everett$(BUILD_PLAT)/bl2/arm_dev_protpk.o: $(ARM_PROTPK) 1261035a706SSandrine Bailleuxendif 1271035a706SSandrine Bailleux 128f2423792Slaurenw-armifeq (${COT},cca) 129f2423792Slaurenw-arm# Platform and Secure World Root of Trust key files. 130*da57b6e3SRyan EverettARM_PROTPK := $(BUILD_PLAT)/arm_protpk.bin 131*da57b6e3SRyan EverettARM_SWD_ROTPK := $(BUILD_PLAT)/arm_swd_rotpk.bin 132f2423792Slaurenw-arm 133f2423792Slaurenw-arm# Provide the private keys to cert_create tool. It needs them to sign the images. 134f2423792Slaurenw-armPROT_KEY := ${ARM_PROT_KEY} 135f2423792Slaurenw-armSWD_ROT_KEY := ${ARM_SWD_ROT_KEY} 136f2423792Slaurenw-arm 137*da57b6e3SRyan Everett$(eval $(call add_define_val,ARM_PROTPK,'"$(ARM_PROTPK)"')) 138*da57b6e3SRyan Everett$(eval $(call add_define_val,ARM_SWD_ROTPK,'"$(ARM_SWD_ROTPK)"')) 139f2423792Slaurenw-arm 140f2423792Slaurenw-armBL1_SOURCES += plat/arm/board/common/protpk/arm_dev_protpk.S \ 141f2423792Slaurenw-arm plat/arm/board/common/swd_rotpk/arm_dev_swd_rotpk.S 142f2423792Slaurenw-armBL2_SOURCES += plat/arm/board/common/protpk/arm_dev_protpk.S \ 143f2423792Slaurenw-arm plat/arm/board/common/swd_rotpk/arm_dev_swd_rotpk.S 144f2423792Slaurenw-arm 145*da57b6e3SRyan Everett$(BUILD_PLAT)/bl1/arm_dev_protpk.o: $(ARM_PROTPK) 146*da57b6e3SRyan Everett$(BUILD_PLAT)/bl1/arm_dev_swd_rotpk.o: $(ARM_SWD_ROTPK) 147*da57b6e3SRyan Everett$(BUILD_PLAT)/bl2/arm_dev_protpk.o: $(ARM_PROTPK) 148*da57b6e3SRyan Everett$(BUILD_PLAT)/bl2/arm_dev_swd_rotpk.o: $(ARM_SWD_ROTPK) 149f2423792Slaurenw-armendif 150f2423792Slaurenw-arm 151*da57b6e3SRyan Everett$(ARM_PROTPK): $(ARM_PROT_KEY) 152*da57b6e3SRyan Everettifndef ARM_PROT_KEY 153*da57b6e3SRyan Everett $(error Cannot generate hash: no PROT_KEY defined) 154*da57b6e3SRyan Everettendif 155*da57b6e3SRyan Everett ${OPENSSL_BIN_PATH}/openssl ${CRYPTO_ALG} -in ${ARM_PROT_KEY} -pubout -outform DER | \ 156*da57b6e3SRyan Everett ${OPENSSL_BIN_PATH}/openssl dgst -${HASH_ALG} -binary -out $@ 157*da57b6e3SRyan Everett 158*da57b6e3SRyan Everett$(ARM_SWD_ROTPK): $(ARM_SWD_ROT_KEY) 159*da57b6e3SRyan Everettifndef ARM_SWD_ROT_KEY 160*da57b6e3SRyan Everett $(error Cannot generate hash: no SWD_KEY defined) 161*da57b6e3SRyan Everettendif 162*da57b6e3SRyan Everett ${OPENSSL_BIN_PATH}/openssl ${CRYPTO_ALG} -in ${ARM_SWD_ROT_KEY} -pubout -outform DER | \ 163*da57b6e3SRyan Everett ${OPENSSL_BIN_PATH}/openssl dgst -${HASH_ALG} -binary -out $@ 16495cfd4adSJuan Castilloendif 165