struct duration bench;
duration_start(&bench);
- if (image_open(&image, CMD_ARGV[0], (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK)
+ retval = image_open(&image, CMD_ARGV[0], (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL);
+ if (retval != ERROR_OK)
{
- return ERROR_OK;
+ return retval;
}
image_size = 0x0;
fastload = (struct FastLoad *)malloc(sizeof(struct FastLoad)*image.num_sections);
if (fastload == NULL)
{
+ command_print(CMD_CTX, "out of memory");
image_close(&image);
return ERROR_FAIL;
}
{
command_print(CMD_CTX, "error allocating buffer for section (%d bytes)",
(int)(image.sections[i].size));
+ retval = ERROR_FAIL;
break;
}
if (fastload[i].data == NULL)
{
free(buffer);
+ command_print(CMD_CTX, "error allocating buffer for section (%d bytes)",
+ length);
+ retval = ERROR_FAIL;
break;
}
memcpy(fastload[i].data, buffer + offset, length);
command_print(CMD_CTX, "Write to 0x%08x, length 0x%08x",
(unsigned int)(fastload[i].address),
(unsigned int)(fastload[i].length));
- if (retval == ERROR_OK)
+ retval = target_write_buffer(target, fastload[i].address, fastload[i].length, fastload[i].data);
+ if (retval != ERROR_OK)
{
- retval = target_write_buffer(target, fastload[i].address, fastload[i].length, fastload[i].data);
+ break;
}
size += fastload[i].length;
}
- int after = timeval_ms();
- command_print(CMD_CTX, "Loaded image %f kBytes/s", (float)(size/1024.0)/((float)(after-ms)/1000.0));
+ if (retval == ERROR_OK)
+ {
+ int after = timeval_ms();
+ command_print(CMD_CTX, "Loaded image %f kBytes/s", (float)(size/1024.0)/((float)(after-ms)/1000.0));
+ }
return retval;
}