This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Smartcard USB application

Hello,
Im writing a usb communication tool on the LPC2368 for smartcard devices. I still don't get any communication between the host and the smartcard device for couple of weeks know. It seems like the program is be missing something and i dont know what.

Do you Know where I can find any smartcard USB application for arm7 microcontroller?

Can anybody help me on it? If necessary I will post the fully commented code that I have written.

Thanks in advance

Parents
  • Thank you for your quick reply Tsuneo!

    I started from the published USB HID driver code source for LPC2368 and try to modify it step by step to a smartcard driver.
    I assume that I ve successfully programmed the device configurations because the Host(Window Vista environment) fully recognize the device as a smartcard. Besides that, the USB sniffer that I use (USBLyser) displays successfully the devices descriptors (Configuration descriptor, Interface descriptor, Class, Endpoints...).

    By doing the configuration, I leaned on a smartcard device I bought.

    So, the main problem I have here is that I can't have any communication between the host and the device. The programm doesn't go through the functions USB_endpoint3 (Interrupt IN - 0x83), USB_endpoint4 (Bulk IN, 0x84) and USB_endpoint5(Bulk OUT(read), 0x05).
    Even If I write the function USB_WriteEP(0x83, msg,cnt) in a ISR (INT0), The USB Sniffer doesn' t display anything!!

    Here the configuration Programm usbdesc.c:

    /* USB Standard Device Descriptor */
    //const BYTE USB_DeviceDescriptor[] = {
    BYTE USB_DeviceDescriptor[] = {
      USB_DEVICE_DESC_SIZE,              /* bLength */
      USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
      WBVAL(0x0200), /* 1.10 */          /* bcdUSB */
      0x00,                              /* bDeviceClass */
      0x00,                              /* bDeviceSubClass */
      0x00,                              /* bDeviceProtocol */
      USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
      WBVAL(0x1xxx),                     /* idVendor */
      WBVAL(0x0xxx),                     /* idProduct */
      WBVAL(0x0302), /* 1.00 */          /* bcdDevice */
      0x04,                              /* iManufacturer */
      0x20,                              /* iProduct */
      0x42,                              /* iSerialNumber */
      0x01                               /* bNumConfigurations */
    };
    
    /* USB Configuration Descriptor */
    /*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
    const BYTE USB_ConfigDescriptor[] = {
    
    /* Configuration 1 */
      USB_CONFIGUARTION_DESC_SIZE,       /* bDescriptorType */
      USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
      WBVAL(                             /* wTotalLength */
        USB_CONFIGUARTION_DESC_SIZE +
        USB_INTERFACE_DESC_SIZE     +
        SMARTCARD_CLASS_DESC_SIZE               +
        3*USB_ENDPOINT_DESC_SIZE
      ),
      0x01,                              /* bNumInterfaces */
      0x01,                              /* bConfigurationValue */
      0x03,                              /* iConfiguration */
      /*USB_CONFIG_BUS_POWERED */       /* bmAttributes */
      0xA0,
      USB_CONFIG_POWER_MA(100),          /* bMaxPower */
    
    /* Interface 0, Alternate Setting 0, HID Class */
      USB_INTERFACE_DESC_SIZE,           /* bLength */
      USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
      0x00,                              /* bInterfaceNumber */
      0x00,                              /* bAlternateSetting */
      0x03,                              /* bNumEndpoints */
      0x0b,                                                          /* bInterfaceClass */
      //USB_DEVICE_CLASS_HUMAN_INTERFACE,  /* bInterfaceClass */
      HID_SUBCLASS_NONE,                 /* bInterfaceSubClass */
      HID_PROTOCOL_NONE,                 /* bInterfaceProtocol */
      0x00,                              /* iInterface */
             /* Smartcard Class Descriptor */
      SMARTCARD_CLASS_DESC_SIZE,                     /* bLength */
      SMARTCARD_SMARTCARD_DESCRIPTOR_TYPE,           /* bDescriptorType */
      WBVAL(0x0100), /* 1.00 */             /* bcdCCID */
      SMARTCARDSLOTS,                       /* bMaxSlotIndex */
      SMARTCARDVOLTAGESUPPORTS,             /* bVoltageSupport */
      WBVAL1(SMARTCARDCONTACTLESS_PROT),    /* dwProtocols */
    
      WBVAL1(SMARTCARDICC_DEFAULTCLOCK ),   /* dwDefaultClock */
      WBVAL1(SMARTCARDICC_MAXCLOCK),                /* dwMaximumClock */
      SMARTCARDCCID_NUMcLOCKsUPPORTED,
      WBVAL1(SMARTCARDICC_DATARATE),                /* Datarate supported by the ICC  */
      WBVAL1(SMARTCARDICC_MAXDATARATE),             /* Maximum of Datarate supported by the ICC */
    
      SMARTCARDICC_NUMdATARATEsUPPORTED,    /* Number of Datarate supported */
      WBVAL1(SMARTCARD_IFSD),                               /* IFSD */
      WBVAL1(SMARTCARD_SyncProt),                   /* Synchron Protocol */
      WBVAL1(SMARTCARDICC_MECHANICAL),              /* Mechanical Features, DWORD */
      WBVAL1(SMARTCARDICC_FEATURES),                /* Features */
      WBVAL1(SMARTCARDCCID_MessageLength),  /* Max CCID Message Length */
      SMARTCARD_ClassGetResponse,               /* Class Get Response */
      SMARTCARD_ClassEnvelope,                          /* Class enveloppe */
      WBVAL(SMARTCARD_Layout),                      /* wLayout */
      SMARTCARD_bPINSupport,                            /* Pin Support */
      SMARTCARD_bMaxCCIDBusySlots,              /* Max CCID Busy Slots */
    
    /* Endpoint, INTERRUPT In */
      USB_ENDPOINT_DESC_SIZE,            /* bLength */
      USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
      0x83,                                          /* bEndpointAddress */
      USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
      WBVAL(0x0008),                     /* wMaxPacketSize */
      0x18,          /* 32ms */          /* bInterval */
    
    /* Endpoint, SMART CARD Bulk In */
      USB_ENDPOINT_DESC_SIZE,            /* bLength */
      USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
      0x84,                /* bEndpointAddress */
      USB_ENDPOINT_TYPE_BULK,       /* bmAttributes */
      WBVAL(0x0040),                     /* wMaxPacketSize */
      0x00,          /* 32ms */          /* bInterval */
    
    /* Endpoint, SMART CARD BULK Out (from the host to the device) */
      USB_ENDPOINT_DESC_SIZE,            /* bLength */
      USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
      0x05,               /* bEndpointAddress */
      USB_ENDPOINT_TYPE_BULK,       /* bmAttributes */
      WBVAL(0x0040),                     /* wMaxPacketSize */
      0x00,          /* 32ms */          /* bInterval */
    
      /* Terminator */
      0                                  /* bLength */
    };
    

Reply
  • Thank you for your quick reply Tsuneo!

    I started from the published USB HID driver code source for LPC2368 and try to modify it step by step to a smartcard driver.
    I assume that I ve successfully programmed the device configurations because the Host(Window Vista environment) fully recognize the device as a smartcard. Besides that, the USB sniffer that I use (USBLyser) displays successfully the devices descriptors (Configuration descriptor, Interface descriptor, Class, Endpoints...).

    By doing the configuration, I leaned on a smartcard device I bought.

    So, the main problem I have here is that I can't have any communication between the host and the device. The programm doesn't go through the functions USB_endpoint3 (Interrupt IN - 0x83), USB_endpoint4 (Bulk IN, 0x84) and USB_endpoint5(Bulk OUT(read), 0x05).
    Even If I write the function USB_WriteEP(0x83, msg,cnt) in a ISR (INT0), The USB Sniffer doesn' t display anything!!

    Here the configuration Programm usbdesc.c:

    /* USB Standard Device Descriptor */
    //const BYTE USB_DeviceDescriptor[] = {
    BYTE USB_DeviceDescriptor[] = {
      USB_DEVICE_DESC_SIZE,              /* bLength */
      USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
      WBVAL(0x0200), /* 1.10 */          /* bcdUSB */
      0x00,                              /* bDeviceClass */
      0x00,                              /* bDeviceSubClass */
      0x00,                              /* bDeviceProtocol */
      USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
      WBVAL(0x1xxx),                     /* idVendor */
      WBVAL(0x0xxx),                     /* idProduct */
      WBVAL(0x0302), /* 1.00 */          /* bcdDevice */
      0x04,                              /* iManufacturer */
      0x20,                              /* iProduct */
      0x42,                              /* iSerialNumber */
      0x01                               /* bNumConfigurations */
    };
    
    /* USB Configuration Descriptor */
    /*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
    const BYTE USB_ConfigDescriptor[] = {
    
    /* Configuration 1 */
      USB_CONFIGUARTION_DESC_SIZE,       /* bDescriptorType */
      USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
      WBVAL(                             /* wTotalLength */
        USB_CONFIGUARTION_DESC_SIZE +
        USB_INTERFACE_DESC_SIZE     +
        SMARTCARD_CLASS_DESC_SIZE               +
        3*USB_ENDPOINT_DESC_SIZE
      ),
      0x01,                              /* bNumInterfaces */
      0x01,                              /* bConfigurationValue */
      0x03,                              /* iConfiguration */
      /*USB_CONFIG_BUS_POWERED */       /* bmAttributes */
      0xA0,
      USB_CONFIG_POWER_MA(100),          /* bMaxPower */
    
    /* Interface 0, Alternate Setting 0, HID Class */
      USB_INTERFACE_DESC_SIZE,           /* bLength */
      USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
      0x00,                              /* bInterfaceNumber */
      0x00,                              /* bAlternateSetting */
      0x03,                              /* bNumEndpoints */
      0x0b,                                                          /* bInterfaceClass */
      //USB_DEVICE_CLASS_HUMAN_INTERFACE,  /* bInterfaceClass */
      HID_SUBCLASS_NONE,                 /* bInterfaceSubClass */
      HID_PROTOCOL_NONE,                 /* bInterfaceProtocol */
      0x00,                              /* iInterface */
             /* Smartcard Class Descriptor */
      SMARTCARD_CLASS_DESC_SIZE,                     /* bLength */
      SMARTCARD_SMARTCARD_DESCRIPTOR_TYPE,           /* bDescriptorType */
      WBVAL(0x0100), /* 1.00 */             /* bcdCCID */
      SMARTCARDSLOTS,                       /* bMaxSlotIndex */
      SMARTCARDVOLTAGESUPPORTS,             /* bVoltageSupport */
      WBVAL1(SMARTCARDCONTACTLESS_PROT),    /* dwProtocols */
    
      WBVAL1(SMARTCARDICC_DEFAULTCLOCK ),   /* dwDefaultClock */
      WBVAL1(SMARTCARDICC_MAXCLOCK),                /* dwMaximumClock */
      SMARTCARDCCID_NUMcLOCKsUPPORTED,
      WBVAL1(SMARTCARDICC_DATARATE),                /* Datarate supported by the ICC  */
      WBVAL1(SMARTCARDICC_MAXDATARATE),             /* Maximum of Datarate supported by the ICC */
    
      SMARTCARDICC_NUMdATARATEsUPPORTED,    /* Number of Datarate supported */
      WBVAL1(SMARTCARD_IFSD),                               /* IFSD */
      WBVAL1(SMARTCARD_SyncProt),                   /* Synchron Protocol */
      WBVAL1(SMARTCARDICC_MECHANICAL),              /* Mechanical Features, DWORD */
      WBVAL1(SMARTCARDICC_FEATURES),                /* Features */
      WBVAL1(SMARTCARDCCID_MessageLength),  /* Max CCID Message Length */
      SMARTCARD_ClassGetResponse,               /* Class Get Response */
      SMARTCARD_ClassEnvelope,                          /* Class enveloppe */
      WBVAL(SMARTCARD_Layout),                      /* wLayout */
      SMARTCARD_bPINSupport,                            /* Pin Support */
      SMARTCARD_bMaxCCIDBusySlots,              /* Max CCID Busy Slots */
    
    /* Endpoint, INTERRUPT In */
      USB_ENDPOINT_DESC_SIZE,            /* bLength */
      USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
      0x83,                                          /* bEndpointAddress */
      USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
      WBVAL(0x0008),                     /* wMaxPacketSize */
      0x18,          /* 32ms */          /* bInterval */
    
    /* Endpoint, SMART CARD Bulk In */
      USB_ENDPOINT_DESC_SIZE,            /* bLength */
      USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
      0x84,                /* bEndpointAddress */
      USB_ENDPOINT_TYPE_BULK,       /* bmAttributes */
      WBVAL(0x0040),                     /* wMaxPacketSize */
      0x00,          /* 32ms */          /* bInterval */
    
    /* Endpoint, SMART CARD BULK Out (from the host to the device) */
      USB_ENDPOINT_DESC_SIZE,            /* bLength */
      USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
      0x05,               /* bEndpointAddress */
      USB_ENDPOINT_TYPE_BULK,       /* bmAttributes */
      WBVAL(0x0040),                     /* wMaxPacketSize */
      0x00,          /* 32ms */          /* bInterval */
    
      /* Terminator */
      0                                  /* bLength */
    };
    

Children
No data