}
}
+ if (!etm_capture_drivers[i])
+ {
+ /* no supported capture driver found, don't register an ETM */
+ free(etm_ctx);
+ ERROR("trace capture driver '%s' not found", args[4]);
+ return ERROR_OK;
+ }
+
etm_ctx->target = target;
etm_ctx->trace_data = NULL;
etm_ctx->trace_depth = 0;
if (argc < 1)
{
- command_print(cmd_ctx, "usage: etm image <file> ['bin'|'ihex'|'elf'] [base address]");
+ command_print(cmd_ctx, "usage: etm image <file> [base address] [type]");
return ERROR_OK;
}
etm_ctx->image->base_address_set = 0;
etm_ctx->image->start_address_set = 0;
- for (i = 1; i < argc; i++)
+ /* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
+ if (argc >= 2)
{
- /* optional argument could be image type */
- if (identify_image_type(&etm_ctx->image->type, args[i], args[0]) == ERROR_IMAGE_TYPE_UNKNOWN)
- {
- /* if it wasn't a valid image type, treat it as the base address */
- etm_ctx->image->base_address_set = 1;
- etm_ctx->image->base_address = strtoul(args[i], NULL, 0);
- }
+ etm_ctx->image->base_address_set = 1;
+ etm_ctx->image->base_address = strtoul(args[1], NULL, 0);
}
-
- if (image_open(etm_ctx->image, args[0], FILEIO_READ) != ERROR_OK)
+ else
+ {
+ etm_ctx->image->base_address_set = 0;
+ }
+
+ if (image_open(etm_ctx->image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
{
command_print(cmd_ctx, "image opening error: %s", etm_ctx->image->error_str);
free(etm_ctx->image);
for (i = 0; i < etm_ctx->trace_depth; i++)
{
- fileio_read_u32(&file, &etm_ctx->trace_data[i].pipestat);
- fileio_read_u32(&file, &etm_ctx->trace_data[i].packet);
- fileio_read_u32(&file, &etm_ctx->trace_data[i].flags);
+ u32 pipestat, packet, flags;
+ fileio_read_u32(&file, &pipestat);
+ fileio_read_u32(&file, &packet);
+ fileio_read_u32(&file, &flags);
+ etm_ctx->trace_data[i].pipestat = pipestat & 0xff;
+ etm_ctx->trace_data[i].packet = packet & 0xffff;
+ etm_ctx->trace_data[i].flags = flags;
}
fileio_close(&file);