I2C Communication between STM32 and SE050 - R-APDU body missing

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C Communication between STM32 and SE050 - R-APDU body missing

Jump to solution
5,640 Views
genygbo
Contributor II

Hello team,

I'm performing an i2c communication between OM-SE050ARD (SE) and STM32F030R8 Nucleo (Master). I'm able to get the response. But whenever I perform an operation (say "Get_Version" or "Digest_OneShot"), I only get the Header part and the CRC as response. The actual response body is not displayed. My output is always seen as "A5, 90, 00, FB, E9". Is there any particular command I need to send for the actual response? Any leads would be much appreciated.

Thanks!

Elshadai

Labels (1)
1 Solution
5,098 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Elshadai,

1. As per my understanding, Lc field is used for the length of the payload. In this case we do not have a payload. So shouldn't we write Lc = 0x00 ?

 - Since no payload but Le is required, so you just need to specify Le here.

2. With the above values this is my trace and i only get 9000 but not the body. Before sending these commands I do a soft reset and read out the ATR bytes which works fine. 

- Did you select the applet after ATR? Please kindly refer to 4.4 from https://www.nxp.com/docs/en/application-note/AN12413-SE050_APDU_specification.pdf  for details.

Hope that helps,

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

14 Replies
5,098 Views
ronan_prezioso
Contributor II

Hello!

I am currently evaluating the SE050 and I am newbie on T=1 and APDU protocols.

I almost get the same problem of R-APDU body missing...


Like Elshadai, I try to get an answer to "Get_Version" command.

First, I send a T=1 interface soft reset request and get a correct ATR anwser.

Then, I send the applet selection command as indicate in 4.4:


- If I set the M bit of the PCB field of the I-Block to 0 (not chained), I get an Nack to my read address byte (0x91).


- If I set the M bit of the PCB field of the I-Block to 1 (chained), I get the R-APDU trailer (9000), but not the R-APDU body (Applet version) as expected.

I don't anderstand why I have to set this M bit to 1 to get answer, and why I can't get the R-APDU body?

Any leads would be much appreciated too!

Thanks in advance!

Ronan

0 Kudos
5,098 Views
badhri_radhakri
Contributor II

Hi ronan.prezioso@swing.e-i.com,

For applet selection, try setting the sequence bit N(S) and the chaining bit M both to 0 of PCB. Please refer section 2.1.1.2.1 of UM11225

Alternatively, you can use the functions in the Plug & Trust middleware library. You just need to set up the I2C functions according to your Master board.

Hope it helps! 

Badhri

5,097 Views
ronan_prezioso
Contributor II

Hi Badhri,

Thank you!

I will try this as soon as possible.

Ronan

0 Kudos
5,097 Views
ronan_prezioso
Contributor II

Hello, 

I tried with N(s) and M both to 0.

First I got a NACK.

Then I added more delay between command and answer, and now, it works fine.

Thank for the help!

Ronan

0 Kudos
5,097 Views
stephaniesmi606
Contributor I

I am a bit concerned with the level shift observed at high level at the moment the I2C starts. Are you sure that you correctly configured GPIO as open drain in the PIO controller of the STM32 ? walgreenslistens

0 Kudos
5,097 Views
genygbo
Contributor II

Hi bukiw nci,

Thanks for the comment. The GPIO is configured as open drain in STM32. The i2c trasmission is acknowledged well. Although, my concern is that I couldn't see the R-APDU body in my output. Trying to figure out the missing data.

0 Kudos
5,097 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Do you have the trace data for a review?

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
5,097 Views
genygbo
Contributor II

Hello Kan,

Thanks for the reply. Kindly find the attached response seen when I try to call 'Get Version'.

Capture_getVersion.PNG

This is the response I get when I also call other functions like digest one shot etc. I'm able to see the R-APDU trailer in the response but I couldn't see the R-APDU body part.  Please let me know if you require more information.

Many Thanks,

Elshadai

0 Kudos
5,098 Views
genygbo
Contributor II

Hello Kan,

Please also find the T=1 block frame values for "Get version" below:

5A 20 08 8004002002410709 7306

Should I send any other values additional to this ?

Many Thanks,

Elshadai

0 Kudos
5,098 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Elshadai,

Thanks for the information! I can recognize Get Version command from the  “80040020", but what is the following "024107" for? From my understanding, this command should be "8004002009" according to the spec.

pastedImage_1.png

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
5,098 Views
genygbo
Contributor II

Thanks for the clarification. I corrected my C-APDU commands as follows:

// for Version Info
uint8_t versionPacket[10] = {0x5A, // NAD
                             0x20, // PCB
                             0x05, // LEN
                             0x80, // CLA
                             0x04, // INS
                             0x00, // P1
                             0x20, // P2
                                   // Lc-?
                             0x09, // Le
                             0x66, // CRC1
                             0xAA  // CRC2 };‍‍‍‍‍‍‍‍‍‍‍‍‍

I have 2 questions: 

1. As per my understanding, Lc field is used for the length of the payload. In this case we do not have a payload. So shouldn't we write Lc = 0x00 ?

2. With the above values this is my trace and i only get 9000 but not the body. Before sending these commands I do a soft reset and read out the ATR bytes which works fine. 

pastedImage_3.png

Really appreciate your help. Thanks!

0 Kudos
5,099 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Elshadai,

1. As per my understanding, Lc field is used for the length of the payload. In this case we do not have a payload. So shouldn't we write Lc = 0x00 ?

 - Since no payload but Le is required, so you just need to specify Le here.

2. With the above values this is my trace and i only get 9000 but not the body. Before sending these commands I do a soft reset and read out the ATR bytes which works fine. 

- Did you select the applet after ATR? Please kindly refer to 4.4 from https://www.nxp.com/docs/en/application-note/AN12413-SE050_APDU_specification.pdf  for details.

Hope that helps,

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

5,098 Views
genygbo
Contributor II

Hi Kan,

Thanks a lot for the clarification. I was missing the part of applet selection. I've included it and now, I'm able to get the R-APDU body. 

Have a nice day !

Elshadai

0 Kudos
4,192 Views
saireddy_saredd
Contributor III

Hallo Elshadai,

Kindly help on these two topics,

1. How acn you calculate the CRC1 and CRC2??

2. Can you share a piece of code how to send the applet selection ??

 

Regards,

Sai 

0 Kudos