int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_dump_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int handle_test_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_bp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_rbp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_wp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
{
register_command(cmd_ctx, NULL, "targets", handle_targets_command, COMMAND_EXEC, "change the current command line target (one parameter) or lists targets (with no parameter)");
- register_command(cmd_ctx, NULL, "virt2phys", handle_virt2phys_command, COMMAND_ANY, "translate a virtual address into a physical address");
- register_command(cmd_ctx, NULL, "profile", handle_profile_command, COMMAND_EXEC, "profiling samples the CPU PC");
- register_command(cmd_ctx, NULL, "fast_load_image", handle_fast_load_image_command, COMMAND_ANY,
- "same args as load_image, image stored in memory - mainly for profiling purposes");
-
- register_command(cmd_ctx, NULL, "fast_load", handle_fast_load_command, COMMAND_ANY,
- "loads active fast load image to current target - mainly for profiling purposes");
register_jim(cmd_ctx, "target", jim_target, "configure target" );
-
- /* script procedures */
- register_jim(cmd_ctx, "ocd_mem2array", jim_mem2array, "read memory and return as a TCL array for script processing");
- register_jim(cmd_ctx, "ocd_array2mem", jim_array2mem, "convert a TCL array to memory locations and write the values");
return ERROR_OK;
}
/* handle unaligned head bytes */
if (address % 4)
{
- int unaligned = 4 - (address % 4);
+ u32 unaligned = 4 - (address % 4);
if (unaligned > size)
unaligned = size;
/* handle unaligned head bytes */
if (address % 4)
{
- int unaligned = 4 - (address % 4);
+ u32 unaligned = 4 - (address % 4);
if (unaligned > size)
unaligned = size;
{
u8 *buffer;
int retval;
- int i;
+ u32 i;
u32 checksum = 0;
if (!target->type->examined)
{
int target_register_user_commands(struct command_context_s *cmd_ctx)
{
int retval = ERROR_OK;
+
+
+ /* script procedures */
+ register_command(cmd_ctx, NULL, "profile", handle_profile_command, COMMAND_EXEC, "profiling samples the CPU PC");
+ register_jim(cmd_ctx, "ocd_mem2array", jim_mem2array, "read memory and return as a TCL array for script processing");
+ register_jim(cmd_ctx, "ocd_array2mem", jim_array2mem, "convert a TCL array to memory locations and write the values");
+
+ register_command(cmd_ctx, NULL, "fast_load_image", handle_fast_load_image_command, COMMAND_ANY,
+ "same args as load_image, image stored in memory - mainly for profiling purposes");
+
+ register_command(cmd_ctx, NULL, "fast_load", handle_fast_load_command, COMMAND_ANY,
+ "loads active fast load image to current target - mainly for profiling purposes");
+
+
+ register_command(cmd_ctx, NULL, "virt2phys", handle_virt2phys_command, COMMAND_ANY, "translate a virtual address into a physical address");
register_command(cmd_ctx, NULL, "reg", handle_reg_command, COMMAND_EXEC, "display or set a register");
register_command(cmd_ctx, NULL, "poll", handle_poll_command, COMMAND_EXEC, "poll target state");
register_command(cmd_ctx, NULL, "wait_halt", handle_wait_halt_command, COMMAND_EXEC, "wait for target halt [time (s)]");
register_command(cmd_ctx, NULL, "load_image", handle_load_image_command, COMMAND_EXEC, "load_image <file> <address> ['bin'|'ihex'|'elf'|'s19'] [min_address] [max_length]");
register_command(cmd_ctx, NULL, "dump_image", handle_dump_image_command, COMMAND_EXEC, "dump_image <file> <address> <size>");
register_command(cmd_ctx, NULL, "verify_image", handle_verify_image_command, COMMAND_EXEC, "verify_image <file> [offset] [type]");
+ register_command(cmd_ctx, NULL, "test_image", handle_test_image_command, COMMAND_EXEC, "test_image <file> [offset] [type]");
if((retval = target_request_register_commands(cmd_ctx)) != ERROR_OK)
return retval;
return retval;
}
+ if (argc == 1)
+ {
+ int wait;
+ char *end;
+
+ wait = strtoul(args[0], &end, 0);
+ if (!*end && !wait)
+ return ERROR_OK;
+ }
+
return handle_wait_halt_command(cmd_ctx, cmd, args, argc);
}
return ERROR_OK;
}
-int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+int handle_verify_image_command_internal(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, int verify)
{
u8 *buffer;
u32 buf_cnt;
break;
}
- /* calculate checksum of image */
- image_calculate_checksum( buffer, buf_cnt, &checksum );
-
- retval = target_checksum_memory(target, image.sections[i].base_address, buf_cnt, &mem_checksum);
- if( retval != ERROR_OK )
+ if (verify)
{
- free(buffer);
- break;
- }
+ /* calculate checksum of image */
+ image_calculate_checksum( buffer, buf_cnt, &checksum );
- if( checksum != mem_checksum )
- {
- /* failed crc checksum, fall back to a binary compare */
- u8 *data;
-
- command_print(cmd_ctx, "checksum mismatch - attempting binary compare");
-
- data = (u8*)malloc(buf_cnt);
-
- /* Can we use 32bit word accesses? */
- int size = 1;
- int count = buf_cnt;
- if ((count % 4) == 0)
+ retval = target_checksum_memory(target, image.sections[i].base_address, buf_cnt, &mem_checksum);
+ if( retval != ERROR_OK )
{
- size *= 4;
- count /= 4;
+ free(buffer);
+ break;
}
- retval = target->type->read_memory(target, image.sections[i].base_address, size, count, data);
- if (retval == ERROR_OK)
+
+ if( checksum != mem_checksum )
{
- int t;
- for (t = 0; t < buf_cnt; t++)
+ /* failed crc checksum, fall back to a binary compare */
+ u8 *data;
+
+ command_print(cmd_ctx, "checksum mismatch - attempting binary compare");
+
+ data = (u8*)malloc(buf_cnt);
+
+ /* Can we use 32bit word accesses? */
+ int size = 1;
+ int count = buf_cnt;
+ if ((count % 4) == 0)
{
- if (data[t] != buffer[t])
- {
- command_print(cmd_ctx, "Verify operation failed address 0x%08x. Was 0x%02x instead of 0x%02x\n", t + image.sections[i].base_address, data[t], buffer[t]);
- free(data);
- free(buffer);
- retval=ERROR_FAIL;
- goto done;
- }
- if ((t%16384)==0)
+ size *= 4;
+ count /= 4;
+ }
+ retval = target->type->read_memory(target, image.sections[i].base_address, size, count, data);
+ if (retval == ERROR_OK)
+ {
+ u32 t;
+ for (t = 0; t < buf_cnt; t++)
{
- keep_alive();
+ if (data[t] != buffer[t])
+ {
+ command_print(cmd_ctx, "Verify operation failed address 0x%08x. Was 0x%02x instead of 0x%02x\n", t + image.sections[i].base_address, data[t], buffer[t]);
+ free(data);
+ free(buffer);
+ retval=ERROR_FAIL;
+ goto done;
+ }
+ if ((t%16384)==0)
+ {
+ keep_alive();
+ }
}
}
- }
- free(data);
+ free(data);
+ }
+ } else
+ {
+ command_print(cmd_ctx, "address 0x%08x length 0x%08x", image.sections[i].base_address, buf_cnt);
}
free(buffer);
return retval;
}
+int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ return handle_verify_image_command_internal(cmd_ctx, cmd, args, argc, 1);
+}
+
+int handle_test_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ return handle_verify_image_command_internal(cmd_ctx, cmd, args, argc, 0);
+}
+
int handle_bp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
int retval;
}
/* Dump a gmon.out histogram file. */
-static void writeGmon(u32 *samples, int sampleNum, char *filename)
+static void writeGmon(u32 *samples, u32 sampleNum, char *filename)
{
- int i;
+ u32 i;
FILE *f=fopen(filename, "w");
if (f==NULL)
return;
int addressSpace=(max-min+1);
- static int const maxBuckets=256*1024; /* maximum buckets. */
- int length=addressSpace;
+ static const u32 maxBuckets = 256 * 1024; /* maximum buckets. */
+ u32 length = addressSpace;
if (length > maxBuckets)
{
length=maxBuckets;
u32 v;
const char *varname;
u8 buffer[4096];
- int i, n, e, retval;
+ int n, e, retval;
+ u32 i;
/* argv[1] = name of array to receive the data
* argv[2] = desired width
u32 v;
const char *varname;
u8 buffer[4096];
- int i, n, e, retval;
+ int n, e, retval;
+ u32 i;
/* argv[1] = name of array to get the data
* argv[2] = desired width
teap = target->event_action;
/* replace existing? */
while( teap ){
- if( teap->event == n->value ){
+ if( teap->event == (enum target_event)n->value ){
break;
}
teap = teap->next;
int i;
int ms=timeval_ms();
int size=0;
+ int retval=ERROR_OK;
for (i=0; i<fastload_num;i++)
{
- int retval;
target_t *target = get_current_target(cmd_ctx);
- if ((retval = target_write_buffer(target, fastload[i].address, fastload[i].length, fastload[i].data)) != ERROR_OK)
+ command_print(cmd_ctx, "Write to 0x%08x, length 0x%08x", fastload[i].address, fastload[i].length);
+ if (retval==ERROR_OK)
{
- return retval;
+ retval = target_write_buffer(target, fastload[i].address, fastload[i].length, fastload[i].data);
}
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));
- return ERROR_OK;
+ return retval;
}