This dumps out the serial communication so you can see where things go wrong.
Signed-off-by: Keith Packard <keithp@keithp.com>
#include "ccdbg.h"
#include "ao-stmload.h"
#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);
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);
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");
int byte;
cc_usb_sync(cc);
cc_usb_printf(cc, "W %x\n", address);
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]);
for (byte = 0; byte < 0x100; byte++) {
cc_usb_printf(cc, "%c", block[byte]);
-// printf (" %02x", block[byte]);
-// if ((byte & 0xf) == 0xf)
-// printf ("\n");
putchar('.'); fflush(stdout);
}
printf("done\n");
putchar('.'); fflush(stdout);
}
printf("done\n");
+ cc_usb_printf(cc,"a\n");
{ .name = "device", .has_arg = 1, .val = 'D' },
{ .name = "cal", .has_arg = 1, .val = 'c' },
{ .name = "serial", .has_arg = 1, .val = 's' },
{ .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)
{
{ 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);
int use_stlink = 0;
char *tty = NULL;
int success;
int use_stlink = 0;
char *tty = NULL;
int success;
- 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;
switch (c) {
case 'T':
tty = optarg;
case 'S':
use_stlink = 1;
break;
case 'S':
use_stlink = 1;
break;
+ case 'v':
+ verbose++;
+ break;
default:
usage(argv[0]);
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]);
filename = argv[optind];
if (filename == NULL)
usage(argv[0]);
fprintf(stderr, "Cannot switch to boot loader\n");
exit(1);
}
fprintf(stderr, "Cannot switch to boot loader\n");
exit(1);
}
{
uint8_t check[256];
int i = 0;
{
uint8_t check[256];
int i = 0;
}
/* Go fetch existing config values
}
/* Go fetch existing config values
int
ao_self_write(struct cc_usb *cc, struct hex_image *image);
int
ao_self_write(struct cc_usb *cc, struct hex_image *image);
+extern int ao_self_verbose;
+
#endif /* _AO_STMLOAD_H_ */
#endif /* _AO_STMLOAD_H_ */
static void
cc_usb_dbg(int indent, uint8_t *bytes, int len)
{
static void
cc_usb_dbg(int indent, uint8_t *bytes, int len)
{
+ ccdbg_debug(CC_DEBUG_BITBANG, "<<<%d bytes>>>", len);
while (len--) {
c = *bytes++;
if (eol) {
while (len--) {
c = *bytes++;
if (eol) {
}
switch (c) {
case '\r':
}
switch (c) {
case '\r':
- ccdbg_debug(CC_DEBUG_BITBANG, "^M");
+ ccdbg_debug(CC_DEBUG_BITBANG, "\\r");
break;
case '\n':
eol = 1;
break;
case '\n':
eol = 1;
+ ccdbg_debug(CC_DEBUG_BITBANG, "\\n\n");
+ break;
default:
if (c < ' ' || c > '~')
ccdbg_debug(CC_DEBUG_BITBANG, "\\%02x", c);
default:
if (c < ' ' || c > '~')
ccdbg_debug(CC_DEBUG_BITBANG, "\\%02x", c);
ret = read(cc->fd, cc->in_buf + cc->in_count,
CC_IN_BUF - cc->in_count);
if (ret > 0) {
ret = read(cc->fd, cc->in_buf + cc->in_count,
CC_IN_BUF - cc->in_count);
if (ret > 0) {
cc_usb_dbg(24, cc->in_buf + cc->in_count, ret);
cc->in_count += ret;
if (cc->hex_count)
cc_usb_dbg(24, cc->in_buf + cc->in_count, ret);
cc->in_count += ret;
if (cc->hex_count)