So, I’m trying to install a Letstrust TPM Module on the Jetson Nano Development kit with an ao2 chip.
I’m not an electrical engineer and am working the first time with spi, device trees and gpio pins.
I connected the tpm with the pins 17-26 (Schema) and am powering the nano with via the micro usb port.
Using the Jetson Hacks buildKernelAndModule scripts, I modified the kernel to edit the config using this script
#!/bin/bash
SOURCE_TARGET="/usr/src/"
KERNEL_RELEASE=$( uname -r | cut -d. -f1-2)
KERNEL_URI=$SOURCE_TARGET"kernel/kernel-"$KERNEL_RELEASE
if [ ! -d "$KERNEL_URI" ] ; then
echo "Cannot find kernel source in $SOURCE_TARGET."
echo "You will need to install the kernel source before proceeding."
exit 1
fi
cd "$KERNEL_URI"
sudo bash scripts/config --file .config \
--set-val CONFIG_HW_RANDOM_TPM m \
--set-val CONFIG_TCG_TPM m \
--set-val CONFIG_TCG_TIS_CORE m \
--set-val CONFIG_TCG_TIS_SPI m \
--set-val CONFIG_SECURITYFS y
echo "Config edit complete"
Build the kernel
./makeKernel.sh
Build the required modules
./makeModules.sh
and applied the new Image
./copyImage.sh
and rebooted the nano
Using
cat /proc/config.gz | gunzip | grep TCG
CONFIG_TCG_TPM=m
CONFIG_TCG_TIS_CORE=m
CONFIG_TCG_TIS_SPI=m
and
cat /proc/config.gz | gunzip | grep TPM
CONFIG_HW_RANDOM_TPM=m
CONFIG_TCG_TPM=m
I was able to verify that the config has been applied.
I also added the modules to /etc/modules
so they can load at boot time
tpm-rng
tpm_tis_spi
tpm_tis_core
tpm
I already dug through countless forum topics of people who are trying to achieve something similar, and scrambled this dts file together
/dts-v1/;
/plugin/;
#include <dt-bindings/pinctrl/pinctrl-tegra.h>
#include <dt-bindings/gpio/tegra-gpio.h>
/ {
compatible = "nvidia,p3449-0000-a02+p3448-0000-a02", "nvidia,jetson-nano", "nvidia,tegra210";
overlay-name = "Letstrust TPM2 slb9670";
jetson-header-name = "Jetson 40pin Header";
fragment@0 {
target-path = "/spi@7000d400";
__overlay__ {
status = "okay";
#address-cells = <0x1>;
#size-cells = <0x0>;
cs-gpios = <&gpio TEGRA_GPIO(C, 4) GPIO_ACTIVE_LOW>;
gpio-sck = <&gpio TEGRA_GPIO(C, 2) GPIO_ACTIVE_HIGH>;
gpio-mosi = <&gpio TEGRA_GPIO(C, 0) GPIO_ACTIVE_HIGH>;
gpio-miso = <&gpio TEGRA_GPIO(C, 1) GPIO_ACTIVE_HIGH>;
sck-gpios = <&gpio TEGRA_GPIO(C, 2) GPIO_ACTIVE_HIGH>;
mosi-gpios = <&gpio TEGRA_GPIO(C, 0) GPIO_ACTIVE_HIGH>;
miso-gpios = <&gpio TEGRA_GPIO(C, 1) GPIO_ACTIVE_HIGH>;
num-chipselect = <1>;
spi@0 {
status = "disabled";
};
spi@1 {
status = "disabled";
};
slb9670: slb9670@0 {
status = "okay";
compatible = "infineon,slb9670", "tis,tpm2-spi", "tcg,tpm_tis-spi";
reg = <1>;
spi-max-frequency = <32000000>;
#address-cells = <1>;
#size-cells = <0>;
gpio-reset = <&gpio TEGRA_GPIO(C, 7) GPIO_ACTIVE_LOW>;
controller-data {
/* nvidia,enable-hw-based-cs; */
nvidia,variable-length-transfer;
nvidia,rx-clk-tap-delay = <7>;
};
};
};
};
fragment@1 {
target-path = "/";
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <0x1>;
exp-header-pinmux {
linux,phandle = <0x1>;
phandle = <0x1>;
hdr40-pin19 {
nvidia,pins = "spi1_mosi_pc0";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
};
hdr40-pin21 {
nvidia,pins = "spi1_miso_pc1";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_ENABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
};
hdr40-pin23 {
nvidia,pins = "spi1_sck_pc2";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
};
hdr40-pin24 {
nvidia,pins = "spi1_cs0_pc3";
nvidia,function = "spi1";
vidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
};
hdr40-pin26 {
nvidia,pins = "spi1_cs1_pc4";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
};
};
};
};
};
To compile the file, I created this Makefile
COMPILE_DTS_TARGET:="letstrust-tpm-overlay.dts"
COMPILE_DTS_OUTPUT:="/boot/slb9670-overlay.dtbo"
decompile-user-custom:
dtc -I dtb -O dts /boot/*user-custom.dtb -o user-custom.dts.decompiled
decompile-overlay:
dtc -I dtb -O dts $(COMPILE_DTS_OUTPUT) -o $(COMPILE_DTS_TARGET).decompiled
preprocess:
cpp -nostdinc -I include -I arch -undef -x assembler-with-cpp ${COMPILE_DTS_TARGET} ${COMPILE_DTS_TARGET}.preprocessed
dtb: preprocess
sudo dtc -O dtb -o ${COMPILE_DTS_OUTPUT} -@ ${COMPILE_DTS_TARGET}.preprocessed
list-devices:
sudo /opt/nvidia/jetson-io/config-by-hardware.py -l
apply:
sudo /opt/nvidia/jetson-io/config-by-hardware.py -n "Letstrust TPM2 slb9670"
cleanup:
echo "Removing tmp files"
rm *.preprocessed
all: dtb cleanup apply
As you can see, I’m using the /opt/nvidia/jetson-io/configure-by-hardware.py
script to apply my dts overlay. After rebooting my device is available under /proc/device-tree/spi@7000d400/slb9670@0/
However, the tpm device is not being detected. It is not available under /dev/tpm0
and
dmesg | grep -i tpm
returns nothing
dmesg | grep -i spi
[ 0.441419] iommu: Adding device 7000d400.spi to group 7
[ 0.441679] iommu: Adding device 7000d600.spi to group 8
[ 0.441953] iommu: Adding device 70410000.spi to group 9
[ 1.187799] tegra-qspi 70410000.spi: Prod settings list not found
[ 1.189179] qspi_mtd spi32766.0: MX25U3235F (4096 Kbytes)
[ 1.189189] qspi_mtd spi32766.0: mtd .name = spi32766.0, .size = 0x400000 (4MiB) .erasesize = 0x00001000 (4KiB) .numeraseregions = 0
cat /proc/interrupts | grep spi
66: 204 0 0 0 LIC 59 Level 7000d400.spi
67: 0 0 0 0 LIC 82 Level 7000d600.spi
68: 45238 0 0 0 LIC 10 Level 70410000.spi
Looking into /var/log/syslog
is also not very informative.
I don’t have access to an oscilloscope so checking the currents is also not possible for me.
I have already studied those forum posts for hours, but sadly the OP’s haven’t posted what they have changed to make their systems work. The “solution” of those posts are only linking to the 40 pin usage considerations but I only understand a third of it and don’t know how this is supposed to help me:
I’m also unsure about some of the setting ins my spi file:
/* what is there purpose? */
nvidia,enable-hw-based-cs;
nvidia,variable-length-transfer;
nvidia,rx-clk-tap-delay = </*how do i know which value I need? */>;
Where can I look up what they do? If I google them, I only get forum posts using them without any further elaboration on what they do