str9x.c: remove optimization when erasing the whole bank
Using the erase bank command will cause a time out error. Replacing this with the erase sector bank will provide a slower but safer and stable method to erase the flash. Signed-off-by: Laurentiu Cocanu <laurentiu.cocanu@zylin.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
This commit is contained in:
parent
e1679a29f0
commit
24653c950a
|
@ -230,17 +230,9 @@ static int str9x_erase(struct flash_bank *bank, int first, int last)
|
||||||
return ERROR_TARGET_NOT_HALTED;
|
return ERROR_TARGET_NOT_HALTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we erase whole bank */
|
/*A slower but stable way of erasing*/
|
||||||
if ((first == 0) && (last == (bank->num_sectors - 1)))
|
/* Erase sector command */
|
||||||
{
|
erase_cmd = 0x20;
|
||||||
/* Optimize to run erase bank command instead of sector */
|
|
||||||
erase_cmd = 0x80;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Erase sector command */
|
|
||||||
erase_cmd = 0x20;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = first; i <= last; i++)
|
for (i = first; i <= last; i++)
|
||||||
{
|
{
|
||||||
|
@ -296,10 +288,6 @@ static int str9x_erase(struct flash_bank *bank, int first, int last)
|
||||||
LOG_ERROR("error erasing flash bank, status: 0x%x", status);
|
LOG_ERROR("error erasing flash bank, status: 0x%x", status);
|
||||||
return ERROR_FLASH_OPERATION_FAILED;
|
return ERROR_FLASH_OPERATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we ran erase bank command, we are finished */
|
|
||||||
if (erase_cmd == 0x80)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = first; i <= last; i++)
|
for (i = first; i <= last; i++)
|
||||||
|
|
Loading…
Reference in New Issue