Erase_all now erases all upgrade images, not just the first one

This commit is contained in:
Ross Owen
2013-07-25 14:03:54 +01:00
parent 3364b3f867
commit 2cd8fbdcb6

View File

@@ -218,11 +218,33 @@ int flash_cmd_write_page_data(unsigned char *data)
int flash_cmd_erase_all(void) int flash_cmd_erase_all(void)
{ {
fl_BootImageInfo tmp_image = upgrade_image;
if (upgrade_image_valid) if (upgrade_image_valid)
{ {
if (fl_deleteImage(&upgrade_image) != 0) if (fl_deleteImage(&upgrade_image) != 0)
{
FLASH_ERROR(); FLASH_ERROR();
upgrade_image_valid = 0; }
// Keep deleting all upgrade images
// TODO Perhaps using replace would be nicer...
while(1)
{
if (fl_getNextBootImage(&tmp_image) == 0)
{
if (fl_deleteImage(&tmp_image) != 0)
{
FLASH_ERROR();
}
}
else
{
break;
}
}
upgrade_image_valid = 0;
} }
return 0; return 0;
} }