#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 */
register_command(cmd_ctx, NULL, "wp", handle_wp_command, COMMAND_EXEC, "set watchpoint <address> <length> <r/w/a> [value] [mask]");
register_command(cmd_ctx, NULL, "rwp", handle_rwp_command, COMMAND_EXEC, "remove watchpoint <adress>");
- register_command(cmd_ctx, NULL, "load_image", handle_load_image_command, COMMAND_EXEC, "load_image <file> <address> ['bin'|'ihex']");
+ register_command(cmd_ctx, NULL, "load_image", handle_load_image_command, COMMAND_EXEC, "load_image <file> <address> ['bin'|'ihex'|'elf']");
register_command(cmd_ctx, NULL, "dump_image", handle_dump_image_command, COMMAND_EXEC, "dump_image <file> <address> <size>");
register_command(cmd_ctx, NULL, "load_binary", handle_load_image_command, COMMAND_EXEC, "[DEPRECATED] load_binary <file> <address>");
register_command(cmd_ctx, NULL, "dump_binary", handle_dump_image_command, COMMAND_EXEC, "[DEPRECATED] dump_binary <file> <address> <size>");
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;
int handle_wp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
target_t *target = get_current_target(cmd_ctx);
+ int retval;
if (argc == 0)
{
{
data_mask = strtoul(args[4], NULL, 0);
}
- watchpoint_add(target, strtoul(args[0], NULL, 0), strtoul(args[1], NULL, 0), type, data_value, data_mask);
+
+ if ((retval = watchpoint_add(target, strtoul(args[0], NULL, 0),
+ strtoul(args[1], NULL, 0), type, data_value, data_mask)) != ERROR_OK)
+ {
+ switch (retval)
+ {
+ case ERROR_TARGET_NOT_HALTED:
+ command_print(cmd_ctx, "target must be halted to set watchpoints");
+ break;
+ case ERROR_TARGET_RESOURCE_NOT_AVAILABLE:
+ command_print(cmd_ctx, "no more watchpoints available");
+ break;
+ default:
+ command_print(cmd_ctx, "unknown error, watchpoint not set");
+ break;
+ }
+ }
}
else
{