On rockpi, enable everyone to access ftrace

This is handy for debugging timing issues.  We have passwordless root
already, so there's no real security issue.

Change-Id: I5c9890b8e11b11462750fcac48e2f6336819d71f
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/rockpi/contents/etc/systemd/system/frc971chrt.service b/frc971/rockpi/contents/etc/systemd/system/frc971chrt.service
index 6086fa0..1fc304e 100644
--- a/frc971/rockpi/contents/etc/systemd/system/frc971chrt.service
+++ b/frc971/rockpi/contents/etc/systemd/system/frc971chrt.service
@@ -1,9 +1,10 @@
 [Unit]
-Description=Configure IRQs
+Description=Configure tracing to be available by everyone
+After=sys-kernel-tracing.mount
 
 [Service]
 Type=oneshot
-ExecStart=/home/pi/bin/chrt.sh
+ExecStart=/root/bin/chrt.sh
 
 [Install]
 WantedBy=multi-user.target
diff --git a/frc971/rockpi/contents/root/bin/chrt.sh b/frc971/rockpi/contents/root/bin/chrt.sh
new file mode 100644
index 0000000..4a6b917
--- /dev/null
+++ b/frc971/rockpi/contents/root/bin/chrt.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -ex
+
+chmod a+rwx /sys/kernel/debug
+
+# Make sure /sys/kernel/tracing is reasonably accessible so --enable_ftrace
+# works.
+chmod a+w /sys/kernel/tracing/trace_marker
+echo 10000 > /sys/kernel/tracing/buffer_size_kb
+chmod a+rw /sys/kernel/tracing/tracing_on
+chmod a+rwx /sys/kernel/tracing
+
+# Make sure we never scale the CPUs down.
+# This takes time to do which we don't have...
+cat /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq > \
+  /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
+cat /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freq > \
+  /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq