Skip to content
virtuoso edited this page Jan 30, 2012 · 5 revisions

To compile a decoder, clone etm2human tree and run make.

On your target device, once you’ve compiled a kernel with the CONFIG_OC_ETM option enabled (you will also need platform support code, which in case of OMAP is enabled with CONFIG_OMAP3_EMU), you’ll have /sys/bus/amba/devices/etm/, which implements the following:

  • trace_info: misc info about the state of etm/etb,
  • trace_running: turns tracing on and off when you echo 0 or non-zero there,
  • trace_mode: changing trace port width and cycle accurate tracing.

What you do is: you start tracing by echoing 1 to trace_running, you then stop it by echoing 0 there and you


$ dd if=/dev/tracebuf of=somewhere bs=4k

Or you can hit SysRQ+v combo, which will dump the contents of the buffer to the console in hex form. That can then be decoded by feeding it to etm2human like

$ ./etm2human -C -c 4 -i somewhere

(“-C” means “cycle accurate”, “-c 4” means 4 bytes are used to log context id, “-i” means input file; you can give it hexdumps as well with “-h” instead of “-i”). That will give you a trace of execution flow, only addresses at this point. You can then feed the addresses to addr2line or objdump if you want function names, file names and line numbers.

This will give you stuff looking like


trace flow started at c000bf24, cycle 26499, ctxid 0
insn at c000bf24: X cycle: 26387 cond: PASS
insn at c000bf28: X cycle: 26389 cond: PASS
insn at c000bf2c: X cycle: 26390 cond: PASS
insn at c000bf30: X cycle: 26390 cond: PASS
insn at c000bf34: X cycle: 26390 cond: PASS
insn at c000bf38: X cycle: 26392 cond: PASS
insn at c000bf3c: X cycle: 26392 cond: FAIL
insn at c000bf40: X cycle: 26392 cond: PASS
insn at c000bf44: X cycle: 26395 cond: PASS

which is basically an instruction flow with addresses, cycle counter and condition code pass/fail. Then, if you have a vmlinux of the kernel that’s been running when the trace was taken, you can match those addresses against it using addr2line or objdump.

If you think that the decoder is misbehaving, add a -D 15 to its command line and send me its output together with the trace that it choked on.

Clone this wiki locally