Skip to content

Instantly share code, notes, and snippets.

@wormyrocks
Created December 7, 2020 23:11
Show Gist options
  • Save wormyrocks/01497aacb1fec050a0af5994a87eb557 to your computer and use it in GitHub Desktop.
Save wormyrocks/01497aacb1fec050a0af5994a87eb557 to your computer and use it in GitHub Desktop.
raspi init_debug
#!/bin/sh
# This script is a template for debugging things that run as init (PID=1)
test_me () {
echo hello world!
lsusb
}
printf '\033[2J\033[0;0H' # clear screen
mount -t proc proc /proc
mount -t sysfs sys /sys
mount -t tmpfs tmp /run
mkdir -p run/systemd
mount /boot
test_me > /boot/log
cat /boot/log
mount /dev/mmcblk0p2 / -o remount,rw
# this gives you an interactive shell on uart0, here you can edit
# the contents of this script and read the output of test_me in /boot/log.
# ctrl-D to reboot when ready to try again
sh
# clean up
rm -r boot/log
sync
# reboot
echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment