diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-07-17 10:03:26 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-07-17 21:52:49 -0700 |
commit | 8d6bbaf73d3271ee3ae74b22e2bf3bd5b8fba3e8 (patch) | |
tree | 4cc4c7ef7ff04f8126d5a36a18b7fb304ad48b79 /util/ectool.c | |
parent | 220d6884b3a00bb3067a4fdcbaf5b6e2b4f891fe (diff) | |
download | chrome-ec-8d6bbaf73d3271ee3ae74b22e2bf3bd5b8fba3e8.tar.gz |
ectool: Allow for chips with more than 1 MB of flash
ectool currently assumes any offset >= 0x100000 (1MB) is invalid,
this is not true on STM32H7.
BRANCH=none
BUG=none
TEST=ectool --name=cros_fp flasherase 0x120000 131072 does not fail
with "Bad offset."
Change-Id: I5f8e29b03dbc4c1a3f1566b0e78d4466f4a44565
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1139951
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'util/ectool.c')
-rw-r--r-- | util/ectool.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/util/ectool.c b/util/ectool.c index bbabd7332a..cc4aaa8bdc 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -30,6 +30,9 @@ #include "ps8xxx.h" #include "usb_pd.h" +/* Maximum flash size (16 MB, conservative) */ +#define MAX_FLASH_SIZE 0x1000000 + /* Command line options */ enum { OPT_DEV = 1000, @@ -676,7 +679,7 @@ int cmd_read_test(int argc, char *argv[]) } offset = strtol(argv[1], &e, 0); size = strtol(argv[2], &e, 0); - if ((e && *e) || size <= 0 || size > 0x100000) { + if ((e && *e) || size <= 0 || size > MAX_FLASH_SIZE) { fprintf(stderr, "Bad size.\n"); return -1; } @@ -852,12 +855,12 @@ int cmd_flash_read(int argc, char *argv[]) return -1; } offset = strtol(argv[1], &e, 0); - if ((e && *e) || offset < 0 || offset > 0x100000) { + if ((e && *e) || offset < 0 || offset > MAX_FLASH_SIZE) { fprintf(stderr, "Bad offset.\n"); return -1; } size = strtol(argv[2], &e, 0); - if ((e && *e) || size <= 0 || size > 0x100000) { + if ((e && *e) || size <= 0 || size > MAX_FLASH_SIZE) { fprintf(stderr, "Bad size.\n"); return -1; } @@ -898,7 +901,7 @@ int cmd_flash_write(int argc, char *argv[]) } offset = strtol(argv[1], &e, 0); - if ((e && *e) || offset < 0 || offset > 0x100000) { + if ((e && *e) || offset < 0 || offset > MAX_FLASH_SIZE) { fprintf(stderr, "Bad offset.\n"); return -1; } @@ -934,13 +937,13 @@ int cmd_flash_erase(int argc, char *argv[]) } offset = strtol(argv[1], &e, 0); - if ((e && *e) || offset < 0 || offset > 0x100000) { + if ((e && *e) || offset < 0 || offset > MAX_FLASH_SIZE) { fprintf(stderr, "Bad offset.\n"); return -1; } size = strtol(argv[2], &e, 0); - if ((e && *e) || size <= 0 || size > 0x100000) { + if ((e && *e) || size <= 0 || size > MAX_FLASH_SIZE) { fprintf(stderr, "Bad size.\n"); return -1; } |