Skip to content

Conversation

@aidangarske
Copy link
Contributor

@aidangarske aidangarske commented Jan 9, 2026

Description

  • Add U-Boot SPI HAL support for native TPM communication
  • Fix build compatibility for U-Boot environment

Testing

  • Build wolfTPM with U-Boot (sandbox target) (Complete)
  • Verified MMIO mode still works with swtpm/QEMU linux path fine
  • Test SPI communication with TPM hardware (TODO)
  • tested with latest code here

Changes

hal/tpm_io.c

  • Add U-Boot SPI HAL implementation (TPM2_IoCb_Uboot_SPI)
  • Implement TIS SPI protocol with wait-state handling (WOLFTPM_CHECK_WAIT_STATE)
  • Add configurable SPI bus/CS via TPM_SPI_BUS, TPM_SPI_CS, TPM_SPI_MAX_HZ
  • Use U-Boot's spi_get_bus_and_cs() and spi_xfer() APIs

src/tpm2.c

  • Guard close(ctx->fd) with !defined(UBOOT) to prevent build error (U-Boot doesn't have file descriptors in this context)

Configuration

When UBOOT is defined:

  • Uses U-Boot's SPI driver model via <spi.h> and <dm/uclass.h>
  • SPI settings configurable in user_settings.h or board config
  • Supports both wait-state polling and direct transfer modes

@aidangarske aidangarske self-assigned this Jan 9, 2026
@dgarske dgarske self-requested a review January 9, 2026 21:49
@dgarske dgarske self-assigned this Jan 9, 2026
@aidangarske aidangarske marked this pull request as ready for review January 24, 2026 01:08
  - Change default TPM_SPI_CS to 1 (CE1/GPIO7) to match official
    Raspberry Pi tpm-slb9670 overlay used by LetsTrust and Infineon HATs
  - Use _spi_get_bus_and_cs() with explicit speed/mode parameters
    for proper SPI device initialization
  - Add required includes for asm/io.h and dm/device-internal.h
  - Improve debug message prefixes for clarity

  Tested on Raspberry Pi 4 with Infineon SLB9672 TPM HAT.
@aidangarske
Copy link
Contributor Author

@dgarske this is ready to be review/merged now. I tested everything on latest wolftpm uboot changes

@dgarske dgarske merged commit 6898e84 into wolfSSL:master Jan 26, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants