aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nxp_tgt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nxp_tgt.c b/src/nxp_tgt.c
index a9f1c92..a22eda8 100644
--- a/src/nxp_tgt.c
+++ b/src/nxp_tgt.c
@@ -146,7 +146,7 @@ lpc11xx_flash_prepare(struct target_s *target, uint32_t addr, int len)
memset(&flash_pgm.p, 0, sizeof(flash_pgm.p));
flash_pgm.p.command[0] = IAP_CMD_PREPARE;
flash_pgm.p.command[1] = addr / 4096;
- flash_pgm.p.command[2] = (addr + len) / 4096;
+ flash_pgm.p.command[2] = (addr + len - 1) / 4096;
lpc11x_iap_call(target, &flash_pgm.p, sizeof(flash_pgm.p));
if (flash_pgm.p.result[0] != IAP_STATUS_CMD_SUCCESS) {
@@ -170,7 +170,7 @@ lpc11xx_flash_erase(struct target_s *target, uint32_t addr, int len)
/* and now erase them */
flash_pgm.p.command[0] = IAP_CMD_ERASE;
flash_pgm.p.command[1] = addr / 4096;
- flash_pgm.p.command[2] = (addr + len) / 4096;
+ flash_pgm.p.command[2] = (addr + len - 1) / 4096;
flash_pgm.p.command[3] = 12000; /* XXX safe to assume this? */
lpc11x_iap_call(target, &flash_pgm.p, sizeof(flash_pgm.p));
if (flash_pgm.p.result[0] != IAP_STATUS_CMD_SUCCESS) {