Merge branch 'master-fixes' into stm-flash-fixes
[fw/altos] / ao-tools / ao-stmload / ao-stmload.c
index 35d4b2990d7946078299efd20663e8f455c41cec..dd25f07f8e0cb6f2d355a15a72c1e09931a1c92e 100644 (file)
 
 struct sym ao_symbols[] = {
 
-       { 0, 0x08002100,        "ao_romconfig_version", 1 },
+       { 0, AO_BOOT_APPLICATION_BASE + 0x100,  "ao_romconfig_version", 1 },
 #define AO_ROMCONFIG_VERSION   (ao_symbols[0].addr)
 
-       { 0, 0x08002102,        "ao_romconfig_check",   1 },
+       { 0, AO_BOOT_APPLICATION_BASE + 0x102,  "ao_romconfig_check",   1 },
 #define AO_ROMCONFIG_CHECK     (ao_symbols[1].addr)
 
-       { 0, 0x08002104,        "ao_serial_number", 1 },
+       { 0, AO_BOOT_APPLICATION_BASE + 0x104,  "ao_serial_number", 1 },
 #define AO_SERIAL_NUMBER       (ao_symbols[2].addr)
 
-       { 0, 0x08002108,        "ao_radio_cal", 0 },
+       { 0, AO_BOOT_APPLICATION_BASE + 0x108,  "ao_radio_cal", 0 },
 #define AO_RADIO_CAL           (ao_symbols[3].addr)
 
-       { 0, 0x0800210c,        "ao_usb_descriptors", 0 },
+       { 0, AO_BOOT_APPLICATION_BASE + 0x10c,  "ao_usb_descriptors", 0 },
 #define AO_USB_DESCRIPTORS     (ao_symbols[4].addr)
 };
 
@@ -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,11 +422,12 @@ main (int argc, char **argv)
                        fprintf(stderr, "Cannot switch to boot loader\n");
                        exit(1);
                }
+#if 0
                {
                        uint8_t check[256];
                        int     i = 0;
 
-                       ao_self_block_read(cc, 0x08002000, check);
+                       ao_self_block_read(cc, AO_BOOT_APPLICATION_BASE, check);
                        for (;;) {
                                uint8_t block[256];
                                putchar ('.');
@@ -425,14 +436,15 @@ main (int argc, char **argv)
                                        i = 0;
                                }
                                fflush(stdout);
-                               ao_self_block_write(cc, 0x08002000, block);
-                               ao_self_block_read(cc, 0x08002000, block);
+                               ao_self_block_write(cc, AO_BOOT_APPLICATION_BASE, block);
+                               ao_self_block_read(cc, AO_BOOT_APPLICATION_BASE, block);
                                if (memcmp(block, check, 256) != 0) {
                                        fprintf (stderr, "read differed\n");
                                        exit(1);
                                }
                        }
                }
+#endif
        }
 
        /* Go fetch existing config values