ATXRaspi with Retropie script problem

Home Forums RetroPie Project Everything else related to the RetroPie Project ATXRaspi with Retropie script problem

RetroPie has a new website and forum. Please visit https://retropie.org.uk/ for the new site. The new forum is located at https://retropie.org.uk/forum/. This forum is left here as a read-only archive.

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of cybergei cybergei 2 years, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #90159
    Profile photo of rednas32
    rednas32
    Participant

    Hi guys,

    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!

    • This topic was modified 2 years, 1 month ago by Profile photo of rednas32 rednas32.

    #91509
    Profile photo of cybergei
    cybergei
    Participant

    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.

    #91567
    Profile photo of cybergei
    cybergei
    Participant

    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

Viewing 3 posts - 1 through 3 (of 3 total)

Forums are currently read only - please visit the new RetroPie forums at https://retropie.org.uk/forums/

Skip to toolbar