1 #!/bin/bash
2 #Deamon to crash kernel on a GPIO button
3 #Crashes kernel using sysrq
4 #https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html
6 #Detect the board on which the script is running
7 BRD=`cat /proc/device-tree/model`
9 # Setup SW11(SYS_IRQz) => WAKEUP GPIO0_7 (CTRLMMR_WKUP_PADCONFIG51)
10 devmem2 0x4301c0cc w 0x44007
12 #Setup GPIO muxmode and input
13 echo 7 > /sys/class/gpio/export
14 echo in > /sys/class/gpio/gpio7/direction
16 # Setup SW10(SOC_EXTINTn) => MAIN GPIO0_7 (CTRLMMR_PADCONFIG0)
17 devmem2 0x11c000 w 0x44007
19 #Setup GPIO muxmode and input
20 echo 84 > /sys/class/gpio/export
21 echo in > /sys/class/gpio/gpio84/direction
23 #Wait till the button is pressed and crash the kernel
24 while true;
25 do
26 val=`cat /sys/class/gpio/gpio7/value`
27 if [ $val -eq "0" ]; then
28 wall "SW11 button pressed, Crashing the root cell (Cluster VM)"
29 msleep 100
30 echo c > /proc/sysrq-trigger
31 fi
33 val=`cat /sys/class/gpio/gpio84/value`
34 if [ $val -eq "0" ]; then
35 wall "SW10 button pressed, Crashing the inmate cell (Infotainment VM)"
36 msleep 100
37 jailhouse cell destroy 1
38 fi
40 msleep 100
41 done &