User avatar
syedelec
Posts: 9
Joined: Thu Nov 03, 2022 9:37 am

Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot [SOLVED]

Thu Feb 02, 2023 9:48 am

Hi

I would like to enable the ST33 TPM on the Raspberry Pi 4B for U-Boot: https://www.st.com/en/evaluation-tools/stpm4raspi.html

I have enabled the following options as described in my last post: viewtopic.php?t=342421
Now the TPM is recognized and is working well in linux userspace.

Regarding u-boot, I enabled the following options:

Code: Select all

CONFIG_CMD_TPM=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_SOFT_SPI=y
# CONFIG_TPM_V1 is not set
CONFIG_TPM2_TIS_SPI=y
CONFIG_TPM=y
I have the following error:

Code: Select all

U-Boot> tpm2 init
Couldn't set TPM 0 (rc = 1)
I suppose the device tree needs to be updated but I am not sure where can I find documentation regarding this.

Thanks

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4954
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Thu Feb 02, 2023 10:05 am

Have you read through this guide? https://github.com/joholl/rpi4-uboot-tpm

User avatar
syedelec
Posts: 9
Joined: Thu Nov 03, 2022 9:37 am

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Thu Feb 02, 2023 6:32 pm

PhilE wrote:
Thu Feb 02, 2023 10:05 am
Have you read through this guide? https://github.com/joholl/rpi4-uboot-tpm
Thanks.
Yes, I went through that guide however it's not the same TPM so I am not sure about the pins/gpios used in the device tree.

The STPM4RasPI is an official extension board to connect the ST33 TPM products to the Raspberry Pi, I was expecting to find a specific documentation on it.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4954
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Thu Feb 02, 2023 7:30 pm

It's not one of our products. Have you asked the manufacturer?

User avatar
syedelec
Posts: 9
Joined: Thu Nov 03, 2022 9:37 am

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Tue Feb 07, 2023 2:57 pm

Here is the working device tree for U-Boot and Kernel.

Code: Select all

/*
 * Device Tree overlay for the STPM4RasPI Trusted Platform Module hat
 */

/dts-v1/;
/plugin/;

/ {
	fragment@0 {
		target = <&spidev0>;
		__overlay__ {
			status = "disabled";
		};
	};

	fragment@1 {
		target = <&spi0>;
		__overlay__ {
			compatible = "spi-gpio";
			gpio-sck = <&gpio 11 0>;
			gpio-mosi = <&gpio 10 0>;
			gpio-miso = <&gpio 9 0>;
			cs-gpios = <&gpio 8 1>;
			spi-delay-us = <0>;
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";
			st33htpm0: st33htpm@0 {
				reg = <0>; /* CS #0 */
				compatible = "st,st33htpm-spi", "tcg,tpm_tis-spi";
				reset-gpios = <&gpio 24 1>;
				#address-cells = <1>;
				#size-cells = <0>;
				spi-max-frequency = <10000000>;
				status = "okay";
			};
		};
	};
};

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4954
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Tue Feb 07, 2023 3:07 pm

Here is the working device tree for U-Boot and Kernel.
Does that mean your problem is solved?

It's strange that you have to use a bit-bashed SPI interface:

Code: Select all

			compatible = "spi-gpio";

User avatar
syedelec
Posts: 9
Joined: Thu Nov 03, 2022 9:37 am

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Tue Feb 28, 2023 1:50 pm

Sorry for the delay.

Yes it worked for U-Boot and the Kernel. I was not sure also but I followed the link you sent me and adapted to the ST33 TPM chip.
Let me know if you have any other suggestion.

Is there an issue using the spi-gpio driver?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4954
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Tue Feb 28, 2023 2:43 pm

Is there an issue using the spi-gpio driver?
Probably not, but it will use more CPU and power than the hardware SPI interface, which is available on exactly those same pins. Perhaps the author of the overlay is trying to work around a bug or incompatibility between the hardware SPI interface and the ST33.

Can I mark this as SOLVED?

User avatar
syedelec
Posts: 9
Joined: Thu Nov 03, 2022 9:37 am

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Fri Mar 03, 2023 2:33 pm

How can I use the SPI hardware interface in the device tree overlay ? If you have any hints, let me know so I can investigate.

If I don't manage to use the hardware SPI driver, after some few attempts I will let you know to mark it as SOLVED. Thanks!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4954
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Fri Mar 03, 2023 2:46 pm

You should just have to delete these lines:

Code: Select all

			compatible = "spi-gpio";
			gpio-sck = <&gpio 11 0>;
			gpio-mosi = <&gpio 10 0>;
			gpio-miso = <&gpio 9 0>;
(Actually, deleting the first line should be enough, but the other lines will do nothing except confuse you)

User avatar
syedelec
Posts: 9
Joined: Thu Nov 03, 2022 9:37 am

Re: Enable STPM4RasPI extension board to connect the ST33 TPM on Rpi 4B for U-Boot

Tue Mar 14, 2023 2:19 pm

I tried but I could not make it work using hardware SPI bus.
I will keep this in mind and update this post if I find a solution. You can mark it as solved.

Return to “Device Tree”