Dear Sir.

I was have a experence like you.

And i was resolved. To implementation the "tpm set_enable" command on u-boot.


My source is see below.

=================================================

/* Control code of startup */
static
uchar cmd_startup[] = {
  0x00, 0xC1, 0x00, 0x00,
  0x00, 0x0C, 0x00, 0x00,
  0x00, 0x99, 0x00, 0x01
};

/* Control code of physPres_present */
static
uchar cmd_physPres_present[] = {
  0x00, 0xC1, 0x00, 0x00,
  0x00, 0x0C, 0x40, 0x00,
  0x00, 0x0A, 0x00, 0x08
};

/* Control code of physEnable */
static
uchar cmd_physEnable[] = {
  0x00, 0xC1, 0x00, 0x00,
  0x00, 0x0A, 0x00, 0x00,
  0x00, 0x6F
};

/* Control code of physicalDisable */
static
uchar cmd_physicalDisable[] = {
  0x00, 0xC1, 0x00, 0x00,
  0x00, 0x0A, 0x00, 0x00,
  0x00, 0x70
};

/* Control code of physicalSetDeactivated_false */
static
uchar cmd_physicalSetDeactivated_false[] = {
  0x00, 0xC1, 0x00, 0x00,
  0x00, 0x0B, 0x00, 0x00,
  0x00, 0x72, 0x00
};

/* Control code of physicalSetDeactivated_true */
static
uchar cmd_physicalSetDeactivated_true[] = {
  0x00, 0xC1, 0x00, 0x00,
  0x00, 0x0B, 0x00, 0x00,
  0x00, 0x72, 0x01
};


static
int
__tpm_command(const uint cmd,    /* tpm command */
              const uint subAddr,/* I2C sub addr */
              const uint mDelay, /* delay time between write and read */
const uint dump) /* If is set, will print out buffer to console */
{
  int len = 0;
  int ret;
  unsigned char *cmd_buf = NULL, r_buf[512];

  switch(cmd)
  {
    case TPM_CMD_STARTUP:
        printf("## TPM_CMD_STARTUP\n");
        cmd_buf = cmd_startup;
        len = sizeof(cmd_startup)/sizeof(uchar);
      break;
    case TPM_CMD_PHYS_PRES_PRESENT:
        printf("## TPM_CMD_PHYS_PRES_PRESENT\n");
        cmd_buf = cmd_physPres_present;
        len = sizeof(cmd_physPres_present)/sizeof(uchar);
      break;
    case TPM_CMD_PHYS_ENABLE:
        printf("## TPM_CMD_PHYS_ENABLE\n");
        cmd_buf = cmd_physEnable;
        len = sizeof(cmd_physEnable)/sizeof(uchar);
      break;
    case TPM_CMD_PHYS_DISABLE:
        printf("## TPM_CMD_PHYS_DISABLE\n");
        cmd_buf = cmd_physicalDisable;
        len = sizeof(cmd_physicalDisable)/sizeof(uchar);
      break;
    case TPM_CMD_PHYS_SET_DEACTIVATED_FALSE:
        printf("## TPM_CMD_PHYS_SET_DEACTIVATED_FALSE\n");
        cmd_buf = cmd_physicalSetDeactivated_false;
        len = sizeof(cmd_physicalSetDeactivated_false)/sizeof(uchar);
      break;
    case TPM_CMD_PHYS_SET_DEACTIVATED_TRUE:
        printf("## TPM_CMD_PHYS_SET_DEACTIVATED_TRUE\n");
        cmd_buf = cmd_physicalSetDeactivated_true;
        len = sizeof(cmd_physicalSetDeactivated_true)/sizeof(uchar);
      break;
    default:
        printf("%s() : Wrong command\n", __FUNCTION__);
      break;
  }

  memset(r_buf, 0x00, sizeof(r_buf));

  ret = tpm_i2c_write(subAddr, cmd_buf, len, dump);

  mdelay(mDelay);

  ret = tpm_i2c_read(subAddr, r_buf, sizeof(r_buf), dump);

  mdelay(10);

  return ret;
}


static
int
do_tpm_setEnable(cmd_tbl_t *cmdtp,
                 int flag,
                 int argc,
                 char * const argv[])
{
  int subAddr = CONFIG_TPM_ATMEL_ADDR;
FUNC_DEBUG("# %s(), subAddr 0x%x\n", __FUNCTION__, CONFIG_TPM_ATMEL_ADDR);

  if (!FLAG_TPM_POWER_UP)
  {
    do_tpm_power_up(cmdtp, flag, argc, argv);
  }

  __tpm_command(TPM_CMD_STARTUP, subAddr, 100, ENABLE);
  __tpm_command(TPM_CMD_PHYS_PRES_PRESENT, subAddr, 10, ENABLE);
  __tpm_command(TPM_CMD_PHYS_ENABLE, subAddr, 10, ENABLE);
  __tpm_command(TPM_CMD_PHYS_SET_DEACTIVATED_FALSE, subAddr, 10, ENABLE);

  return 0;
}


=================================================


Please refer this code.

Thank you.




2016-07-19 오후 3:51에 mipsan.K 이(가) 쓴 글:
Dear,

I'm handling a TPM with Exynos5422, and Debian Jessie as an OS.
TPM is connected via I2C with SoC.
 - Kernel ver: 3.10.96
 - Debian Jessie 8.1
 - trousers: 0.3.13-4
 - tpm-tools: 1.3.8-2

After start TrouSers, tpm_version command shows as follow;
Restarting trousers (via systemctl): trousers.service.
  TPM 1.2 Version Info:
  Chip Version:        1.2.133.32
  Spec Level:          2
  Errata Revision:     3
  TPM Vendor ID:       IFX
  Vendor Specific data: 85200050 0074706d 3438ffff ff
  TPM Version:         01010000
  Manufacturer Info:   49465800

However, when I try to takeownership, it returns an error as follow;
and setenable as well.

root@odroid:/home/odroid# tpm_takeownership
Enter owner password:
Confirm password:
Enter SRK password:
Confirm password:
Tspi_TPM_TakeOwnership failed: 0x00000007 - layer=tpm, code=0007 (7), TPM is disabled

root@odroid:/home/odroid# tpm_clear -f
Tspi_TPM_ClearOwner failed: 0x00000007 - layer=tpm, code=0007 (7), TPM is disabled

root@odroid:/home/odroid# tpm_setenable -e
Enter owner password:
Tspi_TPM_SetStatus failed: 0x00000001 - layer=tpm, code=0001 (1), Authentication failed

root@odroid:/home/odroid# tpm_setenable -e
Enter owner password:
Tspi_TPM_SetStatus failed: 0x00000803 - layer=tpm, code=0803 (2051), TPM is defending against dictionary attacks and is in some time-out period
-------------------------

I cannot clear TPM nor get ownership for further job.
Any idea would be appreciated.

Thanks
mipsan



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev


_______________________________________________
TrouSerS-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-users


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
TrouSerS-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-users

Reply via email to