while ((run_address + run_size < c->base + c->size)
&& (section_last + 1 < image->num_sections))
{
- if (image->sections[section_last + 1].base_address > (run_address + run_size))
- break;
if (image->sections[section_last + 1].base_address < (run_address + run_size))
+ {
WARNING("section %d out of order", section_last + 1);
+ break;
+ }
+ if (image->sections[section_last + 1].base_address != (run_address + run_size))
+ break;
run_size += image->sections[++section_last].size;
}
if (retval != ERROR_OK)
snprintf(*error_str, FLASH_MAX_ERROR_STR, "error reading from image: %s", image->error_str);
else
-
snprintf(*error_str, FLASH_MAX_ERROR_STR, "error reading from image");
+
return ERROR_IMAGE_TEMPORARILY_UNAVAILABLE;
}
{
etb_t *etb = etm_ctx->capture_driver_priv;
u32 etb_ctrl_value = 0x1;
+ u32 trigger_count;
if ((etm_ctx->portmode & ETM_PORT_MODE_MASK) == ETM_PORT_DEMUXED)
{
if ((etm_ctx->portmode & ETM_PORT_MODE_MASK) == ETM_PORT_MUXED)
return ERROR_ETM_PORTMODE_NOT_SUPPORTED;
- etb_write_reg(&etb->reg_cache->reg_list[ETB_TRIGGER_COUNTER], 0x600);
+ trigger_count = (etb->ram_depth * etm_ctx->trigger_percent) / 100;
+
+ etb_write_reg(&etb->reg_cache->reg_list[ETB_TRIGGER_COUNTER], trigger_count);
etb_write_reg(&etb->reg_cache->reg_list[ETB_RAM_WRITE_POINTER], 0x0);
etb_write_reg(&etb->reg_cache->reg_list[ETB_CTRL], etb_ctrl_value);
jtag_execute_queue();
u32 old_index = ctx->pipe_index;
u32 last_instruction = ctx->last_instruction;
u32 cycles = 0;
+ int current_pc_ok = ctx->pc_ok;
if (ctx->trace_data[ctx->pipe_index].flags & ETMV1_TRIGGER_CYCLE)
{
break;
case 0x4: /* periodic synchronization point */
next_pc = ctx->last_branch;
+ /* if we had no valid PC prior to this synchronization point,
+ * we have to move on with the next trace cycle
+ */
+ if (!current_pc_ok)
+ {
+ command_print(cmd_ctx, "--- periodic synchronization point at 0x%8.8x ---", next_pc);
+ ctx->current_pc = next_pc;
+ ctx->pipe_index++;
+ continue;
+ }
break;
default: /* reserved */
ERROR("BUG: branch reason code 0x%x is reserved", ctx->last_branch_reason);
}
else if (retval == ERROR_TRACE_INSTRUCTION_UNAVAILABLE)
{
- /* TODO: handle incomplete images */
+ /* TODO: handle incomplete images
+ * for now we just quit the analsysis*/
+ return retval;
}
}
do {
if ((retval = etmv1_next_packet(ctx, &packet, 0)) != 0)
- return -1;
+ return ERROR_ETM_ANALYSIS_FAILED;
ctx->last_ptr &= ~(0x7f << shift);
ctx->last_ptr |= (packet & 0x7f) << shift;
shift += 7;
{
u32 data;
if (etmv1_data(ctx, 4, &data) != 0)
- return -1;
+ return ERROR_ETM_ANALYSIS_FAILED;
command_print(cmd_ctx, "data: 0x%8.8x", data);
}
}
{
u32 data;
if (etmv1_data(ctx, arm_access_size(&instruction), &data) != 0)
- return -1;
+ return ERROR_ETM_ANALYSIS_FAILED;
command_print(cmd_ctx, "data: 0x%8.8x", data);
}
}
armv4_5_common_t *armv4_5;
arm7_9_common_t *arm7_9;
etm_context_t *etm_ctx;
+ int retval;
target = get_current_target(cmd_ctx);
return ERROR_OK;
}
- etmv1_analyze_trace(etm_ctx, cmd_ctx);
+ if ((retval = etmv1_analyze_trace(etm_ctx, cmd_ctx)) != ERROR_OK)
+ {
+ switch(retval)
+ {
+ case ERROR_ETM_ANALYSIS_FAILED:
+ command_print(cmd_ctx, "further analysis failed (corrupted trace data or just end of data");
+ break;
+ case ERROR_TRACE_INSTRUCTION_UNAVAILABLE:
+ command_print(cmd_ctx, "no instruction for current address available, analysis aborted");
+ break;
+ case ERROR_TRACE_IMAGE_UNAVAILABLE:
+ command_print(cmd_ctx, "no image available for trace analysis");
+ break;
+ default:
+ command_print(cmd_ctx, "unknown error: %i", retval);
+ }
+ }
return ERROR_OK;
}