cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the STSAFE_A110 serial number

dylanou
Associate III

dylanou_0-1713604004224.png

Hi 

I have the project with the chip STSAFE_A110

I don't need to development the application 

I just need to confirm the hardware is ok, for example, obtained the sn of the chip is successfully or other way

I don't want to add the stsw-safea1-mw to my project, There's no other easy way?

1 ACCEPTED SOLUTION

Accepted Solutions
Benjamin BARATTE
ST Employee

Hi @dylanou,

you can get inspiration with the following code https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/+/refs/heads/main/platform/ext/target/stm/common/secure_element/stsafea/se_psa/se_psa.c

in the psa_se_st_get_serial() you have a simple example on how to get the serial number of the STSAFE-A without the middleware.

You have this variable  

uint8_t sn_data[] = { 0x14, 0x11, 0xFC, 0xBE };  

which is the command to do a query product data to the STSAFE-A.

Then the basic communication over the I2C : 

  ret = BSP_I2C_Send(0x40, sn_data, 4);
  if (ret == 0)
  {
    BSP_TimeDelay(5);
    ret = BSP_I2C_Recv(0x40, r_data, 69);
  }
  if (ret != 0)
  {
    return PSA_ERROR_HARDWARE_FAILURE;
  }

You need to adapt the BSP_I2C_Send to your I2C driver.

and here a simple trick to get the Serial Number directly from the response :

  uint8_t r_data[100];
  uint8_t *sn = &r_data[10];

 

The serial number is 9 bytes long.

Best Regards,

Benjamin

 

View solution in original post

9 REPLIES 9
dylanou
Associate III

if We have to use the stsw-safea1-mw middleware, how to read the chip serial number or product ID?

Pavel A.
Evangelist III

Have you tried to look at documentation and examples?

 

dylanou
Associate III

Do I have to use the stsw-safea1-mw middleware to communication with the chip?

dylanou
Associate III

Of course, I have look the documentation.But I have some questions

Pavel A.
Evangelist III

@dylanou If your questions are confidential, consider a support request here.

Or are you just looking for help to make a small test application that reads the serial number from STSAFE? On which eval. board?

I don't want to add the stsw-safea1-mw to my project, There's no other easy way?

Of course, there is easy way. Someone else can do this. Make it Someone Else's Problem, and warp your project forward ))

 

Or are you just looking for help to make a small test application that reads the serial number from STSAFE? On which eval. board?

> Yes,that is right.I just need to confirm the hardware is ok by read ID or serial number or other

dylanou_0-1713834926590.png

 

Pavel A.
Evangelist III

I just need to confirm the hardware is ok by read ID or serial number or other

This is possible without the "middleware" libraries.  You just can check that HAL_I2C_IsDeviceReady succeeds to be quite sure that the device is responding. Then find in the documentation how to read the serial number and just do it. Hopefully this can be done using HAL_I2C_Mem_Read or HAL_I2C_Master_Receive, without any crypto voodoo. If this still sounds too hard, please see above. Make it Someone Else's Problem.

 

Benjamin BARATTE
ST Employee

Hi @dylanou,

you can get inspiration with the following code https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/+/refs/heads/main/platform/ext/target/stm/common/secure_element/stsafea/se_psa/se_psa.c

in the psa_se_st_get_serial() you have a simple example on how to get the serial number of the STSAFE-A without the middleware.

You have this variable  

uint8_t sn_data[] = { 0x14, 0x11, 0xFC, 0xBE };  

which is the command to do a query product data to the STSAFE-A.

Then the basic communication over the I2C : 

  ret = BSP_I2C_Send(0x40, sn_data, 4);
  if (ret == 0)
  {
    BSP_TimeDelay(5);
    ret = BSP_I2C_Recv(0x40, r_data, 69);
  }
  if (ret != 0)
  {
    return PSA_ERROR_HARDWARE_FAILURE;
  }

You need to adapt the BSP_I2C_Send to your I2C driver.

and here a simple trick to get the Serial Number directly from the response :

  uint8_t r_data[100];
  uint8_t *sn = &r_data[10];

 

The serial number is 9 bytes long.

Best Regards,

Benjamin

 

Thank you very much