Dear David,
Thank-you very much for your answer!
After a lot of debugging, an error was found in our wolf TPM port, the response from the TPM is in fact a duplicate of the buffer sent (with small alteration). After fixing it, here is the output of the wolf TPM unit test:
[init -> spi_drv] ECSPI initialized.
[init -> test-wolftpm] tar archive 'examples.tar' local at 0x10c000, size is 450560
[init -> test-wolftpm] Waiting TPM initialization
[init -> test-wolftpm] TPM2: Caps 0x00000000, Did 0x0000, Vid 0x0000, Rid 0x 0
[init -> test-wolftpm] TPM2: Caps 0x00000000, Did 0x0000, Vid 0x0000, Rid 0x 0
[init -> test-wolftpm] [send] buffer(12): 80 01 00 00 00 0c 00 00 01 45 00 00
[init -> imx8q_spi_drv] Begin transaction with 12 bytes.
[init -> imx8q_spi_drv] Session bus settings:
[init -> imx8q_spi_drv] slave_select: 0
[init -> imx8q_spi_drv] mode: 0x0
[init -> imx8q_spi_drv] clk_polarity: 0x0
[init -> imx8q_spi_drv] clk_phase: 0x0
[init -> imx8q_spi_drv] clock_idle_state: 0x0
[init -> imx8q_spi_drv] ss_line_active_state: 0x0
[init -> imx8q_spi_drv] Pre-divider: 0xb
[init -> imx8q_spi_drv] Post-divider: 0x0
[init -> imx8q_spi_drv] Burst length: 95
[init -> imx8q_spi_drv] write: 0x80010000
[init -> imx8q_spi_drv] write: 0x000c0000
[init -> imx8q_spi_drv] write: 0x01450000
[init -> imx8q_spi_drv] Rx FIFO is ready.
[init -> imx8q_spi_drv] Tx transaction completed.
[init -> imx8q_spi_drv] read: 0x01000000
[init -> imx8q_spi_drv] read: 0x00004081
[init -> imx8q_spi_drv] read: 0xffff3f01
[init -> test-wolftpm] [received] buffer(12): 00 00 00 01 81 40 00 00 01 3f ff ff
[init -> test-wolftpm] TPM2_Shutdown failed 319: Unknown
[init -> test-wolftpm] Test TPM Wrapper: Init: Passed
[init -> test-wolftpm] TPM2: Caps 0x00000000, Did 0x0000, Vid 0x0000, Rid 0x 0
[init -> test-wolftpm] [send] buffer(22): 80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 01 05 00 00 00 08
[init -> imx8q_spi_drv] Begin transaction with 22 bytes.
[init -> imx8q_spi_drv] Session bus settings:
[init -> imx8q_spi_drv] slave_select: 0
[init -> imx8q_spi_drv] mode: 0x0
[init -> imx8q_spi_drv] clk_polarity: 0x0
[init -> imx8q_spi_drv] clk_phase: 0x0
[init -> imx8q_spi_drv] clock_idle_state: 0x0
[init -> imx8q_spi_drv] ss_line_active_state: 0x0
[init -> imx8q_spi_drv] Pre-divider: 0xb
[init -> imx8q_spi_drv] Post-divider: 0x0
[init -> imx8q_spi_drv] Burst length: 175
[init -> imx8q_spi_drv] Unaligned write: 0x80010000
[init -> imx8q_spi_drv] write: 0x00000016
[init -> imx8q_spi_drv] write: 0x0000017a
[init -> imx8q_spi_drv] write: 0x00000006
[init -> imx8q_spi_drv] write: 0x00000105
[init -> imx8q_spi_drv] write: 0x00000008
[init -> imx8q_spi_drv] Rx FIFO is ready.
[init -> imx8q_spi_drv] Tx transaction completed.
[init -> imx8q_spi_drv] unaligned read: 0x00000000
[init -> imx8q_spi_drv] read: 0x00000100
[init -> imx8q_spi_drv] read: 0x3f010000
[init -> imx8q_spi_drv] read: 0xffffffff
[init -> imx8q_spi_drv] read: 0xffffffff
[init -> imx8q_spi_drv] read: 0xffffffff
[init -> test-wolftpm] [received] buffer(22): 00 00 00 01 00 00 00 00 01 3f ff ff ff ff ff ff ff ff ff ff ff ff
[init -> test-wolftpm] TPM2_GetCapability failed 0x13f: Unknown
[init -> test-wolftpm]
[init -> test-wolftpm] ERROR - /XXXX/src/lib/wolftpm/tests/unit_tests.c line 132 failed with:
[init -> test-wolftpm] expected: rc == 0
[init -> test-wolftpm] result: 319(0x13f) != 0(0x0)
[init -> test-wolftpm]
[init -> test-wolftpm] Error: raise(ABRT)
[init] child "test-wolftpm" exited with exit value -1
I have added verbosity to the SPI driver. Please note on this run every word are swapped, the result is the same if not. Also, I don't have a read/write logic for the SPI driver. But only a 'transaction', I give a buffer of X bytes to the driver, it returns me that buffer with the X bytes received from the slave devices during the transaction.
We can now observe that in contrast with my first post, the data we received seems incoherent no matter the command we send. As you suggest, I have double-checked and made a peer-review about those parameters. Unfortunately, I couldn't get an oscilloscope connected to the bus because it is wired to the TPM through a PCI connector. I will set up a Linux environment for this platform to run the wolfTPM unit-test and make sure the initial bus configuration is correct and that the device is fully-functional.
------------
I don't really understand how the data must be sent through SPI. For one command should I send one burst of x bytes. Or x burst of one byte. Or something else?
Thanks for your time!
Best,
JA