[<<][simtrace][>>][..]
Mon Jul 15 14:04:29 EDT 2013

latest pcsc-lite & libccid

# wget https://alioth.debian.org/frs/download.php/file/3920/ccid-1.4.11.tar.bz2
# wget https://alioth.debian.org/frs/download.php/file/3862/pcsc-lite-1.8.8.tar.bz2

sudo LIBCCID_ifdLogLevel=0x000F /usr/local/sbin/pcscd --foreground --debug --apdu 

These are also in debian/sid

Next problem is that pcscd seems to load the DFU configurations.
How does that work really? Why are the DFU configs enabled?
It does expose 4 interfaces.


# lsusb -v -d 03eb:6129

Bus 003 Device 074: ID 03eb:6129 Atmel Corp. AT91SAM Mass Storage Demo Application
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x03eb Atmel Corp.
  idProduct          0x6129 AT91SAM Mass Storage Demo Application
  bcdDevice            1.00
  iManufacturer           1 ATMEL
  iProduct                2 ATMEL AT91 CCID DRIVER 
  iSerial                 3 0123456789AF
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          120
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass        11 Chip/SmartCard
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      ChipCard Interface Descriptor:
        bLength                54
        bDescriptorType        33
        bcdCCID              1.10  (Warning: Only accurate for version 1.0)
        nMaxSlotIndex           0
        bVoltageSupport         1  5.0V 
        dwProtocols             1  T=0
        dwDefaultClock       3580
        dwMaxiumumClock      3580
        bNumClockSupported      0
        dwDataRate           9600 bps
        dwMaxDataRate        9600 bps
        bNumDataRatesSupp.      0
        dwMaxIFSD             254
        dwSyncProtocols  00000000 
        dwMechanical     00000000 
        dwFeatures       00010072
          Auto configuration based on ATR
          Auto clock change
          Auto baud rate change
          Auto parameter negotation made by CCID
          TPDU level exchange
        dwMaxCCIDMsgLen       271
        bClassGetResponse    echo
        bClassEnvelope       echo
        wlcdLayout           none
        bPINSupport             0 
        bMaxCCIDBusySlots       1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              16
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1 
      iInterface              4 SimTrace DFU Interface - Application Partition
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1 
      iInterface              5 SimTrace DFU Interface - Bootloader Partition
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1 
      iInterface              6 SimTrace DFU Interface - RAM
Device Status:     0x0000
  (Bus Powered)



The DFU interfaces give trouble.

Jul 15 14:22:16 zoo pcscd: ccid_usb.c:1065:ControlUSB() control failed (3/74): -7 Success
Jul 15 14:22:16 zoo pcscd: ifdwrapper.c:348:IFDStatusICC() Card not transacted: 612
Jul 15 14:22:16 zoo pcscd: eventhandler.c:202:EHSpawnEventHandler() Initial Check Failed on Sysmocom SIMtrace (0123456789AF) 00 00
Jul 15 14:22:16 zoo pcscd: readerfactory.c:338:RFAddReader() Sysmocom SIMtrace (0123456789AF) init failed.
Jul 15 14:22:16 zoo pcscd: hotplug_libudev.c:384:HPAddDevice() Failed adding USB device: Sysmocom SIMtrace
Jul 15 14:22:16 zoo pcscd: ifdhandler.c:117:CreateChannelByNameOrChannel() failed
Jul 15 14:22:16 zoo pcscd: readerfactory.c:1009:RFInitializeReader() Open Port 0x200001 Failed (usb:03eb/6129:libudev:1:/dev/bus/usb/003/074)
Jul 15 14:22:16 zoo pcscd: readerfactory.c:312:RFAddReader() Sysmocom SIMtrace [SimTrace DFU Interface - Application Partition] (0123456789AF) init failed.
Jul 15 14:22:16 zoo pcscd: ifdhandler.c:117:CreateChannelByNameOrChannel() failed
Jul 15 14:22:16 zoo pcscd: readerfactory.c:1009:RFInitializeReader() Open Port 0x200002 Failed (uhttps://news.ycombinator.com/item?id=6048993sb:03eb/6129:libudev:2:/dev/bus/usb/003/074)
Jul 15 14:22:16 zoo pcscd: readerfactory.c:312:RFAddReader() Sysmocom SIMtrace [SimTrace DFU Interface - Bootloader Partition] (0123456789AF) init failed.
Jul 15 14:22:16 zoo pcscd: ifdhandler.c:117:CreateChannelByNameOrChannel() failed
Jul 15 14:22:16 zoo pcscd: readerfactory.c:1009:RFInitializeReader() Open Port 0x200003 Failed (usb:03eb/6129:libudev:3:/dev/bus/usb/003/074)
Jul 15 14:22:16 zoo pcscd: readerfactory.c:312:RFAddReader() Sysmocom SIMtrace [SimTrace DFU Interface - RAM] (0123456789AF) init failed.


Removing BOARD_USB_DFU
pcscd -a -d -f



pcsc :: eventhandler.c :: EHSpawnEventHandler()   # Initial Check Failed on Sysmocom SIMtrace (0123456789AF) 00 00
pcsc :: ifdwrapper.c :: IFDStatusICC() # Card not transacted: 612

That rv is from 

#ifndef PCSCLITE_STATIC_DRIVER
	rv = (*IFDH_icc_presence) (rContext->slot);
#else
	rv = IFDHICCPresence(rContext->slot);
#endif



I need to trace this in the debugger..  too hard to follow.

gdb --args pcscd -a -d -f

sudo gdb -i-mi --args pcscd -a -d -f

Break IFDStatusICC


    ifdhandler.c           59054 C/l              ~/priv/git-private/beep/SIM/tools/ccid-1.4.11/src/ifdhandler.c
EXTERNAL RESPONSECODE IFDHICCPresence(DWORD Lun)

	return_value = CmdGetSlotStatus(reader_index, pcbuffer);


#define IFD_COMMUNICATION_ERROR		612 /**< generic error */

sudo cp src/.libs/libccid.so /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Linux/



Yeah wtf.. not easy to get it all set up.
Basically, the CmdGetSlotStatus() -> IFD_COMMUNICATION_ERROR is where to look.

It's the GET_SLOT_STATUS request.

It returns:
(gdb) p/x (unsigned char[10])buffer
$4 = {0xf0, 0xe5, 0xff, 0xff, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0}

The CmdGetSlotStatus() actually doesn't return the error.  It is the
caller IFDHICCPresence() which decides it in the switch statement on
L1716 in ifdhandler.c

switch (pcbuffer[7] & CCID_ICC_STATUS_MASK) {
}
#define CCID_ICC_STATUS_MASK 0x03
#define CCID_ICC_PRESENT_ACTIVE		0x00	/* 00 0000 00 */
#define CCID_ICC_PRESENT_INACTIVE	0x01	/* 00 0000 01 */
#define CCID_ICC_ABSENT			0x02	/* 00 0000 10 */


contents pf pcbuffer[7] is 0x03 which not in the 3 cases.

Why is SIZE_GET_SLOT_STATUS == 10, and the buffer smaller? -> nope, same.

Next: why does cciddriver.c :: RDRtoPCSlotStatus() store 0x03 as status?


Still wrong:
Need to distinguish:
6.3.1  slot change
6.2.6  slot status


Where does the slot status come from?


RDRtoPCSlotStatus() uses ccidDriver.SlotStatus, which uses the
encoding from the slot change message.

Seems the fix would be to translate the change to the status
representation.





[Reply][About]
[<<][simtrace][>>][..]