summaryrefslogtreecommitdiff
path: root/util/ectool
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2015-02-02 08:51:30 +0100
committerPeter Stuge <peter@stuge.se>2015-02-11 02:35:32 +0100
commita5410dc450ec0272e578bdc7d0a33983c94aed0b (patch)
tree0f2a1a6277254e11e14e8001781ae846cd93f539 /util/ectool
parent754fac43467f87d6b926a181b6150867a08fb9b3 (diff)
downloadcoreboot-a5410dc450ec0272e578bdc7d0a33983c94aed0b.tar.xz
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> Reviewed-on: http://review.coreboot.org/8323 Tested-by: build bot (Jenkins) Reviewed-by: Nicolas Reinecke <nr@das-labor.org> Reviewed-by: Peter Stuge <peter@stuge.se>
Diffstat (limited to 'util/ectool')
-rw-r--r--util/ectool/ectool.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/util/ectool/ectool.c b/util/ectool/ectool.c
index ab7728238f..da5143ab85 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"
@@ -45,12 +46,14 @@ void print_version(void)
void print_usage(const char *name)
{
- printf("usage: %s [-vh?Vi]\n", name);
+ printf("usage: %s [-vh?Vi] [-w 0x<addr> -z 0x<data>]\n", name);
printf("\n"
" -v | --version: print the version\n"
" -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++) {