Hi everyone,
I’m currently trying to get a TPM2 chip working via SPI1 (40-pin header) on a Jetson Orin Nano board, with the specific goal of using the TPM from within the Trusted Zone with OP-TEE and the ARM Trusted Firmware. For reference, when booting an image without the dTPM component, it works fine outside of the Trusted Zone and I am able to use tpm2 commands like pcrread or pcrextend. The ultimate goal is to enable measured boot and have the ability to read PCR registers from within OP-TEE.
To enable TPM support, I’m following the guidance from the Measured Boot with dTPM PoC and used the official Driver Package (BSP) Sources as a base. I made the necessary changes to integrate the TPM module with the arm-trusted-firmware sources, including adding the TPM folder from the upstream repo, updating the YAML, Makefile, and event_log.c, and was able to successfully build the BL31 binary using the following make command:
make PLAT=tegra TARGET_SOC=t234 DEBUG=1 SPD=opteed MEASURED_BOOT=1 TRUSTED_BOARD_BOOT=1 DISCRETE_TPM=1 MBOOT_TPM_HASH_ALG=sha256 TPM_INTERFACE=FIFO_SPI EVENT_LOG_LEVEL=40
With the custom BL31, I generated a new tos-optee image using gen_tos_part_img.py and flashed the Jetson with:
./gen_tos_part_img.py \
--monitor /home/nik71841/jetpack/jp62/target/Linux_for_Tegra/source/atf_build/arm-trusted-firmware/generic-t234/tegra/t234/release/bl31.bin \
--os /home/nik71841/jetpack/jp62/target/Linux_for_Tegra/source/jetson-optee-srcs/nvidia-jetson-optee-source/optee/build/t234/core/tee-raw.bin \
--dtb /home/nik71841/jetpack/jp62/target/Linux_for_Tegra/source/jetson-optee-srcs/nvidia-jetson-optee-source/optee/tegra234-optee.dtb \
--tostype optee \
./tos.img
After flashing, during boot, I only see this message:
tpm tpm0: A TPM error (256) occurred attempting the self test
Additionally, when running tpm2_pcrread, all PCR registers are empty.
Given this behavior, I am wondering if I might be using a tegra234-optee.dtb that does not actually support the dTPM node, or if there are required changes to the device tree (or elsewhere) to properly enable or discover the dTPM for use in OP-TEE/secure world. Do I need to manually patch the DTB for dTPM support? Is there anything else I might be missing in the integration or initialization steps? I would really appreciate any advice, hints, or pointers for debugging this issue, especially since the chip itself works fine in the normal world but fails when trying to use it from the secure world.
My current tegra234-optee.dts looks like this:
/*
* SPDX-License-Identifier: BSD-2-Clause
*
* SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
*/
/dts-v1/;
/ {
#address-cells = <2>;
#size-cells = <2>;
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
tpm-event-log@0 {
compatible = "arm,tpm_event_log";
tpm_event_log_addr = <0x0 0x0>;
tpm_event_log_size = <0x0>;
};
};
efuse@3810000 {
compatible = "nvidia,tegra234-efuse";
reg = <0x0 0x3810000 0x0 0x600>;
status = "disabled";
secure-status = "okay";
};
se0@3b50000 {
compatible = "nvidia,tegra234-se0";
reg = <0x0 0x3b50000 0x0 0x30000>;
status = "disabled";
secure-status = "okay";
};
rng1@3b70000 {
compatible = "nvidia,tegra234-rng1";
reg = <0x0 0x3b70000 0x0 0x10000>;
status = "disabled";
secure-status = "okay";
};
stmm-device-mappings {
uuid = <0xed32d533 0x99e64209 0x9cc02d72 0xcdd998a7>;
description = "UEFI-mm";
device-regions {
combuart-t234 {
base-address = <0x00000000 0x0c198000>;
pages-count = <0x1>;
attributes = <0x3>;
};
qspi0-t234 {
base-address = <0x00000000 0x03270000>;
pages-count = <0x10>;
attributes = <0x3>;
};
scratch-t234 {
base-address = <0x00000000 0x0c390000>;
pages-count = <0x2>;
attributes = <0x3>;
};
};
};
spi@3210000 {
slb9670@1 {
compatible = "infineon,slb9670", "infineon,slb9672", "tis,tpm2-spi", "tcg,tpm_tis-spi";
reg = <1>;
spi-max-frequency = <32000000>;
status = "okay";
};
};
};
Thanks in advance for any help!