Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for setgpio script to avoid resource busy errors #11

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions bin/setgpio
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,35 @@ if [[ -n $NINJA_HARDWARE_TYPE ]]; then
echo -e "\x07" > /sys/kernel/debug/omap_mux/gpmc_ad6
fi
if [ "$NINJA_HARDWARE_TYPE" == "BBB" ] || [ "$NINJA_HARDWARE_TYPE" == "BBW" ]; then
sudo echo "$NINJA_CAPE_DETECT_GPIO" > /sys/class/gpio/export;
if [[ -n $NINJA_CAPE_V11V12_RESETGPIO ]]; then
sudo echo "$NINJA_CAPE_V11V12_RESETGPIO" > /sys/class/gpio/export;
if [ ! -d /sys/class/gpio/gpio$NINJA_CAPE_DETECT_GPIO ] ; then
echo "$NINJA_CAPE_DETECT_GPIO" > /sys/class/gpio/export;
fi
if [[ -n $NINJA_CAPE_V121_RESETGPIO ]]; then
sudo echo "$NINJA_CAPE_V121_RESETGPIO" > /sys/class/gpio/export;
if [ -n "$NINJA_CAPE_V11V12_RESETGPIO" ] && [ ! -d /sys/class/gpio/gpio$NINJA_CAPE_V11V12_RESETGPIO ] ; then
echo "$NINJA_CAPE_V11V12_RESETGPIO" > /sys/class/gpio/export;
fi
if [ -n "$NINJA_CAPE_V121_RESETGPIO" ] && [ ! -d /sys/class/gpio/gpio$NINJA_CAPE_V121_RESETGPIO ] ; then
echo "$NINJA_CAPE_V121_RESETGPIO" > /sys/class/gpio/export;
fi
elif [ "$NINJA_HARDWARE_TYPE" == "RPI" ]; then
if [[ -n $NINJA_CRUST_V10_RESETGPIO ]]; then
sudo echo "$NINJA_CRUST_V10_RESETGPIO" > /sys/class/gpio/export;
if [ -n "$NINJA_CRUST_V10_RESETGPIO" ] && [ ! -d /sys/class/gpio/gpio$NINJA_CRUST_V10_RESETGPIO ] ; then
echo "$NINJA_CRUST_V10_RESETGPIO" > /sys/class/gpio/export;
fi
fi
sleep 1;
if [ "$NINJA_HARDWARE_TYPE" == "BBB" ] || [ "$NINJA_HARDWARE_TYPE" == "BBW" ]; then
sudo echo "in" > /sys/class/gpio/gpio$NINJA_CAPE_DETECT_GPIO/direction;
echo "in" > /sys/class/gpio/gpio$NINJA_CAPE_DETECT_GPIO/direction;
if [[ -n $NINJA_CAPE_V11V12_RESETGPIO ]]; then
sudo echo "out" > /sys/class/gpio/gpio$NINJA_CAPE_V11V12_RESETGPIO/direction;
sudo chown -R ubuntu /sys/class/gpio/gpio$NINJA_CAPE_V11V12_RESETGPIO/value
echo "out" > /sys/class/gpio/gpio$NINJA_CAPE_V11V12_RESETGPIO/direction;
chown -R ubuntu /sys/class/gpio/gpio$NINJA_CAPE_V11V12_RESETGPIO/value
fi
if [[ -n $NINJA_CAPE_V121_RESETGPIO ]]; then
sudo echo "out" > /sys/class/gpio/gpio$NINJA_CAPE_V121_RESETGPIO/direction;
sudo chown -R ubuntu /sys/class/gpio/gpio$NINJA_CAPE_V121_RESETGPIO/value
echo "out" > /sys/class/gpio/gpio$NINJA_CAPE_V121_RESETGPIO/direction;
chown -R ubuntu /sys/class/gpio/gpio$NINJA_CAPE_V121_RESETGPIO/value
fi
elif [ "$NINJA_HARDWARE_TYPE" == "RPI" ]; then
if [[ -n $NINJA_CRUST_V10_RESETGPIO ]]; then
sudo echo "out" > /sys/class/gpio/gpio$NINJA_CRUST_V10_RESETGPIO/direction;
sudo chown -R pi /sys/class/gpio/gpio$NINJA_CRUST_V10_RESETGPIO/value
echo "out" > /sys/class/gpio/gpio$NINJA_CRUST_V10_RESETGPIO/direction;
chown -R pi /sys/class/gpio/gpio$NINJA_CRUST_V10_RESETGPIO/value
fi
fi
fi
Expand Down