RE: Latest testusb.c, with my additions... While opening usbtest, what device should be opened?!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Greg,

Here are my comments.

The kernel I am using from its Makefile:
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 34
EXTRAVERSION = .10
NAME = Sheep on Meth

Why do you think the version of this kernel is outdated. I don't think so!?

The device on USB address 7 went away, but it came back upon new registration and numeration, as device 8 (/proc/bus/usb/002/008). So the original conditions are very true/correct. Please, do note that I ran with:
./testusb -a  -t 0

Yes, I am trying to reach on target platform g_printer device, for some reason I am not able to register g_zero on target (enumeration process fails). But g_printer behaves very correctly. It should work also with g_printer, as my understanding is.

I see that on my host the directory /sys/bus/usb/devices/2-2.1/ (which is printer gadget), structure:
struct usb_device_descriptor {
        __u8  bLength;
        __u8  bDescriptorType;
        __u16 bcdUSB;
        __u8  bDeviceClass;
        __u8  bDeviceSubClass;
        __u8  bDeviceProtocol;
        __u8  bMaxPacketSize0;
        __u16 idVendor;
	__u16 idProduct;
        __u16 bcdDevice;
        __u8  iManufacturer;
        __u8  iProduct;
	__u8  iSerialNumber;
        __u8  bNumConfigurations;
} __attribute__ ((packed));

Is initialized correctly.

Please, find attached diff text file between original and modified version (Copyright (c) 2002 by David Brownell- * + * Copyright (c) 2010 by Samsung Electronics+ * Author: Michal Nazarewicz <m.nazarewicz@xxxxxxxxxxx>).

Thank you,
Zoran Stojsavljevic

-----Original Message-----
From: Greg KH [mailto:greg@xxxxxxxxx] 
Sent: Saturday, January 21, 2012 2:09 PM
To: Stojsavljevic, Zoran
Cc: linux-usb@xxxxxxxxxxxxxxx
Subject: Re: Latest testusb.c, with my additions... While opening usbtest, what device should be opened?!

On Sat, Jan 21, 2012 at 12:47:46PM +0000, Stojsavljevic, Zoran wrote:
> Hello Linux USB members,
> 
> Your name came to my attention while trying to test max3420 SPI USB 
> driver on target platform, we in INTEL call it Moon Creek (N450 Atom +
> ICH8 PCH), kernel 2.6.34.10 running on this platform.

You do realize just how old and out of date that kernel is, and the fact that we can't support you, or do anything about such an obsolete kernel version here, right?

> The driver is properly configured and it does shows signs of 
> activities on both host (and on the host I am using VMware Guest OS:
> Fedora 14 x86_64), which runs on VMware Player, installed on Win 7, 
> and target (as mentioned).
> 
> I had an idea to test this whole thing with testusb.c using usbtest.c 
> driver, but, apparently I am NOT able to reach _ioctl function on 
> usbtest driver, which happily inserts into host Fedora 14 x86_64 .
> 
> Please, find attached both modified testusb.c and usbtest.c (which I 
> compile externally as module using the host /lib/modules/$(shell uname 
> -r)/build soft link which points to right kernel structure.
> As you see, I added to function static int testdev_ifnum(FILE *fd) printer gadget device:

Sorry, we can't see your changes, could you provide them in 'diff -u'
format so that we can?

>         /*
>                 * -- From /proc/bus/usb/devices file --
>                 *
>                 *    T:  Bus=02 Lev=02 Prnt=03 Port=00 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
>                 *    D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
>                 *    P:  Vendor=0525 ProdID=a4a8 Rev= 2.27
>                 *    S:  Product=Printer Gadget
>                 *    C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=  2mA
>                 *    I:* If#= 0 Alt= 0 #EPs= 1 Cls=07(print) Sub=01 Prot=02 Driver=(none)
>                 *    E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
>                 */

so your device shows up properly, right?

>                 /* "printer gadget", Linux-USB test software */
>                 if (dev.idVendor == 0x0525 && dev.idProduct == 0xa4a8) {
>                         printf("Found Test Device Vendor id 0x%x and Product Id 0x%x!\n", dev.idVendor, dev.idProduct);
>                         return 0;
> }
> 
> As I mentioned, the problem is that I do NOT see _ioctl function on 
> usbtest driver, which says to me that while opening it, I did NOT 
> reach correct device!

That's probably true.

> When I insert usbtest.ko, I see it in sysfs: 
> /sys/bus/usb/drivers/usbtest
> 
> The outcome of the whole thing is:
> [root@localhost modules_fedora-14-x86_14]# ./testusb -a  -t 0 Found 
> Test Device Vendor id 0x525 and Product Id 0xa4a8!
> Let me report Test Device /proc/bus/usb/002/008!
> high speed          /proc/bus/usb/002/008                0
> Opened dev->name /proc/bus/usb/002/008 file with file descriptor 3 
> Entering kernel ioctl system call with the following parameters:fd = 
> 3, dev->ifnum = 0x0, USBTEST_REQUEST = 3223868772, test number = 0, 
> test = 0 Here is actual _ioctl system call: fd = 3, wrapper.ifno = 0, 
> USBDEVFS_IOCTL = 3222295826 request = 3223868772 status = -1, errno = 
> 25, error string = Inappropriate ioctl for device
> /proc/bus/usb/002/008 test 0 --> 25 (Inappropriate ioctl for device) 
> [root@localhost modules_fedora-14-x86_14]#
> 
> It says that I opened device with the name /proc/bus/usb/002/008 which 
> IS the USB device connected to target platform and correctly 
> enumerated, whn the registration occurred (last few lines from the 
> host dmesg);
> 
> [33735.851834] usb 2-2.1: USB disconnect, address 7

Your device went away.

> [96008.243718] usb 2-2.1: new full speed USB device using uhci_hcd and 
> address 8 [96008.387399] usb 2-2.1: config 1 interface 0 altsetting 0 
> has an invalid endpoint with address 0x0, skipping [96008.438092] usb 
> 2-2.1: New USB device found, idVendor=0525, idProduct=a4a8 
> [96008.438096] usb 2-2.1: New USB device strings: Mfr=1, Product=2, 
> SerialNumber=3 [96008.438098] usb 2-2.1: Product: Printer Gadget 
> [96008.438116] usb 2-2.1: Manufacturer: Linux 
> 2.6.34.10-WR4.3.0.0_standard with max_udc [96008.438118] usb 2-2.1: 
> SerialNumber: 1
> 
> Question: what is the device which we should open to reach usb test driver? /proc/bus/usb/002/008? I don't think so!!!

Why not?

But let's get to your most basic issue here, what exactly are you trying to do?  Why are you using the usbtest module for a printer device?

greg k-h
--------------------------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland 
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
*** testusb.c.original	2012-01-21 05:28:05.906634903 -0800
--- testusb.c	2012-01-21 05:26:35.310634016 -0800
***************
*** 208,213 ****
--- 208,230 ----
  	if (dev.idVendor == 0x0525 && dev.idProduct == 0xa4a0)
  	        return 0;
  
+         /*
+ 	 * -- From /proc/bus/usb/devices file --
+ 	 *
+ 	 *    T:  Bus=02 Lev=02 Prnt=03 Port=00 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
+ 	 *    D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
+ 	 *    P:  Vendor=0525 ProdID=a4a8 Rev= 2.27
+ 	 *    S:  Product=Printer Gadget
+ 	 *    C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=  2mA
+ 	 *    I:* If#= 0 Alt= 0 #EPs= 1 Cls=07(print) Sub=01 Prot=02 Driver=(none)
+ 	 *    E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
+ 	 */
+ 	/* "printer gadget", Linux-USB test software */
+ 	if (dev.idVendor == 0x0525 && dev.idProduct == 0xa4a8) {
+ 	        printf("Found Test Device Vendor id 0x%x and Product Id 0x%x!\n", dev.idVendor, dev.idProduct);
+ 		return 0;
+ 	}
+ 
  	/* user mode subset of that */
  	if (dev.idVendor == 0x0525 && dev.idProduct == 0xa4a4)
                  return testdev_ffs_ifnum(fd);
***************
*** 272,277 ****
--- 289,299 ----
                  goto nomem;
  
          entry->name = strdup(name);
+ 	printf("Let me report Test Device %s!\n", entry->name);
+ 
+ 	// FIXME about usb speed here, assuming USB 2.0
+ 	entry->speed = USB_SPEED_HIGH;
+ 
  	if (!entry->name) {
                  free(entry);
  nomem:
***************
*** 281,287 ****
  
          entry->ifnum = ifnum;
  
!         /* FIXME ask usbfs what speed; update USBDEVFS_CONNECTINFO so
           * it tells about high speed etc */
  
          fprintf(stderr, "%s speed\t%s\t%u\n",
--- 303,309 ----
  
  	entry->ifnum = ifnum;
  
!         /*FIXME ask usbfs what speed; update USBDEVFS_CONNECTINFO so
           * it tells about high speed etc */
  
          fprintf(stderr, "%s speed\t%s\t%u\n",
***************
*** 301,306 ****
--- 323,329 ----
  	wrapper.ioctl_code = request;
  	wrapper.data = param;
  
+ 	printf("Here is actual _ioctl system call: fd = %d, wrapper.ifno = %d, USBDEVFS_IOCTL = %lu request = %u\n", fd, ifno, USBDEVFS_IOCTL, request);
  	return ioctl (fd, USBDEVFS_IOCTL, &wrapper);
  }
  
***************
*** 315,330 ****
                  return 0;
          }
   
  restart:
          for (i = 0; i < TEST_CASES; i++) {
                  if (dev->test != -1 && dev->test != i)
                          continue;
                  dev->param.test_num = i;
   
                  status = usbdev_ioctl (fd, dev->ifnum,
                                  USBTEST_REQUEST, &dev->param);
!                 if (status < 0 && errno == EOPNOTSUPP)
!                        continue;
  
                  /* FIXME need a "syslog it" option for background testing */
  
--- 338,358 ----
                  return 0;
          }
  
+ 	printf("Opened dev->name %s file with file descriptor %d\n", dev->name, fd);
  restart:
  	for (i = 0; i < TEST_CASES; i++) {
  	        if (dev->test != -1 && dev->test != i)
                          continue;
  		dev->param.test_num = i;
  
+ 		printf("Entering kernel ioctl system call with the following parameters:fd = %d, dev->ifnum = 0x%x, USBTEST_REQUEST = %lu, test number = %u, test = %u\n", fd, dev->ifnum, USBTEST_REQUEST, dev->param.test_num, dev->test);
                  status = usbdev_ioctl (fd, dev->ifnum,
                                  USBTEST_REQUEST, &dev->param);
! 		printf("status = %d, errno = %d, error string = %s\n", status, errno, strerror(errno));
! 		// for now iGNORE these
! 		//    if (status < 0 && errno == EOPNOTSUPP)
! 		//      continue;
! 		// EOPNOTSUPP is 95
  
                  /* FIXME need a "syslog it" option for background testing */
  

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux