2024-04-20 02:26 AM
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?
Solved! Go to Solution.
2024-04-25 07:57 AM
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
2024-04-20 02:49 AM
if We have to use the stsw-safea1-mw middleware, how to read the chip serial number or product ID?
2024-04-20 09:40 AM
Have you tried to look at documentation and examples?
2024-04-21 06:23 PM
Do I have to use the stsw-safea1-mw middleware to communication with the chip?
2024-04-21 06:25 PM
Of course, I have look the documentation.But I have some questions
2024-04-22 12:56 AM - edited 2024-04-22 01:03 AM
@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 ))
2024-04-22 06:17 PM
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
2024-04-23 05:11 AM - edited 2024-04-23 05:11 AM
> 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.
2024-04-25 07:57 AM
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
2024-04-25 07:15 PM
Thank you very much