Skip to contentSkip to conversation

U-Boot support for wolfTPM and firmware update for SLB9672/SLB9673

PATCH David Garske 6 participants 21 messages May 7, 2025 – Feb 17

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Attached is the patch based on latest master 3b6760ddeb4 to review.



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

From d0e00eb942cd30415e5e98dfd11debc1d8150a65 Mon Sep 17 00:00:00 2001
From: David Garske <[email protected]>
Date: Wed, 7 May 2025 12:22:39 -0700
Subject: [PATCH] Add support for wolfTPM 2.0 library. Adds new option to use
wolfTPM and has ports for all of the existing TPM commands. Also add firmware update support for Infineon SLB9672 and SLB9673 TPM 2.0 modules.

---
 .gitmodules                       |    3 +
 README                            |    3 +
 cmd/Kconfig                       |    7 +
 cmd/Makefile                      |   12 +-
 cmd/tpm-common.c                  |    4 +-
 cmd/wolftpm.c                     | 1433 +++++++++++++++++++++++++++++
 include/configs/user_settings.h   |   67 ++
 include/hash.h                    |   17 +
 include/linux/byteorder/generic.h |   31 +-
 include/tpm-common.h              |   22 +
 lib/Kconfig                       |   13 +
 lib/Makefile                      |   20 +
 lib/wolftpm                       |    1 +
 lib/wolftpm.c                     |   55 ++
 14 files changed, 1679 insertions(+), 9 deletions(-)
 create mode 100644 .gitmodules
 create mode 100644 cmd/wolftpm.c
 create mode 100644 include/configs/user_settings.h
 create mode 160000 lib/wolftpm
 create mode 100644 lib/wolftpm.c
.gitmodules new file +3 -0
new file mode 100644
index 00000000000..3f95a7c3eb9
@@ -0,0 +1,3 @@
+[submodule "lib/wolftpm"]
+	path = lib/wolftpm
+	url = https://github.com/wolfssl/wolfTPM.git
README +3 -0
index 334bbcf0dd1..c09f97ddf77 100644
@@ -392,6 +392,9 @@ The following options need to be configured:
 		CONFIG_TPM
 		Support TPM devices.
 
+		CONFIG_TPM_WOLF
+		Enables support for wolfTPM library.
+
 		CONFIG_TPM_TIS_INFINEON
 		Support for Infineon i2c bus TPM devices. Only one device
 		per system is supported at this time.
cmd/Kconfig +7 -0
index f21d27cb27f..2092d615ab8 100644
@@ -3098,4 +3098,11 @@ config CMD_SPAWN_NUM_JOBS
 	  When a jobs exits, its identifier is available to be re-used by the next
 	  spawn command.
 
+config CMD_WOLFTPM
+    bool "Enable wolfTPM commands"
+    depends on TPM
+    help
+      This provides commands for interacting with TPM 2.0 devices
+      using the wolfTPM library.
+
 endif
cmd/Makefile +11 -1
index 80cf70b7fe8..35ad31ef93b 100644
@@ -186,9 +186,19 @@ obj-$(CONFIG_CMD_TIMER) += timer.o
 obj-$(CONFIG_CMD_TRACE) += trace.o
 obj-$(CONFIG_HUSH_PARSER) += test.o
 obj-$(CONFIG_CMD_TPM) += tpm-common.o
-obj-$(CONFIG_CMD_TPM_V1) += tpm-v1.o
 obj-$(CONFIG_CMD_TPM_TEST) += tpm_test.o
+ifeq ($(CONFIG_TPM_WOLF),y)
+ifeq ($(CONFIG_TPM_V2),y)
+ccflags-y += -Ilib/wolftpm \
+             -Iinclude/configs \
+			 -DWOLFTPM_USER_SETTINGS \
+			 -DWOLFTPM2_NO_WOLFCRYPT
+obj-$(CONFIG_TPM_WOLF) += wolftpm.o
+endif
+else
+obj-$(CONFIG_CMD_TPM_V1) += tpm-v1.o
 obj-$(CONFIG_CMD_TPM_V2) += tpm-v2.o
+endif
 obj-$(CONFIG_CMD_CROS_EC) += cros_ec.o
 obj-$(CONFIG_CMD_TSI148) += tsi148.o
 obj-$(CONFIG_CMD_UBI) += ubi.o
cmd/tpm-common.c +2 -2
index 1cd57f901b6..30e99e10758 100644
@@ -234,7 +234,7 @@ int type_string_write_vars(const char *type_str, u8 *data,
 	return 0;
 }
 
-static int tpm_show_device(void)
+int tpm_show_device(void)
 {
 	struct udevice *dev;
 	char buf[80];
@@ -253,7 +253,7 @@ static int tpm_show_device(void)
 	return 0;
 }
 
-static int tpm_set_device(unsigned long num)
+int tpm_set_device(unsigned long num)
 {
 	struct udevice *dev;
 	unsigned long n = 0;
cmd/wolftpm.c new file +1433 -0

1,433 lines not on this page · raw message

include/configs/user_settings.h new file +67 -0

67 lines not on this page · raw message

include/hash.h +17 -0
index 8b3f79ec473..242de9f0e84 100644
@@ -6,6 +6,8 @@
 #ifndef _HASH_H
 #define _HASH_H
 
+#include <linux/types.h>
+
 #ifdef USE_HOSTCC
 #include <linux/kconfig.h>
 #endif
@@ -163,4 +165,19 @@ int hash_progressive_lookup_algo(const char *algo_name,
  */
 int hash_parse_string(const char *algo_name, const char *str, uint8_t *result);
 
+#ifdef WOLFTPM2_NO_WOLFCRYPT
+/**
+ * wc_Sha384Hash() - Calculate SHA384 hash
+ * @data:	Data to hash
+ * @len:	Length of data
+ * @hash:	Output buffer for hash
+ *
+ * This is a wrapper function to provide wolfCrypt-compatible SHA384 hashing
+ * when wolfCrypt is not available.
+ *
+ * Return: 0 on success, -1 on error
+ */
+int wc_Sha384Hash(const unsigned char* data, unsigned int len, unsigned char* hash);
+#endif /* WOLFTPM2_NO_WOLFCRYPT */
+
 #endif
include/linux/byteorder/generic.h +25 -6
index bee0ff60336..def601eed2b 100644
@@ -89,12 +89,6 @@
 #define le32_to_cpu __le32_to_cpu
 #define cpu_to_le16 __cpu_to_le16
 #define le16_to_cpu __le16_to_cpu
-#define cpu_to_be64 __cpu_to_be64
-#define be64_to_cpu __be64_to_cpu
-#define cpu_to_be32 __cpu_to_be32
-#define be32_to_cpu __be32_to_cpu
-#define cpu_to_be16 __cpu_to_be16
-#define be16_to_cpu __be16_to_cpu
 #define cpu_to_le64p __cpu_to_le64p
 #define le64_to_cpup __le64_to_cpup
 #define cpu_to_le32p __cpu_to_le32p
@@ -120,6 +114,31 @@
 #define cpu_to_be16s __cpu_to_be16s
 #define be16_to_cpus __be16_to_cpus
 
+/*
+ * Check if byte-order functions are already defined by the system:
+ * wolfTPM, wolfCrypt, and U-boot all define these functions, so
+ * we need to check if they are already defined before defining
+ * them again.
+ */
+#ifndef cpu_to_be16
+#define cpu_to_be16 __cpu_to_be16
+#endif
+#ifndef cpu_to_be32
+#define cpu_to_be32 __cpu_to_be32
+#endif
+#ifndef cpu_to_be64
+#define cpu_to_be64 __cpu_to_be64
+#endif
+#ifndef be16_to_cpu
+#define be16_to_cpu __be16_to_cpu
+#endif
+#ifndef be32_to_cpu
+#define be32_to_cpu __be32_to_cpu
+#endif
+#ifndef be64_to_cpu
+#define be64_to_cpu __be64_to_cpu
+#endif
+
 /*
  * They have to be macros in order to do the constant folding
  * correctly - if the argument passed into a inline function
include/tpm-common.h +22 -0
index bfb84a931d1..1ea4463fbbe 100644
@@ -337,4 +337,26 @@ enum tpm_version tpm_get_version(struct udevice *dev);
 /* Iterate on all TPM devices */
 #define for_each_tpm_device(dev) uclass_foreach_dev_probe(UCLASS_TPM, (dev))
 
+/**
+ * tpm_show_device() - Show all TPM devices
+ *
+ * Return: 0 on success, -ve on failure
+ */
+int tpm_show_device(void);
+
+/**
+ * tpm_set_device() - Set the TPM device to use
+ *
+ * @num: The number of the TPM device to use
+ * Return: 0 on success, -ve on failure
+ */
+int tpm_set_device(unsigned long num);
+
+/**
+ * get_tpm() - Get the TPM device
+ *
+ * Return: 0 on success, -ve on failure
+ */
+int get_tpm(struct udevice **devp);
+
 #endif /* __TPM_COMMON_H */
lib/Kconfig +13 -0
index b2aecd8a49e..68b6339a67b 100644
@@ -483,6 +483,19 @@ config TPM
 	  If you want a fully functional TPM enable all hashing algorithms.
 	  If you enabled measured boot all hashing algorithms are selected.
 
+config TPM_WOLF
+    bool "Enable wolfTPM support"
+	depends on DM
+	imply DM_RNG
+	select SHA1
+    help
+        This option enables support for wolfTPM in U-Boot. WolfTPM can be
+		used to update ARM specific platforms. Enabling this option allows
+		U-Boot to interact with the TPM using wolfTPM commands such as
+		firmware updates, PCR extend, and more. It is especially useful on
+		platforms that require support for secure boot and other TPM-related
+		functionality.
+
 config SPL_TPM
 	bool "Trusted Platform Module (TPM) Support in SPL"
 	depends on SPL_DM
lib/Makefile +20 -0
index 18ae0cd87bf..7fda1699310 100644
@@ -53,6 +53,7 @@ obj-$(CONFIG_BITREVERSE) += bitrev.o
 obj-y += list_sort.o
 endif
 
+# U-boot TPM
 obj-$(CONFIG_$(PHASE_)TPM) += tpm-common.o
 ifeq ($(CONFIG_$(PHASE_)TPM),y)
 obj-$(CONFIG_TPM) += tpm_api.o
@@ -62,6 +63,25 @@ obj-$(CONFIG_EFI_TCG2_PROTOCOL) += tpm_tcg2.o
 obj-$(CONFIG_MEASURED_BOOT) += tpm_tcg2.o
 endif
 
+# wolfTPM with TPM 2.0 support (including TPM firmware update)
+ifeq ($(CONFIG_TPM_WOLF),y)
+ifeq ($(CONFIG_TPM_V2),y)
+ccflags-y += -Ilib/wolftpm \
+             -Iinclude/configs \
+             -DWOLFTPM_USER_SETTINGS \
+             -DWOLFTPM2_NO_WOLFCRYPT
+obj-y += wolftpm/hal/tpm_io.o
+obj-y += wolftpm/hal/tpm_io_uboot.o
+obj-y += wolftpm/src/tpm2_linux.o
+obj-y += wolftpm/src/tpm2.o
+obj-y += wolftpm/src/tpm2_packet.o
+obj-y += wolftpm/src/tpm2_tis.o
+obj-y += wolftpm/src/tpm2_wrap.o
+obj-y += wolftpm/src/tpm2_param_enc.o
+obj-y += wolftpm.o
+endif
+endif
+
 obj-$(CONFIG_$(PHASE_)CRC8) += crc8.o
 obj-$(CONFIG_$(PHASE_)CRC16) += crc16.o
 obj-$(CONFIG_$(PHASE_)CRC16) += crc16-ccitt.o
lib/wolftpm new file +1 -0
new file mode 160000
index 00000000000..33a5f47eafe
@@ -0,0 +1 @@
+Subproject commit 33a5f47eafebf1b0d946d418a2b03c5944ed93a7
lib/wolftpm.c new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.46.0
#1 lore raw

Hi David

Quoted 5 lines

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

It's easier if you CC the appropriate maintainers for each subsystem next time!

Quoted 2 lines

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

We recently added a few external libraries. mbedTLS and lwIP. Both of these are pulled as subtrees, so I'd like to stick to that.

I briefly went through the patch and I don't disagree in pulling an external library as long as it's reasonably stable and will continue to be maintained. A few questions since I am not familiar with wolfTPM

- Have you made any size comparisons wrt to the final binary size?
- Does wolfTPM have stable releases that we can use?
- Is there a CVE policy ?

The current patch is quite big and I honestly don't have time to go through all of it in detail. I'll be away next week, but I can give some general feedback in ~10days. The easiest thing to do is try to split it a reasonable amount of patches -- and only include the bare minimum of what's required to work.

Thanks
/Ilias

Quoted 11 lines

Attached is the patch based on latest master 3b6760ddeb4 to review.



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#2 lore raw

Hi Ilias,

Thank you for the quick reply. I am happy that you will consider wolfTPM as a submodule. We have 100’s of commercial customers and it is very actively maintained. In fact we will continue to provide direct maintenance for any u-boot issues that come up using wolfTPM. Also we’ve done safety critical DO-178 certification on wolfTPM.

1) U-Boot subsystem maintainers. Can you point me to that list of maintainers?
2) Size: I haven’t run any size comparisons but I expect to be inline with existing code. I will make sure we run some comparisons.
3) Releases: Yes we have stable releases done each quarter. I am about to do a release v3.9.0 next week that includes the U-boot support, so I will update the submodule to use the tagged release when it’s ready.
4) CVE: Yes we track and create CVE’s if we find issues or any are reported. We typically have a fix posted within 36 hours of a report. Vulnerabilities are published in the release notes and for our premium support customers they get early notification.
5) Patch Size: I will work on reducing the changes and splitting them into logical commits.

Enjoy your time away. I’ll have updates to share soon.

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

Quoted 48 lines · Ilias Apalodimas

Hi David

Quoted 5 lines

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

It's easier if you CC the appropriate maintainers for each subsystem next time!

Quoted 2 lines

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

We recently added a few external libraries. mbedTLS and lwIP. Both of these are pulled as subtrees, so I'd like to stick to that.

I briefly went through the patch and I don't disagree in pulling an external library as long as it's reasonably stable and will continue to be maintained. A few questions since I am not familiar with wolfTPM

- Have you made any size comparisons wrt to the final binary size?
- Does wolfTPM have stable releases that we can use?
- Is there a CVE policy ?

The current patch is quite big and I honestly don't have time to go through all of it in detail. I'll be away next week, but I can give some general feedback in ~10days. The easiest thing to do is try to split it a reasonable amount of patches -- and only include the bare minimum of what's required to work.

Thanks
/Ilias

Quoted 11 lines

Attached is the patch based on latest master 3b6760ddeb4 to review.



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#3 lore raw
Quoted 6 lines · David Garske

Hi Ilias,

Thank you for the quick reply. I am happy that you will consider wolfTPM as a submodule. We have 100’s of commercial customers and it is very actively maintained. In fact we will continue to provide direct maintenance for any u-boot issues that come up using wolfTPM. Also we’ve done safety critical DO-178 certification on wolfTPM.

1) U-Boot subsystem maintainers. Can you point me to that list of maintainers?

it's in MAINTAINERS. I am responsible for TPM

Quoted 6 lines

2) Size: I haven’t run any size comparisons but I expect to be inline with existing code. I will make sure we run some comparisons.
3) Releases: Yes we have stable releases done each quarter. I am about to do a release v3.9.0 next week that includes the U-boot support, so I will update the submodule to use the tagged release when it’s ready.
4) CVE: Yes we track and create CVE’s if we find issues or any are reported. We typically have a fix posted within 36 hours of a report. Vulnerabilities are published in the release notes and for our premium support customers they get early notification.
5) Patch Size: I will work on reducing the changes and splitting them into logical commits.

Enjoy your time away. I’ll have updates to share soon.

Thanks
/Ilias

Quoted 60 lines

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On May 9, 2025, at 5:22 AM, Ilias Apalodimas <[email protected]> wrote:

Hi David

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

It's easier if you CC the appropriate maintainers for each subsystem next time!

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

We recently added a few external libraries. mbedTLS and lwIP. Both of these are pulled as subtrees, so I'd like to stick to that.

I briefly went through the patch and I don't disagree in pulling an external library as long as it's reasonably stable and will continue to be maintained. A few questions since I am not familiar with wolfTPM

- Have you made any size comparisons wrt to the final binary size?
- Does wolfTPM have stable releases that we can use?
- Is there a CVE policy ?

The current patch is quite big and I honestly don't have time to go through all of it in detail. I'll be away next week, but I can give some general feedback in ~10days. The easiest thing to do is try to split it a reasonable amount of patches -- and only include the bare minimum of what's required to work.

Thanks
/Ilias

Attached is the patch based on latest master 3b6760ddeb4 to review.



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#4 lore raw

Hi Ilias,

Thank you! It’s a pleasure to meet you! I’m the author and maintainer or wolfTPM.

Perhaps it would be useful to meet and chat for a bit? Are you free next week May 28th at 7:30 AM PT?

I loved the feedback from Simon Glass and we will be implementing those and suggesting a new patch soon.

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

Quoted 81 lines · Ilias Apalodimas
Quoted 6 lines · David Garske

Hi Ilias,

Thank you for the quick reply. I am happy that you will consider wolfTPM as a submodule. We have 100’s of commercial customers and it is very actively maintained. In fact we will continue to provide direct maintenance for any u-boot issues that come up using wolfTPM. Also we’ve done safety critical DO-178 certification on wolfTPM.

1) U-Boot subsystem maintainers. Can you point me to that list of maintainers?

it's in MAINTAINERS. I am responsible for TPM

Quoted 6 lines

2) Size: I haven’t run any size comparisons but I expect to be inline with existing code. I will make sure we run some comparisons.
3) Releases: Yes we have stable releases done each quarter. I am about to do a release v3.9.0 next week that includes the U-boot support, so I will update the submodule to use the tagged release when it’s ready.
4) CVE: Yes we track and create CVE’s if we find issues or any are reported. We typically have a fix posted within 36 hours of a report. Vulnerabilities are published in the release notes and for our premium support customers they get early notification.
5) Patch Size: I will work on reducing the changes and splitting them into logical commits.

Enjoy your time away. I’ll have updates to share soon.

Thanks
/Ilias

Quoted 60 lines

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On May 9, 2025, at 5:22 AM, Ilias Apalodimas <[email protected]> wrote:

Hi David

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

It's easier if you CC the appropriate maintainers for each subsystem next time!

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

We recently added a few external libraries. mbedTLS and lwIP. Both of these are pulled as subtrees, so I'd like to stick to that.

I briefly went through the patch and I don't disagree in pulling an external library as long as it's reasonably stable and will continue to be maintained. A few questions since I am not familiar with wolfTPM

- Have you made any size comparisons wrt to the final binary size?
- Does wolfTPM have stable releases that we can use?
- Is there a CVE policy ?

The current patch is quite big and I honestly don't have time to go through all of it in detail. I'll be away next week, but I can give some general feedback in ~10days. The easiest thing to do is try to split it a reasonable amount of patches -- and only include the bare minimum of what's required to work.

Thanks
/Ilias

Attached is the patch based on latest master 3b6760ddeb4 to review.



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#5 lore raw

Hi David,

Quoted 8 lines · David Garske

Hi Ilias,

Thank you! It’s a pleasure to meet you! I’m the author and maintainer or wolfTPM.

Perhaps it would be useful to meet and chat for a bit? Are you free next week May 28th at 7:30 AM PT?

I loved the feedback from Simon Glass and we will be implementing those and suggesting a new patch soon.

I am a bit overloaded. Is there anything specific you would like to discuss?

Thanks
/Ilias

Quoted 94 lines

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On May 19, 2025, at 1:52 AM, Ilias Apalodimas <[email protected]> wrote:

On Fri, 9 May 2025 at 18:43, David Garske <[email protected]> wrote:

Hi Ilias,

Thank you for the quick reply. I am happy that you will consider wolfTPM as a submodule. We have 100’s of commercial customers and it is very actively maintained. In fact we will continue to provide direct maintenance for any u-boot issues that come up using wolfTPM. Also we’ve done safety critical DO-178 certification on wolfTPM.

1) U-Boot subsystem maintainers. Can you point me to that list of maintainers?

it's in MAINTAINERS. I am responsible for TPM

2) Size: I haven’t run any size comparisons but I expect to be inline with existing code. I will make sure we run some comparisons.
3) Releases: Yes we have stable releases done each quarter. I am about to do a release v3.9.0 next week that includes the U-boot support, so I will update the submodule to use the tagged release when it’s ready.
4) CVE: Yes we track and create CVE’s if we find issues or any are reported. We typically have a fix posted within 36 hours of a report. Vulnerabilities are published in the release notes and for our premium support customers they get early notification.
5) Patch Size: I will work on reducing the changes and splitting them into logical commits.

Enjoy your time away. I’ll have updates to share soon.

Thanks
/Ilias

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On May 9, 2025, at 5:22 AM, Ilias Apalodimas <[email protected]> wrote:

Hi David

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

It's easier if you CC the appropriate maintainers for each subsystem next time!

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

We recently added a few external libraries. mbedTLS and lwIP. Both of these are pulled as subtrees, so I'd like to stick to that.

I briefly went through the patch and I don't disagree in pulling an external library as long as it's reasonably stable and will continue to be maintained. A few questions since I am not familiar with wolfTPM

- Have you made any size comparisons wrt to the final binary size?
- Does wolfTPM have stable releases that we can use?
- Is there a CVE policy ?

The current patch is quite big and I honestly don't have time to go through all of it in detail. I'll be away next week, but I can give some general feedback in ~10days. The easiest thing to do is try to split it a reasonable amount of patches -- and only include the bare minimum of what's required to work.

Thanks
/Ilias

Attached is the patch based on latest master 3b6760ddeb4 to review.



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#6 lore raw

Hi Ilias,

Thank you for the reply. I totally understand about being busy! There is nothing specific to discuss at this point. I’ll reach out again soon with the proposed u-boot wolfTPM patches.

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

Quoted 112 lines · Ilias Apalodimas

Hi David,

Quoted 8 lines · David Garske

Hi Ilias,

Thank you! It’s a pleasure to meet you! I’m the author and maintainer or wolfTPM.

Perhaps it would be useful to meet and chat for a bit? Are you free next week May 28th at 7:30 AM PT?

I loved the feedback from Simon Glass and we will be implementing those and suggesting a new patch soon.

I am a bit overloaded. Is there anything specific you would like to discuss?

Thanks
/Ilias

Quoted 94 lines

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On May 19, 2025, at 1:52 AM, Ilias Apalodimas <[email protected]> wrote:

On Fri, 9 May 2025 at 18:43, David Garske <[email protected]> wrote:

Hi Ilias,

Thank you for the quick reply. I am happy that you will consider wolfTPM as a submodule. We have 100’s of commercial customers and it is very actively maintained. In fact we will continue to provide direct maintenance for any u-boot issues that come up using wolfTPM. Also we’ve done safety critical DO-178 certification on wolfTPM.

1) U-Boot subsystem maintainers. Can you point me to that list of maintainers?

it's in MAINTAINERS. I am responsible for TPM

2) Size: I haven’t run any size comparisons but I expect to be inline with existing code. I will make sure we run some comparisons.
3) Releases: Yes we have stable releases done each quarter. I am about to do a release v3.9.0 next week that includes the U-boot support, so I will update the submodule to use the tagged release when it’s ready.
4) CVE: Yes we track and create CVE’s if we find issues or any are reported. We typically have a fix posted within 36 hours of a report. Vulnerabilities are published in the release notes and for our premium support customers they get early notification.
5) Patch Size: I will work on reducing the changes and splitting them into logical commits.

Enjoy your time away. I’ll have updates to share soon.

Thanks
/Ilias

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On May 9, 2025, at 5:22 AM, Ilias Apalodimas <[email protected]> wrote:

Hi David

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

It's easier if you CC the appropriate maintainers for each subsystem next time!

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

We recently added a few external libraries. mbedTLS and lwIP. Both of these are pulled as subtrees, so I'd like to stick to that.

I briefly went through the patch and I don't disagree in pulling an external library as long as it's reasonably stable and will continue to be maintained. A few questions since I am not familiar with wolfTPM

- Have you made any size comparisons wrt to the final binary size?
- Does wolfTPM have stable releases that we can use?
- Is there a CVE policy ?

The current patch is quite big and I honestly don't have time to go through all of it in detail. I'll be away next week, but I can give some general feedback in ~10days. The easiest thing to do is try to split it a reasonable amount of patches -- and only include the bare minimum of what's required to work.

Thanks
/Ilias

Attached is the patch based on latest master 3b6760ddeb4 to review.



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#7 lore raw

Hi David,

Quoted 4 lines · David Garske

Hi Ilias,

Thank you for the reply. I totally understand about being busy! There is nothing specific to discuss at this point. I’ll reach out again soon with the proposed u-boot wolfTPM patches.

Thanks, the best advice I can give is look at the mbedTLS, lwIP & the external DT integration and how that was done. We've done enough reviews on it, so it will you you a good idea of how things should look like

Cheers
/Ilias

Quoted 124 lines

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On May 30, 2025, at 12:32 AM, Ilias Apalodimas <[email protected]> wrote:

Hi David,

On Wed, 21 May 2025 at 20:12, David Garske <[email protected]> wrote:

Hi Ilias,

Thank you! It’s a pleasure to meet you! I’m the author and maintainer or wolfTPM.

Perhaps it would be useful to meet and chat for a bit? Are you free next week May 28th at 7:30 AM PT?

I loved the feedback from Simon Glass and we will be implementing those and suggesting a new patch soon.

I am a bit overloaded. Is there anything specific you would like to discuss?

Thanks
/Ilias

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On May 19, 2025, at 1:52 AM, Ilias Apalodimas <[email protected]> wrote:

On Fri, 9 May 2025 at 18:43, David Garske <[email protected]> wrote:

Hi Ilias,

Thank you for the quick reply. I am happy that you will consider wolfTPM as a submodule. We have 100’s of commercial customers and it is very actively maintained. In fact we will continue to provide direct maintenance for any u-boot issues that come up using wolfTPM. Also we’ve done safety critical DO-178 certification on wolfTPM.

1) U-Boot subsystem maintainers. Can you point me to that list of maintainers?

it's in MAINTAINERS. I am responsible for TPM

2) Size: I haven’t run any size comparisons but I expect to be inline with existing code. I will make sure we run some comparisons.
3) Releases: Yes we have stable releases done each quarter. I am about to do a release v3.9.0 next week that includes the U-boot support, so I will update the submodule to use the tagged release when it’s ready.
4) CVE: Yes we track and create CVE’s if we find issues or any are reported. We typically have a fix posted within 36 hours of a report. Vulnerabilities are published in the release notes and for our premium support customers they get early notification.
5) Patch Size: I will work on reducing the changes and splitting them into logical commits.

Enjoy your time away. I’ll have updates to share soon.

Thanks
/Ilias

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On May 9, 2025, at 5:22 AM, Ilias Apalodimas <[email protected]> wrote:

Hi David

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

It's easier if you CC the appropriate maintainers for each subsystem next time!

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

We recently added a few external libraries. mbedTLS and lwIP. Both of these are pulled as subtrees, so I'd like to stick to that.

I briefly went through the patch and I don't disagree in pulling an external library as long as it's reasonably stable and will continue to be maintained. A few questions since I am not familiar with wolfTPM

- Have you made any size comparisons wrt to the final binary size?
- Does wolfTPM have stable releases that we can use?
- Is there a CVE policy ?

The current patch is quite big and I honestly don't have time to go through all of it in detail. I'll be away next week, but I can give some general feedback in ~10days. The easiest thing to do is try to split it a reasonable amount of patches -- and only include the bare minimum of what's required to work.

Thanks
/Ilias

Attached is the patch based on latest master 3b6760ddeb4 to review.



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#8 lore raw
In reply to David Garske

Hi David,

Quoted 10 lines · David Garske

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as WOLFTPM_SLB9672/3
- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon

Quoted 10 lines



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#9 lore raw

Hi Simon,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 49 lines · Simon Glass

Hi David,

Quoted 4 lines · David Garske

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch

allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

Quoted 2 lines

I think there is probably some more cleanup and testing needed, but I

wanted to submit this to start the discussion and see your thoughts.

Quoted 2 lines

The wolfTPM library is GPLv2 and added as a submodule. If the license or

submodule is an issue let’s discuss! I’m positive we can resolve anything.

Quoted 2 lines

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as WOLFTPM_SLB9672/3
- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon

Quoted 10 lines



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#10 lore raw

Hi Simon and Ilias,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 73 lines · Aidan Garske

Hi Simon,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 51 lines · Simon Glass

Hi David,

Quoted 4 lines · David Garske

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch

allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

Quoted 2 lines

I think there is probably some more cleanup and testing needed, but I

wanted to submit this to start the discussion and see your thoughts.

Quoted 2 lines

The wolfTPM library is GPLv2 and added as a submodule. If the license

or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Quoted 2 lines

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as WOLFTPM_SLB9672/3
- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon

Quoted 10 lines



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#11 lore raw

Hi Aidan,

Quoted 17 lines · Aidan Garske

Hi Simon and Ilias,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 7 lines
Quoted 6 lines · Aidan Garske

Hi Simon,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?

It's been a while and I am not sure I am following on that

Quoted 1 line
Quoted 1 line

2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Are you expecting it to be reusable by something else? If not just keep it to cmd/wolftpm.c

Thanks
/Ilias

Quoted 56 lines
Quoted 56 lines

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 44 lines · Simon Glass

Hi David,

Quoted 10 lines · David Garske

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as WOLFTPM_SLB9672/3
- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon

Quoted 10 lines



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#12 lore raw

Hi Ilias,

Sounds good, I will keep them in cmd/wolftpm.c. I guess Simon can probably answer the other question the best.
He had asked if I could "put the driver code into drivers/ with just the command code in cmd/" so I am just trying
to get clarity on what driver code he is specifically referring to.

Thanks for the help,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 108 lines · Ilias Apalodimas

Hi Aidan,

Quoted 4 lines · Aidan Garske

Hi Simon and Ilias,

Thank you for the great feedback. Currently I am working in the refactor

you suggested and I wanted to ask a question about some of your comments.

Quoted 3 lines

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a

cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Quoted 10 lines

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 5 lines
Quoted 4 lines · Aidan Garske

Hi Simon,

Thank you for the great feedback. Currently I am working in the

refactor you suggested and I wanted to ask a question about some of your comments.

Quoted 2 lines
Quoted 2 lines

1. What exactly is the "driver code" you are referring to in this case?

It's been a while and I am not sure I am following on that

Quoted 1 line
Quoted 1 line

2. Do you want me to separate out our helper functions into a

cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Are you expecting it to be reusable by something else? If not just keep it to cmd/wolftpm.c

Thanks
/Ilias

Quoted 13 lines
Quoted 13 lines

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 1 line · Simon Glass
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Hi David,

Quoted 4 lines · David Garske

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch

allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I think there is probably some more cleanup and testing needed, but

I wanted to submit this to start the discussion and see your thoughts.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The wolfTPM library is GPLv2 and added as a submodule. If the

license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as

WOLFTPM_SLB9672/3

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines

- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon

Quoted 10 lines



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

#13 lore raw

Hi Ilias,

We have made the U-Boot changes requested and attached a patch for upstream. Let me know if you have any issues or questions.

Fork: https://github.com/aidangarske/u-boot/tree/rpi4-wolftpm-uboot
Instructions: https://github.com/aidangarske/rpi4-wolftpm-uboot/tree/master



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

Quoted 17 lines · Aidan Garske

Hi Ilias,

Sounds good, I will keep them in cmd/wolftpm.c. I guess Simon can probably answer the other question the best. He had asked if I could "put the driver code into drivers/ with just the command code in cmd/" so I am just trying to get clarity on what driver code he is specifically referring to.

Thanks for the help,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 96 lines
Quoted 95 lines · On Tue, Aug 5, 2025 at 1:17 AM Ilias Apalodimas <[email protected]…

Hi Aidan,

Quoted 17 lines · On Sat, 2 Aug 2025 at 01:59, Aidan Garske <[email protected]…

Hi Simon and Ilias,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 7 lines
Quoted 6 lines · On Wed, Jul 30, 2025 at 8:40 AM Aidan Garske <[email protected]…

Hi Simon,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?

It's been a while and I am not sure I am following on that

Quoted 1 line
Quoted 1 line

2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Are you expecting it to be reusable by something else? If not just keep it to cmd/wolftpm.c

Thanks
/Ilias

Quoted 56 lines
Quoted 56 lines

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 44 lines · On Sat, May 10, 2025 at 4:25 AM Simon Glass <[email protected]…

Hi David,

Quoted 10 lines · On Thu, 8 May 2025 at 00:41, David Garske <[email protected]…

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as WOLFTPM_SLB9672/3
- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon

Quoted 10 lines



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/> <https://www.wolfssl.com/>
https://github.com/wolfssl

.gitmodules new file +3 -0
new file mode 100644
index 00000000000..3f95a7c3eb9
@@ -0,0 +1,3 @@
+[submodule "lib/wolftpm"]
+	path = lib/wolftpm
+	url = https://github.com/wolfssl/wolfTPM.git
README +3 -0
index 20a73bab802..b9bfe14a1c7 100644
@@ -361,6 +361,9 @@ The following options need to be configured:
 		CONFIG_TPM
 		Support TPM devices.
 
+		CONFIG_TPM_WOLF
+		Enables support for wolfTPM library.
+
 		CONFIG_TPM_TIS_INFINEON
 		Support for Infineon i2c bus TPM devices. Only one device
 		per system is supported at this time.
README.wolftpm.md new file +149 -0

149 lines not on this page · raw message

arch/arm/dts/bcm2711-rpi-4-b.dts +20 -0
index 72ce80fbf26..a09276dc279 100644
@@ -8,6 +8,11 @@
 	compatible = "raspberrypi,4-model-b", "brcm,bcm2711";
 	model = "Raspberry Pi 4 Model B";
 
+	/* Alias hardware SPI as spi0 so wolfTPM finds it at bus 0 */
+	aliases {
+		spi0 = &spi;
+	};
+
 	chosen {
 		/* 8250 auxiliary UART instead of pl011 */
 		stdout-path = "serial1:115200n8";
@@ -54,6 +59,21 @@
 		enable-active-high;
 		gpio = <&expgpio 6 GPIO_ACTIVE_HIGH>;
 	};
+
+};
+
+/* Hardware SPI with TPM - matches Linux tpm-slb9670 overlay */
+&spi {
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi0_gpio7>;
+
+	/* Infineon SLB9670/9672 TPM 2.0 on CE1 (GPIO7) */
+	tpm@1 {
+		compatible = "infineon,slb9670", "tcg,tpm_tis-spi";
+		reg = <1>;  /* CE1 */
+		spi-max-frequency = <32000000>;
+	};
 };
 
 &ddc0 {
arch/arm/dts/qemu-arm64.dts +4 -0
index 95fcf53ed74..e74d036a532 100644
@@ -12,4 +12,8 @@
 #endif
 
 / {
+	tpm@0c000000 {
+		compatible = "tcg,tpm-tis-mmio";
+		reg = <0x0 0x0c000000 0x0 0x5000>;
+	};
 };
arch/sandbox/dts/sandbox.dtsi +11 -0
index 02b03894eaf..2fdd7f0e942 100644
@@ -286,6 +286,17 @@
 			spi-max-frequency = <40000000>;
 			sandbox,filename = "spi.bin";
 		};
+
+		tpm_spi: tpm@1 {
+			reg = <1>;
+			compatible = "sandbox,tpm-spi";
+			spi-max-frequency = <10000000>;
+			sandbox,emul = <&tpm_spi_emul>;
+		};
+	};
+
+	tpm_spi_emul: tpm-spi-emul {
+		compatible = "sandbox,tpm-spi-emul";
 	};
 
 	spl-test {
cmd/Kconfig +16 -0
index b71ac554c0b..f1bf7637f6b 100644
@@ -2814,6 +2814,9 @@ config CMD_TPM
 	  command requires a suitable TPM on your board and the correct driver
 	  must be enabled.
 
+	  Note: For TPM2, do not enable both CMD_TPM and CMD_WOLFTPM as they
+	  both provide the tpm2 command.
+
 if CMD_TPM
 
 config CMD_TPM_TEST
@@ -3194,4 +3197,17 @@ config CMD_SPAWN_NUM_JOBS
 	  When a jobs exits, its identifier is available to be re-used by the next
 	  spawn command.
 
+config CMD_WOLFTPM
+	bool "Enable wolfTPM tpm2 command (replaces standard tpm2)"
+	depends on TPM && TPM_V2
+	select TPM_WOLF
+	help
+	  This provides the 'tpm2' command using the wolfTPM library instead
+	  of the standard U-Boot TPM2 implementation. wolfTPM offers additional
+	  features including firmware update support for Infineon TPMs and
+	  enhanced capabilities reporting.
+
+	  Note: Do not enable both CMD_TPM and CMD_WOLFTPM as they both
+	  provide the tpm2 command.
+
 endif
cmd/Makefile +10 -1
index 4cd13d4fa6e..9c622e3d717 100644
@@ -191,9 +191,18 @@ obj-$(CONFIG_CMD_TIMER) += timer.o
 obj-$(CONFIG_CMD_TRACE) += trace.o
 obj-$(CONFIG_HUSH_PARSER) += test.o
 obj-$(CONFIG_CMD_TPM) += tpm-common.o
-obj-$(CONFIG_CMD_TPM_V1) += tpm-v1.o
 obj-$(CONFIG_CMD_TPM_TEST) += tpm_test.o
+ifeq ($(CONFIG_TPM_WOLF),y)
+ifeq ($(CONFIG_TPM_V2),y)
+ccflags-y += -Ilib/wolftpm \
+             -Iinclude/configs \
+             -DWOLFTPM_USER_SETTINGS
+obj-$(CONFIG_TPM_WOLF) += wolftpm.o
+endif
+else
+obj-$(CONFIG_CMD_TPM_V1) += tpm-v1.o
 obj-$(CONFIG_CMD_TPM_V2) += tpm-v2.o
+endif
 obj-$(CONFIG_CMD_CROS_EC) += cros_ec.o
 obj-$(CONFIG_CMD_UBI) += ubi.o
 obj-$(CONFIG_CMD_UBIFS) += ubifs.o
cmd/tpm-common.c +2 -2
index 1cd57f901b6..30e99e10758 100644
@@ -234,7 +234,7 @@ int type_string_write_vars(const char *type_str, u8 *data,
 	return 0;
 }
 
-static int tpm_show_device(void)
+int tpm_show_device(void)
 {
 	struct udevice *dev;
 	char buf[80];
@@ -253,7 +253,7 @@ static int tpm_show_device(void)
 	return 0;
 }
 
-static int tpm_set_device(unsigned long num)
+int tpm_set_device(unsigned long num)
 {
 	struct udevice *dev;
 	unsigned long n = 0;
cmd/wolftpm.c new file +1443 -0

1,443 lines not on this page · raw message

configs/rpi_4_defconfig +28 -1
index 8362242b97f..22280d9b70e 100644
@@ -69,4 +69,31 @@ CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_VIDEO_BCM2835=y
 CONFIG_CONSOLE_SCROLL_LINES=10
 CONFIG_PHYS_TO_BUS=y
-# CONFIG_HEXDUMP is not set
+# HEXDUMP enabled for unit tests
+
+# SPI support (hardware SPI - matches Linux tpm-slb9670 overlay)
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_BCM2835_SPI=y
+# CONFIG_SOFT_SPI is not set
+CONFIG_CMD_SPI=y
+
+# TPM and wolfTPM support
+CONFIG_TPM=y
+CONFIG_TPM_V2=y
+CONFIG_CMD_TPM=y
+CONFIG_TPM_WOLF=y
+# CONFIG_WOLFTPM_LINUX_DEV is not set
+CONFIG_WOLFTPM_SLB9672=y
+CONFIG_CMD_WOLFTPM=y
+
+# Logging (debug level to see log_debug output)
+CONFIG_LOG=y
+CONFIG_LOGLEVEL=7
+CONFIG_LOG_MAX_LEVEL=7
+CONFIG_LOG_DEFAULT_LEVEL=7
+
+# Unit testing support
+CONFIG_UNIT_TEST=y
+CONFIG_CONSOLE_RECORD=y
+CONFIG_HEXDUMP=y
doc/usage/cmd/wolftpm.rst new file +694 -0

694 lines not on this page · raw message

drivers/mtd/spi/sandbox.c +21 -9
index e5ebc3479fb..41bd07817aa 100644
@@ -571,16 +571,28 @@ int sandbox_spi_get_emul(struct sandbox_state *state,
 
 	info = &state->spi[busnum][cs];
 	if (!info->emul) {
-		/* Use the same device tree node as the SPI flash device */
-		debug("%s: busnum=%u, cs=%u: binding SPI flash emulation: ",
-		      __func__, busnum, cs);
-		ret = sandbox_sf_bind_emul(state, busnum, cs, bus,
-					   dev_ofnode(slave), slave->name);
-		if (ret) {
-			debug("failed (err=%d)\n", ret);
-			return ret;
+		struct udevice *emul;
+		ofnode node = dev_ofnode(slave);
+
+		/* First check for sandbox,emul phandle property */
+		ret = uclass_get_device_by_phandle(UCLASS_SPI_EMUL, slave,
+						   "sandbox,emul", &emul);
+		if (!ret) {
+			debug("%s: busnum=%u, cs=%u: using phandle emulator\n",
+			      __func__, busnum, cs);
+			info->emul = emul;
+		} else {
+			/* Fall back to SPI flash emulation binding */
+			debug("%s: busnum=%u, cs=%u: binding SPI flash emulation: ",
+			      __func__, busnum, cs);
+			ret = sandbox_sf_bind_emul(state, busnum, cs, bus,
+						   node, slave->name);
+			if (ret) {
+				debug("failed (err=%d)\n", ret);
+				return ret;
+			}
+			debug("OK\n");
 		}
-		debug("OK\n");
 	}
 	*emulp = info->emul;
 
drivers/spi/Kconfig +9 -0
index 63d61ccf8ed..02ee2b2e6a0 100644
@@ -116,6 +116,15 @@ config ATMEL_SPI
 	  many AT91 (ARM) chips. This driver can be used to access
 	  the SPI Flash, such as AT25DF321.
 
+config BCM2835_SPI
+	bool "BCM2835/BCM2711 SPI driver"
+	depends on ARCH_BCM283X
+	help
+	  Enable the BCM2835/BCM2711 SPI controller driver. This driver
+	  can be used to access SPI devices on Raspberry Pi boards
+	  including Pi 3 and Pi 4. It uses the hardware SPI controller
+	  rather than GPIO bit-banging.
+
 config BCM63XX_HSSPI
 	bool "BCM63XX HSSPI driver"
 	depends on (ARCH_BMIPS || ARCH_BCMBCA)
drivers/spi/Makefile +1 -0
index 0dc2d23e172..47a1c6194b1 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_APPLE_SPI) += apple_spi.o
 obj-$(CONFIG_ATH79_SPI) += ath79_spi.o
 obj-$(CONFIG_ATMEL_QSPI) += atmel-quadspi.o
 obj-$(CONFIG_ATMEL_SPI) += atmel_spi.o
+obj-$(CONFIG_BCM2835_SPI) += bcm2835_spi.o
 obj-$(CONFIG_BCM63XX_HSSPI) += bcm63xx_hsspi.o
 obj-$(CONFIG_BCMBCA_HSSPI) += bcmbca_hsspi.o
 obj-$(CONFIG_BCM63XX_SPI) += bcm63xx_spi.o
drivers/spi/bcm2835_spi.c new file +429 -0

429 lines not on this page · raw message

drivers/tpm/Kconfig +36 -0
index 219ea606b50..d4694946b94 100644
@@ -158,6 +158,14 @@ config TPM2_TIS_SANDBOX
 	  such as basic configuration, PCR extension and PCR read. Extended
 	  functionalities are not implemented.
 
+config TPM2_SPI_SANDBOX
+	bool "Enable sandbox TPM SPI emulator"
+	depends on TPM_V2 && SANDBOX && DM_SPI
+	help
+	  This driver emulates a TPM connected via SPI for sandbox testing.
+	  It implements the TPM TIS SPI protocol and can be used to test
+	  wolfTPM SPI HAL code without physical hardware.
+
 config TPM2_TIS_SPI
 	bool "Enable support for TPMv2.x SPI chips"
 	depends on TPM_V2 && DM_SPI
@@ -200,6 +208,34 @@ config TPM2_EVENT_LOG_SIZE
 	  allocated twice. One for the eventlog it self and one for the
 	  configuration table that is required from the TCG2 spec
 
+config WOLFTPM_LINUX_DEV
+    bool "Use device-level TPM interface (bypass wolfTPM TIS layer)"
+    depends on TPM_V2 && TPM_WOLF
+    default y
+    help
+      Enable wolfTPM to use the underlying TPM driver instead of its own
+      TIS (TPM Interface Specification) layer. On U-Boot, this uses the
+      U-Boot TPM driver model (tpm_xfer). On Linux, this uses /dev/tpm0.
+      This is the recommended setting for U-Boot.
+
+config WOLFTPM_SLB9672
+    bool "Enable support for Infineon SLB9672 TPM"
+    depends on TPM_V2 && TPM_WOLF
+    help
+      Enable support for Infineon SLB9672 TPM features in wolfTPM.
+
+config WOLFTPM_SLB9673
+    bool "Enable support for Infineon SLB9673 TPM"
+    depends on TPM_V2 && TPM_WOLF
+    help
+      Enable support for Infineon SLB9673 TPM features in wolfTPM.
+
+config WOLFTPM_FIRMWARE_UPGRADE
+    bool "Enable firmware upgrade support for wolfTPM"
+    depends on TPM_V2 && TPM_WOLF
+    help
+      Enable support for Infineon TPM firmware upgrade commands in wolfTPM.
+
 endif # TPM_V2
 
 endmenu
drivers/tpm/Makefile +9 -0
index b83ce703ec0..39de454cacf 100644
@@ -10,7 +10,16 @@ obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o sandbox_common.o
 
 obj-$(CONFIG_$(PHASE_)TPM2_CR50_I2C) += cr50_i2c.o
 obj-$(CONFIG_TPM2_TIS_SANDBOX) += tpm2_tis_sandbox.o sandbox_common.o
+obj-$(CONFIG_TPM2_SPI_SANDBOX) += tpm_spi_sandbox.o
 obj-$(CONFIG_TPM2_TIS_SPI) += tpm2_tis_core.o tpm2_tis_spi.o
 obj-$(CONFIG_TPM2_TIS_I2C) += tpm2_tis_core.o tpm2_tis_i2c.o
 obj-$(CONFIG_TPM2_FTPM_TEE) += tpm2_ftpm_tee.o
 obj-$(CONFIG_TPM2_MMIO) += tpm2_tis_core.o tpm2_tis_mmio.o
+
+# wolfTPM helper functions
+ifeq ($(CONFIG_TPM_WOLF),y)
+ccflags-y += -Ilib/wolftpm \
+             -Iinclude/configs \
+             -DWOLFTPM_USER_SETTINGS
+obj-y += wolftpm_common.o
+endif
drivers/tpm/tpm_spi_sandbox.c new file +410 -0

410 lines not on this page · raw message

drivers/tpm/wolftpm_common.c new file +135 -0

135 lines not on this page · raw message

include/configs/user_settings.h new file +118 -0

118 lines not on this page · raw message

include/hash.h +17 -0
index 8b3f79ec473..242de9f0e84 100644

Lines of this file are not shown. View the raw message.

include/linux/byteorder/generic.h +25 -6
index bee0ff60336..def601eed2b 100644

Lines of this file are not shown. View the raw message.

include/tpm-common.h +22 -0
index bfb84a931d1..1ea4463fbbe 100644

Lines of this file are not shown. View the raw message.

include/wolftpm.h new file +33 -0
new file mode 100644
index 00000000000..dfa8af327f4

Lines of this file are not shown. View the raw message.

lib/Kconfig +13 -0
index 931d5206936..24477ea53c9 100644

Lines of this file are not shown. View the raw message.

lib/Makefile +18 -0
index 70667f3728c..ba3a9e85c11 100644

Lines of this file are not shown. View the raw message.

lib/wolftpm new file +1 -0
new file mode 160000
index 00000000000..19559386121

Lines of this file are not shown. View the raw message.

lib/wolftpm.c new file +56 -0

56 lines not on this page · raw message

scripts/check-local-export +9 -0
index 6ccc2f46741..ce520772866 100755

Lines of this file are not shown. View the raw message.

test/cmd/Makefile +1 -0
index 2476068aee6..08fbc31a06a 100644

Lines of this file are not shown. View the raw message.

test/cmd/wolftpm.c new file +364 -0

364 lines not on this page · raw message

test/py/tests/test_wolftpm.py new file +373 -0

373 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#14 lore raw

Hi David,

Quoted 1 line

We have made the U-Boot changes requested and attached a patch for upstream. Let me know if you have any issues or questions.

Please send the patch using 'git send-emaiil' or a similar tool.

Regards,
Peter

Quoted 126 lines

Fork: https://github.com/aidangarske/u-boot/tree/rpi4-wolftpm-uboot
Instructions: https://github.com/aidangarske/rpi4-wolftpm-uboot/tree/master



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

Quoted 113 lines · Aidan Garske

Hi Ilias,

Sounds good, I will keep them in cmd/wolftpm.c. I guess Simon can probably answer the other question the best. He had asked if I could "put the driver code into drivers/ with just the command code in cmd/" so I am just trying to get clarity on what driver code he is specifically referring to.

Thanks for the help,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 95 lines · On Tue, Aug 5, 2025 at 1:17 AM Ilias Apalodimas <[email protected]…

Hi Aidan,

Quoted 17 lines · On Sat, 2 Aug 2025 at 01:59, Aidan Garske <[email protected]…

Hi Simon and Ilias,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 7 lines
Quoted 6 lines · On Wed, Jul 30, 2025 at 8:40 AM Aidan Garske <[email protected]…

Hi Simon,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?

It's been a while and I am not sure I am following on that

Quoted 1 line
Quoted 1 line

2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Are you expecting it to be reusable by something else? If not just keep it to cmd/wolftpm.c

Thanks
/Ilias

Quoted 56 lines
Quoted 56 lines

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 44 lines · On Sat, May 10, 2025 at 4:25 AM Simon Glass <[email protected]…

Hi David,

Quoted 10 lines · On Thu, 8 May 2025 at 00:41, David Garske <[email protected]…

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as WOLFTPM_SLB9672/3
- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon

Quoted 10 lines



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/> <https://www.wolfssl.com/>
https://github.com/wolfssl

#15 lore raw

Hi,

Thanks for the followup. As Peter suggested, please submit it as a patch. Github might be fine for the development, but we do have an email based review system. Maintainers are already overloaded, so it's easier for us to follow the guidelines

Thanks
/Ilias

Quoted 136 lines · Peter Robinson

Hi David,

Quoted 1 line

We have made the U-Boot changes requested and attached a patch for upstream. Let me know if you have any issues or questions.

Please send the patch using 'git send-emaiil' or a similar tool.

Regards,
Peter

Quoted 126 lines

Fork: https://github.com/aidangarske/u-boot/tree/rpi4-wolftpm-uboot
Instructions: https://github.com/aidangarske/rpi4-wolftpm-uboot/tree/master



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

Quoted 113 lines · Aidan Garske

Hi Ilias,

Sounds good, I will keep them in cmd/wolftpm.c. I guess Simon can probably answer the other question the best. He had asked if I could "put the driver code into drivers/ with just the command code in cmd/" so I am just trying to get clarity on what driver code he is specifically referring to.

Thanks for the help,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 95 lines · On Tue, Aug 5, 2025 at 1:17 AM Ilias Apalodimas <[email protected]…

Hi Aidan,

Quoted 17 lines · On Sat, 2 Aug 2025 at 01:59, Aidan Garske <[email protected]…

Hi Simon and Ilias,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 7 lines
Quoted 6 lines · On Wed, Jul 30, 2025 at 8:40 AM Aidan Garske <[email protected]…

Hi Simon,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?

It's been a while and I am not sure I am following on that

Quoted 1 line
Quoted 1 line

2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Are you expecting it to be reusable by something else? If not just keep it to cmd/wolftpm.c

Thanks
/Ilias

Quoted 56 lines
Quoted 56 lines

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 44 lines · On Sat, May 10, 2025 at 4:25 AM Simon Glass <[email protected]…

Hi David,

Quoted 10 lines · On Thu, 8 May 2025 at 00:41, David Garske <[email protected]…

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as WOLFTPM_SLB9672/3
- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon

Quoted 10 lines



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/> <https://www.wolfssl.com/>
https://github.com/wolfssl

#16 lore raw

Hi Ilias,

Thanks for your reply. I did submit the patch via git send-email on Jan 28 to [email protected] <mailto:[email protected]> with subject "[PATCH] tpm: Add wolfTPM library support for TPM 2.0”. Can you check if you received it? Copy of the email is attached.



David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

Quoted 9 lines · Ilias Apalodimas

Hi,

Thanks for the followup. As Peter suggested, please submit it as a patch. Github might be fine for the development, but we do have an email based review system. Maintainers are already overloaded, so it's easier for us to follow the guidelines

Quoted 140 lines

Thanks
/Ilias

Quoted 136 lines · Peter Robinson

Hi David,

Quoted 1 line

We have made the U-Boot changes requested and attached a patch for upstream. Let me know if you have any issues or questions.

Please send the patch using 'git send-emaiil' or a similar tool.

Regards,
Peter

Quoted 126 lines

Fork: https://github.com/aidangarske/u-boot/tree/rpi4-wolftpm-uboot
Instructions: https://github.com/aidangarske/rpi4-wolftpm-uboot/tree/master



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

Quoted 113 lines · Aidan Garske

Hi Ilias,

Sounds good, I will keep them in cmd/wolftpm.c. I guess Simon can probably answer the other question the best. He had asked if I could "put the driver code into drivers/ with just the command code in cmd/" so I am just trying to get clarity on what driver code he is specifically referring to.

Thanks for the help,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 95 lines · On Tue, Aug 5, 2025 at 1:17 AM Ilias Apalodimas <[email protected]…

Hi Aidan,

Quoted 17 lines · On Sat, 2 Aug 2025 at 01:59, Aidan Garske <[email protected]…

Hi Simon and Ilias,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 7 lines
Quoted 6 lines · On Wed, Jul 30, 2025 at 8:40 AM Aidan Garske <[email protected]…

Hi Simon,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?

It's been a while and I am not sure I am following on that

Quoted 1 line
Quoted 1 line

2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Are you expecting it to be reusable by something else? If not just keep it to cmd/wolftpm.c

Thanks
/Ilias

Quoted 56 lines
Quoted 56 lines

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

Quoted 44 lines · On Sat, May 10, 2025 at 4:25 AM Simon Glass <[email protected]…

Hi David,

Quoted 10 lines · On Thu, 8 May 2025 at 00:41, David Garske <[email protected]…

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as WOLFTPM_SLB9672/3
- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon

Quoted 10 lines



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/> <https://www.wolfssl.com/>
https://github.com/wolfssl

From: Aidan Garske <[email protected]>

Add wolfTPM library integration to U-Boot, providing an alternative TPM 2.0 implementation with native API access and enhanced features.

wolfTPM is a portable, open-source TPM 2.0 library that provides:
- Native TPM 2.0 API with direct access to all TPM 2.0 commands
- Wrapper API for simplified common TPM operations
- Direct SPI communication via internal TIS layer
- Firmware update support for Infineon SLB9672/SLB9673 TPMs

The standard tpm2 commands (init, startup, self_test, pcr_read, pcr_extend, clear, etc.) work with any TPM 2.0 compliant module. Firmware update functionality is specific to Infineon SLB9672/SLB9673 TPMs only.

Key components added:
- cmd/wolftpm.c: TPM2 command implementation using wolfTPM APIs
- lib/wolftpm: wolfTPM library as git submodule
- drivers/spi/bcm2835_spi.c: BCM2835 SPI driver for Raspberry Pi 4
- drivers/tpm/tpm_spi_sandbox.c: TPM SPI sandbox driver for testing
- drivers/tpm/wolftpm_common.c: Common wolfTPM driver functions
- include/configs/user_settings.h: wolfTPM build configuration

Configuration options:
- CONFIG_TPM_WOLF: Enable wolfTPM support (mutually exclusive with CONFIG_CMD_TPM_V2)
- CONFIG_WOLFTPM_SLB9672: Enable Infineon SLB9672/SLB9673 firmware update support
- CONFIG_BCM2835_SPI: Enable BCM2835 SPI driver

Device tree updates for Raspberry Pi 4, QEMU arm64, and sandbox environments to support TPM over SPI.

Tested on Raspberry Pi 4 Model B with Infineon SLB9670 (LetsTrust HAT) and SLB9672 TPMs.

---
 .gitmodules                       |    3 +
 README                            |    3 +
 README.wolftpm.md                 |  149 +++
 arch/arm/dts/bcm2711-rpi-4-b.dts  |   20 +
 arch/arm/dts/qemu-arm64.dts       |    4 +
 arch/sandbox/dts/sandbox.dtsi     |   11 +
 cmd/Kconfig                       |   16 +
 cmd/Makefile                      |   11 +-
 cmd/tpm-common.c                  |    4 +-
 cmd/wolftpm.c                     | 1443 +++++++++++++++++++++++++++++
 configs/rpi_4_defconfig           |   29 +-
 doc/usage/cmd/wolftpm.rst         |  694 ++++++++++++++
 drivers/mtd/spi/sandbox.c         |   30 +-
 drivers/spi/Kconfig               |    9 +
 drivers/spi/Makefile              |    1 +
 drivers/spi/bcm2835_spi.c         |  429 +++++++++
 drivers/tpm/Kconfig               |   36 +
 drivers/tpm/Makefile              |    9 +
 drivers/tpm/tpm_spi_sandbox.c     |  410 ++++++++
 drivers/tpm/wolftpm_common.c      |  135 +++
 include/configs/user_settings.h   |  118 +++
 include/hash.h                    |   17 +
 include/linux/byteorder/generic.h |   31 +-
 include/tpm-common.h              |   22 +
 include/wolftpm.h                 |   33 +
 lib/Kconfig                       |   13 +
 lib/Makefile                      |   18 +
 lib/wolftpm                       |    1 +
 lib/wolftpm.c                     |   56 ++
 scripts/check-local-export        |    9 +
 test/cmd/Makefile                 |    1 +
 test/cmd/wolftpm.c                |  364 ++++++++
 test/py/tests/test_wolftpm.py     |  373 ++++++++
 33 files changed, 4483 insertions(+), 19 deletions(-)
 create mode 100644 .gitmodules
 create mode 100644 README.wolftpm.md
 create mode 100644 cmd/wolftpm.c
 create mode 100644 doc/usage/cmd/wolftpm.rst
 create mode 100644 drivers/spi/bcm2835_spi.c
 create mode 100644 drivers/tpm/tpm_spi_sandbox.c
 create mode 100644 drivers/tpm/wolftpm_common.c
 create mode 100644 include/configs/user_settings.h
 create mode 100644 include/wolftpm.h
 create mode 160000 lib/wolftpm
 create mode 100644 lib/wolftpm.c
 create mode 100644 test/cmd/wolftpm.c
 create mode 100644 test/py/tests/test_wolftpm.py
.gitmodules new file +3 -0
new file mode 100644
index 00000000000..3f95a7c3eb9
@@ -0,0 +1,3 @@
+[submodule "lib/wolftpm"]
+	path = lib/wolftpm
+	url = https://github.com/wolfssl/wolfTPM.git
README +3 -0
index 20a73bab802..b9bfe14a1c7 100644
@@ -361,6 +361,9 @@ The following options need to be configured:
 		CONFIG_TPM
 		Support TPM devices.
 
+		CONFIG_TPM_WOLF
+		Enables support for wolfTPM library.
+
 		CONFIG_TPM_TIS_INFINEON
 		Support for Infineon i2c bus TPM devices. Only one device
 		per system is supported at this time.
README.wolftpm.md new file +149 -0

149 lines not on this page · raw message

arch/arm/dts/bcm2711-rpi-4-b.dts +20 -0
index 72ce80fbf26..a09276dc279 100644
@@ -8,6 +8,11 @@
 	compatible = "raspberrypi,4-model-b", "brcm,bcm2711";
 	model = "Raspberry Pi 4 Model B";
 
+	/* Alias hardware SPI as spi0 so wolfTPM finds it at bus 0 */
+	aliases {
+		spi0 = &spi;
+	};
+
 	chosen {
 		/* 8250 auxiliary UART instead of pl011 */
 		stdout-path = "serial1:115200n8";
@@ -54,6 +59,21 @@
 		enable-active-high;
 		gpio = <&expgpio 6 GPIO_ACTIVE_HIGH>;
 	};
+
+};
+
+/* Hardware SPI with TPM - matches Linux tpm-slb9670 overlay */
+&spi {
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi0_gpio7>;
+
+	/* Infineon SLB9670/9672 TPM 2.0 on CE1 (GPIO7) */
+	tpm@1 {
+		compatible = "infineon,slb9670", "tcg,tpm_tis-spi";
+		reg = <1>;  /* CE1 */
+		spi-max-frequency = <32000000>;
+	};
 };
 
 &ddc0 {
arch/arm/dts/qemu-arm64.dts +4 -0
index 95fcf53ed74..e74d036a532 100644
@@ -12,4 +12,8 @@
 #endif
 
 / {
+	tpm@0c000000 {
+		compatible = "tcg,tpm-tis-mmio";
+		reg = <0x0 0x0c000000 0x0 0x5000>;
+	};
 };
arch/sandbox/dts/sandbox.dtsi +11 -0
index 02b03894eaf..2fdd7f0e942 100644
@@ -286,6 +286,17 @@
 			spi-max-frequency = <40000000>;
 			sandbox,filename = "spi.bin";
 		};
+
+		tpm_spi: tpm@1 {
+			reg = <1>;
+			compatible = "sandbox,tpm-spi";
+			spi-max-frequency = <10000000>;
+			sandbox,emul = <&tpm_spi_emul>;
+		};
+	};
+
+	tpm_spi_emul: tpm-spi-emul {
+		compatible = "sandbox,tpm-spi-emul";
 	};
 
 	spl-test {
cmd/Kconfig +16 -0
index cc4dd5a3163..3a4be20268e 100644
@@ -2814,6 +2814,9 @@ config CMD_TPM
 	  command requires a suitable TPM on your board and the correct driver
 	  must be enabled.
 
+	  Note: For TPM2, do not enable both CMD_TPM and CMD_WOLFTPM as they
+	  both provide the tpm2 command.
+
 if CMD_TPM
 
 config CMD_TPM_TEST
@@ -3194,4 +3197,17 @@ config CMD_SPAWN_NUM_JOBS
 	  When a jobs exits, its identifier is available to be re-used by the next
 	  spawn command.
 
+config CMD_WOLFTPM
+	bool "Enable wolfTPM tpm2 command (replaces standard tpm2)"
+	depends on TPM && TPM_V2
+	select TPM_WOLF
+	help
+	  This provides the 'tpm2' command using the wolfTPM library instead
+	  of the standard U-Boot TPM2 implementation. wolfTPM offers additional
+	  features including firmware update support for Infineon TPMs and
+	  enhanced capabilities reporting.
+
+	  Note: Do not enable both CMD_TPM and CMD_WOLFTPM as they both
+	  provide the tpm2 command.
+
 endif
cmd/Makefile +10 -1
index 4cd13d4fa6e..9c622e3d717 100644
@@ -191,9 +191,18 @@ obj-$(CONFIG_CMD_TIMER) += timer.o
 obj-$(CONFIG_CMD_TRACE) += trace.o
 obj-$(CONFIG_HUSH_PARSER) += test.o
 obj-$(CONFIG_CMD_TPM) += tpm-common.o
-obj-$(CONFIG_CMD_TPM_V1) += tpm-v1.o
 obj-$(CONFIG_CMD_TPM_TEST) += tpm_test.o
+ifeq ($(CONFIG_TPM_WOLF),y)
+ifeq ($(CONFIG_TPM_V2),y)
+ccflags-y += -Ilib/wolftpm \
+             -Iinclude/configs \
+             -DWOLFTPM_USER_SETTINGS
+obj-$(CONFIG_TPM_WOLF) += wolftpm.o
+endif
+else
+obj-$(CONFIG_CMD_TPM_V1) += tpm-v1.o
 obj-$(CONFIG_CMD_TPM_V2) += tpm-v2.o
+endif
 obj-$(CONFIG_CMD_CROS_EC) += cros_ec.o
 obj-$(CONFIG_CMD_UBI) += ubi.o
 obj-$(CONFIG_CMD_UBIFS) += ubifs.o
cmd/tpm-common.c +2 -2
index 1cd57f901b6..30e99e10758 100644
@@ -234,7 +234,7 @@ int type_string_write_vars(const char *type_str, u8 *data,
 	return 0;
 }
 
-static int tpm_show_device(void)
+int tpm_show_device(void)
 {
 	struct udevice *dev;
 	char buf[80];
@@ -253,7 +253,7 @@ static int tpm_show_device(void)
 	return 0;
 }
 
-static int tpm_set_device(unsigned long num)
+int tpm_set_device(unsigned long num)
 {
 	struct udevice *dev;
 	unsigned long n = 0;
cmd/wolftpm.c new file +1443 -0

1,443 lines not on this page · raw message

configs/rpi_4_defconfig +28 -1
index 8362242b97f..22280d9b70e 100644
@@ -69,4 +69,31 @@ CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_VIDEO_BCM2835=y
 CONFIG_CONSOLE_SCROLL_LINES=10
 CONFIG_PHYS_TO_BUS=y
-# CONFIG_HEXDUMP is not set
+# HEXDUMP enabled for unit tests
+
+# SPI support (hardware SPI - matches Linux tpm-slb9670 overlay)
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_BCM2835_SPI=y
+# CONFIG_SOFT_SPI is not set
+CONFIG_CMD_SPI=y
+
+# TPM and wolfTPM support
+CONFIG_TPM=y
+CONFIG_TPM_V2=y
+CONFIG_CMD_TPM=y
+CONFIG_TPM_WOLF=y
+# CONFIG_WOLFTPM_LINUX_DEV is not set
+CONFIG_WOLFTPM_SLB9672=y
+CONFIG_CMD_WOLFTPM=y
+
+# Logging (debug level to see log_debug output)
+CONFIG_LOG=y
+CONFIG_LOGLEVEL=7
+CONFIG_LOG_MAX_LEVEL=7
+CONFIG_LOG_DEFAULT_LEVEL=7
+
+# Unit testing support
+CONFIG_UNIT_TEST=y
+CONFIG_CONSOLE_RECORD=y
+CONFIG_HEXDUMP=y
doc/usage/cmd/wolftpm.rst new file +694 -0

694 lines not on this page · raw message

drivers/mtd/spi/sandbox.c +21 -9
index e5ebc3479fb..41bd07817aa 100644
@@ -571,16 +571,28 @@ int sandbox_spi_get_emul(struct sandbox_state *state,
 
 	info = &state->spi[busnum][cs];
 	if (!info->emul) {
-		/* Use the same device tree node as the SPI flash device */
-		debug("%s: busnum=%u, cs=%u: binding SPI flash emulation: ",
-		      __func__, busnum, cs);
-		ret = sandbox_sf_bind_emul(state, busnum, cs, bus,
-					   dev_ofnode(slave), slave->name);
-		if (ret) {
-			debug("failed (err=%d)\n", ret);
-			return ret;
+		struct udevice *emul;
+		ofnode node = dev_ofnode(slave);
+
+		/* First check for sandbox,emul phandle property */
+		ret = uclass_get_device_by_phandle(UCLASS_SPI_EMUL, slave,
+						   "sandbox,emul", &emul);
+		if (!ret) {
+			debug("%s: busnum=%u, cs=%u: using phandle emulator\n",
+			      __func__, busnum, cs);
+			info->emul = emul;
+		} else {
+			/* Fall back to SPI flash emulation binding */
+			debug("%s: busnum=%u, cs=%u: binding SPI flash emulation: ",
+			      __func__, busnum, cs);
+			ret = sandbox_sf_bind_emul(state, busnum, cs, bus,
+						   node, slave->name);
+			if (ret) {
+				debug("failed (err=%d)\n", ret);
+				return ret;
+			}
+			debug("OK\n");
 		}
-		debug("OK\n");
 	}
 	*emulp = info->emul;
 
drivers/spi/Kconfig +9 -0
index 8c6c095a8cf..9625b1e073e 100644
@@ -117,6 +117,15 @@ config ATMEL_SPI
 	  many AT91 (ARM) chips. This driver can be used to access
 	  the SPI Flash, such as AT25DF321.
 
+config BCM2835_SPI
+	bool "BCM2835/BCM2711 SPI driver"
+	depends on ARCH_BCM283X
+	help
+	  Enable the BCM2835/BCM2711 SPI controller driver. This driver
+	  can be used to access SPI devices on Raspberry Pi boards
+	  including Pi 3 and Pi 4. It uses the hardware SPI controller
+	  rather than GPIO bit-banging.
+
 config BCM63XX_HSSPI
 	bool "BCM63XX HSSPI driver"
 	depends on (ARCH_BMIPS || ARCH_BCMBCA)
drivers/spi/Makefile +1 -0
index 0dc2d23e172..47a1c6194b1 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_APPLE_SPI) += apple_spi.o
 obj-$(CONFIG_ATH79_SPI) += ath79_spi.o
 obj-$(CONFIG_ATMEL_QSPI) += atmel-quadspi.o
 obj-$(CONFIG_ATMEL_SPI) += atmel_spi.o
+obj-$(CONFIG_BCM2835_SPI) += bcm2835_spi.o
 obj-$(CONFIG_BCM63XX_HSSPI) += bcm63xx_hsspi.o
 obj-$(CONFIG_BCMBCA_HSSPI) += bcmbca_hsspi.o
 obj-$(CONFIG_BCM63XX_SPI) += bcm63xx_spi.o
drivers/spi/bcm2835_spi.c new file +429 -0

429 lines not on this page · raw message

drivers/tpm/Kconfig +36 -0
index 219ea606b50..d4694946b94 100644
@@ -158,6 +158,14 @@ config TPM2_TIS_SANDBOX
 	  such as basic configuration, PCR extension and PCR read. Extended
 	  functionalities are not implemented.
 
+config TPM2_SPI_SANDBOX
+	bool "Enable sandbox TPM SPI emulator"
+	depends on TPM_V2 && SANDBOX && DM_SPI
+	help
+	  This driver emulates a TPM connected via SPI for sandbox testing.
+	  It implements the TPM TIS SPI protocol and can be used to test
+	  wolfTPM SPI HAL code without physical hardware.
+
 config TPM2_TIS_SPI
 	bool "Enable support for TPMv2.x SPI chips"
 	depends on TPM_V2 && DM_SPI
@@ -200,6 +208,34 @@ config TPM2_EVENT_LOG_SIZE
 	  allocated twice. One for the eventlog it self and one for the
 	  configuration table that is required from the TCG2 spec
 
+config WOLFTPM_LINUX_DEV
+    bool "Use device-level TPM interface (bypass wolfTPM TIS layer)"
+    depends on TPM_V2 && TPM_WOLF
+    default y
+    help
+      Enable wolfTPM to use the underlying TPM driver instead of its own
+      TIS (TPM Interface Specification) layer. On U-Boot, this uses the
+      U-Boot TPM driver model (tpm_xfer). On Linux, this uses /dev/tpm0.
+      This is the recommended setting for U-Boot.
+
+config WOLFTPM_SLB9672
+    bool "Enable support for Infineon SLB9672 TPM"
+    depends on TPM_V2 && TPM_WOLF
+    help
+      Enable support for Infineon SLB9672 TPM features in wolfTPM.
+
+config WOLFTPM_SLB9673
+    bool "Enable support for Infineon SLB9673 TPM"
+    depends on TPM_V2 && TPM_WOLF
+    help
+      Enable support for Infineon SLB9673 TPM features in wolfTPM.
+
+config WOLFTPM_FIRMWARE_UPGRADE
+    bool "Enable firmware upgrade support for wolfTPM"
+    depends on TPM_V2 && TPM_WOLF
+    help
+      Enable support for Infineon TPM firmware upgrade commands in wolfTPM.
+
 endif # TPM_V2
 
 endmenu
drivers/tpm/Makefile +9 -0
index b83ce703ec0..39de454cacf 100644
@@ -10,7 +10,16 @@ obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o sandbox_common.o
 
 obj-$(CONFIG_$(PHASE_)TPM2_CR50_I2C) += cr50_i2c.o
 obj-$(CONFIG_TPM2_TIS_SANDBOX) += tpm2_tis_sandbox.o sandbox_common.o
+obj-$(CONFIG_TPM2_SPI_SANDBOX) += tpm_spi_sandbox.o
 obj-$(CONFIG_TPM2_TIS_SPI) += tpm2_tis_core.o tpm2_tis_spi.o
 obj-$(CONFIG_TPM2_TIS_I2C) += tpm2_tis_core.o tpm2_tis_i2c.o
 obj-$(CONFIG_TPM2_FTPM_TEE) += tpm2_ftpm_tee.o
 obj-$(CONFIG_TPM2_MMIO) += tpm2_tis_core.o tpm2_tis_mmio.o
+
+# wolfTPM helper functions
+ifeq ($(CONFIG_TPM_WOLF),y)
+ccflags-y += -Ilib/wolftpm \
+             -Iinclude/configs \
+             -DWOLFTPM_USER_SETTINGS
+obj-y += wolftpm_common.o
+endif
drivers/tpm/tpm_spi_sandbox.c new file +410 -0

410 lines not on this page · raw message

drivers/tpm/wolftpm_common.c new file +135 -0

135 lines not on this page · raw message

include/configs/user_settings.h new file +118 -0

118 lines not on this page · raw message

include/hash.h +17 -0
index 8b3f79ec473..242de9f0e84 100644

Lines of this file are not shown. View the raw message.

include/linux/byteorder/generic.h +25 -6
index bee0ff60336..def601eed2b 100644

Lines of this file are not shown. View the raw message.

include/tpm-common.h +22 -0
index bfb84a931d1..1ea4463fbbe 100644

Lines of this file are not shown. View the raw message.

include/wolftpm.h new file +33 -0
new file mode 100644
index 00000000000..dfa8af327f4

Lines of this file are not shown. View the raw message.

lib/Kconfig +13 -0
index 931d5206936..24477ea53c9 100644

Lines of this file are not shown. View the raw message.

lib/Makefile +18 -0
index 70667f3728c..ba3a9e85c11 100644

Lines of this file are not shown. View the raw message.

lib/wolftpm new file +1 -0
new file mode 160000
index 00000000000..19559386121

Lines of this file are not shown. View the raw message.

lib/wolftpm.c new file +56 -0

56 lines not on this page · raw message

scripts/check-local-export +9 -0
index 6ccc2f46741..ce520772866 100755

Lines of this file are not shown. View the raw message.

test/cmd/Makefile +1 -0
index 2476068aee6..08fbc31a06a 100644

Lines of this file are not shown. View the raw message.

test/cmd/wolftpm.c new file +364 -0

364 lines not on this page · raw message

test/py/tests/test_wolftpm.py new file +373 -0

373 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.0

Part of the diff is not shown here. View the raw message.

#17 lore raw

Hi David,

Quoted 4 lines · David Garske

Hi Ilias,

Thanks for your reply. I did submit the patch via git send-email on Jan 28 to [email protected] with subject "[PATCH] tpm: Add wolfTPM library support for TPM 2.0”. Can you check if you received it? Copy of the email is attached.

I haven't and i can't find it on
https://lore.kernel.org/u-boot/?q=Add+wolfTPM+ either. Any chance git failed to send it?

Thanks
/Ilias

Quoted 168 lines

David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On Feb 11, 2026, at 2:24 AM, Ilias Apalodimas <[email protected]> wrote:

Hi,

Thanks for the followup. As Peter suggested, please submit it as a patch. Github might be fine for the development, but we do have an email based review system. Maintainers are already overloaded, so it's easier for us to follow the guidelines

Thanks
/Ilias

On Wed, 28 Jan 2026 at 06:26, Peter Robinson <[email protected]> wrote:

Hi David,

We have made the U-Boot changes requested and attached a patch for upstream. Let me know if you have any issues or questions.

Please send the patch using 'git send-emaiil' or a similar tool.

Regards,
Peter

Fork: https://github.com/aidangarske/u-boot/tree/rpi4-wolftpm-uboot
Instructions: https://github.com/aidangarske/rpi4-wolftpm-uboot/tree/master



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

On Aug 5, 2025, at 8:31 AM, Aidan Garske <[email protected]> wrote:

Hi Ilias,

Sounds good, I will keep them in cmd/wolftpm.c. I guess Simon can probably answer the other question the best. He had asked if I could "put the driver code into drivers/ with just the command code in cmd/" so I am just trying to get clarity on what driver code he is specifically referring to.

Thanks for the help,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

On Tue, Aug 5, 2025 at 1:17 AM Ilias Apalodimas <[email protected] <mailto:[email protected]>> wrote:

Hi Aidan,

On Sat, 2 Aug 2025 at 01:59, Aidan Garske <[email protected] <mailto:[email protected]>> wrote:

Hi Simon and Ilias,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?
2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

On Wed, Jul 30, 2025 at 8:40 AM Aidan Garske <[email protected] <mailto:[email protected]>> wrote:

Hi Simon,

Thank you for the great feedback. Currently I am working in the refactor you suggested and I wanted to ask a question about some of your comments.

1. What exactly is the "driver code" you are referring to in this case?

It's been a while and I am not sure I am following on that

2. Do you want me to separate out our helper functions into a cmd/wolftpm-common.c or should I keep them in cmd/wolftpm.c?

Are you expecting it to be reusable by something else? If not just keep it to cmd/wolftpm.c

Thanks
/Ilias

Looking forward to your response,
Aidan
-------------------------------------
Aidan Garske
Engineering Intern, wolfSSL
+1 (916) 337-1246
-------------------------------------

On Sat, May 10, 2025 at 4:25 AM Simon Glass <[email protected] <mailto:[email protected]>> wrote:

Hi David,

On Thu, 8 May 2025 at 00:41, David Garske <[email protected] <mailto:[email protected]>> wrote:

Hi Denx,

We at wolfSSL have developed a port for wolfTPM in U-Boot. The patch allows using the current built-in TPM 2.0 support or switching to wolfTPM via CONFIG_TPM_WOLF=y. It also supports TPM 2.0 firmware update for the Infineon SLB9672 and SLB9673.

I think there is probably some more cleanup and testing needed, but I wanted to submit this to start the discussion and see your thoughts.

The wolfTPM library is GPLv2 and added as a submodule. If the license or submodule is an issue let’s discuss! I’m positive we can resolve anything.

Attached is the patch based on latest master 3b6760ddeb4 to review.

Thank you for doing this!

Here are a few thoughts:

- Use lower case for function names
- Avoid camel case
- What is XMEMSET()? - Can you use memset() ?
- Convert most prinf() functions to log_debug()
- Can you use subcommands (from command.h) instead of parsing the subcommand yourself?
- put the FIRMWARE_UPGRADE thing into Kconfig, as well as WOLFTPM_SLB9672/3
- put the driver code into drivers/ with just the command code in cmd/
- add config WOLFTPM, separate from CMD_WOLFTPM
- can you add a test in test/ and docs in doc/usage/cmd/ ?

Regards,
Simon



Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/> <https://www.wolfssl.com/>
https://github.com/wolfssl

#18 lore raw
Quoted 11 lines · Ilias Apalodimas

Hi David,

Quoted 4 lines · David Garske

Hi Ilias,

Thanks for your reply. I did submit the patch via git send-email on Jan 28 to [email protected] with subject "[PATCH] tpm: Add wolfTPM library support for TPM 2.0”. Can you check if you received it? Copy of the email is attached.

I haven't and i can't find it on
https://lore.kernel.org/u-boot/?q=Add+wolfTPM+ either. Any chance git failed to send it?

It's:
https://lore.kernel.org/u-boot/[email protected]/

Signature · 1 line
Tom
#19 lore raw

Hi Ilias,

Can you confirm that the patch was received correctly? It appears it was based on the link Tom shared. Let me know if you have any feedback.

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com <https://www.wolfssl.com/>
https://github.com/wolfssl

Quoted 21 lines · Tom Rini
Quoted 11 lines · Ilias Apalodimas

Hi David,

Quoted 4 lines · David Garske

Hi Ilias,

Thanks for your reply. I did submit the patch via git send-email on Jan 28 to [email protected] with subject "[PATCH] tpm: Add wolfTPM library support for TPM 2.0”. Can you check if you received it? Copy of the email is attached.

I haven't and i can't find it on
https://lore.kernel.org/u-boot/?q=Add+wolfTPM+ either. Any chance git failed to send it?

It's:
https://lore.kernel.org/u-boot/[email protected]/

Signature · 1 line
Tom
#20 lore raw
Quoted 4 lines · David Garske

Hi Ilias,

Can you confirm that the patch was received correctly? It appears it was based on the link Tom shared. Let me know if you have any feedback.

Yes I found it in my patchwork now. I'll try having a look by the end of the week

Regards
/Ilias

Quoted 34 lines

Thanks,
David Garske
Software Engineer, wolfSSL
+1 (530) 409-2990
https://www.wolfssl.com
https://github.com/wolfssl

On Feb 12, 2026, at 11:46 AM, Tom Rini <[email protected]> wrote:

On Thu, Feb 12, 2026 at 02:58:19PM +0200, Ilias Apalodimas wrote:

Hi David,

On Thu, 12 Feb 2026 at 04:11, David Garske <[email protected]> wrote:

Hi Ilias,

Thanks for your reply. I did submit the patch via git send-email on Jan 28 to [email protected] with subject "[PATCH] tpm: Add wolfTPM library support for TPM 2.0”. Can you check if you received it? Copy of the email is attached.

I haven't and i can't find it on
https://lore.kernel.org/u-boot/?q=Add+wolfTPM+ either. Any chance git failed to send it?

It's:
https://lore.kernel.org/u-boot/[email protected]/

--
Tom