add 'flash list', rewrite 'flash banks'
authorZachary T Welch <zw@superlucidity.net>
Mon, 7 Dec 2009 05:30:21 +0000 (21:30 -0800)
committerZachary T Welch <zw@superlucidity.net>
Mon, 7 Dec 2009 05:39:35 +0000 (21:39 -0800)
Rename the existing 'flash banks' implementation as 'flash list', and
replace the broken 'flash_banks' TCL wrapper with a new command handler.

Adds documentation for the new 'flash list' command in the user guide.

doc/openocd.texi
src/flash/nor/tcl.c
src/flash/startup.tcl

index b6be87e13640c19f2e9fb25b61ea160910e4c46e..36517791e22e17146e84921b890666f50be47659 100644 (file)
@@ -3638,12 +3638,18 @@ Use it in board specific configuration files, not interactively.
 @comment the REAL name for this command is "ocd_flash_banks"
 @comment less confusing would be:  "flash list" (like "nand list")
 @deffn Command {flash banks}
-Prints a one-line summary of each device declared
-using @command{flash bank}, numbered from zero.
+Prints a one-line summary of each device that was 
+declared using @command{flash bank}, numbered from zero.
 Note that this is the @emph{plural} form;
 the @emph{singular} form is a very different command.
 @end deffn
 
+@deffn Command {flash list}
+Retrieves a list of associative arrays for each device that was 
+declared using @command{flash bank}, numbered from zero.
+This returned list can be manipulated easily from within scripts.
+@end deffn
+
 @deffn Command {flash probe} num
 Identify the flash, or validate the parameters of the configured flash. Operation
 depends on the flash type.
index d417ca0f6f92e4ba0f69536032b89a866d2b7a5f..5ba941b36f4e528a53b598c08c76dc9dafe1e78d 100644 (file)
@@ -816,14 +816,30 @@ COMMAND_HANDLER(handle_flash_bank_command)
        flash_bank_add(c);
 
        return ERROR_OK;
-
 }
 
+COMMAND_HANDLER(handle_flash_banks_command)
+{
+       if (CMD_ARGC != 0)
+               return ERROR_INVALID_ARGUMENTS;
 
-static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+       unsigned n = 0;
+       for (struct flash_bank *p = flash_bank_list(); p; p = p->next, n++)
+       {
+               LOG_USER("#%u: %s at 0x%8.8" PRIx32 ", size 0x%8.8" PRIx32 ", "
+                       "buswidth %u, chipwidth %u", n,
+                       p->driver->name, p->base, p->size,
+                       p->bus_width, p->chip_width);
+       }
+       return ERROR_OK;
+}
+
+static int jim_flash_list(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 {
-       if (argc != 1) {
-               Jim_WrongNumArgs(interp, 1, argv, "no arguments to flash_banks command");
+       if (argc != 1)
+       {
+               Jim_WrongNumArgs(interp, 1, argv,
+                               "no arguments to 'flash list' command");
                return JIM_ERR;
        }
 
@@ -890,8 +906,14 @@ static const struct command_registration flash_config_command_handlers[] = {
        {
                .name = "banks",
                .mode = COMMAND_ANY,
-               .jim_handler = &jim_flash_banks,
-               .help = "return information about the flash banks",
+               .handler = &handle_flash_banks_command,
+               .help = "return readable information about the flash banks",
+       },
+       {
+               .name = "list",
+               .mode = COMMAND_ANY,
+               .jim_handler = &jim_flash_list,
+               .help = "returns a list of details about the flash banks",
        },
        COMMAND_REGISTRATION_DONE
 };
index 2c335d9f7b1e0a73dc915bb86873244f841c5448..6cb7d8e8a402f1c02e84e035da5344ec46869f2a 100644 (file)
@@ -1,16 +1,2 @@
 # Defines basic Tcl procs for OpenOCD flash module
 
-# Show flash in human readable form
-# This is an example of a human readable form of a low level fn
-proc flash_banks {} {
-       set i 0
-       set result ""
-       foreach {a} [ocd_flash banks] {
-               if {$i > 0} {
-                       set result "$result\n"
-               }
-               set result [format "$result#%d: %s at 0x%08x, size 0x%08x, buswidth %d, chipwidth %d" $i $a(name) $a(base) $a(size) $a(bus_width) $a(chip_width)]
-               set i [expr $i+1]
-       }
-       return $result
-}

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)