#!/bin/sh
CS=/sys/bus/coresight/devices
ETR=$CS/20070000.etr
ETM=$CS/22040000.etm
CPU=$(cat $ETM/cpu)

echo 1 > "$ETR/enable_sink"
echo 1 > "$ETM/enable_source"

taskset -c "$CPU" "$@"

echo 0 > "$ETM/enable_source"
dd if=/dev/20070000.etr of=cstrace.bin
echo 0 > "$ETR/enable_sink"
