diff options
author | Bill Richardson <wfrichar@chromium.org> | 2014-11-13 13:57:10 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-11-14 22:47:13 +0000 |
commit | e28b6184b117bfa3e0193ce8ed6a84b70c631c51 (patch) | |
tree | c98f4fae5916525001921a2ac5fbe04301473ac1 | |
parent | 399a810103839ecf990c1add90156aa49d631317 (diff) | |
download | chrome-ec-e28b6184b117bfa3e0193ce8ed6a84b70c631c51.tar.gz |
tweak: Allow "rw" command to read AND write memory.
It's really annoying to have to type two different commands. If I
want to read a location and then write it and then read it back
(which often happens when poking at hardware), then this:
rw 0x40570008
rw 0x40570008 14
rw 0x40570008
is much easier to enter than this:
rw 0x40570008
ww 0x40570008 14
rw 0x40570008
The "ww" command is still there, if you're really attached to it.
BUG=none
BRANCH=none
TEST=manual
Tried the example above. It worked.
Change-Id: I2302ed60df3dd3ec2224afa7c32d997bd2468ec1
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/229660
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | chip/g/uart.c | 2 | ||||
-rw-r--r-- | common/memory_commands.c | 24 |
2 files changed, 20 insertions, 6 deletions
diff --git a/chip/g/uart.c b/chip/g/uart.c index f8260dc9ec..6b33deecfa 100644 --- a/chip/g/uart.c +++ b/chip/g/uart.c @@ -69,7 +69,7 @@ int uart_tx_ready(void) int uart_rx_available(void) { /* True if the RX buffer is not completely empty. */ - /* TODO(crosbug.com/p/33432): Ask Scott for a single bit for this. */ + /* TODO(crosbug.com/p/33432): Want a single bit (b2/18273495) */ return G_UART_RFIFO(0) & 0x0fc0; } diff --git a/common/memory_commands.c b/common/memory_commands.c index c8a1ea76df..3886a3ac1d 100644 --- a/common/memory_commands.c +++ b/common/memory_commands.c @@ -43,20 +43,34 @@ static int command_read_word(int argc, char **argv) uint32_t value; char *e; - if (argc != 2) + if (argc < 2) return EC_ERROR_PARAM_COUNT; address = (uint32_t *)(uintptr_t)strtoi(argv[1], &e, 0); if (*e) return EC_ERROR_PARAM1; - value = *address; + /* Just reading? */ + if (argc < 3) { + value = *address; + ccprintf("read 0x%p = 0x%08x\n", address, value); + return EC_SUCCESS; + } - ccprintf("read 0x%p = 0x%08x\n", address, value); + /* Writing! */ + value = strtoi(argv[2], &e, 0); + if (*e) + return EC_ERROR_PARAM2; + + ccprintf("write 0x%p = 0x%08x\n", address, value); + cflush(); /* Flush before writing in case this crashes */ + + *address = value; return EC_SUCCESS; + } DECLARE_CONSOLE_COMMAND(rw, command_read_word, - "addr", - "Read a word from memory", + "addr [value]", + "Read or write a word in memory", NULL); |