Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Apr 2007 07:55:23 +0800
From:      "Xiaofan Chen" <xiaofanc@gmail.com>
To:        "Hans Petter Selasky" <hselasky@c2i.net>
Cc:        freebsd-usb@freebsd.org
Subject:   Re: libusb usb_interrupt_read hangs under FreeBSD
Message-ID:  <a276da400704031655j8e0f1dcy30cfebfd4eadcdb6@mail.gmail.com>
In-Reply-To: <200704031642.26519.hselasky@c2i.net>
References:  <a276da400704030427g6fcfdc37u43bdf0fd1cd69ea8@mail.gmail.com> <200704031426.38277.hselasky@c2i.net> <a276da400704030634ma2bed6dif4f5db276c5f6171@mail.gmail.com> <200704031642.26519.hselasky@c2i.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4/3/07, Hans Petter Selasky <hselasky@c2i.net> wrote:
> Hi,
>
> I think that your device is broken, and goes bad when it receives a
> clear-stall request for the interrupt pipe. That is not very uncommon.

Could you be more clearer? I'd like to communicate this problem
to the firmware developer of PICKit 2 inside Microchip. Thanks.

> Could you try the attached patch. Just apply the patch by hand if "patch"
> won't take it.
>
> The file in question is /sys/dev/usb/ugen.c .
>
> After that, compile a new ugen module or kernel.
>
> If you are using the "ugen" module, then you can simply do like this after
> that you have re-installed it:
>
> kldunload ugen
> kldload ugen
>
> --HPS

The patch works! Thanks a lot.

===[mcuee] ~/Desktop/build/mypk2 # sudo python testpk2.py
Password:
usb_set_debug: Setting debugging level to 255 (on)
usb_os_find_busses: Found /dev/usb0
usb_os_find_busses: Found /dev/usb1
usb_os_find_busses: Found /dev/usb2
usb_os_find_devices: Found /dev/ugen0 on /dev/usb1
usb_control_msg: 128 6 512 0 0xbfbfe2e8 8 1000
usb_control_msg: 128 6 512 0 0x81222c0 41 1000
skipped 1 class/vendor specific interface descriptors
usb_control_msg: 128 6 513 0 0xbfbfe2e8 8 1000
usb_control_msg: 128 6 513 0 0x8116900 32 1000
setConfiguration params:
        configuration: 1
set Configuration 1
claimInterface params:
        interfaceNumber: 0
claim Interface 0
Turing power on by USB interrupt write
interruptWrite params:
        endpoint: 1
        timeout: 1000
interruptWrite buffer param:
56 31 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a 5a 5a
Sending version command by USB interrupt write
interruptWrite params:
        endpoint: 1
        timeout: 1000
interruptWrite buffer param:
76 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a 5a 5a
Getting version command by USB interrupt read
interruptRead params:
        endpoint: 1
        size: 64
        timeout: 1000
(2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
usb_os_close: closing endpoint 4

Thanks again. Now I also get the real pk2 application works
for PICkit 2.

===[mcuee] ~/Desktop/build/pk2-2.04 # sudo ./pk2 -device

PK2 version 2.04 - 2006/12/17
 ./pk2 -device
usb_set_debug: Setting debugging level to 255 (on)

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
usb_os_find_busses: Found /dev/usb0
usb_os_find_busses: Found /dev/usb1
usb_os_find_busses: Found /dev/usb2
usb_os_find_devices: Found /dev/ugen0 on /dev/usb1
usb_control_msg: 128 6 512 0 0xbfbfe7a8 8 1000
usb_control_msg: 128 6 512 0 0x806b080 41 1000
skipped 1 class/vendor specific interface descriptors
usb_control_msg: 128 6 513 0 0xbfbfe7a8 8 1000
usb_control_msg: 128 6 513 0 0x8066100 32 1000
Found USB PICkit as device '/dev/ugen0' on USB bus /dev/usb1
Setting USB configuration is okay.
Claiming USB interface is okay.
Sending GETVERSION command using interrupt transfer.
USB> 76
Receiving PICkit VERSION information using interrupt transfer.
Communication established. PICkit2 firmware version is 1.21.0
USB> 56 00

USB> 56 00
USB> 4d
USB> 73 00 1d 40 3d 82 2d
USB> 4d
USB> 4d
USB> 4d
USB> 90 80 02 fe ff 3f 91
USB> 56 00
USB> 4d
USB> 73 80 2a 40 df bd a6
USB> 4d
USB> 4d
USB> 50 43 52 70
USB> 4f 43 52 70
USB> 50 80 02 fe ff 3f 70
Device ID 0x0c80
PIC18F2620 Rev 3 found
USB> 56 00
USB> 4d
USB> 73 80 2a 40 df bd a6
USB> 4d
  Family:         PIC18F
  Program size:   0x8000 (32768) words, width 0xffff
  Eeprom size:    0x400 (1024) bytes
  ID location:    0x0
  ID size:        0x4 (4) bytes
  Device ID       0x0c80
  Write burst     16
  Program command P
  Program mode    G
  Program timing  N
  Data timing     D
  Erase mode
  CP mask         0xc00f
  Bandgap mask    0x0000 0x0000
  Config mask     0xcf00 0x1f1f 0x8700 0x00c5 0xc00f 0xe00f 0x400f
  Save osccal     0
  Save bandgap    0
  Command table   63 00 02 03 04 05 06 08 18 0a 09 0b ff ff ff ff


Regards,
Xiaofan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a276da400704031655j8e0f1dcy30cfebfd4eadcdb6>