ao-chaosread: Add support for the new flash endpoint in chaoskey
authorKeith Packard <keithp@keithp.com>
Mon, 7 May 2018 04:16:25 +0000 (21:16 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 7 May 2018 16:21:56 +0000 (09:21 -0700)
This adds support for endpoint 0x87, which streams the contents of the
onboard flash to the host for firmware verification.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/ao-chaosread/ao-chaosread.1
ao-tools/ao-chaosread/ao-chaosread.c

index e6ed2fac64443bd21d3cd9942c650ca0b70b49c9..94ca5ce9e0fc06d543415dc3b75aadb220325daf 100644 (file)
@@ -47,6 +47,12 @@ from the noise source.
 .TP
 \-r | --raw
 Read raw data from the noise source. This is the default.
 .TP
 \-r | --raw
 Read raw data from the noise source. This is the default.
+.TP
+\-f | --flash
+Read the contents of flash memory on the device. This loops through
+flash memory, so you can read the contents more than once, but there's
+no way to reset the pointer back to the start other than making sure
+you read the whole contents.
 .SH USAGE
 .I ao-chaosread
 reads noise data.
 .SH USAGE
 .I ao-chaosread
 reads noise data.
index 8a814a009ed7b20b405877431a334d6918c03a73..5c0de1257fbded71cda28e0d7dbaaf2fcffaba7c 100644 (file)
@@ -174,6 +174,7 @@ chaoskey_close(struct chaoskey *ck)
 
 #define COOKED_ENDPOINT        0x85
 #define RAW_ENDPOINT   0x86
 
 #define COOKED_ENDPOINT        0x85
 #define RAW_ENDPOINT   0x86
+#define FLASH_ENDPOINT 0x87
 
 int
 chaoskey_read(struct chaoskey *ck, int endpoint, void *buffer, int len)
 
 int
 chaoskey_read(struct chaoskey *ck, int endpoint, void *buffer, int len)
@@ -208,12 +209,13 @@ static const struct option options[] = {
        { .name = "bytes", .has_arg = 0, .val = 'b' },
        { .name = "cooked", .has_arg = 0, .val = 'c' },
        { .name = "raw", .has_arg = 0, .val = 'r' },
        { .name = "bytes", .has_arg = 0, .val = 'b' },
        { .name = "cooked", .has_arg = 0, .val = 'c' },
        { .name = "raw", .has_arg = 0, .val = 'r' },
+       { .name = "flash", .has_arg = 0, .val = 'f' },
        { 0, 0, 0, 0},
 };
 
 static void usage(char *program)
 {
        { 0, 0, 0, 0},
 };
 
 static void usage(char *program)
 {
-       fprintf(stderr, "usage: %s [--serial=<serial>] [--length=<length>[kMG]] [--infinite] [--bytes] [--cooked] [--raw]\n", program);
+       fprintf(stderr, "usage: %s [--serial=<serial>] [--length=<length>[kMG]] [--infinite] [--bytes] [--cooked] [--raw] [--flash]\n", program);
        exit(1);
 }
 
        exit(1);
 }
 
@@ -233,7 +235,7 @@ main (int argc, char **argv)
        int     bytes = 0;
        int     endpoint = RAW_ENDPOINT;
 
        int     bytes = 0;
        int     endpoint = RAW_ENDPOINT;
 
-       while ((c = getopt_long(argc, argv, "s:l:ibcr", options, NULL)) != -1) {
+       while ((c = getopt_long(argc, argv, "s:l:ibcrf", options, NULL)) != -1) {
                switch (c) {
                case 's':
                        serial = optarg;
                switch (c) {
                case 's':
                        serial = optarg;
@@ -262,6 +264,9 @@ main (int argc, char **argv)
                case 'r':
                        endpoint = RAW_ENDPOINT;
                        break;
                case 'r':
                        endpoint = RAW_ENDPOINT;
                        break;
+               case 'f':
+                       endpoint = FLASH_ENDPOINT;
+                       break;
                default:
                        usage(argv[0]);
                        break;
                default:
                        usage(argv[0]);
                        break;