This is what we called: the eye trick..Spot the problem if you can.
ret = IAP_PrepareSec(sector_index, sector_index);
if (ret != IAP_STA_CMD_SUCCESS)
while (1)
ret = IAP_CopyRAMToFlash(app_addr, (unsigned int)&data[0], 256);
if (ret != IAP_STA_CMD_SUCCESS)
while (1);