summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-09-04 15:30:22 -0700
committerKeith Packard <keithp@keithp.com>2009-09-04 15:30:22 -0700
commit73adae3661160d410dcc802873b530d255c210e5 (patch)
tree2fdecad2b9b36f2d991a88afced068b2b8395780
parent332b056459b1352e233a8bf5f08498df12d32160 (diff)
Add --device/-D support to the command line tools and manuals
Use the new cc_usbdevs_find_by_arg function to locate suitable target devices connected via USB. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--ao-tools/ao-dbg/ao-dbg-main.c5
-rw-r--r--ao-tools/ao-dbg/ao-dbg-parse.c5
-rw-r--r--ao-tools/ao-dbg/ao-dbg.120
-rw-r--r--ao-tools/ao-dbg/ao-dbg.h2
-rw-r--r--ao-tools/ao-eeprom/ao-eeprom.126
-rw-r--r--ao-tools/ao-load/ao-load.126
-rw-r--r--ao-tools/ao-load/ao-load.c12
-rw-r--r--ao-tools/ao-rawload/ao-rawload.126
-rw-r--r--ao-tools/ao-rawload/ao-rawload.c11
9 files changed, 125 insertions, 8 deletions
diff --git a/ao-tools/ao-dbg/ao-dbg-main.c b/ao-tools/ao-dbg/ao-dbg-main.c
index f1e2c111..21b83a3d 100644
--- a/ao-tools/ao-dbg/ao-dbg-main.c
+++ b/ao-tools/ao-dbg/ao-dbg-main.c
@@ -34,6 +34,7 @@ struct ccdbg *s51_dbg;
int s51_interrupted = 0;
int s51_monitor = 0;
char *s51_tty = NULL;
+char *s51_device = NULL;
static FILE *s51_input;
static FILE *s51_output;
@@ -52,6 +53,7 @@ void s51_sigint()
static const struct option options[] = {
{ .name = "tty", .has_arg = 1, .val = 'T' },
+ { .name = "device", .has_arg = 1, .val = 'D' },
{ 0, 0, 0, 0 },
};
@@ -114,6 +116,9 @@ main(int argc, char **argv)
case 'T':
s51_tty = optarg;
break;
+ case 'D':
+ s51_device = optarg;
+ break;
}
}
if (s51_port) {
diff --git a/ao-tools/ao-dbg/ao-dbg-parse.c b/ao-tools/ao-dbg/ao-dbg-parse.c
index 825d0e9c..dcb9099d 100644
--- a/ao-tools/ao-dbg/ao-dbg-parse.c
+++ b/ao-tools/ao-dbg/ao-dbg-parse.c
@@ -195,6 +195,11 @@ command_read (void)
enum command_result result;
struct command_function *func;
+ if (!s51_tty) {
+ if (!s51_device)
+ s51_device = getenv("AO_DBG_DEVICE");
+ s51_tty = cc_usbdevs_find_by_arg(s51_device, "TIDongle");
+ }
s51_dbg = ccdbg_open (s51_tty);
if (!s51_dbg)
exit(1);
diff --git a/ao-tools/ao-dbg/ao-dbg.1 b/ao-tools/ao-dbg/ao-dbg.1
index a850c454..00d3ac86 100644
--- a/ao-tools/ao-dbg/ao-dbg.1
+++ b/ao-tools/ao-dbg/ao-dbg.1
@@ -35,6 +35,9 @@ ao-dbg \- hex debugger for cc1111 processors
[\-h]
[\-m]
[\-T \fItty-device\fP]
+[\--tty \fItty-device\fP]
+[\-D \fIaltos-device\fP]
+[\--device \fIaltos-device\fP]
.SH DESCRIPTION
.I ao-dbg
connects to a cc1111 processor through either a suitable cc1111 board
@@ -80,11 +83,26 @@ This should print a usage message, but does nothing useful currently.
.IP "\-m"
This option is not present in the original 8051 emulator, and causes ao-dbg to
dump all commands and replies that are received from and sent to sdcdb.
-.IP "\-T"
+.TP
+\-T tty-device | --tty tty-device
This selects which tty device the debugger uses to communicate with
the target device. The special name 'BITBANG' directs ao-dbg to use
the cp2103 connection, otherwise this should be a usb serial port
connected to a suitable cc1111 debug node.
+.TP
+\-D AltOS-device | --device AltOS-device
+Search for a connected device. This requires an argument of one of the
+following forms:
+.IP
+TeleMetrum:2
+.br
+TeleMetrum
+.br
+2
+.IP
+Leaving out the product name will cause the tool to select a suitable
+product, leaving out the serial number will cause the tool to match
+one of the available devices.
.SH COMMANDS
Once started, ao-dbg connects to the cc1111 and then reads and
executes commands, either from stdin, or the nework connection to
diff --git a/ao-tools/ao-dbg/ao-dbg.h b/ao-tools/ao-dbg/ao-dbg.h
index c1789d10..edc650a5 100644
--- a/ao-tools/ao-dbg/ao-dbg.h
+++ b/ao-tools/ao-dbg/ao-dbg.h
@@ -17,12 +17,14 @@
*/
#include <ccdbg.h>
+#include <cc.h>
extern char *s51_prompt;
extern struct ccdbg *s51_dbg;
extern int s51_interrupted;
extern int s51_monitor;
extern char *s51_tty;
+extern char *s51_device;
enum command_result {
command_success, command_debug, command_syntax, command_interrupt, command_error,
diff --git a/ao-tools/ao-eeprom/ao-eeprom.1 b/ao-tools/ao-eeprom/ao-eeprom.1
index 8caff9d1..ed498147 100644
--- a/ao-tools/ao-eeprom/ao-eeprom.1
+++ b/ao-tools/ao-eeprom/ao-eeprom.1
@@ -21,7 +21,31 @@
ao-eeprom \- Fetch eeprom contents from TeleMetrum device
.SH SYNOPSIS
.B "ao-eeprom"
-[\-tty \fItty-device\fP]
+[\-T \fItty-device\fP]
+[\--tty \fItty-device\fP]
+[\-D \fIaltos-device\fP]
+[\--device \fIaltos-device\fP]
+.SH OPTIONS
+.TP
+\-T tty-device | --tty tty-device
+This selects which tty device the debugger uses to communicate with
+the target device. The special name 'BITBANG' directs ao-dbg to use
+the cp2103 connection, otherwise this should be a usb serial port
+connected to a suitable cc1111 debug node.
+.TP
+\-D AltOS-device | --device AltOS-device
+Search for a connected device. This requires an argument of one of the
+following forms:
+.IP
+TeleMetrum:2
+.br
+TeleMetrum
+.br
+2
+.IP
+Leaving out the product name will cause the tool to select a suitable
+product, leaving out the serial number will cause the tool to match
+one of the available devices.
.SH DESCRIPTION
.I ao-eeprom
downloads the eeprom contents from a connected TeleMetrum device.
diff --git a/ao-tools/ao-load/ao-load.1 b/ao-tools/ao-load/ao-load.1
index 10484f3b..eb2bc0d8 100644
--- a/ao-tools/ao-load/ao-load.1
+++ b/ao-tools/ao-load/ao-load.1
@@ -21,13 +21,37 @@
ao-load \- flash a program to a AltOS device
.SH SYNOPSIS
.B "ao-load"
-[\-tty \fItty-device\fP]
+[\-T \fItty-device\fP]
+[\--tty \fItty-device\fP]
+[\-D \fIaltos-device\fP]
+[\--device \fIaltos-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 OPTIONS
+.TP
+\-T tty-device | --tty tty-device
+This selects which tty device the debugger uses to communicate with
+the target device. The special name 'BITBANG' directs ao-dbg to use
+the cp2103 connection, otherwise this should be a usb serial port
+connected to a suitable cc1111 debug node.
+.TP
+\-D AltOS-device | --device AltOS-device
+Search for a connected device. This requires an argument of one of the
+following forms:
+.IP
+TeleMetrum:2
+.br
+TeleMetrum
+.br
+2
+.IP
+Leaving out the product name will cause the tool to select a suitable
+product, leaving out the serial number will cause the tool to match
+one of the available devices.
.SH USAGE
.I ao-load
reads the specified .ihx file into memory, locates the matching .map
diff --git a/ao-tools/ao-load/ao-load.c b/ao-tools/ao-load/ao-load.c
index c27fcbe9..f5466612 100644
--- a/ao-tools/ao-load/ao-load.c
+++ b/ao-tools/ao-load/ao-load.c
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <getopt.h>
#include "ccdbg.h"
+#include "cc.h"
#define AO_USB_DESC_STRING 3
@@ -91,12 +92,13 @@ rewrite(struct hex_image *image, unsigned addr, char *data, int len)
static const struct option options[] = {
{ .name = "tty", .has_arg = 1, .val = 'T' },
+ { .name = "device", .has_arg = 1, .val = 'D' },
{ 0, 0, 0, 0},
};
static void usage(char *program)
{
- fprintf(stderr, "usage: %s [--tty <tty-name>] file.ihx serial-number\n", program);
+ fprintf(stderr, "usage: %s [--tty <tty-name>] [--device <device-name>] file.ihx serial-number\n", program);
exit(1);
}
@@ -122,13 +124,17 @@ main (int argc, char **argv)
unsigned usb_descriptors;
int string_num;
char *tty = NULL;
+ char *device = NULL;
int c;
- while ((c = getopt_long(argc, argv, "T:", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "T:D:", options, NULL)) != -1) {
switch (c) {
case 'T':
tty = optarg;
break;
+ case 'D':
+ device = optarg;
+ break;
default:
usage(argv[0]);
break;
@@ -219,6 +225,8 @@ main (int argc, char **argv)
if (!rewrite(image, usb_descriptors + 2 + image->address, serial_ucs2, serial_ucs2_len))
usage(argv[0]);
+ if (!tty)
+ tty = cc_usbdevs_find_by_arg(device, "TIDongle");
dbg = ccdbg_open(tty);
if (!dbg)
exit (1);
diff --git a/ao-tools/ao-rawload/ao-rawload.1 b/ao-tools/ao-rawload/ao-rawload.1
index e79645f1..6b6a6e2c 100644
--- a/ao-tools/ao-rawload/ao-rawload.1
+++ b/ao-tools/ao-rawload/ao-rawload.1
@@ -21,12 +21,36 @@
ao-rawload \- flash a program to a AltOS device
.SH SYNOPSIS
.B "ao-rawload"
-[\-tty \fItty-device\fP]
+[\-T \fItty-device\fP]
+[\--tty \fItty-device\fP]
+[\-D \fIaltos-device\fP]
+[\--device \fIaltos-device\fP]
\fIfile.ihx\fP
.SH DESCRIPTION
.I ao-rawload
loads the specified .ihx file, without modification, into the target
device flash memory.
+.SH OPTIONS
+.TP
+\-T tty-device | --tty tty-device
+This selects which tty device the debugger uses to communicate with
+the target device. The special name 'BITBANG' directs ao-dbg to use
+the cp2103 connection, otherwise this should be a usb serial port
+connected to a suitable cc1111 debug node.
+.TP
+\-D AltOS-device | --device AltOS-device
+Search for a connected device. This requires an argument of one of the
+following forms:
+.IP
+TeleMetrum:2
+.br
+TeleMetrum
+.br
+2
+.IP
+Leaving out the product name will cause the tool to select a suitable
+product, leaving out the serial number will cause the tool to match
+one of the available devices.
.SH USAGE
.I ao-rawload
reads the specified .ihx file into memory. It then connects to the
diff --git a/ao-tools/ao-rawload/ao-rawload.c b/ao-tools/ao-rawload/ao-rawload.c
index 1f1537b9..255f63ec 100644
--- a/ao-tools/ao-rawload/ao-rawload.c
+++ b/ao-tools/ao-rawload/ao-rawload.c
@@ -22,12 +22,13 @@
static const struct option options[] = {
{ .name = "tty", .has_arg = 1, .val = 'T' },
+ { .name = "device", .has_arg = 1, .val = 'D' },
{ 0, 0, 0, 0},
};
static void usage(char *program)
{
- fprintf(stderr, "usage: %s [--tty <tty-name>] file.ihx\n", program);
+ fprintf(stderr, "usage: %s [--tty <tty-name>] [--device <device-name>] file.ihx\n", program);
exit(1);
}
@@ -42,13 +43,17 @@ main (int argc, char **argv)
char *filename;
FILE *file;
char *tty = NULL;
+ char *device = NULL;
int c;
- while ((c = getopt_long(argc, argv, "T:", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "T:D:", options, NULL)) != -1) {
switch (c) {
case 'T':
tty = optarg;
break;
+ case 'D':
+ device = optarg;
+ break;
default:
usage(argv[0]);
break;
@@ -75,6 +80,8 @@ main (int argc, char **argv)
}
ccdbg_hex_file_free(hex);
+ if (!tty)
+ tty = cc_usbdevs_find_by_arg(device, "TIDongle");
dbg = ccdbg_open(tty);
if (!dbg)
exit (1);