summaryrefslogtreecommitdiff
path: root/src/flash/nor/core.c
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-06-09 17:12:52 +0200
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-06-09 17:12:52 +0200
commit9ab7636ce6276d222662be431a1e6be96d9d34c0 (patch)
tree1602fd77e9eb2bab88a027500f6cc356ae0b1634 /src/flash/nor/core.c
parent49e6c61bcc9a176119721c38004eca02b3e77f19 (diff)
downloadopenocd+libswd-9ab7636ce6276d222662be431a1e6be96d9d34c0.tar.gz
openocd+libswd-9ab7636ce6276d222662be431a1e6be96d9d34c0.tar.bz2
openocd+libswd-9ab7636ce6276d222662be431a1e6be96d9d34c0.tar.xz
openocd+libswd-9ab7636ce6276d222662be431a1e6be96d9d34c0.zip
flash: add error message if image is too big for flash
replaced assert() w/error message if the image is too big. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src/flash/nor/core.c')
-rw-r--r--src/flash/nor/core.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index 1bd09b44..429bad67 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -636,7 +636,11 @@ int flash_write_unlock(struct target *target, struct image *image,
LOG_INFO("Padding image section %d with %d bytes", section_last-1, pad_bytes);
}
- assert (run_address + run_size - 1 <= c->base + c->size - 1);
+ if (run_address + run_size - 1 > c->base + c->size - 1)
+ {
+ LOG_ERROR("The image is too big for the flash");
+ return ERROR_FAIL;
+ }
/* If we're applying any sector automagic, then pad this
* (maybe-combined) segment to the end of its last sector.