From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Brownell Date: Sun, 27 May 2001 15:15:56 +0000 Subject: Hotplug and USB firmware download MIME-Version: 1 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0E11_01C0E685.41135A00" Message-Id: List-Id: To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. ------=_NextPart_000_0E11_01C0E685.41135A00 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit > 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 ------=_NextPart_000_0E11_01C0E685.41135A00 Content-Type: application/octet-stream; name="gflashd.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="gflashd.patch" diff -u gflashd-orig/ezusb.c gflashd/ezusb.c=0A= --- gflashd-orig/ezusb.c Fri May 18 21:54:37 2001=0A= +++ gflashd/ezusb.c Sat May 26 21:21:05 2001=0A= @@ -80,8 +80,10 @@=0A= there is a problem. */=0A= retry =3D 0;=0A= while ((rc =3D ioctl(fd, USBDEVFS_CONTROL, &ctrl)) =3D=3D -1) {=0A= - if (errno !=3D ETIMEDOUT)=0A= + if (errno !=3D ETIMEDOUT) {=0A= + perror ("usb vendor control request");=0A= break;=0A= + }=0A= =0A= if (retry >=3D RETRY_LIMIT)=0A= break;=0A= @@ -105,11 +107,17 @@=0A= * device, and the path is the name of the source file. Open the file,=0A= * interpret the bytes and write as I go.=0A= */=0A= -int ezusb_load_ihex(int fd, const char*path)=0A= +int ezusb_load_ihex(int fd, const char*path, int fx2)=0A= {=0A= unsigned char data[512];=0A= FILE*image;=0A= int rc;=0A= + unsigned short cpucs_addr;=0A= +=0A= + if (fx2)=0A= + cpucs_addr =3D 0xe680;=0A= + else=0A= + cpucs_addr =3D 0x7f92;=0A= =0A= image =3D fopen(path, "r");=0A= if (image =3D=3D 0) {=0A= @@ -122,7 +130,7 @@=0A= the CPU reset. Do this first, so that I'm free to write its=0A= program data later. */=0A= { unsigned char cpucs =3D 0x01;=0A= - ezusb_poke(fd, 0x7f92, &cpucs, 1);=0A= + ezusb_poke(fd, cpucs_addr, &cpucs, 1);=0A= }=0A= =0A= =0A= @@ -195,7 +203,7 @@=0A= release the host reset. After this, the processor is free=0A= to renumerate, or whatever. */=0A= { unsigned char cpucs =3D 0x00;=0A= - ezusb_poke(fd, 0x7f92, &cpucs, 1);=0A= + ezusb_poke(fd, cpucs_addr, &cpucs, 1);=0A= }=0A= =0A= =0A= diff -u gflashd-orig/ezusb.h gflashd/ezusb.h=0A= --- gflashd-orig/ezusb.h Fri May 18 21:54:37 2001=0A= +++ gflashd/ezusb.h Sat May 26 21:21:05 2001=0A= @@ -24,11 +24,12 @@=0A= /*=0A= * This function loads into the opened EZUSB device the firmware in=0A= * the given file. The file is assumed to be in Intel HEX format, and=0A= - * is loaded into the target memory literally.=0A= + * is loaded into the target memory literally. If fx2 is set, uses=0A= + * different reset commands.=0A= *=0A= * The target processor is reset as part of this load.=0A= */=0A= -extern int ezusb_load_ihex(int dev, const char*path);=0A= +extern int ezusb_load_ihex(int dev, const char*path, int fx2);=0A= =0A= /*=0A= * $Log: ezusb.h,v $=0A= diff -u gflashd-orig/main.c gflashd/main.c=0A= --- gflashd-orig/main.c Fri May 18 21:54:37 2001=0A= +++ gflashd/main.c Sat May 26 21:21:05 2001=0A= @@ -27,6 +27,7 @@=0A= * looking for the device.=0A= *=0A= * -I -- Download this firmware (intel hex)=0A= + * -2 -- it's an FX2 (USB 2.0 capable) not FX=0A= *=0A= * -L -- Create a symbolic link to the device.=0A= * -m -- Set the permissions on the device after = download.=0A= @@ -49,10 +50,15 @@=0A= const char*link_path =3D 0;=0A= const char*ihex_path =3D 0;=0A= const char*device_path =3D getenv("DEVICE");=0A= + int fx2 =3D 0;=0A= mode_t mode =3D 0;=0A= int opt;=0A= =0A= - while ((opt =3D getopt(argc, argv, "D:I:L:m:")) !=3D EOF) switch = (opt) {=0A= + while ((opt =3D getopt(argc, argv, "2D:I:L:m:")) !=3D EOF) switch = (opt) {=0A= +=0A= + case '2':=0A= + fx2 =3D 1;=0A= + break;=0A= =0A= case 'D':=0A= device_path =3D optarg;=0A= @@ -71,10 +77,21 @@=0A= mode &=3D 0777;=0A= break;=0A= default:=0A= - break;=0A= + goto usage;=0A= =0A= }=0A= =0A= + if (!device_path) {=0A= + fputs ("no device specified!\n", stderr);=0A= +usage:=0A= + fputs ("usage: ", stderr);=0A= + fputs (argv [0], stderr);=0A= + fputs (" [-2] [-D devpath] [-I hexfile]", stderr);=0A= + fputs ("[-L link] [-m mode]\n", stderr);=0A= + fputs ("... [-D devpath] overrides DEVICE=3D in env\n", stderr);=0A= + return -1;=0A= + }=0A= +=0A= if (ihex_path) {=0A= int fd =3D open(device_path, O_RDWR);=0A= if (fd =3D=3D -1) {=0A= @@ -82,7 +99,7 @@=0A= return -1;=0A= }=0A= =0A= - ezusb_load_ihex(fd, ihex_path);=0A= + ezusb_load_ihex(fd, ihex_path, fx2);=0A= }=0A= =0A= if (link_path) {=0A= @@ -100,6 +117,11 @@=0A= perror(link_path);=0A= return -1;=0A= }=0A= + }=0A= +=0A= + if (!ihex_path && !link_path && !mode) {=0A= + fputs ("missing request! (firmware, link, or mode)\n", stderr);=0A= + return -1;=0A= }=0A= =0A= return 0;=0A= ------=_NextPart_000_0E11_01C0E685.41135A00-- _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel