So this section now looks like:
Code: Select all
fl_BootImageInfo image;
fl_BootImageInfo factory_image;
int flashstatus = fl_getFactoryImage(image);
factory_image = image;
if (flashstatus != 0)
{
debug_printf("No factory image exists in flash\n");
DFU_STATUS = no_factory_image; // No factory image
return 0;
}
else
{
flashstatus = fl_getNextBootImage(image);
if (flashstatus != 0)
{
// No upgrade image exists in flash
debug_printf("No upgrade image exists in flash\n");
debug_printf("Check Point A\n");
}
int result;
do
{
if (flashstatus != 0)
{
result = fl_startImageAdd(factory_image, FLASH_MAX_UPGRADE_IMAGE_SIZE, 0);
debug_printf("Check Point B. result = %d\n", result);
}
else
{
result = fl_startImageReplace(image, FLASH_MAX_UPGRADE_IMAGE_SIZE);
debug_printf("Check Point C. result = %d\n", result);
}
} while (result > 0);