diff options
author | Bdale Garbee <bdale@gag.com> | 2009-08-18 18:09:38 -0600 |
---|---|---|
committer | Bdale Garbee <bdale@gag.com> | 2009-08-18 18:09:38 -0600 |
commit | 4685fc541466afbeefc151bcb64cd054739c048b (patch) | |
tree | d7e0f521bd51897a59dd9c355d74218132da4b75 /ao-tools/ao-load | |
parent | 1c2a0b6653623b689d68d7349a6b2dce3e20a4a6 (diff) | |
parent | c29275b72438637d46d7a50742882d2736eb176a (diff) |
Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
Conflicts:
ao-tools/ao-bitbang/Makefile.am
ao-tools/ao-eeprom/Makefile.am
ao-tools/ao-load/Makefile.am
ao-tools/ao-load/ao-load.c
ao-tools/ao-rawload/Makefile.am
Diffstat (limited to 'ao-tools/ao-load')
-rw-r--r-- | ao-tools/ao-load/Makefile.am | 2 | ||||
-rw-r--r-- | ao-tools/ao-load/ao-load.1 | 38 | ||||
-rw-r--r-- | ao-tools/ao-load/ao-load.c | 55 |
3 files changed, 77 insertions, 18 deletions
diff --git a/ao-tools/ao-load/Makefile.am b/ao-tools/ao-load/Makefile.am index 8a8392af..3c48dc27 100644 --- a/ao-tools/ao-load/Makefile.am +++ b/ao-tools/ao-load/Makefile.am @@ -8,3 +8,5 @@ ao_load_DEPENDENCIES = $(AO_LOAD_LIBS) ao_load_LDADD=$(AO_LOAD_LIBS) $(LIBUSB_LIBS) ao_load_SOURCES = ao-load.c + +man_MANS = ao-load.1 diff --git a/ao-tools/ao-load/ao-load.1 b/ao-tools/ao-load/ao-load.1 new file mode 100644 index 00000000..10484f3b --- /dev/null +++ b/ao-tools/ao-load/ao-load.1 @@ -0,0 +1,38 @@ +.\" +.\" Copyright © 2009 Keith Packard <keithp@keithp.com> +.\" +.\" This program is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, but +.\" WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +.\" General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License along +.\" with this program; if not, write to the Free Software Foundation, Inc., +.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +.\" +.\" +.TH AO-LOAD 1 "ao-load" "" +.SH NAME +ao-load \- flash a program to a AltOS device +.SH SYNOPSIS +.B "ao-load" +[\-tty \fItty-device\fP] +\fIfile.ihx\fP +\fIdevice serial number\fP +.SH DESCRIPTION +.I ao-load +loads the specified .ihx file into the target device flash memory, +customizing the AltOS image with the specified serial number. +.SH USAGE +.I ao-load +reads the specified .ihx file into memory, locates the matching .map +file and edits the image to customize it using the specified serial +number. It then connects to the specified target device and writes the +program to the target device flash memory. +.SH AUTHOR +Keith Packard diff --git a/ao-tools/ao-load/ao-load.c b/ao-tools/ao-load/ao-load.c index 6966dd3a..642af2fe 100644 --- a/ao-tools/ao-load/ao-load.c +++ b/ao-tools/ao-load/ao-load.c @@ -25,13 +25,6 @@ #define AO_USB_DESC_STRING 3 -void -usage(char *program) -{ - fprintf(stderr, "usage: %s <filename.ihx> <serial>\n", program); - exit(1); -} - struct sym { unsigned addr; char *name; @@ -96,7 +89,21 @@ rewrite(struct hex_image *image, unsigned addr, char *data, int len) memcpy(image->data + addr - image->address, data, len); } +<<<<<<< HEAD:ao-tools/ao-load/ao-load.c static const struct option +======= +static const struct option options[] = { + { .name = "tty", .has_arg = 1, .val = 'T' }, + { 0, 0, 0, 0}, +}; + +static void usage(char *program) +{ + fprintf(stderr, "usage: %s [--tty <tty-name>] file.ihx serial-number\n", program); + exit(1); +} + +>>>>>>> c29275b72438637d46d7a50742882d2736eb176a:ao-tools/ao-load/ao-load.c int main (int argc, char **argv) { @@ -105,12 +112,12 @@ main (int argc, char **argv) uint16_t pc; struct hex_file *hex; struct hex_image *image; - char *filename; - FILE *file; - FILE *map; - char *serial_string; - unsigned int serial; - char *mapname, *dot; + char *filename; + FILE *file; + FILE *map; + char *serial_string; + unsigned int serial; + char *mapname, *dot; char *serial_ucs2; int serial_ucs2_len; char serial_int[2]; @@ -118,8 +125,20 @@ main (int argc, char **argv) int i; unsigned usb_descriptors; int string_num; - - filename = argv[1]; + char *tty = NULL; + int c; + + while ((c = getopt_long(argc, argv, "T:", options, NULL)) != -1) { + switch (c) { + case 'T': + tty = optarg; + break; + default: + usage(argv[0]); + break; + } + } + filename = argv[optind]; if (filename == NULL) usage(argv[0]); mapname = strdup(filename); @@ -128,7 +147,7 @@ main (int argc, char **argv) usage(argv[0]); strcpy(dot, ".map"); - serial_string = argv[2]; + serial_string = argv[optind + 1]; if (serial_string == NULL) usage(argv[0]); @@ -163,7 +182,7 @@ main (int argc, char **argv) serial = strtoul(serial_string, NULL, 0); if (!serial) - usage(argv[0]); +(argv[0]); serial_int[0] = serial & 0xff; serial_int[1] = (serial >> 8) & 0xff; @@ -204,7 +223,7 @@ main (int argc, char **argv) if (!rewrite(image, usb_descriptors + 2 + image->address, serial_ucs2, serial_ucs2_len)) usage(argv[0]); - dbg = ccdbg_open(); + dbg = ccdbg_open(tty); if (!dbg) exit (1); |