summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-07-17 10:03:26 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-12-08 02:14:25 +0000
commit5eba186bb7eefb325aaddceef5a01e87bb4420b0 (patch)
treeffebbbddb44d3b5a7cf686819710c73666a94d2f
parent329043f397a079b80a1767994472947df3648602 (diff)
downloadchrome-ec-5eba186bb7eefb325aaddceef5a01e87bb4420b0.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> Reviewed-on: https://chromium-review.googlesource.com/c/1363827 Reviewed-by: YH Lin <yueherngl@chromium.org> Commit-Queue: YH Lin <yueherngl@chromium.org> Tested-by: YH Lin <yueherngl@chromium.org>
-rw-r--r--util/ectool.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/util/ectool.c b/util/ectool.c
index cda249c8e8..696ab4e834 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,
@@ -668,7 +671,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;
}
@@ -844,12 +847,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;
}
@@ -890,7 +893,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;
}
@@ -926,13 +929,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;
}