AnsweredAssumed Answered

MXC_SIM - mxc_sim_test.c problem when connecting to a SAM AV2

Question asked by Arthur Morrison on Mar 15, 2019
Latest reply on Jun 3, 2019 by Arthur Morrison

Hi I am trying to get the mxc_sim_test.c t_program to execute correctly but without success . I am trying to talk to a MIFARE_SAM_AV2 with necessary T1 protocol.

 

I get as far as the getting atr output:

atr[0]= 0x3b atr[1]= 0xdf atr[2]= 0x18 atr[3]= 0xff atr[4]= 0x81 atr[5]= 0xf1 atr[6]= 0xfe atr[7]= 0x43 atr[8]= 0x0 atr[9]= 0x3f atr[10]= 0x3 atr[11]= 0x83 atr[12]= 0x4d atr[13]= 0x49 atr[14]= 0x46 atr[15]= 0x41 atr[16]= 0x52 atr[17]= 0x45 atr[18]= 0x20 atr[19]= 0x50 atr[20]= 0x6c atr[21]= 0x75 atr[22]= 0x73 atr[23]= 0x20 atr[24]= 0x53 atr[25]= 0x41 atr[26]= 0x4d atr[27]= 0x3b

 

However when I try and run the APDU transcieve commands later in the program I get a hang on receive.

I suspect that I am not filling in the values correctly from the ATR response to the parameter data blocks :

 

  /*Hardcode the setting*/
  timing_data.bgt =0; =????
  if (argc == 1) {
    timing_data.wwt = 9600; =????
    timing_data.cgt = 0x00; =????
    timing_data.cwt = 0x00; =????
   timing_data.bwt = 0x00; =????
  }
/* Values from ATR info fro TA1 in Wiki matching SAM ATR returned vals */
  baud_data.di = 1; =????
  baud_data.fi = 1; =????

 

I cannot easily see how to map the ATR vales to the overwrite the defaults above (which do not work for me). Can someone help me with the values I need to edit in? An example of a T1 equivalent of the 

send_t1_cmd(..) procedure would help too.

 

On online parser gives the following output and some of the values eg bwt= 4 cwt=3. As for the other values I am totally lost.

Results

Parsing ATR:

3B DF 18 FF 81 F1 FE 43 00 3F 03 83 4D 49 46 41 52 45 20 50 6C 75 73 20 53 41 4D 3B
TS = 0x3BDirect Convention
T0 = 0xDFY(1): b1101, K: 15 (historical bytes)
TA(1) = 0x18Fi=372, Di=12, 31 cycles/ETU (129032 bits/s at 4.00 MHz, 161290 bits/s for fMax=5 MHz)
TC(1) = 0xFFExtra guard time: 255 (special value)
TD(1) = 0x81Y(i+1) = b1000, Protocol T=1
----
TD(2) = 0xF1Y(i+1) = b1111, Protocol T=1
----
TA(3) = 0xFEIFSC: 254
TB(3) = 0x43Block Waiting Integer: 4 - Character Waiting Integer: 3
TC(3) = 0x00Error detection code: LRC
TD(3) = 0x3FY(i+1) = b0011, Protocol T=15
----
TA(4) = 0x03Clock stop: not supported - Class accepted by the card: (3G) A 5V B 3V
TB(4) = 0x83RFU
----
Historical bytes4D 49 46 41 52 45 20 50 6C 75 73 20 53 41 4D
Category indicator byte: 0x4D (proprietary format) "IFARE Plus SAM"

21/03/19 Update on Progress

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

we have made some progress on this.

 


1. The mxc_test_sim.c program is an example of T0 transmission only. Really needed a T1 example talking to the IMX_SIM driver to avoid much of the pain.

 

2. Below is some test source we have created that shows reception of an ATR, the transmission of a PPS message and reply, setting of timer values from values taken from ATR and a T1 frame. In this case a request to Get Version from an onboard MIFARE SAM AV1 . The T1 command requires NAD, Protocol and frame data length bytes prefixing the command buffer. Also the user must compute the LRC (not appended by the driver). A 32 byte version response

 

3. Driver does not support flow control/chaining of T1 as far we can see. It would be helpful if someone at NXP would point us to source of a basic C implementation of T1 that we can use that makes use of this driver.

 

4. The timing values that we used may or may not be optiimal. It would be useful to get feedback on this.

 

See attached test program/output

 

root@mdb-4355642552:~# ./SamIfTest
ReaderStart: 0
ColdReset: 0
ATR result 0 Size: 28
SEND PPSGET PPS lenght 4 PPS[0]: 0xff PPS[1]: 0x11 PPS[2]: 0x1 PPS[3]: 0xef
errval send 0
errval receive 0
 GV[0]: 0x0 GV[1]: 0x20 GV[2]: 0x20 GV[3]: 0x4 GV[4]: 0x1 GV[5]: 0x1 GV[6]: 0x3 GV[7]: 0x2 GV[8]: 0x28 GV[9]: 0x1 GV[10]: 0x4 GV[11]: 0x1 GV[12]: 0x1 GV[13]: 0x3 GV[14]: 0x2 GV[15]: 0x28 GV[16]: 0x1 GV[17]: 0x4 GV[18]: 0x12 GV[19]: 0x3e GV[20]: 0x92 GV[21]: 0x3c GV[22]: 0x50 GV[23]: 0x80 GV[24]: 0x98 GV[25]: 0x76 GV[26]: 0x58 GV[27]: 0x0 GV[28]: 0x0 GV[29]: 0x19 GV[30]: 0x7 GV[31]: 0x11 GV[32]: 0x0 GV[33]: 0xa1 GV[34]: 0x90 GV[35]: 0xde
receive lenght 36
root@mdb-4355642552:~#

Attachments

Outcomes