changeset 2188:33a63029a5f8

* host/bulk-boundaries.tcl(New): test bulk transfers at boundary cases. * doc/usbs.sgml: Documentation of bulk-boundaries.tcl test. * doc/usbs-testing.html: Correct "format" for "data" when specifiying what the data in the USB message will contain. * host/usbhost.c (tcl_run): Fix compiler warnings * host/usbhost.c (pool_function): sem_wait can exit with a EINTR. If so loop and try again. * host/usbchmod.c (usb_scan_devices) propergate previous fix from usbhost.c *host/usbhost.c (usb_scan_devices) Fix parsing EOL for FC4 and others.
author asl
date Sun, 07 May 2006 19:50:34 +0000
parents 2d74b1f822f7
children 35f58e98b6ec
files packages/io/usb/slave/current/ChangeLog packages/io/usb/slave/current/doc/usbs-testing.html packages/io/usb/slave/current/doc/usbs.sgml packages/io/usb/slave/current/host/bulk-boundaries.tcl packages/io/usb/slave/current/host/usbchmod.c packages/io/usb/slave/current/host/usbhost.c packages/io/usb/slave/current/tests/usbtarget.c
diffstat 7 files changed, 169 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/packages/io/usb/slave/current/ChangeLog
+++ b/packages/io/usb/slave/current/ChangeLog
@@ -1,3 +1,28 @@
+2006-05-07  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* host/bulk-boundaries.tcl(New): test bulk transfers at
+	boundary cases.
+	* doc/usbs.sgml: Documentation of bulk-boundaries.tcl test.
+
+2006-04-23  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* doc/usbs-testing.html: Correct "format" for "data" when
+	specifiying what the data in the USB message will contain.
+
+2006-04-16  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* host/usbhost.c (tcl_run): Fix compiler warnings
+	* host/usbhost.c (pool_function): sem_wait can exit with a
+	EINTR. If so loop and try again.
+
+	* host/usbchmod.c (usb_scan_devices) propergate previous fix from
+	usbhost.c
+
+2006-04-16  Frank Pagliughi <fpagliughi@mindspring.com>
+
+	*host/usbhost.c (usb_scan_devices) Fix parsing EOL for FC4 and
+	others.
+
 2006-03-10  Bart Veer  <bartv@ecoscentric.com>
 
 	* src/usbs.c (usbs_devtab_cwrite, usbs_devtab_cwrite): add
--- a/packages/io/usb/slave/current/doc/usbs-testing.html
+++ b/packages/io/usb/slave/current/doc/usbs-testing.html
@@ -1359,7 +1359,7 @@ NAME="AEN1130"
 This can be controlled by the argument <TT
 CLASS="PARAMETER"
 ><I
->data</I
+>format</I
 ></TT
 >
 which can take one of five values: <TT
@@ -1540,7 +1540,7 @@ WIDTH="100%"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
->bulktest 2 IN 1000 data=wordseq data1=42 \
+>bulktest 2 IN 1000 format=wordseq data1=42 \
     data* $usbtest::MULTIPLIER data+ $usbtest::INCREMENT</PRE
 ></TD
 ></TR
@@ -2264,4 +2264,4 @@ VALIGN="top"
 ></DIV
 ></BODY
 ></HTML
->
\ No newline at end of file
+>
--- a/packages/io/usb/slave/current/doc/usbs.sgml
+++ b/packages/io/usb/slave/current/doc/usbs.sgml
@@ -3485,6 +3485,16 @@ test scripts include the following:
       be used.
     </para></listitem>
   </varlistentry>
+  <varlistentry><term><filename>bulk-boundaries.tcl</filename></term>
+    <listitem><para> This script performs simple bulk IN and OUT
+      transfers of different sizes around interesting boundaries. This
+      test is useful to ensure the driver correctly handles the case
+      where a transfer is just smaller than, the same size as, and
+      just bigger than the hardware buffer in the endpoint hardware.
+      This script takes no parameters. It determines what endpoints
+      the device has by asking it.
+    </para></listitem>
+  </varlistentry>
 </variablelist>
 </refsect1>
 
new file mode 100644
--- /dev/null
+++ b/packages/io/usb/slave/current/host/bulk-boundaries.tcl
@@ -0,0 +1,105 @@
+#===============================================================================
+#
+#    bulk-boundaries.tcl
+#
+#    Support for USB testing
+#
+#===============================================================================
+#####ECOSGPLCOPYRIGHTBEGIN####
+## -------------------------------------------
+## This file is part of eCos, the Embedded Configurable Operating System.
+## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+##
+## eCos 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 or (at your option) any later version.
+##
+## eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+##
+## As a special exception, if other files instantiate templates or use macros
+## or inline functions from this file, or you compile this file and link it
+## with other works to produce a work based on this file, this file does not
+## by itself cause the resulting work to be covered by the GNU General Public
+## License. However the source code for this file must still be made available
+## in accordance with section (3) of the GNU General Public License.
+##
+## This exception does not invalidate any other reasons why a work based on
+## this file might be covered by the GNU General Public License.
+## -------------------------------------------
+#####ECOSGPLCOPYRIGHTEND####
+#===============================================================================
+######DESCRIPTIONBEGIN####
+#
+# Author(s):	asl
+# Date:		2006-04-21
+# Purpose:      Test the bulk endpoints with different sizes of packets
+#               at the important boundaries.
+#
+#####DESCRIPTIONEND####
+#===============================================================================
+
+set pktsizes { 1 2 3 4 5 7 8 9 15 16 17 31 32 33 63 64 65 127 128 129 \
+               255 256 257 511 512 513 1023 1024 1025 2047 2048 2049 \
+               4095 4096 4097 }
+
+ if { 0 != [llength $usbtest::bulk_in_endpoints] } {
+     puts "Bulk IN endpoints: $usbtest::bulk_in_endpoints"
+     foreach ep $usbtest::bulk_in_endpoints {
+ 	puts [format "  %2d: packet sizes %d to %d, padding %d" $ep \
+                   $usbtest::bulk_in($ep,min_size) \
+                   $usbtest::bulk_in($ep,max_size) \
+                   $usbtest::bulk_in($ep,max_in_padding)]
+         foreach pktsize $pktsizes {
+             if { $pktsize <=  $usbtest::bulk_in($ep,max_size) } {
+                 puts [format "Testing IN endpoint %d with packet size %4d" \
+                           $ep $pktsize]
+                 usbtest::reset
+                 usbtest::bulktest $ep in 5 txsize1=$pktsize format=byteseq \
+                     data1=42 data* $usbtest::MULTIPLIER \
+                     data+ $usbtest::INCREMENT
+                 if { [usbtest::start 10] } {
+                     puts "Passed"
+                 } else {
+                     puts "Failed"
+                     foreach result $usbtest::results {
+                         puts $result
+                     }
+                 }
+             }
+         }
+     }
+ }
+
+if { 0 != [llength $usbtest::bulk_out_endpoints] } {
+    puts "Bulk OUT endpoints: $usbtest::bulk_out_endpoints"
+    foreach ep $usbtest::bulk_out_endpoints {
+	puts [format "  %2d: packet sizes %d to %d" $ep \
+                  $usbtest::bulk_out($ep,min_size) \
+                  $usbtest::bulk_out($ep,max_size)]
+        foreach pktsize $pktsizes {
+            if { $pktsize <=  $usbtest::bulk_out($ep,max_size) } {
+                puts [format "Testing OUT endpoint %d with packet size %4d" \
+                          $ep $pktsize]
+                usbtest::reset
+                usbtest::bulktest $ep out 5 txsize1=$pktsize format=byteseq \
+                    data1=42 data* $usbtest::MULTIPLIER \
+                    data+ $usbtest::INCREMENT rxsize1=4096 
+                if { [usbtest::start 10] } {
+                    puts "Passed"
+                } else {
+                    puts "Failed"
+                    foreach result $usbtest::results {
+                        puts $result
+                    }
+                }
+            }
+        }
+    }
+}
--- a/packages/io/usb/slave/current/host/usbchmod.c
+++ b/packages/io/usb/slave/current/host/usbchmod.c
@@ -57,6 +57,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
+#include <string.h>
 
 // Note: this code is duplicated in usbhost.c. Any changes here
 // should be propagated. For now the routine is too small to warrant
@@ -94,9 +95,9 @@ usb_scan_devices(int* bus, int* dev)
             } 
         }
         // Move to the end of the current line.
-        do {
+        while ((EOF != ch) && ('\n' != ch)) {
             ch = getc(devs_file);
-        } while ((EOF != ch) && ('\n' != ch));
+        }
         if (EOF != ch) {
             ch = getc(devs_file);
         }
@@ -170,9 +171,7 @@ main(int argc, char** argv)
     if (0 != chmod(devname, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) {
         int old_errno = errno;
         fprintf(stderr, "usbchmod: failed to modify access rights on %s\n", devname);
-        if ((old_errno >= 0) && (old_errno < sys_nerr)) {
-            fprintf(stderr, "         : %s\n", sys_errlist[old_errno]);
-        }
+        fprintf(stderr, "         : %s\n", strerror(old_errno));
         exit(EXIT_FAILURE);
     }
 
--- a/packages/io/usb/slave/current/host/usbhost.c
+++ b/packages/io/usb/slave/current/host/usbhost.c
@@ -216,9 +216,9 @@ usb_scan_devices(int* bus, int* dev)
             } 
         }
         // Move to the end of the current line.
-        do {
+        while ((EOF != ch) && ('\n' != ch)) {
             ch = getc(devs_file);
-        } while ((EOF != ch) && ('\n' != ch));
+        } 
         if (EOF != ch) {
             ch = getc(devs_file);
         }
@@ -280,6 +280,7 @@ usb_open_device(void)
     }
     if (-1 == result) {
         fprintf(stderr, "usbhost: error, failed to open \"%s\", errno %d\n", devname, errno);
+        exit(EXIT_FAILURE);
     }
 
     VERBOSE(1, "USB device now accessible via file descriptor %d\n", result);
@@ -500,8 +501,8 @@ usb_initialise_bulk_in_endpoint(int numb
 static void
 usb_initialise_bulk_out_endpoint(int number, int min_size, int max_size)
 {
-    char buf[1];
-    
+    unsigned char buf[1];
+
     // On the SA1110 the hardware comes up with a bogus default value,
     // causing the hardware to accept packets before the software has
     // set up DMA or in any way prepared for incoming data. This is
@@ -943,8 +944,16 @@ static void*
 pool_function(void* arg)
 {
     PoolEntry*  pool_entry  = (PoolEntry*) arg;
+    int ret;
+    
     for ( ; ; ) {
-        sem_wait(&(pool_entry->wakeup));
+        do {
+             ret = sem_wait(&(pool_entry->wakeup));
+             if (ret != 0 && errno != EINTR) {
+                  perror("sem_wait");
+                  exit(1);
+             }
+        } while (ret != 0);
         run_test(&(pool_entry->test));
         pool_entry->running = 0;
     }
@@ -1560,7 +1569,7 @@ tcl_run(ClientData     clientData    __a
         usb_reliable_control_message(usb_master_fd, USB_TYPE_CLASS | USB_RECIP_DEVICE | USB_DIR_IN, USBTEST_GET_RESULT,
                                      0, i, USBTEST_MAX_CONTROL_DATA, (void*) result_buf);
         if (!result_buf[0]) {
-            Tcl_SetVar(interp, "usbtest::results", &(result_buf[1]),
+            Tcl_SetVar(interp, "usbtest::results", (char *)&(result_buf[1]),
                        all_ok ? TCL_GLOBAL_ONLY : (TCL_GLOBAL_ONLY | TCL_APPEND_VALUE | TCL_LIST_ELEMENT));
             all_ok = 0;
         }
@@ -1576,7 +1585,7 @@ tcl_run(ClientData     clientData    __a
         usb_reliable_control_message(usb_master_fd, USB_TYPE_CLASS | USB_RECIP_DEVICE | USB_DIR_IN, USBTEST_GET_RESULT,
                                      0, i, USBTEST_MAX_CONTROL_DATA, (void*) result_buf);
         if (!result_buf[0]) {
-            Tcl_SetVar(interp, "usbtest::results", &(result_buf[1]),
+            Tcl_SetVar(interp, "usbtest::results", (char *)&(result_buf[1]),
                        all_ok ? TCL_GLOBAL_ONLY : (TCL_GLOBAL_ONLY | TCL_APPEND_VALUE | TCL_LIST_ELEMENT));
             all_ok = 0;
         }
--- a/packages/io/usb/slave/current/tests/usbtarget.c
+++ b/packages/io/usb/slave/current/tests/usbtarget.c
@@ -825,9 +825,11 @@ run_test_bulk_in(UsbTest* test)
         test->recovery.protocol     = USB_ENDPOINT_DESCRIPTOR_ATTR_BULK;
         test->recovery.size         = packet_size + usbs_testing_endpoints[ep_index].max_in_padding;
 
+        CYG_ASSERTC(sizeof(test->buffer) > packet_size);
+        
         // Make sure the buffer contains the data expected by the host
         usbtest_fill_buffer(&(test->test_params.bulk.data), buf, packet_size);
-                            
+
         if (verbose < 3) {
             VERBOSE(2, "Bulk OUT test %d: iteration %d, packet size %d\n", test->id, i, packet_size);
         } else {
@@ -1016,7 +1018,7 @@ static usbs_control_return
 handle_reserved_control_messages(usbs_control_endpoint* endpoint, void* data)
 {
     usb_devreq*         req = (usb_devreq*) endpoint->control_buffer;
-    usbs_control_return result;
+    usbs_control_return result = USBS_CONTROL_RETURN_UNKNOWN;
 
     CYG_ASSERT(endpoint == control_endpoint, "control endpoint mismatch");
     switch(req->request) {
@@ -1049,7 +1051,7 @@ handle_reserved_control_messages(usbs_co
             if (control_in_test_packet_size != len) {
                 control_in_test->result_pass   = 0;
                 snprintf(control_in_test->result_message, USBTEST_MAX_MESSAGE,
-                         "Target, control IN transfer on endpoint %d : the host only requested %d bytes instead of %d",
+                         "Target, control IN transfer : the host only requested %d bytes instead of %d",
                          len, control_in_test_packet_size);
                 cyg_semaphore_post(&(control_in_test->sem));
                 control_in_test = (UsbTest*) 0;
@@ -1835,7 +1837,7 @@ main(int argc, char** argv)
     // function pointer is used to keep track of what operation is actually required.
     for (;;) {
         void (*handler)(void);
-        
+
         cyg_semaphore_wait(&main_wakeup);
         handler = main_thread_action;
         main_thread_action   = 0;