summaryrefslogtreecommitdiff
path: root/ao-tools
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-04-27 00:26:11 -0700
committerKeith Packard <keithp@keithp.com>2013-05-07 21:30:26 -0700
commit1695f6af46ea647119d651fc09c97d604d08c736 (patch)
treedae9c78e46ed05332c51833df9a403a93bc7077c /ao-tools
parentf6d6df03826083a244715b88a30ad681f17b4510 (diff)
ao-tools/ao-stmload: Add --verbose flag
This dumps out the serial communication so you can see where things go wrong. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao-tools')
-rw-r--r--ao-tools/ao-stmload/ao-selfload.c25
-rw-r--r--ao-tools/ao-stmload/ao-stmload.c16
-rw-r--r--ao-tools/ao-stmload/ao-stmload.h2
-rw-r--r--ao-tools/lib/cc-usb.c8
4 files changed, 38 insertions, 13 deletions
diff --git a/ao-tools/ao-stmload/ao-selfload.c b/ao-tools/ao-stmload/ao-selfload.c
index b3105b21..95667dca 100644
--- a/ao-tools/ao-stmload/ao-selfload.c
+++ b/ao-tools/ao-stmload/ao-selfload.c
@@ -26,18 +26,24 @@
#include "ccdbg.h"
#include "ao-stmload.h"
+int ao_self_verbose;
+
+#define TRACE(...) if (ao_self_verbose) printf (__VA_ARGS__)
+
void
ao_self_block_read(struct cc_usb *cc, uint32_t address, uint8_t block[256])
{
int byte;
cc_usb_sync(cc);
cc_usb_printf(cc, "R %x\n", address);
-// printf ("read %08x\n", address);
for (byte = 0; byte < 0x100; byte++) {
block[byte] = cc_usb_getchar(cc);
-// printf (" %02x", block[byte]);
-// if ((byte & 0xf) == 0xf)
-// printf ("\n");
+ }
+ TRACE ("\nread %08x\n", address);
+ for (byte = 0; byte < 0x100; byte++) {
+ TRACE (" %02x", block[byte]);
+ if ((byte & 0xf) == 0xf)
+ TRACE ("\n");
}
}
@@ -47,12 +53,14 @@ ao_self_block_write(struct cc_usb *cc, uint32_t address, uint8_t block[256])
int byte;
cc_usb_sync(cc);
cc_usb_printf(cc, "W %x\n", address);
-// printf ("write %08x\n", address);
+ TRACE ("write %08x\n", address);
+ for (byte = 0; byte < 0x100; byte++) {
+ TRACE (" %02x", block[byte]);
+ if ((byte & 0xf) == 0xf)
+ TRACE ("\n");
+ }
for (byte = 0; byte < 0x100; byte++) {
cc_usb_printf(cc, "%c", block[byte]);
-// printf (" %02x", block[byte]);
-// if ((byte & 0xf) == 0xf)
-// printf ("\n");
}
}
@@ -114,5 +122,6 @@ ao_self_write(struct cc_usb *cc, struct hex_image *image)
putchar('.'); fflush(stdout);
}
printf("done\n");
+ cc_usb_printf(cc,"a\n");
return 1;
}
diff --git a/ao-tools/ao-stmload/ao-stmload.c b/ao-tools/ao-stmload/ao-stmload.c
index 130f8707..dd25f07f 100644
--- a/ao-tools/ao-stmload/ao-stmload.c
+++ b/ao-tools/ao-stmload/ao-stmload.c
@@ -224,12 +224,13 @@ static const struct option options[] = {
{ .name = "device", .has_arg = 1, .val = 'D' },
{ .name = "cal", .has_arg = 1, .val = 'c' },
{ .name = "serial", .has_arg = 1, .val = 's' },
+ { .name = "verbose", .has_arg = 0, .val = 'v' },
{ 0, 0, 0, 0},
};
static void usage(char *program)
{
- fprintf(stderr, "usage: %s [--stlink] [--device=<device>] [-tty=<tty>] [--cal=<radio-cal>] [--serial=<serial>] file.{elf,ihx}\n", program);
+ fprintf(stderr, "usage: %s [--stlink] [--verbose] [--device=<device>] [-tty=<tty>] [--cal=<radio-cal>] [--serial=<serial>] file.{elf,ihx}\n", program);
exit(1);
}
@@ -286,8 +287,9 @@ main (int argc, char **argv)
int use_stlink = 0;
char *tty = NULL;
int success;
+ int verbose = 0;
- while ((c = getopt_long(argc, argv, "T:D:c:s:S", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "T:D:c:s:Sv", options, NULL)) != -1) {
switch (c) {
case 'T':
tty = optarg;
@@ -308,12 +310,20 @@ main (int argc, char **argv)
case 'S':
use_stlink = 1;
break;
+ case 'v':
+ verbose++;
+ break;
default:
usage(argv[0]);
break;
}
}
+ ao_self_verbose = verbose;
+
+ if (verbose > 1)
+ ccdbg_add_debug(CC_DEBUG_BITBANG);
+
filename = argv[optind];
if (filename == NULL)
usage(argv[0]);
@@ -412,6 +422,7 @@ main (int argc, char **argv)
fprintf(stderr, "Cannot switch to boot loader\n");
exit(1);
}
+#if 0
{
uint8_t check[256];
int i = 0;
@@ -433,6 +444,7 @@ main (int argc, char **argv)
}
}
}
+#endif
}
/* Go fetch existing config values
diff --git a/ao-tools/ao-stmload/ao-stmload.h b/ao-tools/ao-stmload/ao-stmload.h
index 754c1c5b..98884535 100644
--- a/ao-tools/ao-stmload/ao-stmload.h
+++ b/ao-tools/ao-stmload/ao-stmload.h
@@ -44,4 +44,6 @@ ao_self_read(struct cc_usb *cc, uint32_t address, uint32_t length);
int
ao_self_write(struct cc_usb *cc, struct hex_image *image);
+extern int ao_self_verbose;
+
#endif /* _AO_STMLOAD_H_ */
diff --git a/ao-tools/lib/cc-usb.c b/ao-tools/lib/cc-usb.c
index 485583f9..d7ac138c 100644
--- a/ao-tools/lib/cc-usb.c
+++ b/ao-tools/lib/cc-usb.c
@@ -123,9 +123,10 @@ cc_handle_hex_read(struct cc_usb *cc)
static void
cc_usb_dbg(int indent, uint8_t *bytes, int len)
{
- int eol = 1;
+ static int eol = 1;
int i;
uint8_t c;
+ ccdbg_debug(CC_DEBUG_BITBANG, "<<<%d bytes>>>", len);
while (len--) {
c = *bytes++;
if (eol) {
@@ -135,10 +136,12 @@ cc_usb_dbg(int indent, uint8_t *bytes, int len)
}
switch (c) {
case '\r':
- ccdbg_debug(CC_DEBUG_BITBANG, "^M");
+ ccdbg_debug(CC_DEBUG_BITBANG, "\\r");
break;
case '\n':
eol = 1;
+ ccdbg_debug(CC_DEBUG_BITBANG, "\\n\n");
+ break;
default:
if (c < ' ' || c > '~')
ccdbg_debug(CC_DEBUG_BITBANG, "\\%02x", c);
@@ -193,7 +196,6 @@ _cc_usb_sync(struct cc_usb *cc, int wait_for_input)
ret = read(cc->fd, cc->in_buf + cc->in_count,
CC_IN_BUF - cc->in_count);
if (ret > 0) {
- int i;
cc_usb_dbg(24, cc->in_buf + cc->in_count, ret);
cc->in_count += ret;
if (cc->hex_count)