#include <string.h>
#include <stdlib.h>
+#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
extern target_type_t arm966e_target;
extern target_type_t arm926ejs_target;
extern target_type_t xscale_target;
+extern target_type_t cortexm3_target;
target_type_t *target_types[] =
{
&arm966e_target,
&arm926ejs_target,
&xscale_target,
+ &cortexm3_target,
NULL,
};
{
if ((retval = target->type->write_memory(target, address, 1, size, buffer)) != ERROR_OK)
return retval;
+ return ERROR_OK;
}
/* handle unaligned head bytes */
{
if ((retval = target->type->read_memory(target, address, 1, size, buffer)) != ERROR_OK)
return retval;
+ return ERROR_OK;
}
/* handle unaligned head bytes */
int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- u32 address;
u8 *buffer;
u32 buf_cnt;
u32 image_size;
target_t *target = get_current_target(cmd_ctx);
- if (argc < 2)
+ if (argc < 1)
{
- command_print(cmd_ctx, "usage: load_image <filename> <address> [type]");
+ command_print(cmd_ctx, "usage: load_image <filename> [address] [type]");
return ERROR_OK;
}
- identify_image_type(&image.type, (argc == 3) ? args[2] : NULL);
-
- image.base_address_set = 1;
- image.base_address = strtoul(args[1], NULL, 0);
+ /* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
+ if (argc >= 2)
+ {
+ image.base_address_set = 1;
+ image.base_address = strtoul(args[1], NULL, 0);
+ }
+ else
+ {
+ image.base_address_set = 0;
+ }
image.start_address_set = 0;
duration_start_measure(&duration);
- if (image_open(&image, args[0], FILEIO_READ) != ERROR_OK)
+ if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
{
command_print(cmd_ctx, "load_image error: %s", image.error_str);
return ERROR_OK;
fileio_close(&fileio);
duration_stop_measure(&duration, &duration_text);
- command_print(cmd_ctx, "dumped %lli byte in %s", fileio.size, duration_text);
+ command_print(cmd_ctx, "dumped %"PRIi64" byte in %s", fileio.size, duration_text);
free(duration_text);
return ERROR_OK;