tpm: Add wolfTPM library support for TPM 2.0
Subsystems (6)
v4 cover tpm: Add wolfTPM library support for TPM 2.0
Hi all,
This is v4 of the wolfTPM TPM 2.0 stack integration for U-Boot.
What this series does
---------------------
wolfTPM (https://github.com/wolfSSL/wolfTPM) is a portable TPM 2.0 library that provides a full TPM 2.0 command set, an SPI/MMIO HAL, and firmware-update support for Infineon SLB9672/SLB9673 hardware. This series wires it into U-Boot as an *optional* alternative backend behind the existing 'tpm2' command, plus the supporting infrastructure to make it run on QEMU+swtpm, sandbox, and real Raspberry Pi 4 + Infineon SLB9672 hardware.
Why a second TPM backend
------------------------
U-Boot already has a working TPM 2.0 stack and Peter Robinson asked in v3 review what value this brings. The honest answer is:
1. Firmware update support for Infineon SLB9672/SLB9673. The existing U-Boot TPM 2.0 stack has no firmware-update command; wolfTPM provides the manifest+image flashing flow used by Infineon's recovery / security-patch tooling. This is the primary "why now" reason for boards shipping Infineon TPM HATs where the field-updatable firmware is part of the supported lifecycle.
2. Optional native SPI HAL. The wolfTPM library can talk to a TPM via either (a) U-Boot's existing TPM driver model (the WOLFTPM_LINUX_DEV path; this is what QEMU+swtpm uses in this series) or (b) its own SPI HAL bypassing driver model. Path (b) is what lets the BCM2835/BCM2711 driver in patch 3 talk straight to the Infineon HAT on a stock Pi 4 without needing the broader TPM uclass machinery.
3. Backend selection is a Kconfig switch; CONFIG_TPM_WOLF is default-off and 'tpm2' continues to dispatch to the existing backend unless the user opts in. No defconfig in tree turns this on today except the new rpi_4_wolftpm one this series adds.
Maintenance
-----------
wolfTPM is imported as a git subtree under lib/wolftpm (mirroring how lib/mbedtls, lib/lwip and dts/upstream are maintained in tree), and tools/update-subtree.sh knows about it. Updates flow through the standard git subtree pull path, not as separate patches.
Note on license: github.com/wolfSSL/wolfTPM currently shows GPL-3.0 in its repo badge. wolfSSL is working on a GPLv2-compatible release for upstreaming purposes; this series is being sent now to get review on the integration shape, with the understanding that the license question is being addressed separately by wolfSSL before this is appropriate to merge. I will follow up on the list when that's resolved.
Changes since v3
----------------
Addressing review from Peter Robinson on v3:
- SPI driver copyright attribution fixed to credit the original Linux kernel authors (Chris Boot, Stephen Warren, Martin Sperl) the U-Boot driver is ported from. The driver is still in this series rather than split off, because nothing else in the tree uses it yet and decoupling it would just create a "blocked on" dependency chain; if reviewers prefer it split, happy to do that in v5.
- rpi_4_defconfig is no longer modified. v3 added CONFIG_LOG / LOGLEVEL=7 / UNIT_TEST / CONSOLE_RECORD / HEXDUMP to it - that was wrong, it's not what the average RPi user wants. Instead, v4 adds a *new* rpi_4_wolftpm_defconfig that enables only the bits a wolfTPM user actually needs (SPI + TPM + wolfTPM). No debug / unit-test pollution. Users who don't want wolfTPM continue to use rpi_4_defconfig untouched.
- The TPM device-tree node for the SLB9670/9672 on RPi 4 has been moved out of bcm2711-rpi-4-b.dts (which is Linux-derived and should match upstream) and into bcm2711-rpi-4-b-u-boot.dtsi (which is the U-Boot convention for U-Boot-only DT additions). This means SystemReady firmware-provided FDTs and the upstream Linux DT are no longer polluted by this series.
- DT changes are now split into three per-device commits (RPi4, QEMU arm64, sandbox) instead of one combined commit.
- Commit messages rewritten to explain *why* the change is being made, not just *what* configs are set.
Branch
------
Full 16-commit history (including the subtree squash + merge that aren't sent to the list because they're too large / are a merge):
https://github.com/aidangarske/u-boot wolftpm-v4-patches
Or pull the wolfTPM source straight from
https://github.com/wolfssl/wolfTPM @ 664db130d57.
Testing
-------
- QEMU arm64 + swtpm Python test framework ./test/py/test.py --bd qemu_arm64 \
-k "test_wolftpm and not ut_cmd"
matches v3: 19 passed, 2 skipped. (The 2 skipped are test_wolftpm_change_auth, which requires wolfCrypt, and test_wolftpm_get_capability.)
- rpi_4_defconfig (unmodified vanilla path) still builds clean.
- rpi_4_wolftpm_defconfig builds clean, TPM node is present in the compiled bcm2711-rpi-4-b.dtb at /soc/spi@7e204000/tpm@1 with compatible "infineon,slb9670", "tcg,tpm_tis-spi".
- Real Raspberry Pi 4 + Infineon SLB9672 hardware: tpm2 autostart / info / get_capability / pcr_read / pcr_extend / caps / clear all return expected output; firmware-update path verified.
v3 thread:
https://lore.kernel.org/u-boot/?q=PATCH+v3+tpm+wolfTPM
Aidan Garske (14):
tpm: export tpm_show_device, tpm_set_device, and get_tpm include/hash: add SHA384 hash wrapper declaration for wolfTPM
spi: add BCM2835/BCM2711 hardware SPI controller driver
arm: dts: bcm2711-rpi-4-b: add Infineon SLB9670/9672 TPM in U-Boot dtsi
arm: dts: qemu-arm64: add TPM TIS MMIO node
sandbox: dts: add TPM SPI emulator node
tpm: add wolfTPM build rules and Kconfig
tpm: add wolfTPM headers and SHA384 glue code
tpm: add wolfTPM driver helpers and Kconfig options
cmd: refactor tpm2 command into frontend/backend architecture
tpm: add sandbox TPM SPI emulator
test: add wolfTPM C unit tests and Python integration tests
doc: add wolfTPM documentation
configs: add rpi_4_wolftpm_defconfig
--
2.47.3
PATCH v4 1/14 tpm: export tpm_show_device, tpm_set_device, and get_tpm
From: Aidan <[email protected]>
Remove static scope from tpm_show_device(), tpm_set_device(), and get_tpm() in cmd/tpm-common.c so they can be called from other translation units. Add corresponding declarations to include/tpm-common.h.
wolfTPM's command backend needs these functions for device enumeration and selection when operating through U-Boot's driver model.
--- cmd/tpm-common.c | 4 ++-- include/tpm-common.h | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
cmd/tpm-common.c +2 -2
@@ -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 ;
include/tpm-common.h +22 -0
@@ -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 */
Signature · 1 line
2.49.0
Re: [PATCH v4 01/14] tpm: export tpm_show_device, tpm_set_device, and get_tpm
Hi Aidan,
Quoted 18 lines · Aidan Garske
tpm: export
tpm_show_device,tpm_set_device, andget_tpmRemove static scope from
tpm_show_device(),tpm_set_device(), andget_tpm()incmd/tpm-common.cso they can be called from other translation units. Add corresponding declarations toinclude/tpm-common.h.wolfTPM's command backend needs these functions for device enumeration and selection when operating through U-Boot's driver model.
Signed-off-by Aidan Garske <[email protected]>
cmd/tpm-common.c| 4 ++--include/tpm-common.h | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
cmd/tpm-common.c int type_string_write_vars(const char *type_str, u8 *data, · line 237
Quoted 5 lines
cmd/tpm-common.c +1
-1@@ -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 )
These three helpers live in cmd/ and operate on a static tpm_dev private to the command layer. Promoting them so a backend in lib/ or drivers/ can call into cmd/ is the wrong direction. If the wolfTPM backend genuinely needs shared 'currently selected TPM' state, please move that state and these helpers into the TPM uclass and have cmd/tpm-common.c call into them, not the other way round.
Quoted 13 lines
include/tpm-common.h +11
-0@@ -337,4 +337,26 @@ enum tpm_version tpm_get_version(struct udevice *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
include/tpm-common.h enum tpm_version tpm_get_version(struct udevice *dev); · line 357
Quoted 10 lines
include/tpm-common.h +10
-0+* 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);
The kerneldoc is wrong. tpm_set_device() and get_tpm() return CMD_RET_FAILURE (1, positive), not -ve. tpm_show_device() ignores per-device errors and unconditionally returns 0. Either document accurately, or make tpm_show_device() propagate the failure from tpm_get_desc().
If these become public API, please also fix the return convention to use proper negative errnos (CMD_RET_* is a command-layer thing) and rename get_tpm() - tpm_get_device() or similar. get_tpm() is too generic for a global symbol.
Also, @devp is undocumented. Please add an entry for it, and note that the function selects device 0 the first time it is called.
Regards,
Simon
PATCH v4 2/14 include/hash: add SHA384 hash wrapper declaration for wolfTPM
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add #include <linux/types.h> to include/hash.h so that basic types (u8, u32, etc.) are available to all includers.
Add a wc_Sha384Hash() wrapper declaration in include/hash.h, gated by WOLFTPM2_NO_WOLFCRYPT. When wolfTPM is built without wolfCrypt, this wrapper provides SHA-384 hashing via U-Boot's hash subsystem, which is needed for Infineon TPM firmware update manifest validation.
--- include/hash.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
include/hash.h +18 -0
@@ -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,20 @@ 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
Signature · 1 line
2.49.0
PATCH v4 3/14 spi: add BCM2835/BCM2711 hardware SPI controller driver
In reply to Aidan GarskeFrom: Aidan <[email protected]>
The BCM2835/BCM2711 SoC on Raspberry Pi 3/4 has no in-tree U-Boot driver for its hardware SPI0 controller; existing U-Boot work with SPI peripherals on these boards has to fall back to GPIO bit-banging via spi-gpio. That fallback is functional but slow (a few hundred kHz versus the 32 MHz the controller supports), and for protocols like the Infineon SLB9670 / SLB9672 TPM 2.0 TIS interface it makes early-boot operations (startup, self-test, PCR extend) noticeably sluggish.
Port the Linux kernel driver drivers/spi/spi-bcm2835.c into U-Boot so existing device-tree nodes using the "brcm,bcm2835-spi" / "brcm,bcm2711-spi" compatible work out of the box. The port keeps the same register layout and software-GPIO chip-select scheme the Linux driver already uses, which is necessary to work around the BCM2835 SPI block's CS auto-deassert behaviour - that behaviour corrupts multi-byte TPM TIS transactions when hardware CS is left enabled.
Notable deltas from the Linux driver:
- DMA, interrupt and slave-mode paths are removed; the U-Boot xfer is a synchronous polled loop, which is appropriate for the pre-OS context.
- U-Boot driver-model glue replaces the Linux spi_controller bookkeeping.
- VideoCore 0x7E000000 peripheral addresses present in the BCM2711 device tree are translated to the ARM-visible 0xFE000000 base.
The first user is the wolfTPM integration on rpi_4_wolftpm_defconfig with an Infineon SLB9672 TPM HAT, but the driver is not TPM-specific and any DM_SPI consumer (SPI-NOR flash, SPI EEPROM, etc.) will work the same way.
Copyright on the ported portions remains with the original Linux authors (Chris Boot, Stephen Warren, Martin Sperl).
--- drivers/spi/Kconfig | 9 + drivers/spi/Makefile | 1 + drivers/spi/bcm2835_spi.c | 440 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 450 insertions(+) create mode 100644 drivers/spi/bcm2835_spi.c
drivers/spi/Kconfig +9 -0
@@ -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
@@ -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 +440 -0
440 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH v4 03/14] spi: add BCM2835/BCM2711 hardware SPI controller driver
Hi Aidan,
Quoted 29 lines · Aidan Garske
spi: add BCM2835/BCM2711 hardware SPI controller driver
The BCM2835/BCM2711 SoC on Raspberry Pi 3/4 has no in-tree U-Boot driver for its hardware SPI0 controller; existing U-Boot work with SPI peripherals on these boards has to fall back to GPIO bit-banging via spi-gpio. That fallback is functional but slow (a few hundred kHz versus the 32 MHz the controller supports), and for protocols like the Infineon SLB9670 / SLB9672 TPM 2.0 TIS interface it makes early-boot operations (startup, self-test, PCR extend) noticeably sluggish.
Port the Linux kernel driver
drivers/spi/spi-bcm2835.cinto U-Boot so existing device-tree nodes using the 'brcm,bcm2835-spi' / 'brcm,bcm2711-spi' compatible work out of the box. The port keeps the same register layout and software-GPIO chip-select scheme the Linux driver already uses, which is necessary to work around the BCM2835 SPI block's CS auto-deassert behaviour - that behaviour corrupts multi-byte TPM TIS transactions when hardware CS is left enabled.[...]
drivers/spi/Kconfig| 9 +drivers/spi/Makefile | 1 + drivers/spi/bcm2835_spi.c | 440 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 450 insertions(+)
drivers/spi/bcm2835_spi.c line 7
Quoted 7 lines
drivers/spi/bcm2835_spi.c +7
-0@@ -0,0 +1,440 @@ +/* TPM Reset via GPIO4 and GPIO24 */ +static void bcm2835_spi_tpm_reset (void ) +{ +void __iomem *gpio_base = (void __iomem *)0xFE200000 ; +u32 val; + +/* Set GPIO4 as output (GPFSEL0, bits 14:12) */
The GPIO base should come from the devicetree and more generally, access to it should be via a GPIO driver. Please use lower-case hex.
This should not be in a generic SPI controller driver, and it contradicts the commit message claim that the driver is not TPM-specific. Any board that probes this driver currently pulses GPIO4 and GPIO24 low for 100 ms - what if something is wired to those pins? TPM reset belongs in the TPM driver (perhaps with a gpio-reset in the DT node for the TPM).
drivers/spi/bcm2835_spi.c line 2
Quoted 4 lines
drivers/spi/bcm2835_spi.c +2
-0@@ -0,0 +1,440 @@ +/* GPIO base for software CS control */ +static void __iomem *g_gpio_base = (void __iomem *)0xFE200000 ;
This is BCM2711-only, so BCM2835 (Pi 3, which the Kconfig help and commit subject both advertise) has its GPIO block at 0x3f200000, so the driver will silently corrupt unrelated memory there. Anyway, U-Boot already has pinctrl (pinctrl-bcm283x.c) and GPIO (bcm2835_gpio.c) drivers for this SoC; please go through those.
drivers/spi/bcm2835_spi.c line 10
Quoted 12 lines
drivers/spi/bcm2835_spi.c +10
-0@@ -0,0 +1,440 @@ +/* Try to get CS GPIO from device tree */ + ret =gpio_request_by_name (bus,'cs-gpios' ,0 , &priv->cs_gpio, +GPIOD_IS_OUT |GPIOD_ACTIVE_LOW ); +if (!ret) { + priv->cs_gpio_valid =1 ; +/* Deassert CS initially */ +dm_gpio_set_value (&priv->cs_gpio,1 ); + }else { + priv->cs_gpio_valid =0 ; + }
priv->cs_gpio and priv->cs_gpio_valid are written here but never read
- bcm2835_spi_xfer() instead does
int cs_pin = (cs == 0) ? 8 : 7;
and pokes GPSET0/GPCLR0 directly, ignoring the DT. Either honour cs-gpios via dm_gpio_set_value() (the normal U-Boot pattern, which DM_SPI_GPIO already handles generically), or drop the cs_gpio request and document that the driver hardcodes the Pi SPI0 CE0/CE1 pin assignment. As written it's half of each.
drivers/spi/bcm2835_spi.c line 10
Quoted 12 lines
drivers/spi/bcm2835_spi.c +10
-0@@ -0,0 +1,440 @@ +struct bcm2835_spi_priv { +void __iomem *regs; +u32 clk_hz; +u32 cs_reg;/* Cached CS register value */ +u32 speed_hz; +u8 mode; +struct gpio_desc cs_gpio; +int cs_gpio_valid; +int cs_asserted;/* Track if CS should stay asserted between transfers */ +};
cs_asserted is assigned in three places in xfer() but never read. Please remove it (and the comment that promises behaviour it does not implement).
drivers/spi/bcm2835_spi.c line 2
Quoted 4 lines
drivers/spi/bcm2835_spi.c +2
-0@@ -0,0 +1,440 @@ +/* Default clock rate - 250 MHz for Pi 4 */ +#define BCM2835_SPI_DEFAULT_CLK 250000000
This is the SPI core/source clock, not a default transfer rate - the default transfer speed is 1 MHz below. The name is confusing. More importantly, on BCM2835 vs BCM2711 vs different VPU clock settings this number is not constant; please pull it from the clk uclass (or from clock-frequency in DT, which you already read, with no hard-coded fallback).
drivers/spi/bcm2835_spi.c line 5
Quoted 7 lines
drivers/spi/bcm2835_spi.c +5
-0@@ -0,0 +1,440 @@ +static inline void bcm2835_spi_writel (struct bcm2835_spi_priv *priv, +u32 reg,u32 val) +{ +writel (val, priv->regs + reg); +}
Please check indent for tab-alignment. Patman or checkpatch will flag these.
drivers/spi/bcm2835_spi.c line 3
Quoted 5 lines
drivers/spi/bcm2835_spi.c +3
-0@@ -0,0 +1,440 @@ +/* Poll for completion - transfer byte by byte */ + timeout =100000 ; +while ((tx_count < len || rx_count < len) && timeout >0 ) {
The 100000 and 10000 timeouts are bare loop counters, not time bounds so at 1 MHz a 4 KB transfer takes ~32 ms and the loop body has no fixed cost, so these mean nothing except 'don't hang forever'. Please convert to get_timer() / timer_get_us(), the way other DM_SPI drivers do, so the timeout is independent of CPU speed and transfer length.
drivers/spi/bcm2835_spi.c line 3
Quoted 5 lines
drivers/spi/bcm2835_spi.c +3
-0@@ -0,0 +1,440 @@ +config BCM2835_SPI + bool "BCM2835/BCM2711 SPI driver" + depends onARCH_BCM283X
Given the hard-coded 0xfe200000 GPIO base and the BCM2711-only fix-up in of_to_plat(), the BCM2835 half of this option is not actually supported. Either fix the driver to derive the GPIO base from DT / from the existing bcm2835_gpio driver and exercise it on a Pi 3, or narrow the Kconfig text and commit subject to say BCM2711 only.
Regards,
Simon
Re: [PATCH v4 03/14] spi: add BCM2835/BCM2711 hardware SPI controller driver
Quoted 137 lines · Simon Glass
Hi Aidan,
Quoted 29 lines · Aidan Garske
spi: add BCM2835/BCM2711 hardware SPI controller driver
The BCM2835/BCM2711 SoC on Raspberry Pi 3/4 has no in-tree U-Boot driver for its hardware SPI0 controller; existing U-Boot work with SPI peripherals on these boards has to fall back to GPIO bit-banging via spi-gpio. That fallback is functional but slow (a few hundred kHz versus the 32 MHz the controller supports), and for protocols like the Infineon SLB9670 / SLB9672 TPM 2.0 TIS interface it makes early-boot operations (startup, self-test, PCR extend) noticeably sluggish.
Port the Linux kernel driver
drivers/spi/spi-bcm2835.cinto U-Boot so existing device-tree nodes using the 'brcm,bcm2835-spi' / 'brcm,bcm2711-spi' compatible work out of the box. The port keeps the same register layout and software-GPIO chip-select scheme the Linux driver already uses, which is necessary to work around the BCM2835 SPI block's CS auto-deassert behaviour - that behaviour corrupts multi-byte TPM TIS transactions when hardware CS is left enabled.[...]
drivers/spi/Kconfig| 9 +drivers/spi/Makefile | 1 + drivers/spi/bcm2835_spi.c | 440 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 450 insertions(+)drivers/spi/bcm2835_spi.c line 7
Quoted 7 lines
drivers/spi/bcm2835_spi.c +7
-0@@ -0,0 +1,440 @@ +/* TPM Reset via GPIO4 and GPIO24 */ +static void bcm2835_spi_tpm_reset (void ) +{ +void __iomem *gpio_base = (void __iomem *)0xFE200000 ; +u32 val; + +/* Set GPIO4 as output (GPFSEL0, bits 14:12) */ The GPIO base should come from the devicetree and more generally, access to it should be via a GPIO driver. Please use lower-case hex.
This should not be in a generic SPI controller driver, and it contradicts the commit message claim that the driver is not TPM-specific. Any board that probes this driver currently pulses GPIO4 and GPIO24 low for 100 ms - what if something is wired to those pins? TPM reset belongs in the TPM driver (perhaps with a gpio-reset in the DT node for the TPM).
drivers/spi/bcm2835_spi.c line 2
Quoted 4 lines
drivers/spi/bcm2835_spi.c +2
-0@@ -0,0 +1,440 @@ +/* GPIO base for software CS control */ +static void __iomem *g_gpio_base = (void __iomem *)0xFE200000 ;This is BCM2711-only, so BCM2835 (Pi 3, which the
Kconfighelp and commit subject both advertise) has its GPIO block at0x3f200000, so the driver will silently corrupt unrelated memory there. Anyway, U-Boot already has pinctrl (pinctrl-bcm283x.c) and GPIO (bcm2835_gpio.c) drivers for this SoC; please go through those.drivers/spi/bcm2835_spi.c line 10
Quoted 12 lines
drivers/spi/bcm2835_spi.c +10
-0@@ -0,0 +1,440 @@ +/* Try to get CS GPIO from device tree */ + ret =gpio_request_by_name (bus,'cs-gpios' ,0 , &priv->cs_gpio, +GPIOD_IS_OUT |GPIOD_ACTIVE_LOW ); +if (!ret) { + priv->cs_gpio_valid =1 ; +/* Deassert CS initially */ +dm_gpio_set_value (&priv->cs_gpio,1 ); + }else { + priv->cs_gpio_valid =0 ; + }
priv->cs_gpioandpriv->cs_gpio_validare written here but never read
-bcm2835_spi_xfer()instead doesint cs_pin = (cs == 0) ? 8 : 7;and pokes GPSET0/GPCLR0 directly, ignoring the DT. Either honour cs-gpios via
dm_gpio_set_value()(the normal U-Boot pattern, whichDM_SPI_GPIOalready handles generically), or drop thecs_gpiorequest and document that the driver hardcodes the Pi SPI0 CE0/CE1 pin assignment. As written it's half of each.drivers/spi/bcm2835_spi.c line 10
Quoted 12 lines
drivers/spi/bcm2835_spi.c +10
-0@@ -0,0 +1,440 @@ +struct bcm2835_spi_priv { +void __iomem *regs; +u32 clk_hz; +u32 cs_reg;/* Cached CS register value */ +u32 speed_hz; +u8 mode; +struct gpio_desc cs_gpio; +int cs_gpio_valid; +int cs_asserted;/* Track if CS should stay asserted between transfers */ +};
cs_assertedis assigned in three places inxfer()but never read. Please remove it (and the comment that promises behaviour it does not implement).drivers/spi/bcm2835_spi.c line 2
Quoted 4 lines
drivers/spi/bcm2835_spi.c +2
-0@@ -0,0 +1,440 @@ +/* Default clock rate - 250 MHz for Pi 4 */ +#define BCM2835_SPI_DEFAULT_CLK 250000000This is the SPI core/source clock, not a default transfer rate - the default transfer speed is 1 MHz below. The name is confusing. More importantly, on BCM2835 vs BCM2711 vs different VPU clock settings this number is not constant; please pull it from the clk uclass (or from clock-frequency in DT, which you already read, with no hard-coded fallback).
drivers/spi/bcm2835_spi.c line 5
Quoted 7 lines
drivers/spi/bcm2835_spi.c +5
-0@@ -0,0 +1,440 @@ +static inline void bcm2835_spi_writel (struct bcm2835_spi_priv *priv, +u32 reg,u32 val) +{ +writel (val, priv->regs + reg); +}Please check indent for tab-alignment. Patman or checkpatch will flag these.
drivers/spi/bcm2835_spi.c line 3
Quoted 5 lines
drivers/spi/bcm2835_spi.c +3
-0@@ -0,0 +1,440 @@ +/* Poll for completion - transfer byte by byte */ + timeout =100000 ; +while ((tx_count < len || rx_count < len) && timeout >0 ) {The 100000 and 10000 timeouts are bare loop counters, not time bounds so at 1 MHz a 4 KB transfer takes ~32 ms and the loop body has no fixed cost, so these mean nothing except 'don't hang forever'. Please convert to
get_timer()/timer_get_us(), the way otherDM_SPIdrivers do, so the timeout is independent of CPU speed and transfer length.
Quoted 11 lines
drivers/spi/bcm2835_spi.c line 3
Quoted 5 lines
drivers/spi/bcm2835_spi.c +3
-0@@ -0,0 +1,440 @@ +config BCM2835_SPI + bool "BCM2835/BCM2711 SPI driver" + depends onARCH_BCM283X Given the hard-coded
0xfe200000GPIO base and the BCM2711-only fix-up inof_to_plat(), the BCM2835 half of this option is not actually supported. Either fix the driver to derive the GPIO base from DT / from the existingbcm2835_gpiodriver and exercise it on a Pi 3, or narrow theKconfigtext and commit subject to say BCM2711 only.
This needs to support all, if it's an option people will try to use it and get a bad experience.
PATCH v4 4/14 arm: dts: bcm2711-rpi-4-b: add Infineon SLB9670/9672 TPM in U-Boot dtsi
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add a TPM 2.0 device-tree node on SPI0 CE1 for the Infineon SLB9670 / SLB9672 TPM HAT. The pinout matches the standard Linux tpm-slb9670 overlay, so a board configured for U-Boot with this addition behaves the same as a Linux kernel using that overlay.
The node is placed in bcm2711-rpi-4-b-u-boot.dtsi (the U-Boot-only DT augmentation file) rather than in bcm2711-rpi-4-b.dts. This keeps the upstream-Linux-derived .dts unchanged, so SystemReady firmware-provided FDTs and the upstream Linux device tree continue to match what kernel.org ships - which addresses the concern raised in v3 review about polluting the Linux DT path.
A spi0 alias is added pointing at the BCM2711 SPI controller, so that wolfTPM's SPI HAL (which addresses the bus by number) finds the TPM at bus 0 CS 1.
--- arch/arm/dts/bcm2711-rpi-4-b-u-boot.dtsi | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 arch/arm/dts/bcm2711-rpi-4-b-u-boot.dtsi
arch/arm/dts/bcm2711-rpi-4-b-u-boot.dtsi new file +39 -0
@@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * U-Boot-only additions for Raspberry Pi 4 Model B + * + * Adds a TPM 2.0 device tree node on SPI0 CE1 for the Infineon + * SLB9670 / SLB9672 TPM HAT (electrically identical pinout to + * the Linux tpm-slb9670 overlay). + * + * The node lives in *-u-boot.dtsi rather than in bcm2711-rpi-4-b.dts + * so it is only visible to U-Boot's bundled FDT and never pollutes + * the upstream Linux DT or a SystemReady firmware-provided FDT. + */ + +#include "bcm283x-u-boot.dtsi" + +/ { + aliases { + spi0 = &spi; + }; +}; + +&gpio { + bootph-all; +}; + +&spi { + status = "okay"; + bootph-all; + pinctrl-names = "default"; + pinctrl-0 = <&spi0_gpio7>; + + /* Infineon SLB9670 / SLB9672 TPM 2.0 on CE1 (GPIO7) */ + tpm@1 { + compatible = "infineon,slb9670", "tcg,tpm_tis-spi"; + reg = <1>; + spi-max-frequency = <32000000>; + bootph-all; + }; +};
Signature · 1 line
2.49.0
Re: [PATCH v4 04/14] arm: dts: bcm2711-rpi-4-b: add Infineon SLB9670/9672 TPM in U-Boot dtsi
Hi Aidan,
Quoted 26 lines · Aidan Garske
arm: dts: bcm2711-rpi-4-b: add Infineon SLB9670/9672 TPM in U-Boot dtsi
Add a TPM 2.0 device-tree node on SPI0 CE1 for the Infineon SLB9670 / SLB9672 TPM HAT. The pinout matches the standard Linux tpm-slb9670 overlay, so a board configured for U-Boot with this addition behaves the same as a Linux kernel using that overlay.
The node is placed in
bcm2711-rpi-4-b-u-boot.dtsi(the U-Boot-only DT augmentation file) rather than inbcm2711-rpi-4-b.dts. This keeps the upstream-Linux-derived .dts unchanged, so SystemReady firmware-provided FDTs and the upstream Linux device tree continue to match what kernel.org ships - which addresses the concern raised in v3 review about polluting the Linux DT path.A spi0 alias is added pointing at the BCM2711 SPI controller, so that wolfTPM's SPI HAL (which addresses the bus by number) finds the TPM at bus 0 CS 1.
Signed-off-by Aidan Garske <[email protected]>
arch/arm/dts/bcm2711-rpi-4-b-u-boot.dtsi| 39 ++++++++++++++++++++++++++++++++1 file changed, 39 insertions(+)arch/arm/dts/bcm2711-rpi-4-b-u-boot.dtsi +1
-0@@ -0,0 +1,39 @@ +#include 'bcm283x-u-boot.dtsi'
arch/arm/dts/bcm2711-rpi-4-b-u-boot.dtsi line 11
Quoted 10 lines
arch/arm/dts/bcm2711-rpi-4-b-u-boot.dtsi +10
-0+ +/ { + aliases { + spi0 = &spi; + }; +}; + +&gpio { + bootph-all; +};
bcm283x-u-boot.dtsi (included a few lines above) already adds bootph-all to &gpio, so you shouldn't need this.
arch/arm/dts/bcm2711-rpi-4-b-u-boot.dtsi line 7
Quoted 9 lines
arch/arm/dts/bcm2711-rpi-4-b-u-boot.dtsi +7
-0@@ -0,0 +1,39 @@ + /* Infineon SLB9670 / SLB9672 TPM 2.0 on CE1 (GPIO7) */ + tpm@1 { + compatible = 'infineon,slb9670', 'tcg,tpm_tis-spi'; + reg = <1>; + spi-max-frequency = <32000000>; + bootph-all; + };
Just to note - drivers/tpm/tpm2_tis_spi.c already binds to tcg,tpm_tis-spi, so this node is not wolfTPM-specific; the in-tree TPM2 stack will probe it too. Combined with Peter's request to split the BCM2835 SPI driver out, one option is a small standalone series that lands patch 3 plus this DT node and lets the existing TPM2 stack drive the SLB9670 on a Pi 4, independent of the wolfTPM question. Anyway, please adjust the commit message, since it under-sells what it enables.
Regards,
Simon
PATCH v4 5/14 arm: dts: qemu-arm64: add TPM TIS MMIO node
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add a TPM 2.0 TIS MMIO node at the address QEMU's virt machine exposes when started with -device tpm-tis-device. This lets the in-tree QEMU+swtpm test path (used by the wolfTPM Python test suite, and similarly usable by anyone bringing up the existing TPM 2.0 stack against swtpm) work without having to inject a DT overlay at runtime.
Address 0x0c000000 / size 0x5000 matches QEMU's virt machine TPM TIS region.
--- arch/arm/dts/qemu-arm64.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/dts/qemu-arm64.dts +4 -0
@@ -12,4 +12,8 @@ #endif / { + tpm@0c000000 { + compatible = "tcg,tpm-tis-mmio"; + reg = <0x0 0x0c000000 0x0 0x5000>; + }; };
Signature · 1 line
2.49.0
Re: [PATCH v4 05/14] arm: dts: qemu-arm64: add TPM TIS MMIO node
Hi Aidan,
Quoted 19 lines · Aidan Garske
arm: dts: qemu-arm64: add TPM TIS MMIO node
Add a TPM 2.0 TIS MMIO node at the address QEMU's virt machine exposes when started with -device tpm-tis-device. This lets the in-tree QEMU+swtpm test path (used by the wolfTPM Python test suite, and similarly usable by anyone bringing up the existing TPM 2.0 stack against swtpm) work without having to inject a DT overlay at runtime.
Address
0x0c000000/ size0x5000matches QEMU's virt machine TPM TIS region.Signed-off-by Aidan Garske <[email protected]>
arch/arm/dts/qemu-arm64.dts| 4 ++++1 file changed, 4 insertions(+)
arch/arm/dts/qemu-arm64.dts line 17
Quoted 6 lines
arch/arm/dts/qemu-arm64.dts +4
-0@@ -12,4 +12,8 @@ / { + tpm@0c000000 { + compatible = 'tcg,tpm-tis-mmio'; + reg = <0x0 0x0c000000 0x0 0x5000>; + }; };
I don't think this addition takes effect at runtime. qemu_arm64 sets imply OF_HAS_PRIOR_STAGE and board_fdt_blob_setup() returns the DTB QEMU loaded into RAM, so U-Boot uses QEMU's generated DT, not the compiled-in qemu-arm64.dtb. OF_OMIT_DTB defaults to y when OF_HAS_PRIOR_STAGE is set, so the compiled DT isn't even bundled into u-boot.bin. See doc/develop/devicetree/dt_qemu.rst
When QEMU is started with -device tpm-tis-device it already adds a tpm node at the same 0x0c000000 region, so the existing TPM 2.0 stack picks it up without any change here. Have you confirmed that removing this hunk actually breaks the test path? If not, please drop the patch; if it does help in some specific path (e.g. -dtb u-boot.dtb), the commit message should call that out.
See also this patch where a similar thing came up (due to a QEMU maintainer refusing to support DT additions, U-Boot needs to do the overlay itself).
I also found the context re QEMU expectations (basically Tianocore).
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Also, the reg property uses four cells but the root node doesn't declare #address-cells/#size-cells, so the defaults (2/1) apply and the cell count is wrong. Per dts/upstream/Bindings/tpm/tcg,tpm-tis-mmio.yaml the compatible needs a vendor-specific string first with tcg,tpm-tis-mmio as the fallback - tcg,tpm-tis-mmio alone fails the schema. If the node really is needed, please match what QEMU emits (or pick a sensible vendor prefix) and wrap it in a parent that sets the address/size cells.
Regards,
Simon
PATCH v4 6/14 sandbox: dts: add TPM SPI emulator node
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add a "sandbox,tpm-spi" slave on the existing sandbox SPI bus and a matching "sandbox,tpm-spi-emul" emulator node, so the sandbox unit-test target can exercise SPI-attached TPM code paths without real hardware.
The slave device sits on CS 1 (CS 0 is the SPI-NOR flash emulator that other sandbox tests use), and the slave's sandbox,emul phandle points at the emulator node added at the root of the sandbox device tree.
--- arch/sandbox/dts/sandbox.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/sandbox/dts/sandbox.dtsi +11 -0
@@ -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 {
Signature · 1 line
2.49.0
Re: [PATCH v4 06/14] sandbox: dts: add TPM SPI emulator node
Hi Aidan,
Quoted 12 lines · Aidan Garske
sandbox: dts: add TPM SPI emulator node
Add a 'sandbox,tpm-spi' slave on the existing sandbox SPI bus and a matching 'sandbox,tpm-spi-emul' emulator node, so the sandbox unit-test target can exercise SPI-attached TPM code paths without real hardware.
The slave device sits on CS 1 (CS 0 is the SPI-NOR flash emulator that other sandbox tests use), and the slave's sandbox,emul phandle points at the emulator node added at the root of the sandbox device tree.
Quoted 4 lines
Signed-off-by Aidan Garske <[email protected]>
arch/sandbox/dts/sandbox.dtsi| 11 +++++++++++1 file changed, 11 insertions(+)
arch/sandbox/dts/sandbox.dtsi line 291
Quoted 8 lines
arch/sandbox/dts/sandbox.dtsi +6
-0@@ -286,6 +286,17 @@ + tpm_spi: tpm@1 { + reg = <1>; + compatible = 'sandbox,tpm-spi'; + spi-max-frequency = <10000000>; + sandbox,emul = <&tpm_spi_emul>; + };
Just to check - is there a reason this is in sandbox.dtsi rather than test.dts? Only the C unit tests in patch 12 exercise this emulator, and test-only nodes normally live in test.dts. The existing sandbox TPM nodes in sandbox.dtsi are arguably an exception rather than the rule. It's fine to have the node in both, though.
Regards,
Simon
PATCH v4 7/14 tpm: add wolfTPM build rules and Kconfig
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Hook the wolfTPM source tree (imported as a subtree at lib/wolftpm/ in the preceding commits) into the U-Boot build and add upstream-pull support to tools/update-subtree.sh, matching how mbedtls, dts, and lwip are maintained.
lib/Kconfig:
Adds CONFIG_TPM_WOLF under library routines, depending on DM, implying DM_RNG, and selecting SHA1.
lib/Makefile:
When CONFIG_TPM_WOLF and CONFIG_TPM_V2 are both enabled, compiles wolfTPM core source files (tpm2.c, tpm2_packet.c, tpm2_tis.c, tpm2_wrap.c, tpm2_param_enc.c) and the HAL layer (tpm_io.c). Sets -I include paths and -DWOLFTPM_USER_SETTINGS so wolfTPM picks up include/configs/user_settings.h.
tools/update-subtree.sh:
Registers the wolftpm subtree (path lib/wolftpm, upstream
https://github.com/wolfssl/wolfTPM.git) so the existing pull/pick workflow can be used for future wolfTPM updates.
--- lib/Kconfig | 13 +++++++++++++ lib/Makefile | 17 +++++++++++++++++ tools/update-subtree.sh | 7 ++++++- 3 files changed, 36 insertions(+), 1 deletion(-)
lib/Kconfig +13 -0
@@ -500,6 +500,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 is a + portable, open-source TPM 2.0 stack licensed under GPLv2. Enabling + this option allows U-Boot to interact with the TPM via wolfTPM, + including firmware updates, PCR extend, and other TPM 2.0 + operations. The wolfTPM source tree lives under lib/wolftpm/ as + a subtree (see tools/update-subtree.sh). + config SPL_TPM bool "Trusted Platform Module (TPM) Support in SPL" depends on SPL_DM
lib/Makefile +17 -0
@@ -64,6 +64,23 @@ obj-$(CONFIG_EFI_TCG2_PROTOCOL) += tpm_tcg2.o obj-$(CONFIG_MEASURED_BOOT) += tpm_tcg2.o endif +# wolfTPM (TPM 2.0 stack, including firmware update support) +ifeq ($(CONFIG_TPM_WOLF),y) +ifeq ($(CONFIG_TPM_V2),y) +ccflags-y += -I$(srctree)/lib/wolftpm \ + -I$(srctree)/include/configs \ + -DWOLFTPM_USER_SETTINGS +obj-y += wolftpm/hal/tpm_io.o +obj-$(CONFIG_WOLFTPM_LINUX_DEV) += 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
tools/update-subtree.sh +6 -1
@@ -17,7 +17,7 @@ set -e print_usage() { echo "usage: $0 <op> <subtree-name> <ref>" echo " <op> pull or pick" - echo " <subtree-name> mbedtls or dts or lwip" + echo " <subtree-name> mbedtls or dts or lwip or wolftpm" echo " <ref> release tag [pull] or commit id [pick]" }
@@ -47,6 +47,11 @@ set_params() { repo_url=https://git.savannah.gnu.org/git/lwip.git remote_name="lwip_upstream" ;; + wolftpm) + path=lib/wolftpm + repo_url=https://github.com/wolfssl/wolfTPM.git + remote_name="wolftpm_upstream" + ;; *) echo "Invalid subtree name: $subtree_name" print_usage
Signature · 1 line
2.49.0
PATCH v4 8/14 tpm: add wolfTPM headers and SHA384 glue code
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add the wolfTPM integration headers and hash wrapper needed to bridge wolfTPM with U-Boot's subsystems.
include/wolftpm.h:
Public header exposing TPM2_PCRs_Print(), TPM2_Init_Device(), and Infineon firmware update helpers (TPM2_IFX_FwData_Cb, TPM2_IFX_GetOpModeStr, TPM2_IFX_PrintInfo). Includes the core wolfTPM headers (tpm2.h, tpm2_wrap.h, tpm2_packet.h).
include/configs/user_settings.h:
wolfTPM compile-time configuration. Selects TPM chip type (SLB9672/SLB9673 for real hardware, WOLFTPM_AUTODETECT for swtpm/QEMU), communication mode (native SPI TIS layer for real hardware, WOLFTPM_LINUX_DEV for U-Boot driver model), timeout tuning, and feature flags (WOLFTPM2_NO_WOLFCRYPT, WOLFTPM2_NO_HEAP, WOLFTPM_CHECK_WAIT_STATE).
user_settings.h pulls in <asm/byteorder.h> up front so U-Boot's cpu_to_beXX / beXX_to_cpu macros are defined before wolfTPM's tpm2_packet.h, whose fallback definitions are #ifndef-guarded. This keeps the workaround on the wolfTPM side rather than modifying linux/byteorder/generic.h.
lib/wolftpm.c:
Provides wc_Sha384Hash() implementation when wolfCrypt is disabled (WOLFTPM2_NO_WOLFCRYPT). Uses U-Boot's hash_lookup_algo("sha384") to compute SHA-384 digests, which is required for Infineon TPM firmware update manifest validation.
--- include/configs/user_settings.h | 123 ++++++++++++++++++++++++++++++++ include/wolftpm.h | 34 +++++++++ lib/wolftpm.c | 56 +++++++++++++++ 3 files changed, 213 insertions(+) create mode 100644 include/configs/user_settings.h create mode 100644 include/wolftpm.h create mode 100644 lib/wolftpm.c
include/configs/user_settings.h new file +123 -0
@@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* wolfTPM build configuration for U-Boot +* +* Copyright (C) 2025 wolfSSL Inc. +* Author: Aidan Garske <[email protected]> +*/ + +#ifndef USER_SETTINGS_H +#define USER_SETTINGS_H + +/* Define U-Boot's byte-order macros first so wolfTPM's #ifndef-guarded +* fallbacks in tpm2_packet.h don't redefine them. +*/ +#include <asm/byteorder.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************/ +/* --- BEGIN wolfTPM U-boot Settings -- */ +/******************************************************************************/ + +/* ========================================================================= +* TPM Chip Configuration +* ========================================================================= +* +* CONFIG_TPM_AUTODETECT: For swtpm/QEMU testing (no specific chip) +* !CONFIG_TPM_AUTODETECT: For real hardware (SLB9672/SLB9673) +*/ +#ifdef CONFIG_TPM_AUTODETECT +#define WOLFTPM_AUTODETECT +#else +/* Real hardware - Infineon SLB9672/SLB9673 +* Firmware upgrade only supported by these chips */ +#define WOLFTPM_FIRMWARE_UPGRADE +#define WOLFTPM_SLB9672 +/* #define WOLFTPM_SLB9673 */ +#endif + +/* Include delay.h and types.h for +* U-boot time delay and types */ +#include <linux/delay.h> +#include <linux/types.h> +#include <stdint.h> + +/* wolfCrypt disabled - pcr_setauthpolicy/pcr_setauthvalue not available +* To enable wolfCrypt, you would need to: +* 1. Uncomment the line below to undefine WOLFTPM2_NO_WOLFCRYPT +* 2. Add wolfCrypt source files to the U-Boot build (lib/Makefile) +* 3. Add wolfCrypt settings for embedded/no-OS use +*/ +#undef WOLFTPM2_NO_WOLFCRYPT +#define WOLFTPM2_NO_WOLFCRYPT + +/* ========================================================================= +* TPM Communication Mode Selection (Auto-detected based on chip type) +* ========================================================================= +* +* For real SPI hardware (SLB9672/SLB9673): +* - Uses wolfTPM's native TIS layer with raw SPI via tpm_io_uboot.c +* - Requires CONFIG_SPI and CONFIG_DM_SPI enabled in U-Boot +* +* For swtpm/QEMU testing (no specific chip defined): +* - Uses WOLFTPM_LINUX_DEV mode with U-Boot's TPM driver (tpm_xfer()) +* - Works with MMIO-based TPM via tpm2_tis_mmio.c +*/ + +#if defined(WOLFTPM_SLB9672 ) || defined(WOLFTPM_SLB9673 ) +/* Real SPI hardware - use native wolfTPM TIS with raw SPI */ +/* WOLFTPM_LINUX_DEV is NOT defined */ +#define WOLFTPM_EXAMPLE_HAL + +/* SPI bus and chip select for TPM +* Official Raspberry Pi tpm-slb9670 overlay uses CE1 (GPIO7) +* This matches LetsTrust and most Infineon evaluation boards */ +#ifndef TPM_SPI_BUS +#define TPM_SPI_BUS 0 +#endif +#ifndef TPM_SPI_CS +#define TPM_SPI_CS 1/* CE1/GPIO7 - official RPi TPM overlay setting */ +#endif +#else +/* swtpm/QEMU - use U-Boot's TPM driver with MMIO communication mode */ +#define WOLFTPM_LINUX_DEV +#endif + +#define XSLEEP_MS (ms) udelay(ms * 1000) + +/* Timeout configuration */ +#ifdef WOLFTPM_FIRMWARE_UPGRADE +/* Firmware update requires much longer timeout for TPM processing */ +#define TPM_TIMEOUT_TRIES 2000000 +#else +/* Normal operations - reduce from default 1,000,000 to prevent long hangs */ +#define TPM_TIMEOUT_TRIES 10000 +#endif + +/* Add small delay between poll attempts to avoid tight spin loop */ +#define XTPM_WAIT () udelay(100) + +/* Do not include API's that use heap(), they are not required */ +#define WOLFTPM2_NO_HEAP + +/* Debugging - disabled for clean output */ +/* #define DEBUG_WOLFTPM */ +/* #define WOLFTPM_DEBUG_VERBOSE */ +/* #define WOLFTPM_DEBUG_IO */ +/* #define WOLFTPM_DEBUG_TIMEOUT */ + +/* SPI Wait state checking - most TPMs use this */ +#define WOLFTPM_CHECK_WAIT_STATE + +/******************************************************************************/ +/* --- END wolfTPM U-boot Settings -- */ +/******************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif /* USER_SETTINGS_H */
include/wolftpm.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* wolfTPM integration header for U-Boot +* +* Copyright (C) 2025 wolfSSL Inc. +* Author: Aidan Garske <[email protected]> +*/ + +#ifndef __WOLFTPM_H__ +#define __WOLFTPM_H__ + +#include <wolftpm/tpm2.h> +#include <wolftpm/tpm2_wrap.h> +#include <wolftpm/tpm2_packet.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef WOLFTPM_FIRMWARE_UPGRADE +int TPM2_IFX_FwData_Cb (uint8_t *data,uint32_t data_req_sz, +uint32_t offset,void *cb_ctx); +const char *TPM2_IFX_GetOpModeStr (int opMode); +void TPM2_IFX_PrintInfo (WOLFTPM2_CAPS *caps); +#endif + +int TPM2_PCRs_Print (void ); +int TPM2_Init_Device (WOLFTPM2_DEV *dev,void *userCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* __WOLFTPM_H__ */
lib/wolftpm.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH v4 9/14 tpm: add wolfTPM driver helpers and Kconfig options
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add wolfTPM helper functions and configuration options to the TPM driver subsystem.
drivers/tpm/wolftpm_common.c:
Shared helper functions used by the wolfTPM command backend:
- TPM2_IFX_FwData_Cb(): firmware data callback for Infineon firmware update streaming
- TPM2_IFX_GetOpModeStr(): converts Infineon operational mode codes to human-readable strings
- TPM2_IFX_PrintInfo(): prints manufacturer, vendor, firmware version, and operational mode from WOLFTPM2_CAPS
- TPM2_PCRs_Print(): enumerates and prints assigned PCR banks and their selected PCR indices
- TPM2_Init_Device(): initializes wolfTPM with the TPM2_IoCb HAL callback
drivers/tpm/Kconfig:
Adds configuration options under TPM_V2:
- TPM2_SPI_SANDBOX: sandbox TPM SPI emulator for testing
- TPM_AUTODETECT: auto-detect TPM chip for swtpm/QEMU
- WOLFTPM_LINUX_DEV: use U-Boot driver model instead of wolfTPM's native TIS layer
- WOLFTPM_SLB9672/SLB9673: Infineon chip-specific features
- WOLFTPM_FIRMWARE_UPGRADE: firmware update support
drivers/tpm/Makefile:
Compiles wolftpm_common.o and sets wolfTPM include paths and -DWOLFTPM_USER_SETTINGS when CONFIG_TPM_WOLF is enabled.
--- drivers/tpm/Kconfig | 44 +++++++++++ drivers/tpm/Makefile | 9 +++ drivers/tpm/wolftpm_common.c | 137 +++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+) create mode 100644 drivers/tpm/wolftpm_common.c
drivers/tpm/Kconfig +44 -0
@@ -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,42 @@ 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 TPM_AUTODETECT + bool "wolfTPM auto-detect TPM chip (for swtpm/QEMU)" + depends on TPM_V2 && TPM_WOLF + help + Enable wolfTPM chip auto-detection instead of using a specific + chip type (SLB9672/SLB9673). Use this for swtpm/QEMU testing + where no specific hardware chip is present. + +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
@@ -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 += -I$(srctree)/lib/wolftpm \ + -I$(srctree)/include/configs \ + -DWOLFTPM_USER_SETTINGS +obj-y += wolftpm_common.o +endif
drivers/tpm/wolftpm_common.c new file +137 -0
137 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH v4 10/14 cmd: refactor tpm2 command into frontend/backend architecture
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Split the tpm2 command implementation into a shared frontend and two selectable backends. This allows wolfTPM to provide its own TPM2 command implementations while keeping the command table, dispatcher, and help text shared.
Architecture:
cmd/tpm-v2.c (frontend - always compiled):
Contains the tpm2_commands[] table, get_tpm2_commands(), the do_tpm2() dispatcher, and the U_BOOT_CMD help text. References backend functions via cmd/tpm2-backend.h. When CONFIG_TPM_WOLF is enabled, additional wolfTPM-only commands (caps, pcr_print, firmware_update, firmware_cancel) are added to the table.
cmd/tpm2-backend.h (new):
Declares all backend function prototypes that both backends must
implement: do_tpm2_device, do_tpm2_info, do_tpm2_init, do_tpm2_startup, do_tpm2_selftest, do_tpm2_clear, do_tpm2_pcr_extend, do_tpm2_pcr_read, do_tpm2_get_capability, do_tpm2_dam_reset, do_tpm2_dam_parameters, do_tpm2_change_auth, do_tpm2_pcr_setauthpolicy, do_tpm2_pcr_setauthvalue, do_tpm2_pcr_allocate, plus wolfTPM-only functions.
cmd/native_tpm2.c (new - native backend):
Contains the original tpm2 command implementations that use U-Boot's TPM driver model (tpm_api.h, tpm-v2.h). Compiled when CONFIG_TPM_WOLF is not set. Common commands delegate to tpm-common.c helpers (do_tpm_device, do_tpm_info, etc.).
cmd/wolftpm.c (new - wolfTPM backend):
Implements all tpm2 commands using wolfTPM library APIs directly (wolfTPM2_Init, wolfTPM2_GetCapabilities, wolfTPM2_ExtendPCR, etc.). Includes Infineon-specific firmware update and cancel commands. Each command initializes its own WOLFTPM2_DEV instance rather than going through U-Boot's driver model.
cmd/Kconfig:
Adds CMD_WOLFTPM option that selects TPM_WOLF and CMD_TPM_V2, providing a single menuconfig toggle for wolfTPM support.
cmd/Makefile:
Conditionally compiles wolftpm.o (when CONFIG_TPM_WOLF=y) or native_tpm2.o (otherwise) alongside the shared tpm-v2.o frontend. Sets wolfTPM include paths and -DWOLFTPM_USER_SETTINGS.
The reason for separate backend files rather than a callback-based approach is that wolfTPM uses fundamentally different types and initialization patterns (WOLFTPM2_DEV vs struct udevice, direct library calls vs driver model ops), making runtime dispatch impractical without heavy abstraction.
--- cmd/Kconfig | 11 + cmd/Makefile | 10 +- cmd/native_tpm2.c | 516 +++++++++++++++++++ cmd/tpm-v2.c | 559 +++------------------ cmd/tpm2-backend.h | 66 +++ cmd/wolftpm.c | 1170 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1840 insertions(+), 492 deletions(-) create mode 100644 cmd/native_tpm2.c create mode 100644 cmd/tpm2-backend.h create mode 100644 cmd/wolftpm.c
cmd/Kconfig +11 -0
@@ -3194,4 +3194,15 @@ 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 "Use wolfTPM as TPM2 backend" + depends on TPM_V2 + select TPM_WOLF + select CMD_TPM_V2 + help + Use the wolfTPM library as the backend for TPM2 commands instead + of the standard U-Boot TPM2 implementation. wolfTPM offers additional + features including firmware update support for Infineon TPMs and + enhanced capabilities reporting. + endif
cmd/Makefile +9 -1
@@ -191,9 +191,17 @@ 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 +obj-$(CONFIG_CMD_TPM_V1) += tpm-v1.o obj-$(CONFIG_CMD_TPM_V2) += tpm-v2.o +ifeq ($(CONFIG_TPM_WOLF),y) +ccflags-y += -I$(srctree)/lib/wolftpm \ + -I$(srctree)/include/configs \ + -DWOLFTPM_USER_SETTINGS +obj-$(CONFIG_CMD_TPM_V2) += wolftpm.o +else +obj-$(CONFIG_CMD_TPM_V2) += native_tpm2.o +endif obj-$(CONFIG_CMD_CROS_EC) += cros_ec.o obj-$(CONFIG_CMD_UBI) += ubi.o obj-$(CONFIG_CMD_UBIFS) += ubifs.o
cmd/native_tpm2.c new file +516 -0
516 lines not on this page · raw message
cmd/tpm-v2.c +68 -491
599 lines not on this page · raw message
cmd/tpm2-backend.h new file +66 -0
66 lines not on this page · raw message
cmd/wolftpm.c new file +1170 -0
1,170 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH v4 10/14] cmd: refactor tpm2 command into frontend/backend architecture
Hi Aidan,
Quoted 32 lines · Aidan Garske
From: Aidan <[email protected]>
Split the tpm2 command implementation into a shared frontend and two selectable backends. This allows wolfTPM to provide its own TPM2 command implementations while keeping the command table, dispatcher, and help text shared.
Architecture:
cmd/tpm-v2.c(frontend - always compiled):
Contains the tpm2_commands[] table,get_tpm2_commands(), thedo_tpm2()dispatcher, and theU_BOOT_CMDhelp text. References backend functions viacmd/tpm2-backend.h. WhenCONFIG_TPM_WOLFis enabled, additional wolfTPM-only commands (caps,pcr_print,firmware_update,firmware_cancel) are added to the table.
cmd/tpm2-backend.h(new):
Declares all backend function prototypes that both backends must
implement:do_tpm2_device,do_tpm2_info,do_tpm2_init,do_tpm2_startup,do_tpm2_selftest,do_tpm2_clear,do_tpm2_pcr_extend,do_tpm2_pcr_read,do_tpm2_get_capability,do_tpm2_dam_reset,do_tpm2_dam_parameters,do_tpm2_change_auth,do_tpm2_pcr_setauthpolicy,do_tpm2_pcr_setauthvalue,do_tpm2_pcr_allocate, plus wolfTPM-only functions.
cmd/native_tpm2.c(new - native backend):
Contains the original tpm2 command implementations that use U-Boot's TPM driver model (tpm_api.h,tpm-v2.h). Compiled whenCONFIG_TPM_WOLFis not set. Common commands delegate totpm-common.chelpers (do_tpm_device,do_tpm_info, etc.).
Quoted 5 lines
cmd/wolftpm.c(new - wolfTPM backend):
Implements all tpm2 commands using wolfTPM library APIs directly (wolfTPM2_Init,wolfTPM2_GetCapabilities,wolfTPM2_ExtendPCR, etc.). Includes Infineon-specific firmware update and cancel commands. Each command initializes its ownWOLFTPM2_DEVinstance
This commit should be split so that the refactor is first and the Wolf stuff later.
Regards,
Simon
Re: [PATCH v4 10/14] cmd: refactor tpm2 command into frontend/backend architecture
In reply to Aidan GarskeHi Aidan,
Quoted 32 lines · Aidan Garske
cmd: refactor tpm2 command into frontend/backend architecture
Split the tpm2 command implementation into a shared frontend and two selectable backends. This allows wolfTPM to provide its own TPM2 command implementations while keeping the command table, dispatcher, and help text shared.
Architecture:
cmd/tpm-v2.c(frontend - always compiled):
Contains the tpm2_commands[] table,get_tpm2_commands(), thedo_tpm2()dispatcher, and theU_BOOT_CMDhelp text. References backend functions viacmd/tpm2-backend.h. WhenCONFIG_TPM_WOLFis enabled, additional wolfTPM-only commands (caps,pcr_print,firmware_update,firmware_cancel) are added to the table.
cmd/tpm2-backend.h(new):
Declares all backend function prototypes that both backends must
implement:do_tpm2_device,do_tpm2_info,do_tpm2_init,do_tpm2_startup,do_tpm2_selftest,do_tpm2_clear,
[...]cmd/Kconfig | 11 +
cmd/Makefile | 10 +- cmd/native_tpm2.c | 516 +++++++++++++++++++++++ cmd/tpm-v2.c | 559 +++---------------------- cmd/tpm2-backend.h | 66 +++ cmd/wolftpm.c | 1170 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1840 insertions(+), 492 deletions(-)
cmd/wolftpm.c line 1
Quoted 1 line
cmd/wolftpm.c +1
-0@@ -0,0 +1,1170 @@ +#define LOG_CATEGORY UCLASS_BOOTSTD
wolftpm.c has nothing to do with the bootstd uclass. Should be UCLASS_TPM (or LOGC_NONE). Likely applies to other files in this series too.
Quoted 7 lines
cmd/wolftpm.c +5
-0@@ -0,0 +1,1170 @@ +/* full test */ +if (fullTest ==YES ) { + rc =wolfTPM2_SelfTest (&dev); +if (rc !=TPM_RC_SUCCESS ) { + log_debug("TPM2 Self Test: Result = 0x%x (%s)\n", rc,
cmd/wolftpm.c line 15
Quoted 10 lines
cmd/wolftpm.c +10
-0+ TPM2_GetRCString(rc)); + } +/* continue test */ + }else { + rc =wolfTPM2_SelfTest (&dev); +if (rc !=TPM_RC_SUCCESS ) { +log_debug ("TPM2 Self Test: Result = 0x%x (%s)\n" , rc, +TPM2_GetRCString (rc)); + } + }
Both branches do the same thing - continue is meant to be incremental, not full. The native backend passes TPMI_YES/TPMI_NO to tpm2_self_test() to distinguish. Please call the appropriate wolfTPM API for the incremental case, or collapse the branches and document that there's no difference.
Quoted 4 lines
cmd/wolftpm.c +2
-0@@ -0,0 +1,1170 @@ + rc =wolfTPM2_ExtendPCR (&dev, pcrIndex, algo, digest, digestLen); +if (rc !=TPM_RC_SUCCESS ) {
cmd/wolftpm.c line 12
Quoted 10 lines
cmd/wolftpm.c +10
-0+log_debug ("TPM2_PCR_Extend failed 0x%x: %s\n" , rc, +TPM2_GetRCString (rc)); + } + +unmap_sysmem (digest); +wolfTPM2_Cleanup (&dev); + +log_debug ("tpm2 pcr_extend: rc = %d (%s)\n" , rc,TPM2_GetRCString (rc)); + +return rc;
Most wolfTPM handlers return the raw TPM2 return code directly to the shell. The native backend funnels everything through report_return_code() which maps non-zero rc to CMD_RET_FAILURE and prints a useful diagnostic. Returning a raw TPM_RC from a cmd_tbl handler is not what the shell expects - please use report_return_code() so the two backends behave the same from the user's perspective.
Quoted 4 lines
cmd/tpm-v2.c +2
-0@@ -511,7 +55,22 @@ struct cmd_tbl *get_tpm2_commands(unsigned int *size) +#ifdef CONFIG_TPM_WOLF + U_BOOT_CMD_MKENT(caps, 0, 1, do_tpm2_caps, "", ""),
cmd/tpm-v2.c struct cmd_tbl *get_tpm2_commands(unsigned int *size) · line 66
Quoted 10 lines
cmd/tpm-v2.c +10
-0+ U_BOOT_CMD_MKENT(pcr_print, 0, 1, do_tpm2_pcr_print, "", ""), +#ifdef WOLFTPM_FIRMWARE_UPGRADE +#if defined(WOLFTPM_SLB9672 ) || defined(WOLFTPM_SLB9673 ) + U_BOOT_CMD_MKENT(firmware_update, 0, 1, + do_tpm2_firmware_update, "", ""), + U_BOOT_CMD_MKENT(firmware_cancel, 0, 1, + do_tpm2_firmware_cancel, "", ""), +#endif /* WOLFTPM_SLB9672 || WOLFTPM_SLB9673 */ +#endif /* WOLFTPM_FIRMWARE_UPGRADE */ +#endif /* CONFIG_TPM_WOLF */
The supposedly-shared frontend now contains four levels of backend-specific #ifdef in both the table and the help text. The shared-command-table argument for splitting the file is weaker than it looks. Worse, the inner #if defined(WOLFTPM_SLB9672)... tests a symbol from a wolfTPM-private header, not a Kconfig - so tpm-v2.c now needs the wolfTPM header search path even though it otherwise has nothing to do with wolfTPM. A Kconfig (e.g. CONFIG_TPM_WOLF_FW_UPGRADE) would be much cleaner.
cmd/wolftpm.c line 10
Quoted 12 lines
cmd/wolftpm.c +10
-0@@ -0,0 +1,1170 @@ +int do_tpm2_device (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +WOLFTPM2_DEV dev; +WOLFTPM2_CAPS caps; +int rc; + +/* Expected 1 arg only in native SPI mode (no device switching) */ +if (argc !=1 ) +return CMD_RET_USAGE ;
The shared help text still advertises 'device [num device]' but this implementation rejects any argument. Either implement device switching or trim the help text when CONFIG_TPM_WOLF is set - quietly diverging from the documented interface is worse than either.
cmd/tpm-v2.c U_BOOT_CMD(tpm2, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command", · line 137
Quoted 13 lines
cmd/tpm-v2.c +5
-1@@ -521,7 +80,7 @@ U_BOOT_CMD(tpm2, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command", 'autostart\n' -" Initalize the tpm, perform a Startup(clear) and run a full selftest\n" +" Initialize the tpm, perform a Startup(clear) and run a full selftest\n" @@ -573,6 +132,10 @@ U_BOOT_CMD(tpm2, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command","change_auth <hierarchy> <new_pw> [<old_pw>]\n" " <hierarchy>: the hierarchy\n" +" * TPM2_RH_LOCKOUT\n" +" * TPM2_RH_ENDORSEMENT\n" +" * TPM2_RH_OWNER\n" +" * TPM2_RH_PLATFORM\n"
These are independent improvements - please split into their own patches so they can be picked up even if the wolfTPM bits don't land.
cmd/wolftpm.c line 7
Quoted 9 lines
cmd/wolftpm.c +7
-0@@ -0,0 +1,1170 @@ +#include <wolftpm/tpm2.h> +#include <wolftpm/tpm2_wrap.h> +#include <wolftpm/tpm2_packet.h> +#include <wolftpm.h> + +#include <stdio.h> +#include <hash.h>
Include ordering is also upside-down: U-Boot convention is <command.h> and core headers first, then driver/library headers. The file also uses camelCase locals (doStartup/fullTest/pcrIndex/digestLen/manifest_bufSz) and uint8_t/uint16_t/uint32_t throughout; U-Boot style is snake_case and u8/u16/u32. Please run patman / checkpatch and adjust.
Regards,
Simon
PATCH v4 11/14 tpm: add sandbox TPM SPI emulator
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add a TPM SPI emulator for sandbox testing that implements the TIS (TPM Interface Specification) SPI protocol, allowing wolfTPM's SPI HAL code to be tested without physical hardware.
drivers/tpm/tpm_spi_sandbox.c (new):
Emulates a TPM connected via SPI by implementing the TIS register set and SPI protocol:
- SPI protocol state machine: parses 4-byte TIS SPI headers (R/W bit, transfer length, register address) and handles data phase with immediate ready signaling (no wait states)
- TIS register emulation: TPM_ACCESS (locality request/grant), TPM_STS (command ready, data expect, data available, burst count), TPM_INTF_CAPS, TPM_DID_VID (Infineon SLB9670 IDs), TPM_RID, and TPM_DATA_FIFO (command/response buffering)
- TIS state machine: IDLE -> READY -> RECEPTION -> EXECUTION -> COMPLETION, with command-ready abort support
- Generates simple TPM_RC_SUCCESS responses (a full implementation would integrate the sandbox TPM2 state machine)
- Registers as UCLASS_SPI_EMUL with compatible "sandbox,tpm-spi-emul"
- Also registers a SPI slave driver (UCLASS_SPI_GENERIC) with compatible "sandbox,tpm-spi" for the DTS device node
drivers/mtd/spi/sandbox.c:
Modify sandbox_spi_get_emul() to check for a "sandbox,emul" phandle property on SPI slave devices before falling back to the default SPI flash emulation binding. This allows non-flash SPI devices (like the TPM emulator) to specify their own emulator via device tree phandle.
--- drivers/mtd/spi/sandbox.c | 30 ++- drivers/tpm/tpm_spi_sandbox.c | 410 ++++++++++++++++++++++++++++++++++ 2 files changed, 431 insertions(+), 9 deletions(-) create mode 100644 drivers/tpm/tpm_spi_sandbox.c
drivers/mtd/spi/sandbox.c +21 -9
@@ -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/tpm/tpm_spi_sandbox.c new file +410 -0
410 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH v4 11/14] tpm: add sandbox TPM SPI emulator
Hi Aidan,
Quoted 33 lines · Aidan Garske
tpm: add sandbox TPM SPI emulator
Add a TPM SPI emulator for sandbox testing that implements the TIS (TPM Interface Specification) SPI protocol, allowing wolfTPM's SPI HAL code to be tested without physical hardware.
drivers/tpm/tpm_spi_sandbox.c(new):
Emulates a TPM connected via SPI by implementing the TIS register set and SPI protocol:
- SPI protocol state machine: parses 4-byte TIS SPI headers (R/W bit, transfer length, register address) and handles data phase with immediate ready signaling (no wait states)
- TIS register emulation:TPM_ACCESS(locality request/grant),TPM_STS(command ready, data expect, data available, burst count),TPM_INTF_CAPS,TPM_DID_VID(Infineon SLB9670 IDs),TPM_RID, andTPM_DATA_FIFO(command/response buffering)
- TIS state machine: IDLE -> READY -> RECEPTION -> EXECUTION -> COMPLETION, with command-ready abort support
- Generates simpleTPM_RC_SUCCESSresponses (a full implementation would integrate the sandbox TPM2 state machine)
[...]
drivers/mtd/spi/sandbox.c| 30 +++-drivers/tpm/tpm_spi_sandbox.c | 410 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 431 insertions(+), 9 deletions(-)drivers/tpm/tpm_spi_sandbox.c +5
-0@@ -0,0 +1,410 @@ +* Generate a simple success response. +* A full implementation would call the +* sandbox TPM2 state machine here. +*/ + priv->rsp_buf[0 ] =0x80 ;/* TPM_ST_NO_SESSIONS */
drivers/tpm/tpm_spi_sandbox.c line 15
Quoted 10 lines
drivers/tpm/tpm_spi_sandbox.c +10
-0+ priv->rsp_buf[1 ] =0x01 ; + priv->rsp_buf[2 ] =0x00 ;/* Response size: 10 */ + priv->rsp_buf[3 ] =0x00 ; + priv->rsp_buf[4 ] =0x00 ; + priv->rsp_buf[5 ] =0x0A ; + priv->rsp_buf[6 ] =0x00 ;/* TPM_RC_SUCCESS */ + priv->rsp_buf[7 ] =0x00 ; + priv->rsp_buf[8 ] =0x00 ; + priv->rsp_buf[9 ] =0x00 ; + priv->rsp_len =10 ;
Every command returns the same canned 10-byte TPM_RC_SUCCESS. Any test exercising tpm2 get_capability, pcr_read, pcr_extend etc. would either fail to parse the response or silently accept garbage as success. As-is, this emulator just lets SPI bytes flow.
Please use lower-case hex.
The real sandbox TPM2 state machine already lives next door in drivers/tpm/tpm2_tis_sandbox.c with sandbox_common.c. Please wire this emulator into sandbox_tpm2_fill_buf() and the existing nvdata/PCR/hierarchy logic so commands actually do what they say. Otherwise the wolfTPM C unit tests in patch 12 can't meaningfully run on sandbox.
drivers/mtd/spi/sandbox.c int sandbox_spi_get_emul(struct sandbox_state *state, · line 580
Quoted 12 lines
drivers/mtd/spi/sandbox.c +10
-0@@ -571,16 +571,28 @@ int sandbox_spi_get_emul(struct sandbox_state *state, +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;
This is a generic change to sandbox SPI emulation that affects every existing sandbox SPI user. Please split it into its own patch ahead of this one, with a commit message justifying the sandbox,emul phandle convention on its own terms, and ideally a doc update. Bundled with the TPM emulator, the reasoning gets lost.
drivers/tpm/tpm_spi_sandbox.c line 6
Quoted 8 lines
drivers/tpm/tpm_spi_sandbox.c +6
-0@@ -0,0 +1,410 @@ +/* +* Handle FIFO writes - the FIFO is at 0x0024 but any address +* from 0x0024 up to 0x0F00 can be used for FIFO access when +* doing multi-byte transfers (address auto-increments). +*/ +if (reg >=TPM_DATA_FIFO_REG && reg <TPM_DID_VID_REG ) {
The comment doesn't match up - the TIS FIFO is a single register at 0x0024 and the address does not auto-increment; the host repeats the same address while burst-count drains. Because the SPI layer does priv->addr + priv->data_pos for every byte, you treat a 3000-byte window as FIFO, which masks the issue but is wrong if anything reads e.g. TPM_INT_ENABLE_REG (0x0008) - one of your #defines, is never handled. Please hold priv->addr constant for FIFO accesses, and either implement the other registers you've declared or drop the #defines.
drivers/tpm/tpm_spi_sandbox.c line 11
Quoted 13 lines
drivers/tpm/tpm_spi_sandbox.c +11
-0@@ -0,0 +1,410 @@ +static const struct udevice_id sandbox_tpm_spi_slave_ids[] = { + { .compatible ='sandbox,tpm-spi' }, + { } +}; + +U_BOOT_DRIVER (sandbox_tpm_spi) = { + .name ='sandbox_tpm_spi' , + .id =UCLASS_SPI_GENERIC , + .of_match = sandbox_tpm_spi_slave_ids, + .probe = sandbox_tpm_spi_slave_probe, +};
Why a UCLASS_SPI_GENERIC stub with a sandbox-specific compatible, rather than reusing tcg,tpm_tis-spi so the existing tpm2_tis_spi.c driver binds on top of the emulator? That would give actual U-Boot TPM uclass coverage on sandbox (currently zero for the SPI path) and let the standard ut dm tpm tests run against this emulator without wolfTPM in the picture. As written, the slave driver exists only to make the DT node bind, and the emulator only ever sees raw bytes from wolfTPM's native HAL, so the U-Boot TPM stack still has no SPI sandbox coverage.
drivers/tpm/tpm_spi_sandbox.c line 3
Quoted 5 lines
drivers/tpm/tpm_spi_sandbox.c +3
-0@@ -0,0 +1,410 @@ +/* Maximum buffer sizes */ +#define TPM_CMD_BUF_SIZE 4096 +#define TPM_RSP_BUF_SIZE 4096
These 4 KiB buffers live in priv_auto, which is fine, but the existing sandbox TPM2 emulator caps responses at TPM2_MAX_BUF_SIZE in tpm-v2.h — please reuse that rather than inventing new sizes, especially since the goal is to integrate with that state machine.
Regards,
Simon
PATCH v4 12/14 test: add wolfTPM C unit tests and Python integration tests
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add comprehensive test suites for wolfTPM commands, modeled after the existing TPM2 test infrastructure.
test/cmd/wolftpm.c (C unit tests):
18 tests using U-Boot's unit test framework (CMD_TEST macro):
- autostart, init, info, state, device: basic lifecycle
- self_test (full and continue): TPM self-test verification
- startup_clear, startup_state: TPM2_Startup modes
- get_capability: read TPM properties
- caps: wolfTPM-enhanced capabilities display
- clear: TPM state reset via LOCKOUT hierarchy
- pcr_read, pcr_extend, pcr_print: PCR operations
- pcr_allocate: PCR bank reconfiguration
- dam_reset, dam_parameters: dictionary attack mitigation
- change_auth: hierarchy password change (requires wolfCrypt)
- cleanup: reset TPM state after tests
Run with: ut cmd cmd_test_wolftpm_*
test/cmd/Makefile:
Adds wolftpm.o when CONFIG_TPM_WOLF is enabled.
test/py/tests/test_wolftpm.py (Python integration tests):
21 tests using pytest with the U-Boot test framework:
- Requires QEMU + swtpm (not sandbox) because wolfTPM bypasses U-Boot's driver model and communicates directly with TPM hardware via its own SPI/MMIO HAL
- Tests mirror the C tests but run end-to-end through the U-Boot console, checking return codes via 'echo $?'
- Includes force_init() helper for TPM reinitialization after test failures
- Skippable via env__wolftpm_device_test_skip config
- Verified: 19 passed, 2 skipped (change_auth requires wolfCrypt, get_capability may skip on some platforms)
--- test/cmd/Makefile | 1 + test/cmd/wolftpm.c | 364 +++++++++++++++++++++++++++++++++ test/py/tests/test_wolftpm.py | 375 ++++++++++++++++++++++++++++++++++ 3 files changed, 740 insertions(+) create mode 100644 test/cmd/wolftpm.c create mode 100644 test/py/tests/test_wolftpm.py
test/cmd/Makefile +1 -0
@@ -45,3 +45,4 @@ endif obj-$(CONFIG_ARM_FFA_TRANSPORT) += armffa.o endif obj-$(CONFIG_CMD_SPAWN) += spawn.o +obj-$(CONFIG_TPM_WOLF) += wolftpm.o
test/cmd/wolftpm.c new file +364 -0
364 lines not on this page · raw message
test/py/tests/test_wolftpm.py new file +375 -0
375 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH v4 12/14] test: add wolfTPM C unit tests and Python integration tests
Hi Aidan,
Quoted 37 lines · Aidan Garske
From: Aidan <[email protected]>
Add comprehensive test suites for wolfTPM commands, modeled after the existing TPM2 test infrastructure.
test/cmd/wolftpm.c(C unit tests):
18 tests using U-Boot's unit test framework (CMD_TESTmacro):
- autostart, init, info, state, device: basic lifecycle
-self_test(full and continue): TPM self-test verification
-startup_clear,startup_state:TPM2_Startupmodes
-get_capability: read TPM properties
- caps: wolfTPM-enhanced capabilities display
- clear: TPM state reset via LOCKOUT hierarchy
-pcr_read,pcr_extend,pcr_print: PCR operations
-pcr_allocate: PCR bank reconfiguration
-dam_reset,dam_parameters: dictionary attack mitigation
-change_auth: hierarchy password change (requires wolfCrypt)
- cleanup: reset TPM state after tests
Run with: ut cmd cmd_test_wolftpm_*test/cmd/Makefile:
Adds wolftpm.o whenCONFIG_TPM_WOLFis enabled.
test/py/tests/test_wolftpm.py(Python integration tests):
21 tests using pytest with the U-Boot test framework:
- Requires QEMU + swtpm (not sandbox) because wolfTPM bypasses U-Boot's driver model and communicates directly with TPM hardware via its own SPI/MMIO HAL
- Tests mirror the C tests but run end-to-end through the U-Boot console, checking return codes via 'echo $?'
- Includesforce_init()helper for TPM reinitialization after test failures
- Skippable viaenv__wolftpm_device_test_skipconfig
- Verified: 19 passed, 2 skipped (change_authrequires wolfCrypt,get_capabilitymay skip on some platforms)
Quoted 8 lines
Signed-off-by Aidan Garske <[email protected]>--- test/cmd/Makefile | 1 + test/cmd/wolftpm.c | 364 +++++++++++++++++++++++++++++++++ test/py/tests/test_wolftpm.py | 375 ++++++++++++++++++++++++++++++++++ 3 files changed, 740 insertions(+) create mode 100644 test/cmd/wolftpm.c create mode 100644 test/py/tests/test_wolftpm.py
Thank you for writing tests here. For the cmd tests it is a good idea to check the console output - see the UTF_CONSOLE flag and things like ut_assert_nextline()
Regards,
Simon
PATCH v4 13/14 doc: add wolfTPM documentation
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add documentation for wolfTPM integration, commands, and testing.
doc/usage/cmd/wolftpm.rst:
Comprehensive RST documentation covering:
- All wolfTPM tpm2 subcommands with usage and examples
- Infineon TPM firmware update step-by-step guide (extract manifest/firmware, load to RAM, perform update, recovery mode)
- Build instructions for RPi4 and QEMU targets
- Enabling debug output (U-Boot log system + wolfTPM library)
- Complete test suite documentation with test coverage table
- Python test framework setup (QEMU + swtpm instructions, helper scripts, verified test results)
README.wolftpm.md:
Quick-start guide with overview, feature comparison vs standard U-Boot TPM, command reference, build instructions, hardware support details, and file listing.
README:
Add CONFIG_TPM_WOLF reference in the configuration options section alongside existing CONFIG_TPM entries.
--- README | 3 + README.wolftpm.md | 154 +++++++++ doc/usage/cmd/wolftpm.rst | 685 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 842 insertions(+) create mode 100644 README.wolftpm.md create mode 100644 doc/usage/cmd/wolftpm.rst
README +3 -0
@@ -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 +154 -0
154 lines not on this page · raw message
doc/usage/cmd/wolftpm.rst new file +685 -0
685 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH v4 14/14 configs: add rpi_4_wolftpm_defconfig
In reply to Aidan GarskeFrom: Aidan <[email protected]>
Add a new defconfig variant for Raspberry Pi 4 that enables the wolfTPM stack and the hardware SPI driver out of the box, so users with an Infineon SLB9670 / SLB9672 TPM HAT can build a working U-Boot in a single 'make rpi_4_wolftpm_defconfig && make' step.
This is a separate defconfig rather than a modification to rpi_4_defconfig because the average RPi 4 user does not have a TPM attached and should not pay for SPI + TPM + wolfTPM code size by default - that was the concern raised against v3's modification of rpi_4_defconfig.
Compared to rpi_4_defconfig this enables:
- CONFIG_SPI / CONFIG_DM_SPI / CONFIG_BCM2835_SPI / CONFIG_CMD_SPI The hardware SPI controller driver added earlier in this series, plus the spi command for diagnostics.
- CONFIG_TPM / CONFIG_TPM_V2 / CONFIG_CMD_TPM
The core TPM 2.0 stack and 'tpm2' command.
- CONFIG_TPM_WOLF / CONFIG_CMD_WOLFTPM / CONFIG_WOLFTPM_SLB9672 wolfTPM as the active TPM backend, with SLB9672 firmware-update support enabled. CONFIG_WOLFTPM_LINUX_DEV is left off so wolfTPM uses its native SPI HAL (the Linux-dev path is the QEMU+swtpm path, not the bare-metal RPi path).
No debug / unit-test config (LOG, LOGLEVEL, UNIT_TEST, CONSOLE_RECORD, HEXDUMP) is enabled - those belong in a developer's local .config, not in a defconfig shipped in tree.
--- configs/rpi_4_wolftpm_defconfig | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 configs/rpi_4_wolftpm_defconfig
configs/rpi_4_wolftpm_defconfig new file +81 -0
@@ -0,0 +1,81 @@ +CONFIG_ARM=y +CONFIG_ARCH_BCM283X=y +CONFIG_TEXT_BASE=0x00080000 +CONFIG_TARGET_RPI_4=y +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe30 +CONFIG_ENV_SIZE=0x4000 +CONFIG_DEFAULT_DEVICE_TREE="bcm2711-rpi-4-b" +CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_DM_RESET=y +CONFIG_SYS_LOAD_ADDR=0x1000000 +CONFIG_PCI=y +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y +CONFIG_BOOTSTD_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y +CONFIG_FDT_SIMPLEFB=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start;" +CONFIG_SYS_PBSIZE=1049 +# CONFIG_DISPLAY_CPUINFO is not set +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_MISC_INIT_R=y +CONFIG_SYS_PROMPT="U-Boot> " +CONFIG_CMD_NVEDIT_EFI=y +CONFIG_CMD_DFU=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PCI=y +CONFIG_CMD_SPI=y +CONFIG_CMD_USB=y +CONFIG_CMD_EFIDEBUG=y +CONFIG_CMD_TPM=y +CONFIG_CMD_FS_UUID=y +CONFIG_CMD_WOLFTPM=y +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" +CONFIG_ENV_RELOC_GD_ENV_ADDR=y +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y +CONFIG_TFTP_TSIZE=y +CONFIG_DM_DMA=y +CONFIG_DFU_MMC=y +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000 +CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000 +CONFIG_BCM2835_GPIO=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y +CONFIG_MMC_SDHCI_BCM2835=y +CONFIG_BCMGENET=y +CONFIG_PCI_BRCMSTB=y +CONFIG_DM_RNG=y +CONFIG_PINCTRL=y +# CONFIG_PINCTRL_GENERIC is not set +CONFIG_RNG_IPROC200=y +# CONFIG_REQUIRE_SERIAL_CONSOLE is not set +CONFIG_SPI=y +CONFIG_DM_SPI=y +CONFIG_BCM2835_SPI=y +CONFIG_SYSINFO=y +CONFIG_SYSINFO_SMBIOS=y +# CONFIG_WOLFTPM_LINUX_DEV is not set +CONFIG_WOLFTPM_SLB9672=y +CONFIG_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PCI=y +CONFIG_USB_KEYBOARD=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="FSL" +CONFIG_USB_GADGET_VENDOR_NUM=0x0525 +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_VIDEO=y +# CONFIG_VIDEO_BPP8 is not set +# CONFIG_VIDEO_BPP16 is not set +CONFIG_SYS_WHITE_ON_BLACK=y +CONFIG_VIDEO_BCM2835=y +CONFIG_CONSOLE_SCROLL_LINES=10 +CONFIG_PHYS_TO_BUS=y +CONFIG_TPM=y +# CONFIG_HEXDUMP is not set
Signature · 1 line
2.49.0
Re: [PATCH v4 14/14] configs: add rpi_4_wolftpm_defconfig
Quoted 25 lines · Aidan Garske
From: Aidan <[email protected]>
Add a new defconfig variant for Raspberry Pi 4 that enables the wolfTPM stack and the hardware SPI driver out of the box, so users with an Infineon SLB9670 / SLB9672 TPM HAT can build a working U-Boot in a single 'make
rpi_4_wolftpm_defconfig&& make' step.This is a separate defconfig rather than a modification to
rpi_4_defconfigbecause the average RPi 4 user does not have a TPM attached and should not pay for SPI + TPM + wolfTPM code size by default - that was the concern raised against v3's modification ofrpi_4_defconfig.Compared to
rpi_4_defconfigthis enables:
-CONFIG_SPI/CONFIG_DM_SPI/CONFIG_BCM2835_SPI/CONFIG_CMD_SPIThe hardware SPI controller driver added earlier in this series, plus the spi command for diagnostics.
-CONFIG_TPM/CONFIG_TPM_V2/CONFIG_CMD_TPM
The core TPM 2.0 stack and 'tpm2' command.
-CONFIG_TPM_WOLF/CONFIG_CMD_WOLFTPM/CONFIG_WOLFTPM_SLB9672wolfTPM as the active TPM backend, with SLB9672 firmware-update support enabled.CONFIG_WOLFTPM_LINUX_DEVis left off so wolfTPM uses its native SPI HAL (the Linux-dev path is the QEMU+swtpm path, not the bare-metal RPi path).
Quoted 5 lines
No debug / unit-test config (LOG, LOGLEVEL,
UNIT_TEST,CONSOLE_RECORD, HEXDUMP) is enabled - those belong in a developer's local .config, not in a defconfig shipped in tree.Signed-off-by Aidan Garske <[email protected]>
Peter what is your view on that. Shall we add config options for specific hats?
I'm inclined to do so, but I wonder if we can have some kind of config overlay instead of a fresh new config. (I'm not aware that U-Boot allows for something like this right now).
Regards,
Matthias
Quoted 92 lines
--- configs/rpi_4_wolftpm_defconfig | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)create mode 100644 configs/rpi_4_wolftpm_defconfig
configs/rpi_4_wolftpm_defconfig new file +81
-0@@ -0,0 +1,81 @@ +CONFIG_ARM=y +CONFIG_ARCH_BCM283X=y +CONFIG_TEXT_BASE=0x00080000 +CONFIG_TARGET_RPI_4=y +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe30 +CONFIG_ENV_SIZE=0x4000 +CONFIG_DEFAULT_DEVICE_TREE="bcm2711-rpi-4-b" +CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_DM_RESET=y +CONFIG_SYS_LOAD_ADDR=0x1000000 +CONFIG_PCI=y +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y +CONFIG_BOOTSTD_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y +CONFIG_FDT_SIMPLEFB=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start;" +CONFIG_SYS_PBSIZE=1049 +# CONFIG_DISPLAY_CPUINFO is not set +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_MISC_INIT_R=y +CONFIG_SYS_PROMPT="U-Boot> " +CONFIG_CMD_NVEDIT_EFI=y +CONFIG_CMD_DFU=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PCI=y +CONFIG_CMD_SPI=y +CONFIG_CMD_USB=y +CONFIG_CMD_EFIDEBUG=y +CONFIG_CMD_TPM=y +CONFIG_CMD_FS_UUID=y +CONFIG_CMD_WOLFTPM=y +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" +CONFIG_ENV_RELOC_GD_ENV_ADDR=y +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y +CONFIG_TFTP_TSIZE=y +CONFIG_DM_DMA=y +CONFIG_DFU_MMC=y +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000 +CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000 +CONFIG_BCM2835_GPIO=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y +CONFIG_MMC_SDHCI_BCM2835=y +CONFIG_BCMGENET=y +CONFIG_PCI_BRCMSTB=y +CONFIG_DM_RNG=y +CONFIG_PINCTRL=y +# CONFIG_PINCTRL_GENERIC is not set +CONFIG_RNG_IPROC200=y +# CONFIG_REQUIRE_SERIAL_CONSOLE is not set +CONFIG_SPI=y +CONFIG_DM_SPI=y +CONFIG_BCM2835_SPI=y +CONFIG_SYSINFO=y +CONFIG_SYSINFO_SMBIOS=y +# CONFIG_WOLFTPM_LINUX_DEV is not set +CONFIG_WOLFTPM_SLB9672=y +CONFIG_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PCI=y +CONFIG_USB_KEYBOARD=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="FSL" +CONFIG_USB_GADGET_VENDOR_NUM=0x0525 +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_VIDEO=y +# CONFIG_VIDEO_BPP8 is not set +# CONFIG_VIDEO_BPP16 is not set +CONFIG_SYS_WHITE_ON_BLACK=y +CONFIG_VIDEO_BCM2835=y +CONFIG_CONSOLE_SCROLL_LINES=10 +CONFIG_PHYS_TO_BUS=y +CONFIG_TPM=y +# CONFIG_HEXDUMP is not set
Re: [PATCH v4 14/14] configs: add rpi_4_wolftpm_defconfig
Quoted 33 lines · Matthias Brugger
Quoted 29 lines · Aidan Garske
From: Aidan <[email protected]>
Add a new defconfig variant for Raspberry Pi 4 that enables the wolfTPM stack and the hardware SPI driver out of the box, so users with an Infineon SLB9670 / SLB9672 TPM HAT can build a working U-Boot in a single 'make
rpi_4_wolftpm_defconfig&& make' step.This is a separate defconfig rather than a modification to
rpi_4_defconfigbecause the average RPi 4 user does not have a TPM attached and should not pay for SPI + TPM + wolfTPM code size by default - that was the concern raised against v3's modification ofrpi_4_defconfig.Compared to
rpi_4_defconfigthis enables:
-CONFIG_SPI/CONFIG_DM_SPI/CONFIG_BCM2835_SPI/CONFIG_CMD_SPIThe hardware SPI controller driver added earlier in this series, plus the spi command for diagnostics.
-CONFIG_TPM/CONFIG_TPM_V2/CONFIG_CMD_TPM
The core TPM 2.0 stack and 'tpm2' command.
-CONFIG_TPM_WOLF/CONFIG_CMD_WOLFTPM/CONFIG_WOLFTPM_SLB9672wolfTPM as the active TPM backend, with SLB9672 firmware-update support enabled.CONFIG_WOLFTPM_LINUX_DEVis left off so wolfTPM uses its native SPI HAL (the Linux-dev path is the QEMU+swtpm path, not the bare-metal RPi path).No debug / unit-test config (LOG, LOGLEVEL,
UNIT_TEST,CONSOLE_RECORD, HEXDUMP) is enabled - those belong in a developer's local .config, not in a defconfig shipped in tree.
Quoted 7 lines
Quoted 1 line
Signed-off-by Aidan Garske <[email protected]>Peter what is your view on that. Shall we add config options for specific hats?
I'm inclined to do so, but I wonder if we can have some kind of config overlay instead of a fresh new config. (I'm not aware that U-Boot allows for something like this right now).
I covered it in my reply to the cover letter[1], in short it should likely be based on rpi_arm64, and it can use include files to reduce maintenance burden.
[1] https://lists.denx.de/pipermail/u-boot/2026-May/618524.html
Quoted 96 lines
Regards,
MatthiasQuoted 92 lines
--- configs/rpi_4_wolftpm_defconfig | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)create mode 100644 configs/rpi_4_wolftpm_defconfig
configs/rpi_4_wolftpm_defconfig new file +81
-0@@ -0,0 +1,81 @@ +CONFIG_ARM=y +CONFIG_ARCH_BCM283X=y +CONFIG_TEXT_BASE=0x00080000 +CONFIG_TARGET_RPI_4=y +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe30 +CONFIG_ENV_SIZE=0x4000 +CONFIG_DEFAULT_DEVICE_TREE="bcm2711-rpi-4-b" +CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_DM_RESET=y +CONFIG_SYS_LOAD_ADDR=0x1000000 +CONFIG_PCI=y +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y +CONFIG_BOOTSTD_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y +CONFIG_FDT_SIMPLEFB=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start;" +CONFIG_SYS_PBSIZE=1049 +# CONFIG_DISPLAY_CPUINFO is not set +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_MISC_INIT_R=y +CONFIG_SYS_PROMPT="U-Boot> " +CONFIG_CMD_NVEDIT_EFI=y +CONFIG_CMD_DFU=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PCI=y +CONFIG_CMD_SPI=y +CONFIG_CMD_USB=y +CONFIG_CMD_EFIDEBUG=y +CONFIG_CMD_TPM=y +CONFIG_CMD_FS_UUID=y +CONFIG_CMD_WOLFTPM=y +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" +CONFIG_ENV_RELOC_GD_ENV_ADDR=y +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y +CONFIG_TFTP_TSIZE=y +CONFIG_DM_DMA=y +CONFIG_DFU_MMC=y +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000 +CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000 +CONFIG_BCM2835_GPIO=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y +CONFIG_MMC_SDHCI_BCM2835=y +CONFIG_BCMGENET=y +CONFIG_PCI_BRCMSTB=y +CONFIG_DM_RNG=y +CONFIG_PINCTRL=y +# CONFIG_PINCTRL_GENERIC is not set +CONFIG_RNG_IPROC200=y +# CONFIG_REQUIRE_SERIAL_CONSOLE is not set +CONFIG_SPI=y +CONFIG_DM_SPI=y +CONFIG_BCM2835_SPI=y +CONFIG_SYSINFO=y +CONFIG_SYSINFO_SMBIOS=y +# CONFIG_WOLFTPM_LINUX_DEV is not set +CONFIG_WOLFTPM_SLB9672=y +CONFIG_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PCI=y +CONFIG_USB_KEYBOARD=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="FSL" +CONFIG_USB_GADGET_VENDOR_NUM=0x0525 +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_VIDEO=y +# CONFIG_VIDEO_BPP8 is not set +# CONFIG_VIDEO_BPP16 is not set +CONFIG_SYS_WHITE_ON_BLACK=y +CONFIG_VIDEO_BCM2835=y +CONFIG_CONSOLE_SCROLL_LINES=10 +CONFIG_PHYS_TO_BUS=y +CONFIG_TPM=y +# CONFIG_HEXDUMP is not set
Hi Aidan
Quoted 2 lines · Aidan Garske
Hi all,
Thanks for all the efforts. Unfortunaltely I don't think we can pick any of these up. WolfTPM is listed as GPLv3, which is incompatible with U-Boot [0]. Tom am I misunderstanding any of this?
Quoted 78 lines
This is v4 of the wolfTPM TPM 2.0 stack integration for U-Boot.
What this series does
---------------------wolfTPM (https://github.com/wolfSSL/wolfTPM) is a portable TPM 2.0 library that provides a full TPM 2.0 command set, an SPI/MMIO HAL, and firmware-update support for Infineon SLB9672/SLB9673 hardware. This series wires it into U-Boot as an *optional* alternative backend behind the existing 'tpm2' command, plus the supporting infrastructure to make it run on QEMU+swtpm, sandbox, and real Raspberry Pi 4 + Infineon SLB9672 hardware.
Why a second TPM backend
------------------------U-Boot already has a working TPM 2.0 stack and Peter Robinson asked in v3 review what value this brings. The honest answer is:
1. Firmware update support for Infineon SLB9672/SLB9673. The existing U-Boot TPM 2.0 stack has no firmware-update command; wolfTPM provides the manifest+image flashing flow used by Infineon's recovery / security-patch tooling. This is the primary "why now" reason for boards shipping Infineon TPM HATs where the field-updatable firmware is part of the supported lifecycle.
2. Optional native SPI HAL. The wolfTPM library can talk to a TPM via either (a) U-Boot's existing TPM driver model (the
WOLFTPM_LINUX_DEVpath; this is what QEMU+swtpm uses in this series) or (b) its own SPI HAL bypassing driver model. Path (b) is what lets the BCM2835/BCM2711 driver in patch 3 talk straight to the Infineon HAT on a stock Pi 4 without needing the broader TPM uclass machinery.3. Backend selection is a
Kconfigswitch;CONFIG_TPM_WOLFis default-off and 'tpm2' continues to dispatch to the existing backend unless the user opts in. No defconfig in tree turns this on today except the newrpi_4_wolftpmone this series adds.Maintenance
-----------wolfTPM is imported as a git subtree under lib/wolftpm (mirroring how lib/mbedtls, lib/lwip and dts/upstream are maintained in tree), and
tools/update-subtree.shknows about it. Updates flow through the standardgit subtree pullpath, not as separate patches.Note on license: github.com/wolfSSL/wolfTPM currently shows GPL-3.0 in its repo badge. wolfSSL is working on a GPLv2-compatible release for upstreaming purposes; this series is being sent now to get review on the integration shape, with the understanding that the license question is being addressed separately by wolfSSL before this is appropriate to merge. I will follow up on the list when that's resolved.
Changes since v3
----------------Addressing review from Peter Robinson on v3:
- SPI driver copyright attribution fixed to credit the original Linux kernel authors (Chris Boot, Stephen Warren, Martin Sperl) the U-Boot driver is ported from. The driver is still in this series rather than split off, because nothing else in the tree uses it yet and decoupling it would just create a "blocked on" dependency chain; if reviewers prefer it split, happy to do that in v5.
-rpi_4_defconfigis no longer modified. v3 addedCONFIG_LOG/ LOGLEVEL=7 /UNIT_TEST/CONSOLE_RECORD/ HEXDUMP to it - that was wrong, it's not what the average RPi user wants. Instead, v4 adds a *new*rpi_4_wolftpm_defconfigthat enables only the bits a wolfTPM user actually needs (SPI + TPM + wolfTPM). No debug / unit-test pollution. Users who don't want wolfTPM continue to userpi_4_defconfiguntouched.
- The TPM device-tree node for the SLB9670/9672 on RPi 4 has been moved out ofbcm2711-rpi-4-b.dts(which is Linux-derived and
Quoted 9 lines
should match upstream) and into
bcm2711-rpi-4-b-u-boot.dtsi(which is the U-Boot convention for U-Boot-only DT additions). This means SystemReady firmware-provided FDTs and the upstream Linux DT are no longer polluted by this series.
- DT changes are now split into three per-device commits (RPi4, QEMU arm64, sandbox) instead of one combined commit.
- Commit messages rewritten to explain *why* the change is being made, not just *what* configs are set.
[...]
[0] https://github.com/wolfSSL/wolfTPM/blob/master/LICENSE
Thanks
/Ilias
Quoted 9 lines · Ilias Apalodimas
Hi Aidan
Quoted 2 lines · Aidan Garske
Hi all,
Thanks for all the efforts. Unfortunaltely I don't think we can pick any of these up. WolfTPM is listed as GPLv3, which is incompatible with U-Boot [0]. Tom am I misunderstanding any of this?
Yes, as I understand it as well (and Peter raised this question on v3 yesterday too), this is GPLv3 and not GPLv2 (older wolfSSL used to be v2) and so no, isn't compatible.
Signature · 1 line
Tom
Hi all,
Yes we have moved all our libraries to GPLv3. We have made exceptions for some open source projects to allow GPLv2 see here: https://github.com/wolfSSL/wolfssl/blob/master/LICENSING#L8. We are willing to do this for wolfTPM and DENX/U-Boot.
Thanks,
Aidan
Quoted 19 lines · Tom Rini
Quoted 9 lines · Ilias Apalodimas
Hi Aidan
Quoted 2 lines · Aidan Garske
Hi all,
Thanks for all the efforts. Unfortunaltely I don't think we can pick any of these up. WolfTPM is listed as GPLv3, which is incompatible with U-Boot [0]. Tom am I misunderstanding any of this?
Yes, as I understand it as well (and Peter raised this question on v3 yesterday too), this is GPLv3 and not GPLv2 (older wolfSSL used to be v2) and so no, isn't compatible.
Signature · 1 line
Tom
Hi Aidan,
Quoted 27 lines
This is v4 of the wolfTPM TPM 2.0 stack integration for U-Boot.
What this series does
---------------------wolfTPM (https://github.com/wolfSSL/wolfTPM) is a portable TPM 2.0 library that provides a full TPM 2.0 command set, an SPI/MMIO HAL, and firmware-update support for Infineon SLB9672/SLB9673 hardware. This series wires it into U-Boot as an *optional* alternative backend behind the existing 'tpm2' command, plus the supporting infrastructure to make it run on QEMU+swtpm, sandbox, and real Raspberry Pi 4 + Infineon SLB9672 hardware.
Why a second TPM backend
------------------------U-Boot already has a working TPM 2.0 stack and Peter Robinson asked in v3 review what value this brings. The honest answer is:
1. Firmware update support for Infineon SLB9672/SLB9673. The existing U-Boot TPM 2.0 stack has no firmware-update command; wolfTPM provides the manifest+image flashing flow used by Infineon's recovery / security-patch tooling. This is the primary "why now" reason for boards shipping Infineon TPM HATs where the field-updatable firmware is part of the supported lifecycle.
Quoted 7 lines
2. Optional native SPI HAL. The wolfTPM library can talk to a TPM via either (a) U-Boot's existing TPM driver model (the
WOLFTPM_LINUX_DEVpath; this is what QEMU+swtpm uses in this series) or (b) its own SPI HAL bypassing driver model. Path (b) is what lets the BCM2835/BCM2711 driver in patch 3 talk straight to the Infineon HAT on a stock Pi 4 without needing the broader TPM uclass machinery.
I don't see what value a HAL provides here, I'm not sure we want to bypass the driver model. What value does "Not needing the broader TPM uclass machinery" provide? It's removing one layer, just for the TPM pieces, and replacing it with another.
It adds a support burden on U-Boot maintainers, potentially having to debug two different paths when issues are reported as well as the extra maintenance burden, to achieve basically the same thing. It also adds a layer of confusion for users.
Quoted 4 lines
3. Backend selection is a
Kconfigswitch;CONFIG_TPM_WOLFis default-off and 'tpm2' continues to dispatch to the existing backend unless the user opts in. No defconfig in tree turns this on today except the newrpi_4_wolftpmone this series adds.
That's not a feature, it's an implementation detail.
Quoted 7 lines
Maintenance
-----------wolfTPM is imported as a git subtree under lib/wolftpm (mirroring how lib/mbedtls, lib/lwip and dts/upstream are maintained in tree), and
tools/update-subtree.shknows about it. Updates flow through the standardgit subtree pullpath, not as separate patches.
That's the technical details, it doesn't describe who takes the added burden, CVEs, etc
Quoted 7 lines
Note on license: github.com/wolfSSL/wolfTPM currently shows GPL-3.0 in its repo badge. wolfSSL is working on a GPLv2-compatible release for upstreaming purposes; this series is being sent now to get review on the integration shape, with the understanding that the license question is being addressed separately by wolfSSL before this is appropriate to merge. I will follow up on the list when that's resolved.
From my experience license exceptions, as you mentioned in your followup email, are a complete pain in the butt, to add to it we're linking in mbedtls, libdtc, LWIP and there's likely license issues there too, note I haven't looked, which might be affected because firmware pieces all link together in a single binary.
Quoted 5 lines
Changes since v3
----------------Addressing review from Peter Robinson on v3:
Quoted 7 lines
- SPI driver copyright attribution fixed to credit the original Linux kernel authors (Chris Boot, Stephen Warren, Martin Sperl) the U-Boot driver is ported from. The driver is still in this series rather than split off, because nothing else in the tree uses it yet and decoupling it would just create a "blocked on" dependency chain; if reviewers prefer it split, happy to do that in v5.
Please split it out to it's own series, It can be tested with the standard TPM2 stack using a RPi SLB9672 module. Please see doc/CONTRIBUTE.rst about patch series for explicit details on this.
Quoted 7 lines
-
rpi_4_defconfigis no longer modified. v3 addedCONFIG_LOG/ LOGLEVEL=7 /UNIT_TEST/CONSOLE_RECORD/ HEXDUMP to it - that was wrong, it's not what the average RPi user wants. Instead, v4 adds a *new*rpi_4_wolftpm_defconfigthat enables only the bits a wolfTPM user actually needs (SPI + TPM + wolfTPM). No debug / unit-test pollution. Users who don't want wolfTPM continue to userpi_4_defconfiguntouched.
It should probably be a rpi_arm64_defconfig derived option, and I am not enamored, as the Raspberry Pi maintainer, having another option to maintain and test for regressions. Please at least look at using an #include at the very least.
Quoted 6 lines
- The TPM device-tree node for the SLB9670/9672 on RPi 4 has been moved out of
bcm2711-rpi-4-b.dts(which is Linux-derived and should match upstream) and intobcm2711-rpi-4-b-u-boot.dtsi(which is the U-Boot convention for U-Boot-only DT additions). This means SystemReady firmware-provided FDTs and the upstream Linux DT are no longer polluted by this series.
That statement is incorrect. The bcm2711-rpi-4-b-u-boot.dtsi additions still end up in the DT that is provided to the OS via FW DT.
Quoted 4 lines
- DT changes are now split into three per-device commits (RPi4, QEMU arm64, sandbox) instead of one combined commit.
- Commit messages rewritten to explain *why* the change is being made, not just *what* configs are set.
Overall I am quite conflicted on this, I don't see largely what the value is vs the extra maintenance effort.
I think we might be better off looking at what pieces need to land to make maintaining this out of tree straight forward and easy for users that wish to use the alternative option that wolfTPM provides. ATM I don't know what that would look like, it's just a thought I am expressing.
Regards,
Peter
Quoted 48 lines
Branch
------Full 16-commit history (including the subtree squash + merge that aren't sent to the list because they're too large / are a merge):
https://github.com/aidangarske/u-boot wolftpm-v4-patchesOr pull the wolfTPM source straight from
https://github.com/wolfssl/wolfTPM @664db130d57.Testing
-------- QEMU arm64 + swtpm Python test framework
./test/py/test.py--bdqemu_arm64\
-k "test_wolftpmand notut_cmd"
matches v3: 19 passed, 2 skipped. (The 2 skipped aretest_wolftpm_change_auth, which requires wolfCrypt, andtest_wolftpm_get_capability.)
-rpi_4_defconfig(unmodified vanilla path) still builds clean.
-rpi_4_wolftpm_defconfigbuilds clean, TPM node is present in the compiled bcm2711-rpi-4-b.dtb at /soc/spi@7e204000/tpm@1 with compatible "infineon,slb9670", "tcg,tpm_tis-spi".
- Real Raspberry Pi 4 + Infineon SLB9672 hardware: tpm2 autostart / info /get_capability/pcr_read/pcr_extend/ caps / clear all return expected output; firmware-update path verified.v3 thread:
https://lore.kernel.org/u-boot/?q=PATCH+v3+tpm+wolfTPMAidan Garske (14):
tpm: exporttpm_show_device,tpm_set_device, andget_tpminclude/hash: add SHA384 hash wrapper declaration for wolfTPM
spi: add BCM2835/BCM2711 hardware SPI controller driver
arm: dts: bcm2711-rpi-4-b: add Infineon SLB9670/9672 TPM in U-Boot dtsi
arm: dts: qemu-arm64: add TPM TIS MMIO node
sandbox: dts: add TPM SPI emulator node
tpm: add wolfTPM build rules andKconfig
tpm: add wolfTPM headers and SHA384 glue code
tpm: add wolfTPM driver helpers andKconfigoptions
cmd: refactor tpm2 command into frontend/backend architecture
tpm: add sandbox TPM SPI emulator
test: add wolfTPM C unit tests and Python integration tests
doc: add wolfTPM documentation
configs: addrpi_4_wolftpm_defconfig--
2.47.3