From 2b260e9edcee48c1d701549fb9313f6ba0dee4ad Mon Sep 17 00:00:00 2001 From: "Jes B. Klinke" Date: Wed, 14 Feb 2024 11:23:08 -0800 Subject: [PATCH] [opentitantool] Fix crippled I2C TPM support Is seems that PR #21289 introduced a bug that prevents `opentitantool i2c tpm ...` from working at all. This CL restores the proper use of `Any<>` to allow passing the I2C driver object to the TPM command handler in the way that it expects. Also, a logic condition was accidentally reversed, making the new --gsc-ready flag ineffective for I2C. Change-Id: I2b791de25666876c49dccccd83bdbc9369e608be Signed-off-by: Jes B. Klinke --- sw/host/opentitanlib/src/tpm/driver.rs | 2 +- sw/host/opentitantool/src/command/i2c.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sw/host/opentitanlib/src/tpm/driver.rs b/sw/host/opentitanlib/src/tpm/driver.rs index b1d6d70dd4119..210d193225643 100644 --- a/sw/host/opentitanlib/src/tpm/driver.rs +++ b/sw/host/opentitanlib/src/tpm/driver.rs @@ -394,7 +394,7 @@ impl I2cDriver { } fn try_read_register(&self, register: Register, data: &mut [u8]) -> Result<()> { - if self.gsc_ready_pin.is_some() { + if self.gsc_ready_pin.is_none() { // Do two I2C transfers in one call, for lowest latency. self.i2c.run_transaction( None, /* default addr */ diff --git a/sw/host/opentitantool/src/command/i2c.rs b/sw/host/opentitantool/src/command/i2c.rs index 05bf564481855..663349cd7160d 100644 --- a/sw/host/opentitantool/src/command/i2c.rs +++ b/sw/host/opentitantool/src/command/i2c.rs @@ -278,7 +278,7 @@ impl CommandDispatch for I2cTpm { Some(pin) => Some((transport.gpio_pin(pin)?, transport.gpio_monitoring()?)), None => None, }; - let tpm_driver = Box::new(tpm::I2cDriver::new( + let tpm_driver: Box = Box::new(tpm::I2cDriver::new( context.params.create(transport, "TPM")?, ready_pin, )?);