[<<][staapl][>>][..]
Tue May 29 13:43:47 EDT 2012

Resetting PK2

PK2 gets into a state that is only broken using a hard USB
unplug/replug cycle.  Error in Scheme is:

  Error opening console pickit2:
  procedure application: expected procedure, given: #(struct:exn:fail "error: no-pickit2-found" #<continuation-mark-set>) (no arguments)

  Process staapl-usb exited abnormally with code 1

Error using pk2cmd is:

  No PICkit 2 found.

  make: *** [pk2-2550-48.flash] Error 10

Though the device is still there:

  tom@zoo:~/$ lsusb
  ...
  Bus 001 Device 049: ID 04d8:fc92 Microchip Technology, Inc. 


  tom@zoo:~/$ lsusb -v  -s 1:49

  Bus 001 Device 049: ID 04d8:fc92 Microchip Technology, Inc. 
  Device Descriptor:
    bLength                18
    bDescriptorType         1
    bcdUSB               2.00
    bDeviceClass            2 Communications
    bDeviceSubClass         0 
    bDeviceProtocol         0 
    bMaxPacketSize0         8
    idVendor           0x04d8 Microchip Technology, Inc.
    idProduct          0xfc92 
    bcdDevice            1.00
    iManufacturer           1 
    iProduct                2 
    iSerial                 0 
    bNumConfigurations      1
    Configuration Descriptor:
      bLength                 9
      bDescriptorType         2
      wTotalLength           67
      bNumInterfaces          2
      bConfigurationValue     1
      iConfiguration          0 
      bmAttributes         0x80
        (Bus Powered)
      MaxPower              200mA
      Interface Descriptor:
        bLength                 9
        bDescriptorType         4
        bInterfaceNumber        0
        bAlternateSetting       0
        bNumEndpoints           1
        bInterfaceClass         2 Communications
        bInterfaceSubClass      2 Abstract (modem)
        bInterfaceProtocol      1 AT-commands (v.25ter)
        iInterface              0 
        CDC Header:
          bcdCDC               1.10
        CDC ACM:
          bmCapabilities       0x02
            line coding and serial state
        CDC Union:
          bMasterInterface        0
          bSlaveInterface         1 
        CDC Call Management:
          bmCapabilities       0x00
          bDataInterface          1
        Endpoint Descriptor:
          bLength                 7
          bDescriptorType         5
          bEndpointAddress     0x82  EP 2 IN
          bmAttributes            3
            Transfer Type            Interrupt
            Synch Type               None
            Usage Type               Data
          wMaxPacketSize     0x0008  1x 8 bytes
          bInterval               2
      Interface Descriptor:
        bLength                 9
        bDescriptorType         4
        bInterfaceNumber        1
        bAlternateSetting       0
        bNumEndpoints           2
        bInterfaceClass        10 CDC Data
        bInterfaceSubClass      0 Unused
        bInterfaceProtocol      0 
        iInterface              0 
        Endpoint Descriptor:
          bLength                 7
          bDescriptorType         5
          bEndpointAddress     0x03  EP 3 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     0x83  EP 3 IN
          bmAttributes            2
            Transfer Type            Bulk
            Synch Type               None
            Usage Type               Data
          wMaxPacketSize     0x0040  1x 64 bytes
          bInterval               0
  can't get device qualifier: Operation not permitted
  can't get debug descriptor: Operation not permitted
  cannot read device status, Operation not permitted (1)



Using this code[1] usbreset.c

  #include <stdio.h>
  #include <fcntl.h>
  #include <errno.h>
  #include <sys/ioctl.h>
  #include <linux/usbdevice_fs.h>
  void main(int argc, char **argv)
  {
          const char *filename;
          int fd;
          filename = argv[1];
          fd = open(filename, O_WRONLY);
          ioctl(fd, USBDEVFS_RESET, 0);
          close(fd);
          return;
  }

  ./usbreset /dev/bus/usb/001/049

I still get trouble:

May 29 13:59:08 zoo kernel: [1049324.765287] usb 1-2.1.2.1: reset full speed USB device using ehci_hcd and address 49
May 29 13:59:08 zoo kernel: [1049324.863631] cdc_acm 1-2.1.2.1:1.0: This device cannot do calls on its own. It is not a modem.
May 29 13:59:08 zoo kernel: [1049324.863674] cdc_acm 1-2.1.2.1:1.0: ttyACM0: USB ACM device

It shows up as a serial port.  After unplug, replug gives:

May 29 14:03:54 zoo kernel: [1049610.664984] usb 1-2.1.2.4: new full speed USB device using ehci_hcd and address 50
May 29 14:03:54 zoo kernel: [1049610.767214] usb 1-2.1.2.4: New USB device found, idVendor=04d8, idProduct=0033
May 29 14:03:54 zoo kernel: [1049610.767224] usb 1-2.1.2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
May 29 14:03:54 zoo kernel: [1049610.767232] usb 1-2.1.2.4: Product: PICkit 2 Microcontroller Programmer
May 29 14:03:54 zoo kernel: [1049610.767239] usb 1-2.1.2.4: Manufacturer: Microchip Technology Inc.
May 29 14:03:54 zoo kernel: [1049610.767244] usb 1-2.1.2.4: SerialNumber: 

At which point it works again.  So it seems firmware gets stuck.  USB
reset does not reset the PK2 firmware.  Looks like this bug is a
dead-end.  The only thing I can think of is to rewrite the firmware.

[1] http://www.roman10.net/how-to-reset-usb-device-in-linux/



[Reply][About]
[<<][staapl][>>][..]