linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: linux-hotplug@vger.kernel.org
Subject: Hotplug and USB firmware download
Date: Sun, 27 May 2001 15:15:56 +0000	[thread overview]
Message-ID: <marc-linux-hotplug-99097721520346@msgid-missing> (raw)

[-- Attachment #1: Type: text/plain, Size: 218 bytes --]

>     <ftp://icarus.com/pub/steve/gflashd.tgz>

Here's a small patch adding FX2 support, and some diagnostics.
It worked to download some of the FX2 sample firmware.
(Using high speed USB 2.0 transfers ... :)

- Dave


[-- Attachment #2: gflashd.patch --]
[-- Type: application/octet-stream, Size: 4090 bytes --]

diff -u gflashd-orig/ezusb.c gflashd/ezusb.c
--- gflashd-orig/ezusb.c	Fri May 18 21:54:37 2001
+++ gflashd/ezusb.c	Sat May 26 21:21:05 2001
@@ -80,8 +80,10 @@
 		 there is a problem. */
 	    retry = 0;
 	    while ((rc = ioctl(fd, USBDEVFS_CONTROL, &ctrl)) == -1) {
-		  if (errno != ETIMEDOUT)
+		  if (errno != ETIMEDOUT) {
+			perror ("usb vendor control request");
 			break;
+		  }
 
 		  if (retry >= RETRY_LIMIT)
 			break;
@@ -105,11 +107,17 @@
  * device, and the path is the name of the source file. Open the file,
  * interpret the bytes and write as I go.
  */
-int ezusb_load_ihex(int fd, const char*path)
+int ezusb_load_ihex(int fd, const char*path, int fx2)
 {
       unsigned char data[512];
       FILE*image;
       int rc;
+      unsigned short cpucs_addr;
+
+      if (fx2)
+	    cpucs_addr = 0xe680;
+      else
+	    cpucs_addr = 0x7f92;
 
       image = fopen(path, "r");
       if (image == 0) {
@@ -122,7 +130,7 @@
 	   the CPU reset. Do this first, so that I'm free to write its
 	   program data later. */
       { unsigned char cpucs = 0x01;
-        ezusb_poke(fd, 0x7f92, &cpucs, 1);
+        ezusb_poke(fd, cpucs_addr, &cpucs, 1);
       }
 
 
@@ -195,7 +203,7 @@
 	   release the host reset. After this, the processor is free
 	   to renumerate, or whatever. */
       { unsigned char cpucs = 0x00;
-        ezusb_poke(fd, 0x7f92, &cpucs, 1);
+        ezusb_poke(fd, cpucs_addr, &cpucs, 1);
       }
 
 
diff -u gflashd-orig/ezusb.h gflashd/ezusb.h
--- gflashd-orig/ezusb.h	Fri May 18 21:54:37 2001
+++ gflashd/ezusb.h	Sat May 26 21:21:05 2001
@@ -24,11 +24,12 @@
 /*
  * This function loads into the opened EZUSB device the firmware in
  * the given file. The file is assumed to be in Intel HEX format, and
- * is loaded into the target memory literally.
+ * is loaded into the target memory literally.  If fx2 is set, uses
+ * different reset commands.
  *
  * The target processor is reset as part of this load.
  */
-extern int ezusb_load_ihex(int dev, const char*path);
+extern int ezusb_load_ihex(int dev, const char*path, int fx2);
 
 /*
  * $Log: ezusb.h,v $
diff -u gflashd-orig/main.c gflashd/main.c
--- gflashd-orig/main.c	Fri May 18 21:54:37 2001
+++ gflashd/main.c	Sat May 26 21:21:05 2001
@@ -27,6 +27,7 @@
  * looking for the device.
  *
  *     -I <path>       -- Download this firmware (intel hex)
+ *     -2              -- it's an FX2 (USB 2.0 capable) not FX
  *
  *     -L <path>       -- Create a symbolic link to the device.
  *     -m <mode>       -- Set the permissions on the device after download.
@@ -49,10 +50,15 @@
       const char*link_path = 0;
       const char*ihex_path = 0;
       const char*device_path = getenv("DEVICE");
+      int fx2 = 0;
       mode_t mode = 0;
       int opt;
 
-      while ((opt = getopt(argc, argv, "D:I:L:m:")) != EOF) switch (opt) {
+      while ((opt = getopt(argc, argv, "2D:I:L:m:")) != EOF) switch (opt) {
+
+	  case '2':
+	    fx2 = 1;
+	    break;
 
 	  case 'D':
 	    device_path = optarg;
@@ -71,10 +77,21 @@
 	    mode &= 0777;
 	    break;
 	  default:
-	    break;
+	    goto usage;
 
       }
 
+      if (!device_path) {
+	    fputs ("no device specified!\n", stderr);
+usage:
+	    fputs ("usage: ", stderr);
+	    fputs (argv [0], stderr);
+	    fputs (" [-2] [-D devpath] [-I hexfile]", stderr);
+	    fputs ("[-L link] [-m mode]\n", stderr);
+	    fputs ("... [-D devpath] overrides DEVICE= in env\n", stderr);
+	    return -1;
+      }
+
       if (ihex_path) {
 	    int fd = open(device_path, O_RDWR);
 	    if (fd == -1) {
@@ -82,7 +99,7 @@
 		  return -1;
 	    }
 
-	    ezusb_load_ihex(fd, ihex_path);
+	    ezusb_load_ihex(fd, ihex_path, fx2);
       }
 
       if (link_path) {
@@ -100,6 +117,11 @@
 		  perror(link_path);
 		  return -1;
 	    }
+      }
+
+      if (!ihex_path && !link_path && !mode) {
+	    fputs ("missing request! (firmware, link, or mode)\n", stderr);
+	    return -1;
       }
 
       return 0;

                 reply	other threads:[~2001-05-27 15:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-hotplug-99097721520346@msgid-missing \
    --to=david-b@pacbell.net \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).