Last week i posted that the fsusb_demo code was not working with ubuntu 7.04, and i arranged it fixin the usb_bulk_write/read functions for the usb_interrupt_write/read functions. Today i have updated my ubuntu version to 7.10 and it's not working neither. I guess i have bad luck. Anyway, the error i get when i try to communicate with the Picdem fs usb is:
$ sudo ./fsusb_demo --ledon 3
Locating Microchip(tm) PICDEM(tm) FS USB Demo Board (vendor 0x04d8/product 0x000c) usb_set_debug: Setting debugging level to 255 (on) setting USB debug on by adding usb_set_debug(255) usb_os_init: Found USB VFS at /dev/bus/usb usb_os_find_busses: Found 005 usb_os_find_busses: Found 001 usb_os_find_busses: Found 002 usb_os_find_busses: Found 003 usb_os_find_busses: Found 004 usb_os_find_devices: Found 001 on 005 usb_os_find_devices: Found 001 on 001 usb_os_find_devices: Found 008 on 002 usb_os_find_devices: Found 001 on 002 error obtaining child information: Inappropriate ioctl for device usb_os_find_devices: Found 001 on 003 usb_os_find_devices: Found 001 on 004 Found USB PICDEM FS USB Demo Board as device '008' on USB bus 002 USB error: could not set config 1: Device or resource busy Fatal error> Error setting USB configuration.
I just installed Ubuntu 7.10 and I have not tried it (the mirror does not have the packages I need yet).
Have you tried to use my patch?
For the problems, please refer to the following links. Personally I think it is a bad idea to include the demo inside the kernel. Since I have the patch I do not really want to argue for the removal of the kernel patch.
/* change by Xiaofan */
/* to detach the kernel driver if it is
calimed by some newer kernel ldusb module.
http://www.opensubscriber.com/message/linux-usb-devel@lists.sourceforge.net/7160138.html
*/
#ifdef LINUX
{
int retval;
char dname[32] = {0};
retval = usb_get_driver_np(d, 0, dname, 31);
if (!retval)
usb_detach_kernel_driver_np(d, 0);
}
#endif
I've never worked with patches before, so it would be grateful if the explanation could be with more detail. I understand that i have to add next line to some file, but i don't know which one. #define USB_VENDOR_ID_MICROCHIP 0x04d8 #define USB_DEVICE_ID_PICDEM 0x000c
Great! I believe that LINUX is defined by the compiler but maybe I am wrong. Typically this should be done in the Makefile if it is not defined by the compiler. But I am not good at host side programming.
I just tried the demo program under Ubuntu 7.10 and it works.
Updated Makefile to fix the LINUX define problem.
# This file is part of fsusb_demo
#
# fsusb_demo is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# fsusb_demo is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fsusb_picdem; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# For Windows, please put usb.h and MingW version of libusb.a into
# the MingW include and lib directory respectively.
# For Linux only
LIBUSB = /usr/lib
OPTS=-Wall -D_GNU_SOURCE -DLINUX
OBJS=fsusb_demo.o
CFLAGS=$(OPTS) -I$(LIBUSB)/include
LDFLAGS=-L$(LIBUSB)/lib -lusb
# Needed for static linking under OS X:
# LDFLAGS=-lusb -lIOKit -framework CoreFoundation
all: fsusb_demo
fsusb_demo: $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
clean:
-rm fsusb_demo *.o
ORIGINAL: xiaofan Try to use my version of fsusb_demo.c and see how it goes. You may want to change usb_bulk to usb_interrupt as shown below.
/** Send this binary string command. */
static void send_usb(struct usb_dev_handle * d, int len, const char * src)
{
int r = usb_interrupt_write(d, endpoint_out, (char *)src, len, timeout);
// if( r != reqLen )
if( r < 0 )
{
perror("usb PICDEM FS USB write"); bad("USB write failed");
}
}
/** Read this many bytes from this device */
static void recv_usb(struct usb_dev_handle * d, int len, byte * dest)
{
// int i;
int r = usb_interrupt_read(d, endpoint_in, dest, len, timeout);
if( r != len )
{
perror("usb PICDEM FS USB read"); bad("USB read failed");
}
}
The latest V2.1 stack is using Bulk Transfer for the demo project. So we need to change it back to bulk transfer now.
/****************** Internal I/O Commands *****************/
/** Send this binary string command. */
static void send_usb(struct usb_dev_handle * d, int len, const char * src)
{
int r = usb_bulk_write(d, endpoint_out, (char *)src, len, timeout);
// if( r != reqLen )
if( r < 0 )
{
perror("usb PICDEM FS USB write"); bad("USB write failed");
}
}
/** Read this many bytes from this device */
static void recv_usb(struct usb_dev_handle * d, int len, byte * dest)
{
// int i;
int r = usb_bulk_read(d, endpoint_in, dest, len, timeout);
if( r != len )
{
perror("usb PICDEM FS USB read"); bad("USB read failed");
}
}
Tested under Fedore Core 6. Other distro may need similar changes.
The following output is with USB debugging information on.
[mcuee@localhost demo]$ ./fsusb_demo --ledon 3 Locating Microchip(tm) PICDEM(tm) FS USB Demo Board (vendor 0x04d8/product 0x000c) usb_set_debug: Setting debugging level to 255 (on) setting USB debug on by adding usb_set_debug(255) usb_os_init: Found USB VFS at /dev/bus/usb usb_os_find_busses: Found 003 usb_os_find_busses: Found 001 usb_os_find_busses: Found 002 usb_os_find_devices: couldn't get connect info usb_os_find_devices: Found 001 on 003 error obtaining child information: Operation not permitted usb_os_find_devices: couldn't get connect info usb_os_find_devices: Found 001 on 001 usb_os_find_devices: Found 003 on 001 skipped 1 class/vendor specific interface descriptors error obtaining child information: Operation not permitted error obtaining child information: Inappropriate ioctl for device usb_os_find_devices: couldn't get connect info usb_os_find_devices: Found 001 on 002 usb_os_find_devices: Found 002 on 002 error obtaining child information: Operation not permitted error obtaining child information: Inappropriate ioctl for device Found USB PICDEM FS USB Demo Board as device '002' on USB bus 002 USB error: could not get bound driver: No data available Communication established. answer was correct! Onboard firmware version is 1.0 LED #3 is now on
I've submitted a patch to Linux ldusb driver maintainer.
---------- Forwarded message ---------- From: Xiaofan Chen Date: Tue, May 13, 2008 at 9:52 PM Subject: Linux USB Patch: remove PICDEM FS USB demo (04d8:000c) device from ldusb To: Greg KH Cc: Joey Goncalves "Hund, Michael" , USB list <linux-usb AT vger.kernel.org>
On Tue, May 13, 2008 at 1:14 AM, Greg KH wrote: > > On Sun, May 11, 2008 at 10:58:42PM +0800, Xiaofan Chen wrote: > > Microchip has changed the PICDEM FS USB demo device (0x04d8:000c) > > to use bulk transfer and not interrupt transfer. So I've updated the libusb > > based program here (Post #31). > > http://forum.microchip.com/tm.aspx?m=106426&mpage=2 > > > > So I believe that the in-kernel ldusb driver will no longer work with the > > demo firmware. Should we just remove it so that no confusions > > will be caused? > > Yes, if you think that is the proper thing to do. Please send me a > patch to remove this device id from the driver, with this information in > the body of the email message so that others can refer to it in the > future.
Joey has agreed to remove this device from ldusb.
Let me try. I have not created any patches for the Linux kernel source. Hopefully this is ok.
USB: remove PICDEM FS USB demo (04d8:000c) device from ldusb
Microchip has changed the PICDEM FS USB demo device (0x04d8:000c) to use bulk transfer and not interrupt transfer. So I've updated the libusb based program here (Post #31). http://forum.microchip.com/tm.aspx?m=106426&mpage=2
So I believe that the in-kernel ldusb driver will no longer work with the demo firmware. It should be removed.
HID: add Microchip PICKit 1 and PICkit 2 to blacklist
Microchip PICkit 1 and PICKit 2 USB Programmers are USB HID class of device but they are not real HID device. They are now supported by libusb based programs like the following programs.
I'm running fsusb_demo on Ubuntu 8.04 Hardy Heron and have noted what appears to be a bug in the PICDEM firmware. When executing --ledon 4, led #3 turns on. Likewise --ledon 3 turns on led #4. I'm new with the PICDEM board and have not looked into the firmware, but fsusb_demo calls for the correct leds to be lit.
Some people have some concerns about libusb-win32 0.1.12.1 under Vista. Yes libusb-win32 does not work under Vista 64. It is also said the filter driver will not work under Vista 32 and can cause system problems. But it is said that the device driver works fine.
So I just tried out the demo application under Vista 32 Home premimu using the libusb-win32 device driver and it works fine as reported.
You need to replace the Microchip custom usb driver with the libusb-win32 device driver. You need to use inf wizard to generate the inf file and then "upgrader" Microchip driver to the libusb-win32 device driver. Vista 32 will warn about the unsigned driver during the process.
Here is the sample output.
J:\Downloads\USB\libusb-win32-device-bin-0.1.12.1\bin>ver
Microsoft Windows [Version 6.0.6001]
J:\Downloads\USB\libusb-win32-device-bin-0.1.12.1\bin>fsusb_demo.exe --ledon 4
Locating Microchip(tm) PICDEM(tm) FS USB Demo Board (vendor 0x04d8/product 0x000
c)
setting USB debug on by adding usb_set_debug(255)
LIBUSB_DLL: info: usb_os_init: dll version: 0.1.12.1
LIBUSB_DLL: info: usb_os_init: driver version: 0.1.12.1
LIBUSB_DLL: info: usb_os_find_busses: found bus-0
LIBUSB_DLL: info: usb_os_find_devices: found \\.\libusb0-0001--0x04d8-0x000c on
bus-0
Found USB PICDEM FS USB Demo Board as device '\\.\libusb0-0001--0x04d8-0x000c' o
n USB bus bus-0
Communication established.
answer was correct!
Onboard firmware version is 1.0
LED #4 is now on
J:\Downloads\USB\libusb-win32-device-bin-0.1.12.1\bin>testlibusb.exe -v
Dev #1: Microchip Technology Inc. - PICDEM FS USB Demo Board (C) 2004
wTotalLength: 32
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 0
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
bEndpointAddress: 01h
bmAttributes: 03h
wMaxPacketSize: 64
bInterval: 32
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 64
bInterval: 32
bRefresh: 0
bSynchAddress: 0
INF file generated:
[Version]
Signature = "$Chicago$"
provider = %manufacturer%
DriverVer = 03/20/2007,0.1.12.1
CatalogFile = picdemfsusb_000c.cat
CatalogFile.NT = picdemfsusb_000c.cat
CatalogFile.NTAMD64 = picdemfsusb_000c_x64.cat
Class = LibUsbDevices
ClassGUID = {EB781AAF-9C70-4523-A5DF-642A87ECA567}
[ClassInstall]
AddReg=libusb_class_install_add_reg
[ClassInstall32]
AddReg=libusb_class_install_add_reg
[libusb_class_install_add_reg]
HKR,,,,"LibUSB-Win32 Devices"
HKR,,Icon,,"-20"
[Manufacturer]
%manufacturer%=Devices,NT,NTAMD64
;--------------------------------------------------------------------------
; Files
;--------------------------------------------------------------------------
[SourceDisksNames]
1 = "Libusb-Win32 Driver Installation Disk",,
[SourceDisksFiles]
libusb0.sys = 1,,
libusb0.dll = 1,,
libusb0_x64.sys = 1,,
libusb0_x64.dll = 1,,
[DestinationDirs]
libusb_files_sys = 10,system32\drivers
libusb_files_sys_x64 = 10,system32\drivers
libusb_files_dll = 10,system32
libusb_files_dll_wow64 = 10,syswow64
libusb_files_dll_x64 = 10,system32
[libusb_files_sys]
libusb0.sys
[libusb_files_sys_x64]
libusb0.sys,libusb0_x64.sys
[libusb_files_dll]
libusb0.dll
[libusb_files_dll_wow64]
libusb0.dll
[libusb_files_dll_x64]
libusb0.dll,libusb0_x64.dll
;--------------------------------------------------------------------------
; Device driver
;--------------------------------------------------------------------------
[LIBUSB_DEV]
CopyFiles = libusb_files_sys, libusb_files_dll
AddReg = libusb_add_reg
[LIBUSB_DEV.NT]
CopyFiles = libusb_files_sys, libusb_files_dll
[LIBUSB_DEV.NTAMD64]
CopyFiles = libusb_files_sys_x64, libusb_files_dll_wow64, libusb_files_dll_x64
[LIBUSB_DEV.HW]
DelReg = libusb_del_reg_hw
AddReg = libusb_add_reg_hw
[LIBUSB_DEV.NT.HW]
DelReg = libusb_del_reg_hw
AddReg = libusb_add_reg_hw
[LIBUSB_DEV.NTAMD64.HW]
DelReg = libusb_del_reg_hw
AddReg = libusb_add_reg_hw
[LIBUSB_DEV.NT.Services]
AddService = libusb0, 0x00000002, libusb_add_service
[LIBUSB_DEV.NTAMD64.Services]
AddService = libusb0, 0x00000002, libusb_add_service
[libusb_add_reg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,libusb0.sys
; Older versions of this .inf file installed filter drivers. They are not
; needed any more and must be removed
[libusb_del_reg_hw]
HKR,,LowerFilters
HKR,,UpperFilters
; Device properties
[libusb_add_reg_hw]
HKR,,SurpriseRemovalOK, 0x00010001, 1
;--------------------------------------------------------------------------
; Services
;--------------------------------------------------------------------------
[libusb_add_service]
DisplayName = "LibUsb-Win32 - Kernel Driver 03/20/2007, 0.1.12.1"
ServiceType = 1
StartType = 3
ErrorControl = 0
ServiceBinary = %12%\libusb0.sys
;--------------------------------------------------------------------------
; Devices
;--------------------------------------------------------------------------
[Devices]
"PICDEM FS USB libusb-win32 Device"=LIBUSB_DEV, USB\VID_04d8&PID_000c
[Devices.NT]
"PICDEM FS USB libusb-win32 Device"=LIBUSB_DEV, USB\VID_04d8&PID_000c
[Devices.NTAMD64]
"PICDEM FS USB libusb-win32 Device"=LIBUSB_DEV, USB\VID_04d8&PID_000c
;--------------------------------------------------------------------------
; Strings
;--------------------------------------------------------------------------
[Strings]
manufacturer = "Microchip Technology, Inc."
< Message edited by xiaofan -- Oct. 18, 2008 3:06:46 AM >