Commit aff79eb4 authored by Tjeerd J. Pinkert's avatar Tjeerd J. Pinkert Committed by Grzegorz Daniluk

flash tools, add help message and description in the manual

parent c0e18a70
......@@ -1350,7 +1350,7 @@ one specific SPEC card if you have more than one:
@item -b <bus>
This option specifies the bus number
This option specifies the bus number. See @i{flash-read} for an example.
@item -d <devfn>
......@@ -1403,6 +1403,25 @@ The tools currently available are:
SPEC. The default base address for the peripheral is 0xe0500
but you can can change it passing @code{-u <address>}.
@item flash-read
Program to read (a part of) the flash memory on the SPEC. The argument
for the @code{-b} option can be found using @code{lspci} or @code{dmesg}
to search for the PCI bus on which the SPEC is present. It is the second
number in the address that is shown on insertion of the @code{spec.ko}
kernel module. For the SPEC from the @code{dmesg} line below
@code{-b 0x03} is found.
@code{[182.700162] spec 0000:03:00.0: got file "fmc/spec-init.bin",}
@code{ 1485236 (0x16a9b4) bytes}
@item flash-write
Program to write (a part of) the flash memory on the SPEC. See
@i{flash-read} for an example of how to find the address of the
@code{-b} option.
@end table
@c ##########################################################################
......
......@@ -214,11 +214,15 @@ static int spec_scan_pci(struct spec_pci_id *id, struct spec_device *arr,
return ndevs;
}
static int help(void)
static int help(int retv)
{
fprintf(stderr, "%s: Use: \"%s [-v] [-b <bus>] <addr> <len>\n",
prgname, prgname);
return 1;
fprintf(stderr, "\n <bus> = PCI bus number of SPEC card. (See lspci or dmesg)\n");
fprintf(stderr, " <offset> = syscon_offset\n");
fprintf(stderr, " <addr> = start address in flash to write\n");
fprintf(stderr, " <len> = amount of bytes to write\n");
return retv;
}
int main(int argc, char **argv)
......@@ -229,7 +233,7 @@ int main(int argc, char **argv)
syscon_offset = SPEC_SYSCON_OFFSET;
while ((c = getopt(argc, argv, "b:vc:")) != -1) {
while ((c = getopt(argc, argv, "hb:vc:")) != -1) {
switch(c) {
case 'b':
sscanf(optarg, "%i", &bus);
......@@ -240,12 +244,15 @@ int main(int argc, char **argv)
case 'c':
sscanf(optarg, "%i", &syscon_offset);
break;
case 'h':
exit(help(0));
break;
default:
exit(help());
exit(help(1));
}
}
if (optind != argc - 2)
exit(help());
exit(help(1));
/* find which one to use */
ndev = spec_scan_pci(spec_devices, devs, MAX_DEVICES);
......
......@@ -80,7 +80,7 @@ static int spec_write_flash(struct spec_device *spec, int addr, int len)
fprintf(stderr, "Reading from stdin, please type the data\n");
i = fread(buf, 1, len, stdin);
if (i != len) {
fprintf(stderr, "%s: read error (%i, expeted %i)\n", prgname,
fprintf(stderr, "%s: read error (%i, expected %i)\n", prgname,
i, len);
return 1;
}
......@@ -230,11 +230,15 @@ static int spec_scan_pci(struct spec_pci_id *id, struct spec_device *arr,
return ndevs;
}
static int help(void)
static int help(int retv)
{
fprintf(stderr, "%s: Use: \"%s [-v] [-b <bus>] <addr> <len>\n",
fprintf(stderr, "%s: Use: \"%s [-v] [-b <bus>] [-c <offset>] <addr> <len>\n",
prgname, prgname);
return 1;
fprintf(stderr, "\n <bus> = PCI bus number of SPEC card. (See lspci or dmesg)\n");
fprintf(stderr, " <offset> = syscon_offset\n");
fprintf(stderr, " <addr> = start address in flash to write\n");
fprintf(stderr, " <len> = amount of bytes to write\n");
return retv;
}
int main(int argc, char **argv)
......@@ -245,7 +249,7 @@ int main(int argc, char **argv)
syscon_offset = SPEC_SYSCON_OFFSET;
while ((c = getopt(argc, argv, "b:vc:")) != -1) {
while ((c = getopt(argc, argv, "hb:vc:")) != -1) {
switch(c) {
case 'b':
sscanf(optarg, "%i", &bus);
......@@ -256,12 +260,15 @@ int main(int argc, char **argv)
case 'c':
sscanf(optarg, "%i", &syscon_offset);
break;
case 'h':
exit(help(0));
break;
default:
exit(help());
exit(help(1));
}
}
if (optind != argc - 2)
exit(help());
exit(help(1));
/* find which one to use */
ndev = spec_scan_pci(spec_devices, devs, MAX_DEVICES);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment