Introduced quiet mode option and command-line switch.
Based on a patch by Eric Decker <cire831@gmail.com>
This commit is contained in:
parent
764e5c04a9
commit
9c2ed8c5fc
4
bsl.c
4
bsl.c
|
@ -396,9 +396,9 @@ device_t bsl_open(const char *device)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
printc("Device ID: 0x%02x%02x\n",
|
||||
printc_dbg("Device ID: 0x%02x%02x\n",
|
||||
dev->reply_buf[4], dev->reply_buf[5]);
|
||||
printc("BSL version is %x.%02x\n", dev->reply_buf[14],
|
||||
printc_dbg("BSL version is %x.%02x\n", dev->reply_buf[14],
|
||||
dev->reply_buf[15]);
|
||||
|
||||
return (device_t)dev;
|
||||
|
|
4
devcmd.c
4
devcmd.c
|
@ -471,10 +471,12 @@ static int prog_flush(struct prog_data *prog)
|
|||
if (device_default->ctl(device_default,
|
||||
DEVICE_CTL_ERASE) < 0)
|
||||
return -1;
|
||||
|
||||
printc("Programming...\n");
|
||||
prog->have_erased = 1;
|
||||
}
|
||||
|
||||
printc("Writing %3d bytes to %04x...\n", wlen, prog->addr);
|
||||
printc_dbg("Writing %3d bytes to %04x...\n", wlen, prog->addr);
|
||||
if (device_default->writemem(device_default, prog->addr,
|
||||
prog->buf, wlen) < 0)
|
||||
return -1;
|
||||
|
|
20
fet.c
20
fet.c
|
@ -477,9 +477,9 @@ static int xfer(struct fet_device *dev,
|
|||
|
||||
static void show_dev_info(const char *name, const struct fet_device *dev)
|
||||
{
|
||||
printc("Device: %s\n", name);
|
||||
printc("Code memory starts at 0x%04x\n", dev->code_start);
|
||||
printc("Number of breakpoints: %d\n", dev->base.max_breakpoints);
|
||||
printc_dbg("Device: %s\n", name);
|
||||
printc_dbg("Code memory starts at 0x%04x\n", dev->code_start);
|
||||
printc_dbg("Number of breakpoints: %d\n", dev->base.max_breakpoints);
|
||||
}
|
||||
|
||||
static int identify_old(struct fet_device *dev)
|
||||
|
@ -519,7 +519,7 @@ static int identify_new(struct fet_device *dev, const char *force_id)
|
|||
return -1;
|
||||
}
|
||||
|
||||
printc("Device ID: 0x%02x%02x\n",
|
||||
printc_dbg("Device ID: 0x%02x%02x\n",
|
||||
dev->fet_reply.data[0], dev->fet_reply.data[1]);
|
||||
|
||||
if (force_id)
|
||||
|
@ -812,7 +812,7 @@ static int do_configure(struct fet_device *dev)
|
|||
if (dev->proto_flags & FET_PROTO_SPYBIWIRE) {
|
||||
if (!xfer(dev, C_CONFIGURE, NULL, 0,
|
||||
2, FET_CONFIG_PROTOCOL, 1)) {
|
||||
printc("Configured for Spy-Bi-Wire\n");
|
||||
printc_dbg("Configured for Spy-Bi-Wire\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -822,7 +822,7 @@ static int do_configure(struct fet_device *dev)
|
|||
|
||||
if (!xfer(dev, C_CONFIGURE, NULL, 0,
|
||||
2, FET_CONFIG_PROTOCOL, 2)) {
|
||||
printc("Configured for JTAG (2)\n");
|
||||
printc_dbg("Configured for JTAG (2)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -831,7 +831,7 @@ static int do_configure(struct fet_device *dev)
|
|||
|
||||
if (!xfer(dev, C_CONFIGURE, NULL, 0,
|
||||
2, FET_CONFIG_PROTOCOL, 0)) {
|
||||
printc("Configured for JTAG (0)\n");
|
||||
printc_dbg("Configured for JTAG (0)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -871,14 +871,14 @@ device_t fet_open(transport_t transport, int proto_flags, int vcc_mv,
|
|||
usleep(5000);
|
||||
}
|
||||
|
||||
printc("Initializing FET...\n");
|
||||
printc_dbg("Initializing FET...\n");
|
||||
if (xfer(dev, C_INITIALIZE, NULL, 0, 0) < 0) {
|
||||
printc_err("fet: open failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dev->version = dev->fet_reply.argv[0];
|
||||
printc("FET protocol version is %d\n", dev->version);
|
||||
printc_dbg("FET protocol version is %d\n", dev->version);
|
||||
|
||||
if (xfer(dev, 0x27, NULL, 0, 1, 4) < 0) {
|
||||
printc_err("fet: init failed\n");
|
||||
|
@ -892,7 +892,7 @@ device_t fet_open(transport_t transport, int proto_flags, int vcc_mv,
|
|||
if (xfer(dev, C_VCC, NULL, 0, 1, vcc_mv) < 0)
|
||||
printc_err("warning: fet: set VCC failed\n");
|
||||
else
|
||||
printc("Set Vcc: %d mV\n", vcc_mv);
|
||||
printc_dbg("Set Vcc: %d mV\n", vcc_mv);
|
||||
|
||||
/* Identify the chip */
|
||||
if (do_identify(dev, force_id) < 0) {
|
||||
|
|
40
main.c
40
main.c
|
@ -243,12 +243,24 @@ static const struct driver driver_table[] = {
|
|||
}
|
||||
};
|
||||
|
||||
static void version(void)
|
||||
{
|
||||
printc(
|
||||
"MSPDebug version 0.10 - debugging tool for MSP430 MCUs\n"
|
||||
"Copyright (C) 2009, 2010 Daniel Beer <daniel@tortek.co.nz>\n"
|
||||
"This is free software; see the source for copying conditions. There is NO\n"
|
||||
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR "
|
||||
"PURPOSE.\n");
|
||||
}
|
||||
|
||||
static void usage(const char *progname)
|
||||
{
|
||||
int i;
|
||||
|
||||
printc_err("Usage: %s [options] <driver> [command ...]\n"
|
||||
"\n"
|
||||
" -q\n"
|
||||
" Start in quiet mode.\n"
|
||||
" -d device\n"
|
||||
" Connect via the given tty device, rather than USB.\n"
|
||||
" -U bus:dev\n"
|
||||
|
@ -267,6 +279,8 @@ static void usage(const char *progname)
|
|||
" Override the device ID returned by the FET.\n"
|
||||
" --usb-list\n"
|
||||
" Show a list of available USB devices.\n"
|
||||
" --version\n"
|
||||
" Show copyright and version information.\n"
|
||||
"\n"
|
||||
"Most drivers connect by default via USB, unless told otherwise via the\n"
|
||||
"-d option. By default, the first USB device found is opened.\n"
|
||||
|
@ -339,12 +353,23 @@ static int parse_cmdline_args(int argc, char **argv,
|
|||
{"fet-list", 0, 0, 'L'},
|
||||
{"fet-force-id", 1, 0, 'F'},
|
||||
{"usb-list", 0, 0, 'I'},
|
||||
{"version", 0, 0, 'V'},
|
||||
{NULL, 0, 0, 0}
|
||||
};
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "d:jv:nU:",
|
||||
while ((opt = getopt_long(argc, argv, "d:jv:nU:q",
|
||||
longopts, NULL)) >= 0)
|
||||
switch (opt) {
|
||||
case 'q':
|
||||
{
|
||||
const static union opdb_value v = {
|
||||
.boolean = 1
|
||||
};
|
||||
|
||||
opdb_set("quiet", &v);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
usb_init();
|
||||
usb_find_busses();
|
||||
|
@ -371,6 +396,10 @@ static int parse_cmdline_args(int argc, char **argv,
|
|||
usage(argv[0]);
|
||||
exit(0);
|
||||
|
||||
case 'V':
|
||||
version();
|
||||
exit(0);
|
||||
|
||||
case 'v':
|
||||
args->vcc_mv = atoi(optarg);
|
||||
break;
|
||||
|
@ -438,19 +467,12 @@ int main(int argc, char **argv)
|
|||
struct cmdline_args args = {0};
|
||||
int ret = 0;
|
||||
|
||||
puts(
|
||||
"MSPDebug version 0.10 - debugging tool for MSP430 MCUs\n"
|
||||
"Copyright (C) 2009, 2010 Daniel Beer <daniel@tortek.co.nz>\n"
|
||||
"This is free software; see the source for copying conditions. There is NO\n"
|
||||
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR "
|
||||
"PURPOSE.\n");
|
||||
opdb_reset();
|
||||
|
||||
args.vcc_mv = 3000;
|
||||
if (parse_cmdline_args(argc, argv, &args) < 0)
|
||||
return -1;
|
||||
|
||||
opdb_reset();
|
||||
|
||||
if (setup_driver(&args) < 0)
|
||||
return -1;
|
||||
|
||||
|
|
10
mspdebug.man
10
mspdebug.man
|
@ -24,12 +24,14 @@ On startup, MSPDebug will look for a file called .mspdebug in the user's
|
|||
home directory. If it exists, commands will be read and executed from this
|
||||
file before executing any other commands or starting the interactive
|
||||
reader.
|
||||
.SH OPTIONS
|
||||
.SH COMMAND-LINE OPTIONS
|
||||
Command-line options accepted by MSPDebug are described below. If
|
||||
commands are specified on the end of the command-line, then they are
|
||||
executed after connecting to the device, and the interactive prompt is
|
||||
not started. See the section labelled \fBCOMMANDS\fR for more
|
||||
information.
|
||||
.IP "\-q"
|
||||
Start in quiet mode. See the "quiet" option described below.
|
||||
.IP "\-v \fIvoltage\fR"
|
||||
Set the programming voltage. The voltage should be specified as an integer
|
||||
in millivolts. It defaults to 3000 (3.0 V).
|
||||
|
@ -56,6 +58,8 @@ MSPDebug as one of the given type during initialization. This overrides
|
|||
the device ID returned by the FET.
|
||||
.IP "\-\-usb\-list"
|
||||
List available USB devices and exit.
|
||||
.IP "\-\-version"
|
||||
Show program version and copyright information.
|
||||
.SH DRIVERS
|
||||
A driver name must be specified on the command line for MSPDebug to
|
||||
connect to. Valid driver names are listed here.
|
||||
|
@ -373,6 +377,10 @@ If true, MSPDebug will colorize debugging output.
|
|||
Automatically restart the GDB server after disconnection. If this
|
||||
option is set, then the GDB server keeps running until an error occurs,
|
||||
or the user interrupts with Ctrl+C.
|
||||
.IP "\fBquiet\fR (boolean)"
|
||||
If set, MSPDebug will supress most of its debug-related output. This option
|
||||
defaults to false, but can be set true on start-up using the \fB-q\fR
|
||||
command-line option.
|
||||
.SH BUGS
|
||||
If you find any bugs, you should report them to the author at
|
||||
daniel@tortek.co.nz. It would help if you could include a transcript
|
||||
|
|
8
opdb.c
8
opdb.c
|
@ -39,6 +39,14 @@ const static struct opdb_key keys[] = {
|
|||
.defval = {
|
||||
.boolean = 0
|
||||
}
|
||||
},
|
||||
{
|
||||
.name = "quiet",
|
||||
.type = OPDB_TYPE_BOOLEAN,
|
||||
.help = "Supress debugging output\n",
|
||||
.defval = {
|
||||
.boolean = 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
15
output.c
15
output.c
|
@ -79,6 +79,21 @@ int printc(const char *fmt, ...)
|
|||
return write_text(&stdout_buf, buf, stdout);
|
||||
}
|
||||
|
||||
int printc_dbg(const char *fmt, ...)
|
||||
{
|
||||
char buf[1024];
|
||||
va_list ap;
|
||||
|
||||
if (opdb_get_boolean("quiet"))
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return write_text(&stdout_buf, buf, stdout);
|
||||
}
|
||||
|
||||
int printc_err(const char *fmt, ...)
|
||||
{
|
||||
char buf[1024];
|
||||
|
|
1
output.h
1
output.h
|
@ -26,6 +26,7 @@
|
|||
* codes).
|
||||
*/
|
||||
int printc(const char *fmt, ...);
|
||||
int printc_dbg(const char *fmt, ...);
|
||||
int printc_err(const char *fmt, ...);
|
||||
|
||||
void pr_error(const char *prefix);
|
||||
|
|
9
reader.c
9
reader.c
|
@ -34,6 +34,7 @@
|
|||
#include "cmddb.h"
|
||||
#include "stdcmd.h"
|
||||
#include "reader.h"
|
||||
#include "opdb.h"
|
||||
|
||||
static int modify_flags;
|
||||
static int in_reader_loop;
|
||||
|
@ -146,9 +147,11 @@ void reader_loop(void)
|
|||
|
||||
in_reader_loop = 1;
|
||||
|
||||
printc("\n");
|
||||
cmd_help(NULL);
|
||||
printc("\n");
|
||||
if (!opdb_get_boolean("quiet")) {
|
||||
printc("\n");
|
||||
cmd_help(NULL);
|
||||
printc("\n");
|
||||
}
|
||||
|
||||
do {
|
||||
for (;;) {
|
||||
|
|
Loading…
Reference in New Issue