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)

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
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