尝试将 infenion slb9670 与 wolftpm 一起使用。将 lib 移植到自定义 spi 函数和操作系统接收0x01e(dec 30(时,这意味着TPM_RC_BAD_TAG。如果我已经收到上限,我的 Spi 连接是否正确? (相同的代码在采用STM HAL spi实现的STM32f7板上工作正常( 谢谢
rc = TPM2_Init(&tpm2Ctx, TPM2_IoCb, userCtx);
if (rc != 0)
{
tst_printf("rnTPM init failed! rc = %i;", rc);
break;
}
else
{
tst_printf("rnTPM init success!");
tst_printf("rnTPM2: Caps 0x%08x, Did 0x%04x, Vid 0x%04x, Rid 0x%2x n",
tpm2Ctx.caps,
tpm2Ctx.did_vid >> 16,
tpm2Ctx.did_vid & 0xFFFF,
tpm2Ctx.rid);
}
/* define the default session auth */
XMEMSET(tpm_session, 0, sizeof(tpm_session));
tpm_session[0].sessionHandle = TPM_RS_PW;
TPM2_SetSessionAuth(tpm_session);
if (rc != TPM_RC_SUCCESS &&
rc != TPM_RC_INITIALIZE /* TPM_RC_INITIALIZE = Already started */ ) {
tst_printf("TPM2_SetSessionAuth failed 0x%x: %sn", rc, TPM2_GetRCString(rc));
break;
}
Startup_In startup;
XMEMSET(&startup, 0, sizeof(Startup_In));
startup.startupType = TPM_SU_STATE;
rc = TPM2_Startup(&startup);
if (rc != TPM_RC_SUCCESS &&
rc != TPM_RC_INITIALIZE /* TPM_RC_INITIALIZE = Already started */ ) {
tst_printf("TPM2_Startup failed %i: %sn", rc, TPM2_GetRCString(rc));
//break;
}
tst_printf("rnTPM2_Startup pass!f");
输出:
TPM init success!
TPM2: Caps 0x30000697, Did 0x001b, Vid 0x15d1, Rid 0x10
TPM2_Startup failed 30: Unknown
编辑
cmd 的值(TPM2_TIS_SendCommand(:
80 01 00 00 00 0c 00 00 01 44 00 00 (working example)
00 00 00 00 00 0c 00 00 01 44 00 00 (my case)
80 01-TPM_ST_NO_SESSIONS必须由TPM2_Packet_Finalize添加!
错误在于正在准备数据包的函数。我的 IAR 编译器版本无法处理 16 位值的 __REV((。我使用小宏来处理,现在一切正常。