summaryrefslogtreecommitdiff
path: root/common/memory_commands.c
diff options
context:
space:
mode:
authorSheng-Liang Song <ssl@chromium.org>2014-11-21 15:00:28 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-04 04:02:45 +0000
commitc1e0b0e114655094bafddbd2a835e79310290ee7 (patch)
tree975aab50f51493eb0d17a84b1daa399032431ad9 /common/memory_commands.c
parent0e03ff4ad87e434a176e9e2e2b2963c9f3a83771 (diff)
downloadchrome-ec-c1e0b0e114655094bafddbd2a835e79310290ee7.tar.gz
cr50: Replaced ww with md EC cli
Supported memory commands are: rw and md. - rw: for read/write a word - md: for memory display Usage: rw addr [value] Usage: md addr [num of words (4B)] BRANCH=none BUG=none TEST="make BOARD=cr50" and "md 0 100" > md 0 100 [00000000] : 00018000 0000011d 00000101 00000101 [00000010] : 00000101 00000101 00000101 00000101 ... Signed-off-by: Sheng-Liang Song <ssl@chromium.org> Change-Id: I1de8c690cca006ec3aae42d4e6bd0ba30f7c3238 Reviewed-on: https://chromium-review.googlesource.com/231398 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/memory_commands.c')
-rw-r--r--common/memory_commands.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/common/memory_commands.c b/common/memory_commands.c
index 3886a3ac1d..d0fa6eb191 100644
--- a/common/memory_commands.c
+++ b/common/memory_commands.c
@@ -8,33 +8,38 @@
#include "console.h"
#include "util.h"
-static int command_write_word(int argc, char **argv)
+static int command_mem_dump(int argc, char **argv)
{
volatile uint32_t *address;
- uint32_t value;
+ uint32_t value, num = 1, i;
char *e;
- if (argc != 3)
+ 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 = 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;
+ if (argc >= 3)
+ num = strtoi(argv[2], &e, 0);
+ for (i = 0; i < num; i++) {
+ value = address[i];
+ if (0 == (i%4))
+ ccprintf("\n%08X: %08x", address+i, value);
+ else
+ ccprintf(" %08x", value);
+ cflush();
+ }
+ ccprintf("\n");
+ cflush();
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(ww, command_write_word,
- "addr value",
- "Write a word to memory",
+
+DECLARE_CONSOLE_COMMAND(md, command_mem_dump,
+ "addr [num]",
+ "dump num of words (4B) in memory",
NULL);
static int command_read_word(int argc, char **argv)
@@ -74,3 +79,4 @@ DECLARE_CONSOLE_COMMAND(rw, command_read_word,
"addr [value]",
"Read or write a word in memory",
NULL);
+