From e85845150532528b2996f828b108de81340c029e Mon Sep 17 00:00:00 2001 From: Spencer Oliver Date: Thu, 3 May 2012 10:44:42 +0100 Subject: [PATCH] flash: fix protect check for pic32mx1x/2x family Change-Id: Ib2692d8b79e52cd40f429008047494aa7f552984 Signed-off-by: Spencer Oliver Reviewed-on: http://openocd.zylin.com/612 Tested-by: jenkins Reviewed-by: Xiaofan --- src/flash/nor/pic32mx.c | 9 +++++++-- 1 file 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; -- 2.39.5