rednas32Participant03/04/2015 at 19:34Post count: 2
I am trying to set up my Pi 2 to use an ATXRaspi as a powersupply so I have a on and off switch.
In order for the soft shutdown, pressing the button will run sudo halt on the Pi, I need to set up a script on the Pi. This is where I have run into problems. The Pi keeps auto shuttingdown before it even completelly boots. I have checked the ATXRaspi and it works correctly so I suspect the problem is in the script itself. Could someone with scripting knowledge, I have none myself, look at the script and let me know if anything needs to be changed to work with Retropie?
The ATXRaspi uses 2 pins on the Pi to send and receive data, the boot ok signal it receives and the shutdown signal it sends to the Pi.
The script is:
#!/bin/bash #This is GPIO 7 (pin 26 on the pinout diagram). #This is an input from ATXRaspi to the Pi. #When button is held for ~3 seconds, this pin will become HIGH signalling to this script to poweroff the Pi. SHUTDOWN=7 echo "$SHUTDOWN" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio$SHUTDOWN/direction #This is GPIO 8 (pin 24 on the pinout diagram). #This is an output from Pi to ATXRaspi and signals that the Pi has booted. #This pin is asserted HIGH as soon as this script runs (by writing "1" to /sys/class/gpio/gpio8/value) BOOT=8 echo "$BOOT" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$BOOT/direction echo "1" > /sys/class/gpio/gpio$BOOT/value echo "ATXRaspi shutdown script started: asserted pins ($SHUTDOWN=input,LOW; $BOOT=output,HIGH). Waiting for GPIO$SHUTDOWN to become HIGH..." #This loop continuously checks if the shutdown button was pressed on ATXRaspi (GPIO7 to become HIGH), and issues a shutdown when that happens. #It sleeps as long as that has not happened. while [ 1 ]; do shutdownSignal=$(cat /sys/class/gpio/gpio$SHUTDOWN/value) if [ $shutdownSignal = 0 ]; then /bin/sleep 0.5 else sudo poweroff fi done
Thanks in advance!cybergeiParticipant03/15/2015 at 21:16Post count: 2
I did not expectto find anyone with this exact same problem. Thanks for your post. I just upgraded my sdcard from an older pi to be used in this one. In my exact sme model, my raspi worked fine. Now it is the same as yours. Hereis what I suspect… I think the apt-gt upgrade affected the gpio library somehow. Looking at the script, shut down should only execute if the pin is high.
So question is, why does it think the pin is high? I will start work on this in the morning.cybergeiParticipant03/16/2015 at 06:42Post count: 2
Here is what I have got so far, first the wiring pi library needs to be updated. When I used “gpio readall” it returned that the model board could not be determined.
After updating gpio the read all command worked fine.
Next I ran through each line of the shutdowncheck.sh and now find that when the shutdown and the boot pins are programmed such as when they are written “in”, “out” or given a value, it does not actually have any effect on the pins themselves. However if I am in the terminal and program the pins directly using
gpio mode 25 out
gpio write 25 1
for example, then this has a direct affect. In my case I have put the boot pin on 25. Using the above commands turns on the boot light. But when the system starts, the boot light does not come on.
Next I will find out why, but you should start with updating the wiring pi library since likely yours is old
- You must be logged in to reply to this topic.