[U-Boot] [PATCH v2 07/19] tpm: add possible traces to analyze buffers returned by the TPM

Miquel Raynal miquel.raynal at bootlin.com
Thu Mar 29 07:43:49 UTC 2018


When debugging, it is welcome to get more information about what the TPM
returns. Add the possibility to print the packets received to show their
exact content.

Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
---
 lib/tpm.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/tpm.c b/lib/tpm.c
index 2b329145be..aa46ec1693 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -249,6 +249,7 @@ static uint32_t tpm_sendrecv_command(const void *command,
 	int err, ret;
 	uint8_t response_buffer[COMMAND_BUFFER_SIZE];
 	size_t response_length;
+	int i;
 
 	if (response) {
 		response_length = *size_ptr;
@@ -260,15 +261,24 @@ static uint32_t tpm_sendrecv_command(const void *command,
 	ret = uclass_first_device_err(UCLASS_TPM, &dev);
 	if (ret)
 		return ret;
+
 	err = tpm_xfer(dev, command, tpm_command_size(command),
 		       response, &response_length);
 
 	if (err < 0)
 		return TPM_LIB_ERROR;
+
 	if (size_ptr)
 		*size_ptr = response_length;
 
-	return tpm_return_code(response);
+	ret = tpm_return_code(response);
+
+	debug("TPM response [ret:%d]: ", ret);
+	for (i = 0; i < response_length; i++)
+		debug("%02x ", ((u8 *)response)[i]);
+	debug("\n");
+
+	return ret;
 }
 
 int tpm_set_specification(int version)
-- 
2.14.1



More information about the U-Boot mailing list