aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOlivier Schonken <olivier.schonken@gmail.com>2012-06-04 07:33:15 +0200
committerSpencer Oliver <spen@spen-soft.co.uk>2012-06-26 13:51:59 +0000
commit24a1e7b0fc6b18fd2b8e6f5486d2cece8e1d0d8e (patch)
tree732a8b9c1009f8008bd8c8c8fc32b3e1b67604ab /src
parent5b0a1315948252ddde03fc74763ef8300c5f329c (diff)
Changed SAM4S Erase for effective Sector erase
In the previous iteration, the page counter for erases would not be updated with the erase size. This patch keeps the page counter synced with the sector counter. Signed-off-by: Olivier Schonken <olivier.schonken@gmail.com> Change-Id: I95e56a3257b2ad8301c9f28167b842fa6466334f Reviewed-on: http://openocd.zylin.com/686 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/flash/nor/at91sam4.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c
index c009a139..fd98b7f0 100644
--- a/src/flash/nor/at91sam4.c
+++ b/src/flash/nor/at91sam4.c
@@ -1678,6 +1678,9 @@ static int sam4_erase(struct flash_bank *bank, int first, int last)
struct sam4_bank_private *pPrivate;
int r;
int i;
+ int pageCount;
+ /*16 pages equals 8KB - Same size as a lock region*/
+ pageCount = 16;
uint32_t status;
LOG_DEBUG("Here");
@@ -1705,7 +1708,7 @@ static int sam4_erase(struct flash_bank *bank, int first, int last)
LOG_INFO("sam4 First: 0x%08x Last: 0x%08x", (unsigned int)(first), (unsigned int)(last));
for (i = first; i <= last; i++) {
/*16 pages equals 8KB - Same size as a lock region*/
- r = FLASHD_ErasePages(pPrivate, i, 16, &status);
+ r = FLASHD_ErasePages(pPrivate, (i * pageCount), pageCount, &status);
LOG_INFO("Erasing sector: 0x%08x", (unsigned int)(i));
if (r != ERROR_OK)
LOG_ERROR("SAM4: Error performing Erase page @ lock region number %d",