Hi Folks
This patch fixes a few compiler warnings in the USB test code. It
fixes the parsing of the proc filesystem when trying to find the
device. A new test script is added which performs bulk transfers of
different sizes. A typo in the documentation is also fixed along with
a little documentation about the new test.
Andrew
? io/usb/slave/current/host/confdefs.h
? io/usb/slave/current/host/config.cache
? io/usb/slave/current/host/config.log
Index: io/usb/slave/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/usb/slave/current/ChangeLog,v
retrieving revision 1.14
diff -u -r1.14 ChangeLog
--- io/usb/slave/current/ChangeLog 10 Mar 2006 20:49:54 -0000 1.14
+++ io/usb/slave/current/ChangeLog 7 May 2006 19:48:01 -0000
@@ -1,3 +1,28 @@
+2006-05-07 Andrew Lunn <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
+
+ * doc/usbs-testing.html: Correct "format" for "data" when
+ specifiying what the data in the USB message will contain.
+
+2006-04-16 Andrew Lunn <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
+
+ *host/usbhost.c (usb_scan_devices) Fix parsing EOL for FC4 and
+ others.
+
2006-03-10 Bart Veer <[EMAIL PROTECTED]>
* src/usbs.c (usbs_devtab_cwrite, usbs_devtab_cwrite): add
Index: io/usb/slave/current/doc/usbs-testing.html
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/usb/slave/current/doc/usbs-testing.html,v
retrieving revision 1.1
diff -u -r1.1 usbs-testing.html
--- io/usb/slave/current/doc/usbs-testing.html 20 May 2002 22:24:30 -0000
1.1
+++ io/usb/slave/current/doc/usbs-testing.html 7 May 2006 19:48:03 -0000
@@ -1359,7 +1359,7 @@
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 @@
><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 @@
></DIV
></BODY
></HTML
->
\ No newline at end of file
+>
Index: io/usb/slave/current/doc/usbs.sgml
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/usb/slave/current/doc/usbs.sgml,v
retrieving revision 1.7
diff -u -r1.7 usbs.sgml
--- io/usb/slave/current/doc/usbs.sgml 25 Feb 2003 16:47:56 -0000 1.7
+++ io/usb/slave/current/doc/usbs.sgml 7 May 2006 19:48:09 -0000
@@ -3485,6 +3485,16 @@
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>
Index: io/usb/slave/current/host/bulk-boundaries.tcl
===================================================================
RCS file: io/usb/slave/current/host/bulk-boundaries.tcl
diff -N io/usb/slave/current/host/bulk-boundaries.tcl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ io/usb/slave/current/host/bulk-boundaries.tcl 7 May 2006 19:48:09
-0000
@@ -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
+ }
+ }
+ }
+ }
+ }
+}
Index: io/usb/slave/current/host/usbchmod.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/usb/slave/current/host/usbchmod.c,v
retrieving revision 1.1
diff -u -r1.1 usbchmod.c
--- io/usb/slave/current/host/usbchmod.c 31 May 2002 17:10:26 -0000
1.1
+++ io/usb/slave/current/host/usbchmod.c 7 May 2006 19:48:10 -0000
@@ -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 @@
}
}
// 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 @@
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);
}
Index: io/usb/slave/current/host/usbhost.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/usb/slave/current/host/usbhost.c,v
retrieving revision 1.3
diff -u -r1.3 usbhost.c
--- io/usb/slave/current/host/usbhost.c 26 Jun 2005 21:21:37 -0000 1.3
+++ io/usb/slave/current/host/usbhost.c 7 May 2006 19:48:14 -0000
@@ -216,9 +216,9 @@
}
}
// 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 @@
}
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 @@
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 @@
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 @@
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 @@
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;
}
Index: io/usb/slave/current/tests/usbtarget.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/usb/slave/current/tests/usbtarget.c,v
retrieving revision 1.1
diff -u -r1.1 usbtarget.c
--- io/usb/slave/current/tests/usbtarget.c 31 May 2002 17:10:26 -0000
1.1
+++ io/usb/slave/current/tests/usbtarget.c 7 May 2006 19:48:16 -0000
@@ -825,9 +825,11 @@
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 @@
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 @@
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 @@
// 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;