Index: fxload/ezusb.c =================================================================== RCS file: /cvsroot/linux-hotplug/fxload/ezusb.c,v retrieving revision 1.9 diff -u -r1.9 ezusb.c --- fxload/ezusb.c 11 Jan 2005 03:58:02 -0000 1.9 +++ fxload/ezusb.c 19 Oct 2005 01:25:09 -0000 @@ -428,6 +428,7 @@ int device; ram_mode mode; unsigned total, count; + int request; }; # define RETRY_LIMIT 5 @@ -482,7 +483,7 @@ */ while ((rc = ezusb_write (ctx->device, external ? "write external" : "write on-chip", - external ? RW_MEMORY : RW_INTERNAL, + external ? (ctx->request>=0?ctx->request:RW_MEMORY) : RW_INTERNAL, addr, data, len)) < 0 && retry < RETRY_LIMIT) { if (errno != ETIMEDOUT) @@ -506,7 +507,7 @@ * memory is written, expecting a second stage loader to have already * been loaded. Then file is re-parsed and on-chip memory is written. */ -int ezusb_load_ram (int fd, const char *path, int fx2, int stage) +int ezusb_load_ram (int fd, const char *path, int fx2, int stage, int request) { FILE *image; unsigned short cpucs_addr; @@ -550,6 +551,7 @@ /* scan the image, first (maybe only) time */ ctx.device = fd; ctx.total = ctx.count = 0; + ctx.request = request; status = parse_ihex (image, &ctx, is_external, ram_poke); if (status < 0) { logerror("unable to download %s\n", path); Index: fxload/ezusb.h =================================================================== RCS file: /cvsroot/linux-hotplug/fxload/ezusb.h,v retrieving revision 1.3 diff -u -r1.3 ezusb.h --- fxload/ezusb.h 12 Apr 2002 00:28:21 -0000 1.3 +++ fxload/ezusb.h 19 Oct 2005 01:25:09 -0000 @@ -31,7 +31,7 @@ * * The target processor is reset at the end of this download. */ -extern int ezusb_load_ram (int dev, const char *path, int fx2, int stage); +extern int ezusb_load_ram (int dev, const char *path, int fx2, int stage, int request); /* Index: fxload/main.c =================================================================== RCS file: /cvsroot/linux-hotplug/fxload/main.c,v retrieving revision 1.8 diff -u -r1.8 main.c --- fxload/main.c 11 Jan 2005 03:58:02 -0000 1.8 +++ fxload/main.c 19 Oct 2005 01:25:10 -0000 @@ -30,6 +30,7 @@ * -t -- uController type: an21, fx, fx2 * -s -- use this second stage loader * -c -- Download to EEPROM, with this config byte + * -r -- use this request byte for uploading external data * * -L -- Create a symbolic link to the device. * -m -- Set the permissions on the device after download. @@ -96,8 +97,9 @@ mode_t mode = 0; int opt; int config = -1; + int request = -1; - while ((opt = getopt (argc, argv, "2vV?D:I:L:c:lm:s:t:")) != EOF) + while ((opt = getopt (argc, argv, "2vV?D:I:L:c:lm:s:t:r:")) != EOF) switch (opt) { case '2': // original version of "-t fx2" @@ -156,6 +158,14 @@ case 'v': verbose++; break; + + case 'r': + request = strtoul (optarg, 0, 0); + if (request < 0 || request > 255) { + logerror("illegal request byte: %s\n", optarg); + goto usage; + } + break; case '?': default: @@ -164,6 +174,11 @@ } if (config >= 0) { + if (request >= 0) { + logerror("can't set both a config and a request byte\n"); + goto usage; + } + if (type == 0) { logerror("must specify microcontroller type %s", "to write EEPROM!\n"); @@ -179,6 +194,14 @@ goto usage; } } + + if (request >= 0) { + if (!stage1 || !ihex_path) { + logerror("need 2nd stage loader and firmware %s", + "to use request byte\n"); + goto usage; + } + } if (!device_path) { logerror("no device specified!\n"); @@ -188,7 +211,7 @@ fputs (" [-vV] [-l] [-t type] [-D devpath]\n", stderr); fputs ("\t\t[-I firmware_hexfile] ", stderr); fputs ("[-s loader] [-c config_byte]\n", stderr); - fputs ("\t\t[-L link] [-m mode]\n", stderr); + fputs ("\t\t[-r request_byte] [-L link] [-m mode]\n", stderr); fputs ("... [-D devpath] overrides DEVICE= in env\n", stderr); fputs ("... device types: one of an21, fx, fx2\n", stderr); fputs ("... at least one of -I, -L, -m is required\n", stderr); @@ -218,7 +241,7 @@ /* first stage: put loader into internal memory */ if (verbose) logerror("1st stage: load 2nd stage loader\n"); - status = ezusb_load_ram (fd, stage1, fx2, 0); + status = ezusb_load_ram (fd, stage1, fx2, 0, request); if (status != 0) return status; @@ -226,14 +249,14 @@ if (config >= 0) status = ezusb_load_eeprom (fd, ihex_path, type, config); else - status = ezusb_load_ram (fd, ihex_path, fx2, 1); + status = ezusb_load_ram (fd, ihex_path, fx2, 1, request); if (status != 0) return status; } else { /* single stage, put into internal memory */ if (verbose) logerror("single stage: load on-chip memory\n"); - status = ezusb_load_ram (fd, ihex_path, fx2, 0); + status = ezusb_load_ram (fd, ihex_path, fx2, 0, request); if (status != 0) return status; }