mirror of https://github.com/rusefi/openocd.git
- fix bug with stm32 high density write protection
git-svn-id: svn://svn.berlios.de/openocd/trunk@858 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
parent
c77b785505
commit
dad28d0659
|
@ -385,6 +385,19 @@ int stm32x_protect(struct flash_bank_s *bank, int set, int first, int last)
|
||||||
prot_reg[2] = (u16)(protection >> 16);
|
prot_reg[2] = (u16)(protection >> 16);
|
||||||
prot_reg[3] = (u16)(protection >> 24);
|
prot_reg[3] = (u16)(protection >> 24);
|
||||||
|
|
||||||
|
if (stm32x_info->ppage_size == 2)
|
||||||
|
{
|
||||||
|
/* high density flash */
|
||||||
|
|
||||||
|
/* bit 7 controls sector 62 - 255 protection */
|
||||||
|
if (first > 61 || last <= 255)
|
||||||
|
prot_reg[3] |= (1 << 7);
|
||||||
|
|
||||||
|
if (first > 61)
|
||||||
|
first = 61;
|
||||||
|
if (last > 61)
|
||||||
|
last = 61;
|
||||||
|
|
||||||
for (i = first; i <= last; i++)
|
for (i = first; i <= last; i++)
|
||||||
{
|
{
|
||||||
reg = (i / stm32x_info->ppage_size) / 8;
|
reg = (i / stm32x_info->ppage_size) / 8;
|
||||||
|
@ -395,6 +408,21 @@ int stm32x_protect(struct flash_bank_s *bank, int set, int first, int last)
|
||||||
else
|
else
|
||||||
prot_reg[reg] |= (1 << bit);
|
prot_reg[reg] |= (1 << bit);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* medium density flash */
|
||||||
|
for (i = first; i <= last; i++)
|
||||||
|
{
|
||||||
|
reg = (i / stm32x_info->ppage_size) / 8;
|
||||||
|
bit = (i / stm32x_info->ppage_size) - (reg * 8);
|
||||||
|
|
||||||
|
if( set )
|
||||||
|
prot_reg[reg] &= ~(1 << bit);
|
||||||
|
else
|
||||||
|
prot_reg[reg] |= (1 << bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((status = stm32x_erase_options(bank)) != ERROR_OK)
|
if ((status = stm32x_erase_options(bank)) != ERROR_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Reference in New Issue