diff options
Diffstat (limited to 'ao-tools')
73 files changed, 439 insertions, 121 deletions
diff --git a/ao-tools/ao-cal-accel/ao-cal-accel.c b/ao-tools/ao-cal-accel/ao-cal-accel.c index 9a988648..8a9e6347 100644 --- a/ao-tools/ao-cal-accel/ao-cal-accel.c +++ b/ao-tools/ao-cal-accel/ao-cal-accel.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-cal-freq/ao-cal-freq.c b/ao-tools/ao-cal-freq/ao-cal-freq.c index 464faf0f..12c2a3ae 100644 --- a/ao-tools/ao-cal-freq/ao-cal-freq.c +++ b/ao-tools/ao-cal-freq/ao-cal-freq.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -38,13 +39,13 @@ static const struct option options[] = { { .name = "tty", .has_arg = 1, .val = 'T' }, { .name = "device", .has_arg = 1, .val = 'D' }, { .name = "raw", .has_arg = 0, .val = 'r' }, - { .name = "verbose", .has_arg = 1, .val = 'v' }, + { .name = "verbose", .has_arg = 0, .val = 'v' }, { 0, 0, 0, 0}, }; static void usage(char *program) { - fprintf(stderr, "usage: %s [--verbose=<verbose>] [--device=<device>] [-tty=<tty>]\n", program); + fprintf(stderr, "usage: %s [--verbose] [--device=<device>] [-tty=<tty>]\n", program); exit(1); } @@ -167,7 +168,8 @@ await_key(void) } int -do_cal(struct cc_usb *usb) { +do_cal(char *tty) { + struct cc_usb *usb = NULL; struct flash *b; char line[1024]; double measured_freq; @@ -177,10 +179,17 @@ do_cal(struct cc_usb *usb) { int cur_freq; int cur_cal; int new_cal; - - cc_usb_printf(usb, "E 0\n"); + int ret = 1; for(;;) { + usb = cc_usb_open(tty); + + if (!usb) + exit(1); + + cc_usb_printf(usb, "E 0\n"); + + cc_usb_sync(usb); cc_usb_printf(usb, "C 1\n"); cc_usb_sync(usb); @@ -201,7 +210,8 @@ do_cal(struct cc_usb *usb) { if (!cur_cal_words || !cur_freq_words) { printf("no response\n"); - return 0; + ret = 0; + break; } cur_cal = atoi(cur_cal_words[2]); @@ -217,8 +227,11 @@ do_cal(struct cc_usb *usb) { cc_usb_printf (usb, "c f %d\nc w\n", new_cal); cc_usb_sync(usb); + cc_usb_close(usb); } - return 1; + if (usb) + cc_usb_close(usb); + return ret; } int @@ -231,14 +244,13 @@ main (int argc, char **argv) int i; int c; int tries; - struct cc_usb *cc = NULL; char *tty = NULL; int success; int verbose = 0; int ret = 0; int expected_size; - while ((c = getopt_long(argc, argv, "rT:D:c:s:v:", options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "vrT:D:c:s:", options, NULL)) != -1) { switch (c) { case 'T': tty = optarg; @@ -269,12 +281,6 @@ main (int argc, char **argv) if (!tty) tty="/dev/ttyACM0"; - cc = cc_usb_open(tty); - - if (!cc) - exit(1); - - if (!do_cal(cc)) + if (!do_cal(tty)) ret = 1; - done(cc, ret); } diff --git a/ao-tools/ao-chaosread/ao-chaosread.c b/ao-tools/ao-chaosread/ao-chaosread.c index 806c2ef9..7808f6c9 100644 --- a/ao-tools/ao-chaosread/ao-chaosread.c +++ b/ao-tools/ao-chaosread/ao-chaosread.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -90,7 +91,6 @@ chaoskey_match(libusb_device *dev, char *match_serial) return handle; out: - free(device_serial); if (handle) libusb_close(handle); return 0; @@ -182,15 +182,16 @@ chaoskey_transfer_callback(struct libusb_transfer *transfer) #define ENDPOINT 0x86 int -chaoskey_read(struct chaoskey *ck, uint8_t *buffer, int len) +chaoskey_read(struct chaoskey *ck, void *buffer, int len) { + uint8_t *buf = buffer; int total = 0; while (len) { int ret; int transferred; - ret = libusb_bulk_transfer(ck->handle, ENDPOINT, buffer, len, &transferred, 10000); + ret = libusb_bulk_transfer(ck->handle, ENDPOINT, buf, len, &transferred, 10000); if (ret) { if (total) return total; @@ -200,19 +201,21 @@ chaoskey_read(struct chaoskey *ck, uint8_t *buffer, int len) } } len -= transferred; - buffer += transferred; + buf += transferred; } } static const struct option options[] = { { .name = "serial", .has_arg = 1, .val = 's' }, { .name = "length", .has_arg = 1, .val = 'l' }, + { .name = "infinite", .has_arg = 0, .val = 'i' }, + { .name = "bytes", .has_arg = 0, .val = 'b' }, { 0, 0, 0, 0}, }; static void usage(char *program) { - fprintf(stderr, "usage: %s [--serial=<serial>] [--length=<length>[kMG]]\n", program); + fprintf(stderr, "usage: %s [--serial=<serial>] [--length=<length>[kMG]] [--infinite] [--bytes]\n", program); exit(1); } @@ -220,16 +223,18 @@ int main (int argc, char **argv) { struct chaoskey *ck; - char buf[1024]; + uint16_t buf[512]; int got; int c; char *serial = NULL; char *length_string; char *length_end; unsigned long length = sizeof(buf); - int this_time; + int this_time; + int infinite = 0; + int bytes = 0; - while ((c = getopt_long(argc, argv, "s:l:", options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "s:l:ib", options, NULL)) != -1) { switch (c) { case 's': serial = optarg; @@ -246,6 +251,12 @@ main (int argc, char **argv) else if (strlen(length_end)) usage(argv[0]); break; + case 'i': + infinite = 1; + break; + case 'b': + bytes = 1; + break; default: usage(argv[0]); break; @@ -256,16 +267,24 @@ main (int argc, char **argv) if (!ck) exit(1); - while (length) { + if (bytes) + length *= 2; + + while (length || infinite) { this_time = sizeof(buf); - if (length < sizeof(buf)) + if (!infinite && length < sizeof(buf)) this_time = (int) length; got = chaoskey_read(ck, buf, this_time); if (got < 0) { perror("read"); exit(1); } - write(1, buf, got); + if (bytes) { + int i; + for (i = 0; i < got / 2; i++) + putchar((buf[i] >> 1 & 0xff)); + } else + write(1, buf, got); length -= got; } exit(0); diff --git a/ao-tools/ao-edit-telem/ao-edit-telem.c b/ao-tools/ao-edit-telem/ao-edit-telem.c index 3f6830e7..e2795ede 100644 --- a/ao-tools/ao-edit-telem/ao-edit-telem.c +++ b/ao-tools/ao-edit-telem/ao-edit-telem.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-elftohex/ao-elftohex.c b/ao-tools/ao-elftohex/ao-elftohex.c index db8f86f1..265908c5 100644 --- a/ao-tools/ao-elftohex/ao-elftohex.c +++ b/ao-tools/ao-elftohex/ao-elftohex.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-list/ao-list.c b/ao-tools/ao-list/ao-list.c index 4c065e79..0a970070 100644 --- a/ao-tools/ao-list/ao-list.c +++ b/ao-tools/ao-list/ao-list.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-makebin/ao-makebin.c b/ao-tools/ao-makebin/ao-makebin.c index 31ce1889..e33f2d1a 100644 --- a/ao-tools/ao-makebin/ao-makebin.c +++ b/ao-tools/ao-makebin/ao-makebin.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-mega/ao-mega.c b/ao-tools/ao-mega/ao-mega.c index cfb58bb4..9a12609b 100644 --- a/ao-tools/ao-mega/ao-mega.c +++ b/ao-tools/ao-mega/ao-mega.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-send-telem/ao-send-telem.c b/ao-tools/ao-send-telem/ao-send-telem.c index ef6f892c..a4fc85b7 100644 --- a/ao-tools/ao-send-telem/ao-send-telem.c +++ b/ao-tools/ao-send-telem/ao-send-telem.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-sky-flash/sky_bin.c b/ao-tools/ao-sky-flash/sky_bin.c index 04cfec35..d728d0c2 100644 --- a/ao-tools/ao-sky-flash/sky_bin.c +++ b/ao-tools/ao-sky-flash/sky_bin.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-sky-flash/sky_debug.c b/ao-tools/ao-sky-flash/sky_debug.c index 32571f0e..40151939 100644 --- a/ao-tools/ao-sky-flash/sky_debug.c +++ b/ao-tools/ao-sky-flash/sky_debug.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-sky-flash/sky_flash.c b/ao-tools/ao-sky-flash/sky_flash.c index 55cb2cb6..7dbb6954 100644 --- a/ao-tools/ao-sky-flash/sky_flash.c +++ b/ao-tools/ao-sky-flash/sky_flash.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-sky-flash/sky_flash.h b/ao-tools/ao-sky-flash/sky_flash.h index 77f4c742..6dcbbf72 100644 --- a/ao-tools/ao-sky-flash/sky_flash.h +++ b/ao-tools/ao-sky-flash/sky_flash.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-sky-flash/sky_serial.c b/ao-tools/ao-sky-flash/sky_serial.c index 7230bf8c..94b0b156 100644 --- a/ao-tools/ao-sky-flash/sky_serial.c +++ b/ao-tools/ao-sky-flash/sky_serial.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-sky-flash/sky_srec.c b/ao-tools/ao-sky-flash/sky_srec.c index 6d00f58c..7acdc55c 100644 --- a/ao-tools/ao-sky-flash/sky_srec.c +++ b/ao-tools/ao-sky-flash/sky_srec.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-stmload/ao-stmload.c b/ao-tools/ao-stmload/ao-stmload.c index 4210a111..18fa94ff 100644 --- a/ao-tools/ao-stmload/ao-stmload.c +++ b/ao-tools/ao-stmload/ao-stmload.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-stmload/ao-stmload.h b/ao-tools/ao-stmload/ao-stmload.h index 1ba9a977..bd59d66d 100644 --- a/ao-tools/ao-stmload/ao-stmload.h +++ b/ao-tools/ao-stmload/ao-stmload.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-telem/ao-telem.c b/ao-tools/ao-telem/ao-telem.c index 05a69542..aa54a1b9 100644 --- a/ao-tools/ao-telem/ao-telem.c +++ b/ao-tools/ao-telem/ao-telem.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-test-baro/ao-test-baro.c b/ao-tools/ao-test-baro/ao-test-baro.c index b3058b80..d2b81e4f 100644 --- a/ao-tools/ao-test-baro/ao-test-baro.c +++ b/ao-tools/ao-test-baro/ao-test-baro.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-test-flash/ao-test-flash.c b/ao-tools/ao-test-flash/ao-test-flash.c index cf44ae69..5cbc56d7 100644 --- a/ao-tools/ao-test-flash/ao-test-flash.c +++ b/ao-tools/ao-test-flash/ao-test-flash.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-test-gps/ao-test-gps.c b/ao-tools/ao-test-gps/ao-test-gps.c index 84ed713d..5012028c 100644 --- a/ao-tools/ao-test-gps/ao-test-gps.c +++ b/ao-tools/ao-test-gps/ao-test-gps.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-test-igniter/ao-test-igniter.c b/ao-tools/ao-test-igniter/ao-test-igniter.c index 419c8948..c426e1bd 100644 --- a/ao-tools/ao-test-igniter/ao-test-igniter.c +++ b/ao-tools/ao-test-igniter/ao-test-igniter.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-usbload/ao-usbload.c b/ao-tools/ao-usbload/ao-usbload.c index 1b217e55..758eb696 100644 --- a/ao-tools/ao-usbload/ao-usbload.c +++ b/ao-tools/ao-usbload/ao-usbload.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -40,7 +41,6 @@ get_uint16(struct cc_usb *cc, uint32_t addr) { uint16_t result; result = ao_self_get_uint16(cc, addr); - printf ("read 0x%08x = 0x%04x\n", addr, result); return result; } @@ -54,7 +54,6 @@ get_uint32(struct cc_usb *cc, uint32_t addr) uint32_t result; result = ao_self_get_uint32(cc, addr); - printf ("read 0x%08x = 0x%08x\n", addr, result); return result; } @@ -87,12 +86,13 @@ static const struct option options[] = { { .name = "serial", .has_arg = 1, .val = 's' }, { .name = "verbose", .has_arg = 1, .val = 'v' }, { .name = "wait", .has_arg = 0, .val = 'w' }, + { .name = "force", .has_arg = 0, .val = 'f' }, { 0, 0, 0, 0}, }; static void usage(char *program) { - fprintf(stderr, "usage: %s [--raw] [--verbose=<verbose>] [--device=<device>] [-tty=<tty>] [--cal=<radio-cal>] [--serial=<serial>] [--wait] file.{elf,ihx}\n", program); + fprintf(stderr, "usage: %s [--raw] [--verbose=<verbose>] [--device=<device>] [-tty=<tty>] [--cal=<radio-cal>] [--serial=<serial>] [--wait] [--force] file.{elf,ihx}\n", program); exit(1); } @@ -115,6 +115,48 @@ ends_with(char *whole, char *suffix) return strcmp(whole + whole_len - suffix_len, suffix) == 0; } +static int +ucs2len(uint16_t *ucs2) +{ + int len = 0; + while (*ucs2++) + len++; + return len; +} + +int +putucs4(uint32_t c, FILE *file) +{ + char d; + int bits; + + if (c < 0x80) { d = c; bits= -6; } + else if (c < 0x800) { d= ((c >> 6) & 0x1F) | 0xC0; bits= 0; } + else if (c < 0x10000) { d= ((c >> 12) & 0x0F) | 0xE0; bits= 6; } + else if (c < 0x200000) { d= ((c >> 18) & 0x07) | 0xF0; bits= 12; } + else if (c < 0x4000000) { d= ((c >> 24) & 0x03) | 0xF8; bits= 18; } + else if (c < 0x80000000) { d= ((c >> 30) & 0x01) | 0xFC; bits= 24; } + else return EOF; + + if (putc (d, file) < 0) + return EOF; + + for ( ; bits >= 0; bits-= 6) + if (putc (((c >> bits) & 0x3F) | 0x80, file) < 0) + return EOF; + + return 0; +} + +static void +putucs2str(uint16_t *ucs2str, FILE *file) +{ + uint16_t ucs2; + + while ((ucs2 = *ucs2str++) != 0) + putucs4(ucs2, file); +} + int main (int argc, char **argv) { @@ -145,8 +187,9 @@ main (int argc, char **argv) int num_file_symbols; uint32_t flash_base, flash_bound; int has_flash_size = 0; + int force = 0; - while ((c = getopt_long(argc, argv, "wrT:D:c:s:v:", options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "wrfT:D:c:s:v:", options, NULL)) != -1) { switch (c) { case 'T': tty = optarg; @@ -173,6 +216,9 @@ main (int argc, char **argv) case 'v': verbose++; break; + case 'f': + force = 1; + break; default: usage(argv[0]); break; @@ -322,6 +368,48 @@ main (int argc, char **argv) } } + if (!force && was_flashed) { + struct ao_usb_id new_id, old_id; + uint16_t *new_product, *old_product; + int new_len, old_len; + + if (!ao_heximage_usb_id(load, &new_id)) { + fprintf(stderr, "Can't get new USB id\n"); + done(cc, 1); + } + + if (!ao_self_get_usb_id(cc, &old_id)) { + fprintf(stderr, "Can't get old USB id\n"); + done(cc, 1); + } + if (new_id.vid != old_id.vid || new_id.pid != old_id.pid) { + fprintf(stderr, "USB ID mismatch (device is %04x/%04x image is %04x/%04x)\n", + old_id.vid, old_id.pid, new_id.vid, new_id.pid); + done(cc, 1); + } + + new_product = ao_heximage_usb_product(load); + if (!new_product) { + fprintf(stderr, "Can't get new USB product name\n"); + done(cc, 1); + } + old_product = ao_self_get_usb_product(cc); + if (!old_product) { + fprintf(stderr, "Can't get existing USB product name\n"); + done(cc, 1); + } + new_len = ucs2len(new_product); + old_len = ucs2len(old_product); + if (new_len != old_len || memcmp(new_product, old_product, new_len * 2) != 0) { + fprintf(stderr, "USB product mismatch (device is "); + putucs2str(new_product, stderr); + fprintf(stderr, ", image is "); + putucs2str(old_product, stderr); + fprintf(stderr, ")\n"); + done(cc, 1); + } + } + if (!ao_editaltos(load, serial, cal)) done(cc, 1); } diff --git a/ao-tools/ao-usbload/ao-usbload.h b/ao-tools/ao-usbload/ao-usbload.h index 1ba9a977..bd59d66d 100644 --- a/ao-tools/ao-usbload/ao-usbload.h +++ b/ao-tools/ao-usbload/ao-usbload.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-usbtrng/ao-usbtrng.c b/ao-tools/ao-usbtrng/ao-usbtrng.c index 456885d9..0362f1b4 100644 --- a/ao-tools/ao-usbtrng/ao-usbtrng.c +++ b/ao-tools/ao-usbtrng/ao-usbtrng.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview.glade b/ao-tools/ao-view/aoview.glade index c302ad0d..2a3c1beb 100644 --- a/ao-tools/ao-view/aoview.glade +++ b/ao-tools/ao-view/aoview.glade @@ -729,7 +729,7 @@ <property name="copyright" translatable="yes">Copyright © 2009 Keith Packard</property> <property name="comments" translatable="yes">AltOS data capture and display.</property> <property name="website">http://altusmetrum.org</property> - <property name="license" translatable="yes">AoView is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. + <property name="license" translatable="yes">AoView is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. AoView is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. diff --git a/ao-tools/ao-view/aoview.h b/ao-tools/ao-view/aoview.h index b937df7c..63359892 100644 --- a/ao-tools/ao-view/aoview.h +++ b/ao-tools/ao-view/aoview.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_channel.c b/ao-tools/ao-view/aoview_channel.c index 959173ca..06d28214 100644 --- a/ao-tools/ao-view/aoview_channel.c +++ b/ao-tools/ao-view/aoview_channel.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_convert.c b/ao-tools/ao-view/aoview_convert.c index 8ee05e1d..e0c072e8 100644 --- a/ao-tools/ao-view/aoview_convert.c +++ b/ao-tools/ao-view/aoview_convert.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_dev_dialog.c b/ao-tools/ao-view/aoview_dev_dialog.c index 2ea43203..3c0a7c73 100644 --- a/ao-tools/ao-view/aoview_dev_dialog.c +++ b/ao-tools/ao-view/aoview_dev_dialog.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_eeprom.c b/ao-tools/ao-view/aoview_eeprom.c index 447b83a4..99da1a6b 100644 --- a/ao-tools/ao-view/aoview_eeprom.c +++ b/ao-tools/ao-view/aoview_eeprom.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_file.c b/ao-tools/ao-view/aoview_file.c index 292887a0..ade52263 100644 --- a/ao-tools/ao-view/aoview_file.c +++ b/ao-tools/ao-view/aoview_file.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_flite.c b/ao-tools/ao-view/aoview_flite.c index abcdc491..938bcb77 100644 --- a/ao-tools/ao-view/aoview_flite.c +++ b/ao-tools/ao-view/aoview_flite.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_label.c b/ao-tools/ao-view/aoview_label.c index 24313626..423d018f 100644 --- a/ao-tools/ao-view/aoview_label.c +++ b/ao-tools/ao-view/aoview_label.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_log.c b/ao-tools/ao-view/aoview_log.c index 2880ecb1..fd6b3324 100644 --- a/ao-tools/ao-view/aoview_log.c +++ b/ao-tools/ao-view/aoview_log.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_main.c b/ao-tools/ao-view/aoview_main.c index f8704b89..a197b3e6 100644 --- a/ao-tools/ao-view/aoview_main.c +++ b/ao-tools/ao-view/aoview_main.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_monitor.c b/ao-tools/ao-view/aoview_monitor.c index 1f9937b2..c7f17045 100644 --- a/ao-tools/ao-view/aoview_monitor.c +++ b/ao-tools/ao-view/aoview_monitor.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_replay.c b/ao-tools/ao-view/aoview_replay.c index da7b5d6a..bfdd8d46 100644 --- a/ao-tools/ao-view/aoview_replay.c +++ b/ao-tools/ao-view/aoview_replay.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_serial.c b/ao-tools/ao-view/aoview_serial.c index 29038b79..f560da9a 100644 --- a/ao-tools/ao-view/aoview_serial.c +++ b/ao-tools/ao-view/aoview_serial.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_state.c b/ao-tools/ao-view/aoview_state.c index 505bcddc..8cf99d0b 100644 --- a/ao-tools/ao-view/aoview_state.c +++ b/ao-tools/ao-view/aoview_state.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_table.c b/ao-tools/ao-view/aoview_table.c index e75ae670..d84fd604 100644 --- a/ao-tools/ao-view/aoview_table.c +++ b/ao-tools/ao-view/aoview_table.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_util.c b/ao-tools/ao-view/aoview_util.c index 6ea62ac9..56f42571 100644 --- a/ao-tools/ao-view/aoview_util.c +++ b/ao-tools/ao-view/aoview_util.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/ao-view/aoview_voice.c b/ao-tools/ao-view/aoview_voice.c index 24422df6..9ecbc401 100644 --- a/ao-tools/ao-view/aoview_voice.c +++ b/ao-tools/ao-view/aoview_voice.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/ao-dfu.c b/ao-tools/lib/ao-dfu.c index b6778495..f8aba94b 100644 --- a/ao-tools/lib/ao-dfu.c +++ b/ao-tools/lib/ao-dfu.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/ao-dfu.h b/ao-tools/lib/ao-dfu.h index c3dfc496..4bed1a08 100644 --- a/ao-tools/lib/ao-dfu.h +++ b/ao-tools/lib/ao-dfu.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/ao-editaltos.c b/ao-tools/lib/ao-editaltos.c index 7547c82c..06009653 100644 --- a/ao-tools/lib/ao-editaltos.c +++ b/ao-tools/lib/ao-editaltos.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,23 +21,23 @@ #include "ao-editaltos.h" struct ao_sym ao_symbols[] = { - { + [AO_ROMCONFIG_VERSION_INDEX] = { .name = "ao_romconfig_version", .required = 1 }, - { + [AO_ROMCONFIG_CHECK_INDEX] = { .name = "ao_romconfig_check", .required = 1 }, - { + [AO_SERIAL_NUMBER_INDEX] = { .name = "ao_serial_number", .required = 1 }, - { + [AO_RADIO_CAL_INDEX] = { .name = "ao_radio_cal", .required = 0 }, - { + [AO_USB_DESCRIPTORS_INDEX] = { .name = "ao_usb_descriptors", .required = 0 }, @@ -57,13 +58,6 @@ rewrite(struct ao_hex_image *load, unsigned address, uint8_t *data, int length) if (address < load->address || load->address + load->length < address + length) return false; - printf("rewrite %04x:", address); - for (i = 0; i < length; i++) - printf (" %02x", load->data[address - load->address + i]); - printf(" ->"); - for (i = 0; i < length; i++) - printf (" %02x", data[i]); - printf("\n"); memcpy(load->data + address - load->address, data, length); return true; } @@ -165,3 +159,81 @@ ao_editaltos(struct ao_hex_image *image, } return true; } + +static uint16_t +read_le16(uint8_t *src) +{ + return (uint16_t) src[0] | ((uint16_t) src[1] << 8); +} + +bool +ao_heximage_usb_id(struct ao_hex_image *image, struct ao_usb_id *id) +{ + uint32_t usb_descriptors; + + if (!AO_USB_DESCRIPTORS) + return false; + usb_descriptors = AO_USB_DESCRIPTORS - image->address; + + while (image->data[usb_descriptors] != 0 && usb_descriptors < image->length) { + if (image->data[usb_descriptors+1] == AO_USB_DESC_DEVICE) { + break; + } + usb_descriptors += image->data[usb_descriptors]; + } + + /* + * check to make sure there's at least 0x12 (size of a USB + * device descriptor) available + */ + if (usb_descriptors >= image->length || image->data[usb_descriptors] != 0x12) + return false; + + id->vid = read_le16(image->data + usb_descriptors + 8); + id->pid = read_le16(image->data + usb_descriptors + 10); + + return true; +} + +uint16_t * +ao_heximage_usb_product(struct ao_hex_image *image) +{ + uint32_t usb_descriptors; + int string_num; + uint16_t *product; + uint8_t product_len; + + if (!AO_USB_DESCRIPTORS) + return NULL; + usb_descriptors = AO_USB_DESCRIPTORS - image->address; + + string_num = 0; + while (image->data[usb_descriptors] != 0 && usb_descriptors < image->length) { + if (image->data[usb_descriptors+1] == AO_USB_DESC_STRING) { + ++string_num; + if (string_num == 3) + break; + } + usb_descriptors += image->data[usb_descriptors]; + } + + /* + * check to make sure there's at least 0x12 (size of a USB + * device descriptor) available + */ + if (usb_descriptors >= image->length || image->data[usb_descriptors] == 0) + return NULL; + + product_len = image->data[usb_descriptors] - 2; + + if (usb_descriptors < product_len + 2) + return NULL; + + product = malloc (product_len + 2); + if (!product) + return NULL; + + memcpy(product, image->data + usb_descriptors + 2, product_len); + product[product_len/2] = 0; + return product; +} diff --git a/ao-tools/lib/ao-editaltos.h b/ao-tools/lib/ao-editaltos.h index 74530435..6f2829b0 100644 --- a/ao-tools/lib/ao-editaltos.h +++ b/ao-tools/lib/ao-editaltos.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,19 +26,31 @@ extern struct ao_sym ao_symbols[]; extern int ao_num_symbols; +#define AO_USB_DESC_DEVICE 1 #define AO_USB_DESC_STRING 3 -#define AO_ROMCONFIG_VERSION (ao_symbols[0].addr) -#define AO_ROMCONFIG_CHECK (ao_symbols[1].addr) -#define AO_SERIAL_NUMBER (ao_symbols[2].addr) -#define AO_RADIO_CAL (ao_symbols[3].addr) -#define AO_USB_DESCRIPTORS (ao_symbols[4].addr) +#define AO_ROMCONFIG_VERSION_INDEX 0 +#define AO_ROMCONFIG_CHECK_INDEX 1 +#define AO_SERIAL_NUMBER_INDEX 2 +#define AO_RADIO_CAL_INDEX 3 +#define AO_USB_DESCRIPTORS_INDEX 4 + +#define AO_ROMCONFIG_VERSION (ao_symbols[AO_ROMCONFIG_VERSION_INDEX].addr) +#define AO_ROMCONFIG_CHECK (ao_symbols[AO_ROMCONFIG_CHECK_INDEX].addr) +#define AO_SERIAL_NUMBER (ao_symbols[AO_SERIAL_NUMBER_INDEX].addr) +#define AO_RADIO_CAL (ao_symbols[AO_RADIO_CAL_INDEX].addr) +#define AO_USB_DESCRIPTORS (ao_symbols[AO_USB_DESCRIPTORS_INDEX].addr) struct ao_editaltos_funcs { uint16_t (*get_uint16)(void *closure, uint32_t addr); uint32_t (*get_uint32)(void *closure, uint32_t addr); }; +struct ao_usb_id { + uint16_t vid; + uint16_t pid; +}; + bool ao_editaltos_find_symbols(struct ao_sym *file_symbols, int num_file_symbols, struct ao_sym *symbols, int num_symbols); @@ -47,4 +60,10 @@ ao_editaltos(struct ao_hex_image *image, uint16_t serial, uint32_t radio_cal); +bool +ao_heximage_usb_id(struct ao_hex_image *image, struct ao_usb_id *id); + +uint16_t * +ao_heximage_usb_product(struct ao_hex_image *image); + #endif /* _AO_EDITALTOS_H_ */ diff --git a/ao-tools/lib/ao-elf.c b/ao-tools/lib/ao-elf.c index 680a80f0..c44102f8 100644 --- a/ao-tools/lib/ao-elf.c +++ b/ao-tools/lib/ao-elf.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/ao-elf.h b/ao-tools/lib/ao-elf.h index 0f79d142..5f4e8428 100644 --- a/ao-tools/lib/ao-elf.h +++ b/ao-tools/lib/ao-elf.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/ao-hex.h b/ao-tools/lib/ao-hex.h index a1ab490c..3cd0813b 100644 --- a/ao-tools/lib/ao-hex.h +++ b/ao-tools/lib/ao-hex.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/ao-selfload.c b/ao-tools/lib/ao-selfload.c index 41e45adc..0a23dfda 100644 --- a/ao-tools/lib/ao-selfload.c +++ b/ao-tools/lib/ao-selfload.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -156,3 +157,40 @@ ao_self_get_uint32(struct cc_usb *cc, uint32_t addr) free(hex); return v; } + +bool +ao_self_get_usb_id(struct cc_usb *cc, struct ao_usb_id *id) +{ + struct ao_hex_image *hex; + bool ret; + + if (!AO_USB_DESCRIPTORS) + return false; + + hex = ao_self_read(cc, AO_USB_DESCRIPTORS, 512); + if (!hex) + return false; + + ret = ao_heximage_usb_id(hex, id); + free(hex); + return ret; +} + +uint16_t * +ao_self_get_usb_product(struct cc_usb *cc) +{ + struct ao_hex_image *hex; + uint16_t *ret; + + if (!AO_USB_DESCRIPTORS) + return NULL; + + hex = ao_self_read(cc, AO_USB_DESCRIPTORS, 512); + if (!hex) + return NULL; + + ret = ao_heximage_usb_product(hex); + free(hex); + return ret; +} + diff --git a/ao-tools/lib/ao-selfload.h b/ao-tools/lib/ao-selfload.h index a001a404..4aac5848 100644 --- a/ao-tools/lib/ao-selfload.h +++ b/ao-tools/lib/ao-selfload.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,6 +22,7 @@ #include <stdbool.h> #include "ao-hex.h" #include "cc-usb.h" +#include "ao-editaltos.h" struct ao_hex_image * ao_self_read(struct cc_usb *cc, uint32_t address, uint32_t length); @@ -34,4 +36,13 @@ ao_self_get_uint16(struct cc_usb *cc, uint32_t addr); uint32_t ao_self_get_uint32(struct cc_usb *cc, uint32_t addr); +bool +ao_self_get_usb_id(struct cc_usb *cc, struct ao_usb_id *id); + +uint16_t * +ao_self_get_usb_product(struct cc_usb *cc); + +uint16_t * +ao_self_get_usb_product(struct cc_usb *cc); + #endif /* _AO_SELFLOAD_H_ */ diff --git a/ao-tools/lib/ao-verbose.c b/ao-tools/lib/ao-verbose.c index a1678ed1..d85b524f 100644 --- a/ao-tools/lib/ao-verbose.c +++ b/ao-tools/lib/ao-verbose.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/ao-verbose.h b/ao-tools/lib/ao-verbose.h index 26c2fe41..d23e720c 100644 --- a/ao-tools/lib/ao-verbose.h +++ b/ao-tools/lib/ao-verbose.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-analyse.c b/ao-tools/lib/cc-analyse.c index 27c416a6..52df66e6 100644 --- a/ao-tools/lib/cc-analyse.c +++ b/ao-tools/lib/cc-analyse.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-convert.c b/ao-tools/lib/cc-convert.c index b82dd778..0f7fa809 100644 --- a/ao-tools/lib/cc-convert.c +++ b/ao-tools/lib/cc-convert.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-dsp.c b/ao-tools/lib/cc-dsp.c index 518c1a68..d44c696d 100644 --- a/ao-tools/lib/cc-dsp.c +++ b/ao-tools/lib/cc-dsp.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-integrate.c b/ao-tools/lib/cc-integrate.c index ba50761b..8009f0c3 100644 --- a/ao-tools/lib/cc-integrate.c +++ b/ao-tools/lib/cc-integrate.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-log.c b/ao-tools/lib/cc-log.c index ed51f87e..f7674359 100644 --- a/ao-tools/lib/cc-log.c +++ b/ao-tools/lib/cc-log.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-logfile.c b/ao-tools/lib/cc-logfile.c index 842e5c7c..88ddda58 100644 --- a/ao-tools/lib/cc-logfile.c +++ b/ao-tools/lib/cc-logfile.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-mega.c b/ao-tools/lib/cc-mega.c index 3aa24a6d..2e5a6061 100644 --- a/ao-tools/lib/cc-mega.c +++ b/ao-tools/lib/cc-mega.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-period.c b/ao-tools/lib/cc-period.c index 844ac79e..fb1c3ccd 100644 --- a/ao-tools/lib/cc-period.c +++ b/ao-tools/lib/cc-period.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-process.c b/ao-tools/lib/cc-process.c index c756b570..74b02a74 100644 --- a/ao-tools/lib/cc-process.c +++ b/ao-tools/lib/cc-process.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-telem.c b/ao-tools/lib/cc-telem.c index aa52b7c5..678c078e 100644 --- a/ao-tools/lib/cc-telem.c +++ b/ao-tools/lib/cc-telem.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-telemetry.c b/ao-tools/lib/cc-telemetry.c index 45c10dcb..42315128 100644 --- a/ao-tools/lib/cc-telemetry.c +++ b/ao-tools/lib/cc-telemetry.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-telemetry.h b/ao-tools/lib/cc-telemetry.h index d64c4b30..500de96c 100644 --- a/ao-tools/lib/cc-telemetry.h +++ b/ao-tools/lib/cc-telemetry.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc-util.c b/ao-tools/lib/cc-util.c index 65488ee9..fc617eae 100644 --- a/ao-tools/lib/cc-util.c +++ b/ao-tools/lib/cc-util.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cc.h b/ao-tools/lib/cc.h index ff95e4fc..cbeb705c 100644 --- a/ao-tools/lib/cc.h +++ b/ao-tools/lib/cc.h @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/cephes.h b/ao-tools/lib/cephes.h index f8ec264f..7d66425b 100644 --- a/ao-tools/lib/cephes.h +++ b/ao-tools/lib/cephes.h @@ -10,7 +10,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/i0.c b/ao-tools/lib/i0.c index 6f7b5a57..2156d1c1 100644 --- a/ao-tools/lib/i0.c +++ b/ao-tools/lib/i0.c @@ -10,7 +10,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/lib/mconf.h b/ao-tools/lib/mconf.h index af1ebb51..9898a2e1 100644 --- a/ao-tools/lib/mconf.h +++ b/ao-tools/lib/mconf.h @@ -10,7 +10,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/target/radio/init.c b/ao-tools/target/radio/init.c index ea7c984c..8c2c96bd 100644 --- a/ao-tools/target/radio/init.c +++ b/ao-tools/target/radio/init.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/ao-tools/target/radio/xmit.c b/ao-tools/target/radio/xmit.c index e80a0f8b..a400163c 100644 --- a/ao-tools/target/radio/xmit.c +++ b/ao-tools/target/radio/xmit.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of |