From: pix <pix@test.at>
To: linux-hotplug@vger.kernel.org
Subject: fxload patch to set bRequest byte
Date: Wed, 19 Oct 2005 01:42:59 +0000 [thread overview]
Message-ID: <20051019014259.GD13089@kachi2> (raw)
[-- Attachment #1: Type: text/plain, Size: 821 bytes --]
hi,
i've just made this patch to fxload which lets you set the bRequest byte
that is used when uploading data via a loader (-r). i needed this to get
the emi26 driver out of the kernel (since it's being removed in some
distributions already for being non-free).
according to the driver code, the emi seems to have an fpga which gets
programmed via the ezusb, but it needs to be accessed with a bRequest of
0xa5.
http://lxr.linux.no/source/drivers/usb/misc/emi26.c
perhaps this patch isn't the most elegant way to achieve this, in which
case, please consider this a feature request for someone to come up with
a better solution ;)
but for what it's worth, the fxload derived loader works for me in at
least one case where the kernel-based version doesn't (when loading the
firmware via a usb2.0 hub).
thanks,
pix.
[-- Attachment #2: fxload.patch --]
[-- Type: text/plain, Size: 5269 bytes --]
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 <type> -- uController type: an21, fx, fx2
* -s <path> -- use this second stage loader
* -c <byte> -- Download to EEPROM, with this config byte
+ * -r <byte> -- use this request byte for uploading external data
*
* -L <path> -- Create a symbolic link to the device.
* -m <mode> -- 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;
}
next reply other threads:[~2005-10-19 1:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-19 1:42 pix [this message]
2005-10-20 22:33 ` fxload patch to set bRequest byte Greg KH
2005-10-22 7:09 ` pix
2005-10-26 22:49 ` Greg KH
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=20051019014259.GD13089@kachi2 \
--to=pix@test.at \
--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