aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormirage2013-01-26 11:38:27 +0800
committermirage2013-01-26 11:38:27 +0800
commitb50b3ffa861e2fb522c52d887844c7f3952f226b (patch)
tree7bdadb40d71c8874250b620d922aa5c19f6b9c69
parent99a23a7e1ace245bdb668efc2b06ffa7b4fec47e (diff)
Error in calculating ending sector number.
-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) {