diff options
author | Spencer Oliver <spen@spen-soft.co.uk> | 2012-05-03 10:44:42 +0100 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2012-05-14 09:37:50 +0000 |
commit | e85845150532528b2996f828b108de81340c029e (patch) | |
tree | 0efcdaf401d53298ede0577208c629b7c22f3919 /src/flash/nor/pic32mx.c | |
parent | cad59911356d226525238f1be00697f472ece5ef (diff) |
flash: fix protect check for pic32mx1x/2x family
Change-Id: Ib2692d8b79e52cd40f429008047494aa7f552984
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/612
Tested-by: jenkins
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
Diffstat (limited to 'src/flash/nor/pic32mx.c')
-rw-r--r-- | src/flash/nor/pic32mx.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c index 248e0615..8cd0fe65 100644 --- a/src/flash/nor/pic32mx.c +++ b/src/flash/nor/pic32mx.c @@ -275,8 +275,13 @@ static int pic32mx_protect_check(struct flash_bank *bank) num_pages = 0; /* All pages unprotected */ else num_pages = 0xffff; /* All pages protected */ - } else /* pgm flash */ - num_pages = (~devcfg0 >> 12) & 0xff; + } else { + /* pgm flash */ + if (pic32mx_info->dev_type == MX_1_2) + num_pages = (~devcfg0 >> 10) & 0x3f; + else + num_pages = (~devcfg0 >> 12) & 0xff; + } for (s = 0; s < bank->num_sectors && s < num_pages; s++) bank->sectors[s].is_protected = 1; |