From owner-freebsd-usb@FreeBSD.ORG Tue Apr 3 11:54:39 2007 Return-Path: X-Original-To: freebsd-usb@freebsd.org Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7246F16A401 for ; Tue, 3 Apr 2007 11:54:39 +0000 (UTC) (envelope-from xiaofanc@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.236]) by mx1.freebsd.org (Postfix) with ESMTP id 3584A13C458 for ; Tue, 3 Apr 2007 11:54:39 +0000 (UTC) (envelope-from xiaofanc@gmail.com) Received: by wx-out-0506.google.com with SMTP id s18so1460646wxc for ; Tue, 03 Apr 2007 04:54:38 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=AZdrCXb/5kIBouShO6eSHfihMJY3b9znQdbIyW2z/NLKC7uUVV768zO0GEHSF0/LsyKpKbWHE/Qvo6BjMdYHJLE/of9tlSUCXoG8BqDKfUkAtJGTLU2JyE4FMAxtOKnmwEfZCbuvELoi8v4aYvaFzBaTK5zfRo3IiysjAGLIuMs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=WneBc0tjU7W2yxF2KaOqGc5tmgO2jQ4Pl90QguUdRUBzjJ8XVIVWA1JEmRJtmji6dQXcYCITNKWB8UNK0fuXJ3C6zf+Z9wtbs+S2bWvs7yLPaYakRNoBFUG7gE+Vs8I3R4mqYUJ17R2iblG1+uyQjd04Jq5XNLZ5EFeVlwH51HE= Received: by 10.114.173.15 with SMTP id v15mr2218569wae.1175599658950; Tue, 03 Apr 2007 04:27:38 -0700 (PDT) Received: by 10.114.176.8 with HTTP; Tue, 3 Apr 2007 04:27:38 -0700 (PDT) Message-ID: Date: Tue, 3 Apr 2007 19:27:38 +0800 From: "Xiaofan Chen" To: freebsd-usb@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: libusb usb_interrupt_read hangs under FreeBSD X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2007 11:54:39 -0000 I was redirected to this list as per the suggestion from the libusb mailing list. It will be greatly appreciated that someone can suggest how to debug this problem? Some more information: ===[mcuee] ~ # sudo usbdevs -v Password: Controller /dev/usb0: addr 127: full speed, self powered, config 1, OHCI root hub(0x0000), nVidia(0x0000), rev 1.00 port 1 powered port 2 powered port 3 powered port 4 powered Controller /dev/usb1: addr 126: full speed, power 100 mA, config 1, PICkit 2 Microcontroller Programmer(0x0033), Microchip Technology Inc.(0x04d8), rev 0.01 addr 127: full speed, self powered, config 1, OHCI root hub(0x0000), nVidia(0x0000), rev 1.00 port 1 powered port 2 addr 126: full speed, power 100 mA, config 1, PICkit 2 Microcontroller Programmer(0x0033), Microchip Technology Inc.(0x04d8), rev 0.01 port 3 powered port 4 powered Controller /dev/usb2: addr 127: high speed, self powered, config 1, EHCI root hub(0x0000), nVidia(0x0000), rev 1.00 port 1 powered port 2 powered port 3 powered port 4 powered port 5 powered port 6 powered port 7 powered port 8 powered ===[mcuee] ~ # uname -a FreeBSD FreeBsd61.Mshome 6.2-STABLE FreeBSD 6.2-STABLE #0: Mon Apr 2 19:03:07 SGT 2007 root@FreeBsd61.Mshome:/home/obj/home/src/sys/USBDEBUG i386 ===[mcuee] ~/Desktop/build/pyusb-0.3.5/samples # sudo ./usbenum.py 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 0xbfbfe458 8 1000 usb_control_msg: 128 6 512 0 0x8122240 41 1000 skipped 1 class/vendor specific interface descriptors usb_control_msg: 128 6 513 0 0xbfbfe458 8 1000 usb_control_msg: 128 6 513 0 0x8116900 32 1000 Device: /dev/ugen0 Device class: 0 Device sub class: 0 Device protocol: 0 Max packet size: 8 idVendor: 1240 idProduct: 51 Device Version: 00.01 Configuration: 1 Total length: 41 selfPowered: 0 remoteWakeup: 0 maxPower: 200 Interface: 0 Alternate Setting: 0 Interface class: 3 Interface sub class: 0 Interface protocol: 0 Endpoint: 0x81 Type: 3 Max packet size: 64 Interval: 1 Endpoint: 0x1 Type: 3 Max packet size: 64 Interval: 1 Configuration: 2 Total length: 32 selfPowered: 0 remoteWakeup: 0 maxPower: 200 Interface: 0 Alternate Setting: 0 Interface class: 255 Interface sub class: 0 Interface protocol: 0 Endpoint: 0x81 Type: 3 Max packet size: 64 Interval: 1 Endpoint: 0x1 Type: 3 Max packet size: 64 Interval: 1 ---------- Forwarded message ---------- From: Xiaofan Chen Date: Apr 2, 2007 8:02 PM Subject: Re: libusb usb_interrupt_write hangs under FreeBSD To: libusb-devel@lists.sourceforge.net On 3/24/07, Xiaofan Chen wrote: > PICKit 2 is a small USB programmer from Microchip. It is an HID > device just to avoid using a driver under Windows. Microchip > has released the firmware and Windows host software code. > http://www.microchip.com/pickit2 > > I was trying to get libusb based pk2 application to work under > FreeBSD but so far no success yet. pk2 works under Linux, > Mac OS X and Windows. > > pk2 is at http://home.pacbell.net/theposts/picmicro/. > > I recompiled the FreeBSD kernel to disable uhid and use ugen for > PICKit 2. So pk2 can find PICKit 2. But usb interrupt write just hangs. > After searching the Internet, I found the alternative USB stack for FreeBSD. http://lists.freebsd.org/pipermail/freebsd-usb/2006-July/002410.html I installed the new kernel and with a simple test program using pyusb, I found out that usb interrupt write is now working but usb interrupt reading is still not working. ===[mcuee] ~/Desktop/build/mypk2 # cat testpk2.py #!/usr/local/bin/python -i import usb def opendevice(idVendor, idProduct): devices=[] for b in usb.busses(): for d in b.devices: if d.idVendor==idVendor and d.idProduct==idProduct: devices.append(d) if len(devices)==1: device=devices[0] return device elif not devices: raise "Device not found" else: raise "More than one device found" if __name__=="__main__": device=opendevice(0x04d8, 0x0033) packet_len=64 dh=device.open() dh.setConfiguration(1) print "set Configuration 1" dh.claimInterface(0) print "claim Interface 0" #dh.setAltInterface(0) # First test, turn power on print "Turing power on by USB interrupt write" dh.interruptWrite(1,"V1"+(packet_len-2)*"Z",1000) # Second test, get version number print "Sending version command by USB interrupt write" dh.interruptWrite(1,"v"+(packet_len-1)*"Z",1000) print "Getting version command by USB interrupt write" r=dh.interruptRead(0x81,64,1000) print r ===[mcuee] ~/Desktop/build/mypk2 # sudo python testpk2.py 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/ugen1 on /dev/usb1 usb_os_find_devices: Found /dev/ugen0 on /dev/usb1 usb_control_msg: 128 6 512 0 0xbfbfe2d8 8 1000 usb_control_msg: 128 6 512 0 0x8119500 218 1000 usb_control_msg: 128 6 512 0 0xbfbfe2d8 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 0xbfbfe2d8 8 1000 usb_control_msg: 128 6 513 0 0x8116940 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 write interruptRead params: endpoint: 129 size: 64 timeout: 1000 ^CUSB error: error reading from interrupt endpoint /dev/ugen1.1: Interrupted system call Traceback (most recent call last): File "testpk2.py", line 42, in ? r=dh.interruptRead(0x81,64,1000) usb_os_close: closing endpoint 4 It seems to me that the alternative USB stack still suffers from usb interrupt read problem. Any suggestions? Regards, Xiaofan