Pi shutdown [solved]

Started by sander2506, December 22, 2015, 04:17:45 AM

sander2506

When i install the shutdownscript on my pi it won't boot trough emulationstation, but it stops after the first splashscreen.
When i don't install the shutdownscript it boots normal.

Please help,

Felix


sander2506

i changed the code to see below and it boots to emulationstation, but now the shutdown button doesn't work. 
Quote#!/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=27
REBOOTPULSEMINIMUM=200      #reboot pulse signal should be at least this long
REBOOTPULSEMAXIMUM=600      #reboot pulse signal should be at most this long
echo "$SHUTDOWN" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio$SHUTDOWN/direction

#Added reboot feature (with ATXRaspi R2.6 (or ATXRaspi 2.5 with blue dot on chip)
#Hold ATXRaspi button for at least 500ms but no more than 2000ms and a reboot HIGH pulse of 500ms length will be issued

#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=22
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.2
  else 
    pulseStart=$(date +%s%N | cut -b1-13) # mark the time when Shutoff signal went HIGH (milliseconds since epoch)
    while [ $shutdownSignal = 1 ]; do
      /bin/sleep 0.02
      if [ $(($(date +%s%N | cut -b1-13)-$pulseStart)) -gt $REBOOTPULSEMAXIMUM ]; then
        echo "ATXRaspi triggered a shutdown signal, halting Rpi ... "
        sudo poweroff
        exit
      fi
      shutdownSignal=$(cat /sys/class/gpio/gpio$SHUTDOWN/value)
    done
    #pulse went LOW, check if it was long enough, and trigger reboot
    if [ $(($(date +%s%N | cut -b1-13)-$pulseStart)) -gt $REBOOTPULSEMINIMUM ]; then
      echo "ATXRaspi triggered a reboot signal, recycling Rpi ... "
      sudo reboot
      exit
    fi
  fi
done

Felix

What distribution?
What did you change? Can you dump a diff and not your whole script (specify the changes)?

sander2506

#4
sorry i changed:
SHUTDOWN=27
BOOT=22

i can fire it up with the button but i won't turn off.

raspberry pi 2

Felix

Ok, did you also change the wiring if you changed the pin definitions?
ATXRaspi works on all RaspberryPis.
What distribution means what linux distribution?

sander2506

Quote from: Felix on December 22, 2015, 08:56:38 AM
Ok, did you also change the wiring if you changed the pin definitions?
yes
boot - > GPIO22
shutdown -> GPIO27
Quote
What distribution means what linux distribution?
Wheezy?

Felix

Yes wheezy, should work just fine, that's what I used in the demo.
I would recommend switching back to the original pins and double checking everything.
I don't know what emulationstation is, if that interferes with the boot then maybe you will need to find another way to boot the shutdowncheck script.

sander2506

When i startup the system none of the lights on the ATX-Raspi light up, does that mean something?

Felix

Have you watched the ATXRaspi video?
That shows exactly what to expect and when any lights come on or go off.
Yes at the end of boot, the green LED on ATXRaspi should light up.


sander2506

got it fixed, there as a little bit of solder wrong.
thnx for the help.