Hi David,
Thanks for your reply. After I apply the patch on the tpm2.c and turn on the debug verbose --enable-debug=verbose, the message shows after running the unit_test as,

firefly@firefly:~/wolftpm/tests$ sudo ./unit.test
TPM2_Init failed -173: Bad function argument
Trying TPM @ /dev/spidev0.0 (33 MHz)
Trying TPM @ /dev/spidev0.1 (33 MHz)
Found TPM @ /dev/spidev0.1
TPM2: Caps 0x30000697, Did 0x00fc, Vid 0x1050, Rid 0x 1
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
Test TPM Wrapper:       Init:   Passed
TPM2: Caps 0x30000697, Did 0x00fc, Vid 0x1050, Rid 0x 1
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 05 00 00 00 08                               | ......
Response: 83
        80 01 00 00 00 53 00 00 00 00 01 00 00 00 06 00 | .....S..........
        00 00 08 00 00 01 05 4e 54 43 00 00 00 01 06 4e | .......NTC.....N
        50 43 54 00 00 01 07 37 35 78 00 00 00 01 08 22 | PCT....75x....."
        21 21 34 00 00 01 09 72 6c 73 00 00 00 01 0a 00 | !!4....rls......
        00 00 00 00 00 01 0b 00 07 00 02 00 00 01 0c 00 | ................
        02 00 00                                        | ...
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 2d 00 00 00 01                               | .-....
Response: 27
        80 01 00 00 00 1b 00 00 00 00 3d 7f 91 ea fb b7 | ..........=.....
        be f3 bf af 80 87 01 fd eb de d4                | ...........
Unknown capability type 0x7f91eafb
TPM2: Caps 0x00000000, Did 0x0000, Vid 0x0000, Rid 0x 0
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 05 00 00 00 08                               | ......
Response: 83
        80 01 00 00 00 53 00 00 00 00 01 00 00 00 06 00 | .....S..........
        00 00 08 00 00 01 05 4e 54 43 00 00 00 01 06 4e | .......NTC.....N
        50 43 54 00 00 01 07 37 35 78 00 00 00 01 08 22 | PCT....75x....."
        21 21 34 00 00 01 09 72 6c 73 00 00 00 01 0a 00 | !!4....rls......
        00 00 00 00 00 01 0b 00 07 00 02 00 00 01 0c 00 | ................
        02 00 00                                        | ...
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 2d 00 00 00 01                               | .-....
Response: 27
        80 01 00 00 00 1b 00 00 00 00 3d 7f 91 ea fb b7 | ..........=.....
        be f3 bf af 80 87 01 fd eb de d4                | ...........
Unknown capability type 0x7f91eafb
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
Test TPM Wrapper:       Open Existing:  Passed
TPM2: Caps 0x30000697, Did 0x00fc, Vid 0x1050, Rid 0x 1
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 05 00 00 00 08                               | ......
Response: 83
        80 01 00 00 00 53 00 00 00 00 01 00 00 00 06 00 | .....S..........
        00 00 08 00 00 01 05 4e 54 43 00 00 00 01 06 4e | .......NTC.....N
        50 43 54 00 00 01 07 37 35 78 00 00 00 01 08 22 | PCT....75x....."
        21 21 34 00 00 01 09 72 6c 73 00 00 00 01 0a 00 | !!4....rls......
        00 00 00 00 00 01 0b 00 07 00 02 00 00 01 0c 00 | ................
        02 00 00                                        | ...
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 2d 00 00 00 01                               | .-....
Response: 27
        80 01 00 00 00 1b 00 00 00 00 3d 7f 91 ea fb b7 | ..........=.....
        be f3 bf af 80 87 01 fd eb de d4                | ...........
Unknown capability type 0x7f91eafb
Mfg NTC (4), Vendor NPCT75x"!!4rls, Fw 7.2 (131072), FIPS 140-2 0, CC-EAL4 0
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
Test TPM Wrapper:       Get Capabilities:       Passed
TPM2: Caps 0x30000697, Did 0x00fc, Vid 0x1050, Rid 0x 1
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 03 8b d4 1f | .....,..... ....
        64 c9 a9 72 a0 bf ac 51 41 81 e7 de de 11 07 8a | d..r...QA.......
        9f cc 0c 09 bd f1 8d 00 b3 f4 fc 8a             | ............
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 70 51 2b 29 | .....,..... pQ+)
        7d f6 83 a0 54 4c 9c 2c 45 0c 9f a8 73 a3 8d a7 | }...TL.,E...s...
        fa fe 6d db a7 1c be f8 6b 32 64 da             | ..m.....k2d.
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 77 a6 bb 48 | .....,..... w..H
        88 7f f1 37 22 bc ed 35 5e 27 42 c7 77 b0 54 74 | ...7"..5^'B.w.Tt
        0b 96 af c5 17 68 d4 55 dd fe ff 22             | .....h.U..."
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 7c 16 a7 19 | .....,..... |...
        b6 37 dc 5a 9f 1a 23 c8 c8 87 e3 94 49 34 eb 32 | .7.Z..#.....I4.2
        ed 43 0e 04 36 5f 82 3d 59 5f d1 0e             | .C..6_.=Y_..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 64 5f 3d 21 | .....,..... d_=!
        a3 e6 e2 d4 3b 8a 3b a4 a8 cf bd 00 f5 fc 3e e1 | ....;.;.......>.
        b0 e6 51 8e d4 96 f7 db ac bd 06 32             | ..Q........2
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 ee b2 d4 e7 | .....,..... ....
        c2 03 10 a2 c7 f1 1e 57 d9 c8 df c4 de d6 ab 9d | .......W........
        2d 3c 16 ed db d5 05 a0 8a 73 74 4a             | -<.......stJ
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 31 38 3d e8 | .....,..... 18=.
        c7 8c b7 9c dd 7a 35 79 78 e3 b4 8a e3 77 5c 00 | .....z5yx....w\.
        28 e0 51 63 66 fd 5c b8 30 85 06 93             | (.Qcf.\.0...
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 32 65 e1 18 | .....,..... 2e..
        ed 2d 4f db ca 81 69 0a af 8c 70 d7 c8 79 b7 e8 | .-O...i...p..y..
        bd a3 2e c8 cc 60 ef 4a b2 af 36 19             | .....`.J..6.
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 2a 07 73 14 | .....,..... *.s.
        2f 5a 25 ea 9f ae 7c a8 c0 5e a4 12 12 da 1a 69 | /Z%...|..^.....i
        59 29 63 dc 4a c2 67 25 42 9e b9 f7             | Y)c.J.g%B...
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 84 d8 8d c8 | .....,..... ....
        80 ef 93 58 1a 9f 73 81 70 bf d9 2c 3f c4 d9 55 | ...X..s.p..,?..U
        8e d9 73 76 e1 83 31 d9 e2 ab 90 bf             | ..sv..1.....
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 fb 67 56 6c | .....,..... .gVl
        ff 1c f4 97 fe 6a 89 59 fb 14 93 32 e6 e3 85 b4 | .....j.Y...2....
        c2 58 05 43 00 0b 47 29 38 af 65 39             | .X.C..G)8.e9
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 a8 6e ba a3 | .....,..... .n..
        ba e2 d3 8b 4f a2 59 ef 0a b6 06 96 c1 45 9e 81 | ....O.Y......E..
        62 57 6a 94 b1 4b eb af 96 8b d3 09             | bWj..K......
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 7f 5c 7c cd | .....,..... .\|.
        eb 16 08 1b cc 8b d6 61 21 f8 67 1f 38 f6 0a b2 | .......a!.g.8...
        00 cb 14 43 01 d2 d2 8c c7 fd f7 7e             | ...C.......~
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 9d 2e 61 6b | .....,..... ..ak
        8b 96 d0 81 2f df 0d 22 38 7c 3f 02 ba 39 ab 85 | ..../.."8|?..9..
        34 db 33 81 21 a6 e6 f1 14 7a e8 0d             | 4.3.!....z..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 b6 87 ce bd | .....,..... ....
        bc 31 35 99 b5 ae 89 10 4f 45 b7 a4 b0 88 a3 ee | .15.....OE......
        18 54 80 a5 94 c0 f9 20 f2 ac 86 6b             | .T..... ...k
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 ef 7c 70 98 | .....,..... .|p.
        cd 68 f9 34 6f ef bc dd 74 f4 de 0f f4 70 e9 7a | .h.4o...t....p.z
        9e b7 b4 33 d4 aa 2f 03 98 43 8b b1             | ...3../..C..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 2a 2b 72 01 | .....,..... *+r.
        e2 00 bf ca d5 ad 07 f1 87 fa 3a 9a a8 1c f4 aa | ..........:.....
        d5 d6 1d 22 59 61 40 3e 6e 55 e6 29             | ..."Ya@>nU.)
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 b6 66 bc 35 | .....,..... .f.5
        39 98 3b c0 bf 05 b0 2b 9d 22 d8 83 de 7a f0 cf | 9.;....+."...z..
        70 bd 67 80 1c ed 2f 85 02 9e 12 81             | p.g.../.....
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 84 f9 ea 93 | .....,..... ....
        2a 72 1e a1 f9 9e 6d 16 2c 2a 77 09 94 45 e8 4f | *r....m.,*w..E.O
        36 05 ba f2 99 9f 61 21 ce ec a9 5f             | 6.....a!..._
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 e1 2d 6b 77 | .....,..... .-kw
        5b 6c 8f 6e e0 3b c2 70 f3 85 c3 08 01 90 b6 7d | [l.n.;.p.......}
        29 85 be 51 3e 3f 3a 14 df c1 2c 51             | )..Q>?:...,Q
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 49 fd 49 13 | .....,..... I.I.
        d1 ed 49 93 75 5e 4b f6 fa 49 5c 82 9a fe 9a 9f | ..I.u^K..I\.....
        8d 55 60 cb 42 59 bb 1c da 83 94 bb             | .U`.BY......
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 9e 51 66 db | .....,..... .Qf.
        a0 4f 4a 8c b5 e6 81 8b 75 98 a8 e7 e5 2f 04 33 | .OJ.....u..../.3
        68 5c f0 07 d1 b6 12 eb a6 97 04 dd             | h\..........
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 53 26 d9 be | .....,..... S&..
        1c bd 28 9d a5 99 7d d6 56 c7 31 44 cb c5 05 7a | ..(...}.V.1D...z
        ce e4 92 62 13 b9 e4 df 98 4d fe 19             | ...b.....M..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 1b 04 dd ee | .....,..... ....
        98 50 32 d6 6c 3f de 46 93 b2 10 ac a2 db 36 e1 | .P2.l?.F......6.
        ea 7d bb f1 46 e9 00 da d5 dd 04 2a             | .}..F......*
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 8c cd 26 56 | .....,..... ..&V
        9a 5c 60 4d 1f 4d 6f c2 15 a5 e8 f9 85 57 9d cb | .\`M.Mo......W..
        32 00 24 97 20 c5 a2 b8 38 c6 3f ea             | 2.$. ...8.?.
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 e4 61 00 55 | .....,..... .a.U
        69 f5 e6 1e a5 d4 eb 50 08 ee d1 9d e0 3e 61 15 | i......P.....>a.
        b8 32 fe 49 b0 3d 44 ac 9e d1 8d b5             | .2.I.=D.....
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 04 8c e3 aa | .....,..... ....
        26 89 45 90 cd a1 50 c1 b8 63 6b f3 f7 1f 28 e0 | &.E...P..ck...(.
        50 f2 e7 7d 93 de f5 42 af 87 a2 cf             | P..}...B....
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 09 43 6e cd | .....,..... .Cn.
        28 f4 49 3f e8 69 b5 b4 a3 b8 ac 51 7b cd 35 e8 | (.I?.i.....Q{.5.
        1d 5c f3 71 27 48 5a 1d 50 c6 72 ad             | .\.q'HZ.P.r.
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 25 63 99 f5 | .....,..... %c..
        0c 99 bf db 6c 0d 65 a2 79 7e 12 de a7 b6 55 f3 | ....l.e.y~....U.
        c0 61 f7 59 09 59 07 94 f1 16 41 7d             | .a.Y.Y....A}
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 88 a4 68 25 | .....,..... ..h%
        35 27 bf ce da b5 95 30 94 34 d6 45 49 d3 10 b4 | 5'.....0.4.EI...
        92 be 8a 91 33 83 6d 4b ea a9 f3 55             | ....3.mK...U
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 75 c2 7f 6e | .....,..... u..n
        f4 f3 9d 0b 4d 32 47 f4 4e 5e 28 33 3f 86 c5 e8 | ....M2G.N^(3?...
        ed f7 a6 60 25 40 cf 86 13 e8 bf 17             | ...`%@......
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 8f 2e af 35 | .....,..... ...5
        52 e8 05 f9 62 b5 ab cc 3c 9f 90 f8 83 c2 82 14 | R...b...<.......
        97 04 e4 1c 66 a3 d0 83 ef 74 91 0a             | ....f....t..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 2f 7a 05 12 | .....,..... /z..
        04 a1 91 23 86 5a 5f ae 22 b7 50 1c 9f 7f 11 67 | ...#.Z_.".P....g
        0f c9 81 bc 39 13 92 f7 be 90 3c 10             | ....9.....<.
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 0e 8a 89 55 | .....,..... ...U
        42 56 a0 49 d0 2c d8 98 cf 3b 99 fb f2 9a 03 58 | BV.I.,...;.....X
        a3 be c1 31 fe 09 dd 01 70 59 94 ca             | ...1....pY..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 09 a3 e4 bb | .....,..... ....
        03 95 17 6f 3e 92 64 f5 5e 27 36 97 2f e1 e2 5d | ...o>.d.^'6./..]
        07 b8 b3 d7 9e 8e f2 d8 74 0f 05 14             | ........t...
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 74 0e 5b 25 | .....,..... t.[%
        d0 3d 14 f3 3f e9 97 1b b4 9c ac 70 d6 d2 0c 2c | .=..?......p...,
        49 da d4 d9 5f ef be 58 b7 42 81 ed             | I..._..X.B..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 e6 8e 7f 8c | .....,..... ....
        6c a0 78 cd 09 b9 ff 0f 9f 7e 0d 52 c6 13 49 59 | l.x......~.R..IY
        cb d9 68 c4 7e d6 11 05 fe 5f a3 86             | ..h.~...._..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 dc 2a 44 42 | .....,..... .*DB
        71 36 6b 4b 23 d2 d7 a1 9a 71 40 9c 3d 0f 7b fc | q6kK#....q@.=.{.
        20 ab 37 5b e5 5b a3 67 b3 a8 71 c5             |  .7[.[.g..q.
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 85 32 b3 8f | .....,..... .2..
        fd 8b 39 b4 fb b2 68 24 66 b0 ed bc 2c ec 4a 4f | ..9...h$f...,.JO
        f6 2f 6e ab d9 4c 9b fd 35 a5 13 6e             | ./n..L..5..n
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 cb 1f 98 54 | .....,..... ...T
        46 fa b1 b3 19 b3 bb e2 4c 15 6c 61 44 0d 0c 94 | F.......L.laD...
        d3 98 85 97 61 79 54 e5 5d b3 49 f6             | ....ayT.].I.
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 25 7d 2a 8a | .....,..... %}*.
        35 88 40 a9 8c 12 24 3b ec 9c b7 30 33 a9 a1 05 | 5.@...$;...03...
        13 a8 46 d7 f8 86 9e c6 db b6 a3 d6             | ..F.........
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 e8 ce b8 b0 | .....,..... ....
        91 bf 2c 94 31 94 34 c3 8b 98 5a 4a b8 5a 3e 15 | ..,.1.4...ZJ.Z>.
        48 cb 53 8e 00 b8 1d 47 dd 30 3a 3e             | H.S....G.0:>
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 c9 41 19 f0 | .....,..... .A..
        9c 5d 48 d2 3d 1c 12 e8 44 60 14 f1 e2 e7 ba 35 | .]H.=...D`.....5
        64 e0 40 91 b1 ef 53 f5 42 de 20 b1             | d.@...S.B. .
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 29 5e 72 d4 | .....,..... )^r.
        75 a7 4a 82 97 fc c5 18 53 78 ad 55 f9 fc e2 73 | u.J.....Sx.U...s
        4a ff 03 80 1f 84 38 9b 9e 73 b8 24             | J.....8..s.$
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 7d 27 a3 aa | .....,..... }'..
        b7 a8 2c 6c d7 dd 58 c9 3c d3 ce b4 c7 bb bb 6e | ..,l..X.<......n
        78 8b 20 36 4b 82 a4 f7 e5 cb b8 6c             | x. 6K......l
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 cd 12 4a 0e | .....,..... ..J.
        65 29 36 e5 0e 19 02 10 0e 81 f9 d7 63 09 d4 c6 | e)6.........c...
        05 96 39 e3 95 a3 14 7b 5f 69 d8 f0             | ..9....{_i..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 76 d9 6d 1f | .....,..... v.m.
        23 13 88 f6 b8 d8 09 48 93 5a fc d6 b5 b7 33 c0 | #......H.Z....3.
        47 c3 45 d5 4b 0e 2c 59 c0 a3 2e 2d             | G.E.K.,Y...-
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 fa 77 fe 02 | .....,..... .w..
        82 8c 78 53 e3 3c d1 58 8d 74 93 39 63 11 de 77 | ..xS.<.X.t.9c..w
        d0 bb 6b 4d 3a 80 48 8e 2d 77 ab 3c             | ..kM:.H.-w.<
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 69 0a 23 83 | .....,..... i.#.
        bc 77 ec 19 db 93 52 1f 22 58 ef 4e a9 22 7d cf | .w....R."X.N."}.
        35 b9 e2 5d bb 76 d6 71 26 c4 b3 07             | 5..].v.q&...
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 fa 6b 42 a6 | .....,..... .kB.
        53 bf 30 74 37 cc 76 78 0d 4e ca a9 5a 3a d9 0b | S.0t7.vx.N..Z:..
        9d cd 96 8c c3 9f 57 97 19 fd 71 40             | ......W...q@
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 dc 63 ca a5 | .....,..... .c..
        1a 1f 6d 3b 43 99 eb 35 80 d2 7b a1 4f d4 be 7d | ..m;C..5..{.O..}
        fd 8a 50 45 9b 19 70 99 6d 6f d1 39             | ..PE..p.mo.9
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 71 c7 91 fa | .....,..... q...
        bf 9b 50 22 9f e4 8d 66 19 c9 cb 4c 92 0f cf 05 | ..P"...f...L....
        25 de c3 83 b2 3c 56 41 a2 17 fe a5             | %....<VA....
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 7c 0a d1 e5 | .....,..... |...
        2a 0a 04 ed e9 f3 24 d5 90 62 8c 35 69 2b d0 17 | *.....$..b.5i+..
        13 0a b4 8e 6e 38 99 7e fb 36 e0 de             | ....n8.~.6..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 03 f3 7e 42 | .....,..... ..~B
        a3 b4 0d e2 16 81 2f fc 17 02 ac 05 92 f9 ac c3 | ....../.........
        bb dc 2e 1d 1c d9 ef 44 62 1f b6 7f             | .......Db...
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 f1 09 ef 23 | .....,..... ...#
        aa 79 d2 04 3a a2 98 63 27 30 bc 57 6e 75 55 f3 | .y..:..c'0.WnuU.
        64 ff a7 32 f8 af a3 4b a5 e2 e9 c4             | d..2...K....
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 36 6a b1 de | .....,..... 6j..
        e6 01 8d 4b f4 e7 76 30 8f 78 bf b8 4b fc e9 28 | ...K..v0.x..K..(
        d8 cd ae e3 ce a1 02 fd 16 82 71 fd             | ..........q.
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 04 f8 43 76 | .....,..... ..Cv
        80 be be b8 9d 9b e7 d1 9a 41 73 c8 af ce 02 00 | .........As.....
        c4 a6 2d 60 27 4d c3 52 ee 35 fd 8f             | ..-`'M.R.5..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 b4 04 cf f3 | .....,..... ....
        8c d8 4f 43 fa 85 17 3a 66 2a 30 f7 95 d9 ee 2d | ..OC...:f*0....-
        25 37 d8 df a6 bc a5 e9 50 dc 29 b5             | %7......P.).
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 fd d2 d1 e5 | .....,..... ....
        70 75 2f a2 80 46 a3 e3 63 76 52 24 88 e6 b3 e8 | pu/..F..cvR$....
        fa 18 3b 60 b8 07 9e 6f 51 4d fa 04             | ..;`...oQM..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 00 f1 d3 a8 | .....,..... ....
        83 9f e4 a8 82 95 90 f1 ff 89 3e de 38 0c 02 17 | ..........>.8...
        72 17 b0 52 3e 1a b6 d2 0e af 05 9a             | r..R>.......
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 5b db 70 ef | .....,..... [.p.
        1b f9 b4 47 b1 2e 57 b9 c6 84 87 05 45 b5 8f 37 | ...G..W.....E..7
        e4 5d 81 d1 68 49 e7 ad a3 6f be fb             | .]..hI...o..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 28 bc 10 2f | .....,..... (../
        54 c6 83 8b 18 41 0d fe a2 50 af f4 fe 52 2e 9a | T....A...P...R..
        dc 5c 35 8f b6 4d 0d a3 88 75 98 1f             | .\5..M...u..
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 3b cf a0 50 | .....,..... ;..P
        e2 16 c4 d5 d3 71 62 8b b4 da 8e 30 fc d6 ce 91 | .....qb....0....
        13 5e 31 c3 81 9b e3 e7 33 be 01 27             | .^1.....3..'
Command: 12
        80 01 00 00 00 0c 00 00 01 7b 00 20             | .........{.
Response: 44
        80 01 00 00 00 2c 00 00 00 00 00 20 a4 d0 05 f5 | .....,..... ....
        f7 2d 10 a4 5b 29 14 05 c8 60 da 7a 60 d2 8c e9 | .-..[)...`.z`...
        3f 22 b1 b2 57 20 4f 6e d0 cc 05 5c             | ?"..W On...\
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
Test TPM Wrapper:       Get Random:     Passed
Test TPM Wrapper:       KDFa:   Passed
TPM2: Caps 0x30000697, Did 0x00fc, Vid 0x1050, Rid 0x 1
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 14
        80 01 00 00 00 0e 00 00 01 73 81 00 02 00       | .........s....
Response: 10
        80 01 00 00 00 0a 00 00 01 8b                   | ..........
TPM2_ReadPublic failed 395: TPM_RC_HANDLE: The handle is not correct for the use
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
Test TPM Wrapper:       Read Public Key:        Passed
Test TPM Wrapper:       CSR Subject:    Passed
TPM2: Caps 0x30000697, Did 0x00fc, Vid 0x1050, Rid 0x 1
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
Test TPM Wrapper:       Cleanup:        Passed
Test TPM Wrapper:       Thread Local Storage    Failed

==========================
It looks like go lots further, these is failed on the "Thread Local Storage". So how we can get this storage tested if necessary?
Appreciate your helps for my evaluation project to this point.

Richeal C.

Hi Dgarske,
Many thanks for the reply. I tried the recommendation you mentioned, and the message shows as following,
firefly@firefly:~/wolftpm/examples$ sudo ./wrap/wrap_test
TPM2 Demo for Wrapper API's
Trying TPM @ /dev/spidev0.0 (33 MHz)
Trying TPM @ /dev/spidev0.1 (33 MHz)
Found TPM @ /dev/spidev0.1
TPM2: Caps 0x30000697, Did 0x00fc, Vid 0x1050, Rid 0x 1
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 05 00 00 00 08                               | ......
Response: 83
        80 01 00 00 00 53 00 00 00 00 01 00 00 00 06 00 | .....S..........
        00 00 08 00 00 01 05 4e 54 43 00 00 00 01 06 4e | .......NTC.....N
        50 43 54 00 00 01 07 37 35 78 00 00 00 01 08 22 | PCT....75x....."
        21 21 34 00 00 01 09 72 6c 73 00 00 00 01 0a 00 | !!4....rls......
        00 00 00 00 00 01 0b 00 07 00 02 00 00 01 0c 00 | ................
        02 00 00                                        | ...
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 2d 00 00 00 01                               | .-....
Response: 27
        80 01 00 00 00 1b 00 00 00 00 3d 7f 90 ea fb b7 | ..........=.....
        be f3 bb af 80 87 01 fd eb de d4                | ...........
Unknown capability type 0x7f90eafb
TPM2_GetCapability failed 0xffffffff: unknown error number
Failure 0xffffffff: unknown error number
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
wolfTPM2_Shutdown complete
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........

==============================================
really can not tell if needs more works for the capability verification.  Please advise.
Thanks,
Richeal C.

Hi David,
Many thanks for the reply.
After I put --enable-detectwaitstate and slow to 33 MHz with --enable-autodetect, and --enable-debug=verbose. the message came up as,

firefly@firefly:~/wolftpm/tests$ sudo ./unit.test
TPM2_Init failed -173: Bad function argument
Trying TPM @ /dev/spidev0.0 (33 MHz)
Trying TPM @ /dev/spidev0.1 (33 MHz)
Found TPM @ /dev/spidev0.1
TPM2: Caps 0x30000697, Did 0x00fc, Vid 0x1050, Rid 0x 1
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
Test TPM Wrapper:       Init:   Passed
TPM2: Caps 0x30000697, Did 0x00fc, Vid 0x1050, Rid 0x 1
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 05 00 00 00 08                               | ......
Response: 83
        80 01 00 00 00 53 00 00 00 00 01 00 00 00 06 00 | .....S..........
        00 00 08 00 00 01 05 4e 54 43 00 00 00 01 06 4e | .......NTC.....N
        50 43 54 00 00 01 07 37 35 78 00 00 00 01 08 22 | PCT....75x....."
        21 21 34 00 00 01 09 72 6c 73 00 00 00 01 0a 00 | !!4....rls......
        00 00 00 00 00 01 0b 00 07 00 02 00 00 01 0c 00 | ................
        02 00 00                                        | ...
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 2d 00 00 00 01                               | .-....
Response: 27
        80 01 00 00 00 1b 00 00 00 00 3d 7f 90 ea fb b7 | ..........=.....
        be f3 bb af 80 87 01 fd eb de d4                | ...........
Unknown capability type 0x7f90eafb
TPM2_GetCapability failed 0xffffffff: unknown error number

ERROR - tests/unit_tests.c line 131 failed with:
    expected: rc == 0
    result:   -1(0xffffffff) != 0(0x0)

Aborted
================================================
which shows match with NPCT750 TPM2.0 module
Caps: 0x30000697
Did: 0x00fc
Vid: 0x1050
Rid: 0x1
provided by document.

Then I changed to SLB9670 Asus tpm2.0 module, run the same unit_test with same configuration. the message shows,
firefly@firefly:~/wolftpm/tests$ sudo ./unit.test
TPM2_Init failed -173: Bad function argument
Trying TPM @ /dev/spidev0.0 (33 MHz)
Trying TPM @ /dev/spidev0.1 (33 MHz)
Found TPM @ /dev/spidev0.1
TPM2: Caps 0x30000697, Did 0x001b, Vid 0x15d1, Rid 0x16
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 12
        80 01 00 00 00 0c 00 00 01 45 00 00             | .........E..
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
Test TPM Wrapper:       Init:   Passed
TPM2: Caps 0x30000697, Did 0x001b, Vid 0x15d1, Rid 0x16
Command: 12
        80 01 00 00 00 0c 00 00 01 44 00 00             | .........D..
Response: 10
        80 01 00 00 00 0a 00 00 01 00                   | ..........
TPM2_Startup pass
Command: 11
        80 01 00 00 00 0b 00 00 01 43 01                | .........C.
Response: 10
        80 01 00 00 00 0a 00 00 00 00                   | ..........
TPM2_SelfTest pass
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 05 00 00 00 08                               | ......
Response: 83
        80 01 00 00 00 53 00 00 00 00 01 00 00 00 06 00 | .....S..........
        00 00 08 00 00 01 05 49 46 58 00 00 00 01 06 53 | .......IFX.....S
        4c 42 39 00 00 01 07 36 37 30 00 00 00 01 08 00 | LB9....670......
        00 00 00 00 00 01 09 00 00 00 00 00 00 01 0a 00 | ................
        00 00 00 00 00 01 0b 00 07 00 55 00 00 01 0c 00 | ..........U.....
        11 cb 00                                        | ...
Command: 22
        80 01 00 00 00 16 00 00 01 7a 00 00 00 06 00 00 | .........z......
        01 2d 00 00 00 01                               | .-....
Response: 27
        80 01 00 00 00 1b 00 00 00 00 3c 7f 90 ea fb b5 | ..........<.....
        be f3 bb ae 80 87 00 f5 eb de d4                | ...........
Unknown capability type 0x7f90eafb
TPM2_GetCapability failed 0xffffffff: unknown error number

ERROR - tests/unit_tests.c line 131 failed with:
    expected: rc == 0
    result:   -1(0xffffffff) != 0(0x0)

Aborted
========================================
It also matches with the SLB9670 ID,
Caps:0x3000 0697
Did:0x001b
Vid:0x15d1
Rid:0x16

and passed several start tests.

But both aborted unit_test on the Caps test.

How that Caps test read from both modules with all high ? and how I can further debug them?

Thanks,

Richeal C.

This post is viewed most frequently, wondering if any conclusions come up? I suffered the similar issues, instead of NPCT I use SLB9670 TPM2 module from Asus.
From the unit_test of wolftpm/tests, shows
TX | 80 D4 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |.....|
RX | 00 00 00 01 03 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  |.....|
and keeps on this pair run till the hardware time-out.

however, I use spidev_test,
sudo ./spidev_test -v -s 33000000 -p "\x80\xd4\x00\x00\x00" -D /dev/spidev0.1
spi mode: 0x0
bits per word: 8
max speed: 33000000 Hz (33000 KHz)
TX | 80 D4 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | ��...
RX | 00 00 00 01 82 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | ....�

and got somethings can be read back.
anyone can help out to see how this can be debugged further?

Many thanks,

Richeal C.



however, I used spidev_test , it shows
firefly@firefly:~/spidev_test_dev$ sudo ./spidev_test -v -s 33000000 -p "\x80\xd4\x00\x00\x00" -D /dev/spidev0.1
spi mode: 0x0
bits per word: 8
max speed: 33000000 Hz (33000 KHz)
TX | 80 D4 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | ��...
RX | 00 00 00 01 82 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | ....�

Same 33 MHz on SPI clk for unit_test and spidev_test. Still do not know what these issues may be.