Alexander Couzens (lynxis@fe80.eu) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8323
-gerrit
commit 4a73710c9a0c14434cb3904d032b2b47ccf6aa88 Author: Alexander Couzens lynxis@fe80.eu Date: Mon Feb 2 08:51:30 2015 +0100
ectool: add write support
Use `ectool -w <addr> -z <data>` to write into ec ram
Change-Id: Id4aca045f6b7c2343be96ea474ee74033897b8b7 Signed-off-by: Alexander Couzens lynxis@fe80.eu --- util/ectool/ectool.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/util/ectool/ectool.c b/util/ectool/ectool.c index ab77282..4ceeaf8 100644 --- a/util/ectool/ectool.c +++ b/util/ectool/ectool.c @@ -24,6 +24,7 @@ #include <getopt.h> #include <sys/io.h> #include <ec.h> +#include <stdlib.h>
#define ECTOOL_VERSION "0.1"
@@ -51,6 +52,8 @@ void print_usage(const char *name) " -h | --help: print this help\n\n" " -V | --verbose: print debug information\n" " -i | --idx: print IDX RAM\n" + " -w <addr in hex> write to addr\n" + " -z <data in hex> write to data\n" "\n"); exit(1); } @@ -60,6 +63,8 @@ int verbose = 0, dump_idx = 0; int main(int argc, char *argv[]) { int i, opt, option_index = 0; + long write_data = -1; + long write_addr = -1;
static struct option long_options[] = { {"version", 0, 0, 'v'}, @@ -69,7 +74,7 @@ int main(int argc, char *argv[]) {0, 0, 0, 0} };
- while ((opt = getopt_long(argc, argv, "vh?Vi", + while ((opt = getopt_long(argc, argv, "vh?Viw:z:", long_options, &option_index)) != EOF) { switch (opt) { case 'v': @@ -82,6 +87,12 @@ int main(int argc, char *argv[]) case 'i': dump_idx = 1; break; + case 'w': + write_addr = strtol(optarg , NULL, 16); + break; + case 'z': + write_data = strtol(optarg , NULL, 16); + break; case 'h': case '?': default: @@ -95,6 +106,12 @@ int main(int argc, char *argv[]) printf("You need to be root.\n"); exit(1); } + if (write_addr >= 0 && write_data >= 0) { + write_addr &= 0xff; + write_data &= 0xff; + printf("\nWriting ec %02lx = %02lx\n", write_addr & 0xff, write_data & 0xff); + ec_write(write_addr & 0xff, write_data & 0xff); + }
printf("EC RAM:\n"); for (i = 0; i < 0x100; i++) {