diff options
author | Øyvind Harboe <oyvind.harboe@zylin.com> | 2010-12-14 09:26:08 +0100 |
---|---|---|
committer | Øyvind Harboe <oyvind.harboe@zylin.com> | 2010-12-15 09:48:37 +0100 |
commit | 969b1e66dd46fff70168a69dbd4beaaa18ccb490 (patch) | |
tree | f6c1f923b6047242ad142341ace220f1745b14cd /src/flash | |
parent | 39dbb516a4489c6a934669876774ebc711a0b781 (diff) | |
download | openocd+libswd-969b1e66dd46fff70168a69dbd4beaaa18ccb490.tar.gz openocd+libswd-969b1e66dd46fff70168a69dbd4beaaa18ccb490.tar.bz2 openocd+libswd-969b1e66dd46fff70168a69dbd4beaaa18ccb490.tar.xz openocd+libswd-969b1e66dd46fff70168a69dbd4beaaa18ccb490.zip |
stm32: fix unprotect
the unprotect fn in stm32 needs to unprotect more sectors
than was requested aligned to some boundary.
Print warning when this happens.
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src/flash')
-rw-r--r-- | src/flash/nor/stm32x.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/flash/nor/stm32x.c b/src/flash/nor/stm32x.c index 0edadfd2..3c49b8be 100644 --- a/src/flash/nor/stm32x.c +++ b/src/flash/nor/stm32x.c @@ -487,12 +487,19 @@ static int stm32x_protect(struct flash_bank *bank, int set, int first, int last) return ERROR_TARGET_NOT_HALTED; } - if ((first && (first % stm32x_info->ppage_size)) || ((last + 1) && - (last + 1) % stm32x_info->ppage_size)) + if ((first % stm32x_info->ppage_size) != 0) { - LOG_WARNING("Error: start and end sectors must be on a %d sector boundary", + LOG_WARNING("aligned start protect sector to a %d sector boundary", stm32x_info->ppage_size); - return ERROR_FLASH_SECTOR_INVALID; + first = first - (first % stm32x_info->ppage_size); + } + if (((last + 1) % stm32x_info->ppage_size) != 0) + { + LOG_WARNING("aligned end protect sector to a %d sector boundary", + stm32x_info->ppage_size); + last++; + last = last - (last % stm32x_info->ppage_size); + last--; } /* medium density - each bit refers to a 4bank protection |