cli: Add new `config' CLI for status/config registers
Add a new CLI mode to query and update status and configuration
registers of SPI NOR chips. Programmer initialization and chip
initialization works the same as with the classic CLI (`-p' and
`-c' options). There are two commands `get' and `set' where the
former is implied if no command is given. For a start, only the
`quad-enable' bit can be accessed (for chips that advertise it
in the database).
The `--temporary' option allows to use a volatile write status
register command if the flash chip supports it. So changes made
with this option will not be written to flash and are lost when
the chip is reset.
For instance, the quad-enable bit can then be queried like this
$ flashprog config get -p ch341a_spi quad-enable
or written with
$ flashprog config set -p ch341a_spi quad-enable 1
or
$ flashprog config set -p ch341a_spi --temporary quad-enable 1
Change-Id: I6b9d26c67e6ad65be5df367d2db7942bb98f27ac
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/195
diff --git a/cli.c b/cli.c
index 7bf94cc..f1d483a 100644
--- a/cli.c
+++ b/cli.c
@@ -26,6 +26,8 @@
int (*main)(int argc, char *argv[]);
} commands[] = {
{ "prog", flashprog_classic_main },
+ { "cfg", flashprog_config_main },
+ { "config", flashprog_config_main },
};
static void usage(const char *const name)
@@ -34,6 +36,7 @@
fprintf(stderr, "\nWhere <command> can be\n\n"
" prog Standard memory operations\n"
" (read/erase/write/verify)\n"
+ " cfg | config Status/config register operations\n"
"\n"
"The default is 'prog'. See `%s <command> --help`\n"
"for further instructions.\n\n", name);