Created
July 13, 2022 02:54
-
-
Save mrnuke/1ec74e4fcf3562bf8809680c97d9349a to your computer and use it in GitHub Desktop.
ipq807x gpio prober and destroyer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/ash | |
qpic_gpios="443 445 446 447 448 449 451 452 453 454 455 456 457 458 459" | |
uart_gpios="465 466" | |
mdio_pins="510 511" | |
stay_the_fuck_away="$qpic_gpios $uart_gpios $mdio_pins" | |
is_forbidden() { | |
local gpio_num="$1" | |
for forbidden in $stay_the_fuck_away; do | |
if [ "$gpio_num" = "$forbidden" ]; then | |
true | |
return | |
fi | |
done | |
false | |
} | |
for gpio_num in $(seq 442 511); do | |
gpio="/sys/class/gpio/gpio$gpio_num" | |
if is_forbidden $gpio_num; then | |
echo "Skipping $gpio_num" | |
continue | |
fi | |
if [ ! -d "$gpio" ]; then | |
echo "$gpio_num" > /sys/class/gpio/export | |
fi | |
if [ ! -d "$gpio" ]; then | |
continue | |
fi | |
echo "GPIO$gpio_num = out (hi) -- in 1 sec" | |
sleep 1 | |
echo out > "$gpio/direction" | |
echo 1 > "$gpio/value" | |
done | |
for gpio_num in $(seq 442 511); do | |
gpio="/sys/class/gpio/gpio$gpio_num" | |
if [ ! -d "$gpio" ]; then | |
continue | |
fi | |
echo 0 > "$gpio/value" | |
echo "GPIO$gpio_num = 0" | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment