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 -- Download this firmware (intel hex) + * -2 -- it's an FX2 (USB 2.0 capable) not FX * * -L -- Create a symbolic link to the device. * -m -- 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;