RemotePi Board now fully compatible (shutdown & boot via IR)

Moderators: odroid, mdrjr

RemotePi Board now fully compatible (shutdown & boot via IR)

Unread postby infinity85 » Fri Jun 10, 2016 1:29 am

Hi there!
I wanted to introduce the RemotePi Board from MSLdigital.com, which can be made compatible with Odroid C2 now, if you follow this guide.

Credits
At first I wanted to thank some users who helped me to sort out issues:
- Thank you Tpimp, who solved my first GPIO problems by suggesting not to use pins 8 and 10 because of UART conflict.
- And thank you very very much joerg for finally solving the power cut-off issue by pointing me to use pin 26, which is the only with actual default state 0.
- Also many thanks to Matt from MSL Digital Solutions for his patience and for providing all necessary information (especially to figure out why RemotePi Board did not cut off thr power after successful safe shutdown)


What is this board for?

Well, for those who use their Odroid or Raspberry Pi as a Media Center device this board provides an IR receiver and a power circuit as well as a power button:

  • You can power on and off your Odroid completely via arbitrary IR signal (possible to learn power toggle, as well as discrete on and off commands)
  • Also you can just push the power button for safe shutdown and boot
  • Hence RemotePi Board is responsible for standby mode (draws only some negligible mW while Odroid is completely off)
  • Safe shutdown (scripts provided by msldigital support page)
  • The board powers your Odroid through GPIO, so you'll have to plug your micro-usb power adapter into the RemotePi Board instead of Odroid
As there is no official support yet, I thought I'll give it a try and managed to make it working with some help of those guys mentioned above.

===================================================




Quick overview

    I. Is it plug and play? (Major compatibility issues to be solved or mentioned)
    II. Rewiring/Repinning GPIO connection
    III. Shutdownscripts
    IV. Using RemotePi Board IR-Receiver (general GPIO IR-Receiver) instead of Odroid onboard IR-Receiver in LibreELEC

-----------------------------------------------------------------------


I. Is it plug and play? (Major compatibility issues to be solved or mentioned)

Speaking for my RemotePi board 2015 (for Pi2) with external IR and LED (for placing IR and LED in custom cases or so)... Quick answer: NO, but... :)
  • It does not fit directly onto J2 GPIO header because the Odroids heatsink is interfering with some parts marked red in following picture:
    interfering-parts.gif
    interfering-parts.gif (71.5 KiB) Viewed 7033 times
  • To connect it somehow to the Odroid you'll need wires instead of just putting it ontop (as originally meant for RPi2) to avoid interfering with heatsink. But wachout for the cables diameter for those 4 Pins for 5V and GROUND, as the current could be up to 2A (RemotePi Board for RPi2) or even 2.6A (RemotePi Board for RPi3). Obviously this depends on how many USB devices you connect to your Odroid. And you will need wires in any case, because you must rewire some pins.
  • The RemotePi GPIO pins 8 and 10 need to be connected to different ones on the Odroid C2, because there seem to be some conflict right now (UART interface occupies those apparently and Odroids default state (1=high on Pin 8) is also not what RemotePi expects (GPIO must go into default 0=low for cutting power after shutdown). But as you need to use cables anyway for connecting the RemotePi, this is not a big deal anymore (just repinning the cables to other GPIO pins).
  • As we bypass Odroids power-circuit via powering it through GPIO, the odroids 2.5/2.6Amp over-current protection is also bypassed. Don't worry! RemotePi has also a over-current protection which should ideally match the same value. It does match it since RemotePi Board for Pi3 but in my case (RPi 2 version) it is only 2Amp. Though, this is fine, as the value is lower than Odroids ~2.6Amp, thus RemotePis polyfuse would trigger earlier if I attach too many non externally powered USB drives (which is not a good idea on a SBC anyway). In short: A RemotePi Board for Pi3 would be the best choice ;)
  • As a result of not using the UART pins for getting it to work, the RemotePi's firmware can't be configured I guess. In fact I've never made use of this feature. But if it will be necessary to configure or update the firmware, I guess you would need to rewire RemotePi Pins 8 and 10 back again to Odroids 8 and 10 for the time of firmwareupdate and back again for daily use. Or perhaps you own a Raspberry Pi and put RemotePi ontop for firmware-update purposes
This sounds like a lot of trouble... but actually it's only extending the header-connection and changing one line in the main script (and 2 lines in another script if you make use of it)


II. Rewiring/Repinning GPIO connection

As the RemotePi is originally designed for a Raspberry Pi, it is unfortunately not just plug and play. You'll need to rewire two pins (besides using wires for all pins anyway):

GPIO-Rewiring.gif
GPIO-Rewiring.gif (174.85 KiB) Viewed 7033 times


The picture above should be selfexplaining. But just for the sake of completeness:
  • Rewire RemotePi PIN 8 to Odroid-C2 PIN 26
  • Rewire RemotePi PIN 10 to Odroid-C2 PIN 7

Remarks:

  • If you don't want to use the RemotePi Board IR-Receiver for remote controlling LibreELEC, then pin 12 can be left disconnected. The board will still power on and off via learned IR remote control commands, but controlling LibreELEC GUI will be taken over by Odroids built-in IR-Receiver.
  • But if you have bought a RemotePi board with external LED and IR-Receiver, you may have chosen this for placing it somewhere in a custom case, so the built-in receiver might be hidden and useless. Then you can deactivate the Odroid IR in favour of the external GPIO-IR receiver on RemotePi Board. In this case you'll have to connect pin 12 obviously.
  • How to switch to GPIO-IR receiver in LibreELEC is described in my mini guide here



III. Shutdownscripts for safe shutdown and automatic power cut-off (LibreELEC)

These two scripts can be found (for OpenELEC on Raspberry Pi) at msldigitals support page.
Also there is a guide how to apply these scripts as well as other OS-dependent to e.g. OpenELEC/LibreELEC, RasPlex, OSMC, XBian, Volumio, RuneAudio etc.

  1. irswitch.sh: This script is for safe shutdown via IR-Remote and push-button (quasi external event). After pushing the button, the system will shutdown safely, then RemotePi will wait for the GPIO225 becoming state 0 (low), which comes after a successful system safe shutdown and finally it will cut the power completely.
  2. shutdown.sh: This script is for safe shutdown via program interface or script (quasi internal event). After navigating to the power-off button in GUI, the system will shutdown safely, then RemotePi will wait for the GPIO225 becoming state 0 (low), which comes after a successful and safe system shutdown and then it will finally cut the power completely.

Here are my Odroid compatible adaptions for LibreELEC/OpenELEC:

irswitch.sh (quasi external event from IR or push-button):
just change original msldigital script GPIOpin1=14 to GPIOpin1=225. See here at msldigital for original script and installation instructions
Code: Select all
#!/bin/bash
# prevent restarting XBMC at shutdown. This is only used for OpenElec before V5
LOCKDIR="/var/lock/"
LOCKFILE="xbmc.disabled"
# this is the GPIO pin receiving the shut-down signal
# Raspberry Pi pin8: GPIOpin1=14; Odroid-C2 pin26: GPIOpin1=225
GPIOpin1=225
# functions
add_omit_pids() {
omit_pids="$omit_pids -o $1"
}
safe_shutdown () {
# for OpenElec before V5
touch "$LOCKDIR/$LOCKFILE"
# for OpenElec V5 and later
systemctl stop kodi
add_omit_pids $(pidof connmand)
add_omit_pids $(pidof dbus-daemon)
killall5 -15 $omit_pids
for seq in `seq 1 10` ; do
usleep 500000
clear > /dev/tty1
killall5 -18 $omit_pids || break
done
sync
umount -a >/dev/null 2>&1
poweroff -f
}

echo "$GPIOpin1" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction
while true; do
  sleep 1
  power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
  if [ $power != 0 ]; then
    echo "out" > /sys/class/gpio/gpio$GPIOpin1/direction
    echo "1" > /sys/class/gpio/gpio$GPIOpin1/value
    sleep 3
    safe_shutdown
  fi
done




shutdown.sh (quasi internal event out of program or script in GUI):
just change GPIOpin=15 to GPIOpin=249 and GPIOpin1=14 to GPIOpin1=225. See here at msldigital for original script and installation instructions
Code: Select all
#!/bin/bash
if [ "$1" != "reboot" ]; then
# Raspberry Pi pin10: GPIOpin=15; Odroid-C2 pin7: GPIOpin=249
  GPIOpin=249
# Raspberry Pi pin8: GPIOpin1=14; Odroid-C2 pin26: GPIOpin1=225
  GPIOpin1=225
  echo "$GPIOpin" > /sys/class/gpio/export
  # execute shutdown sequence on pin
  echo "out" > /sys/class/gpio/gpio$GPIOpin/direction
  echo "1" > /sys/class/gpio/gpio$GPIOpin/value
  usleep 125000
  echo "0" > /sys/class/gpio/gpio$GPIOpin/value
  usleep 200000
  echo "1" > /sys/class/gpio/gpio$GPIOpin/value
  usleep 400000
  echo "0" > /sys/class/gpio/gpio$GPIOpin/value
  # set GPIO 14 high to feedback shutdown to RemotePi Board
  # because the irswitch.sh has already been terminated
  echo "$GPIOpin1" > /sys/class/gpio/export
  echo "out" > /sys/class/gpio/gpio$GPIOpin1/direction
  echo "1" > /sys/class/gpio/gpio$GPIOpin1/value
  usleep 4000000
fi


Remark to shutdown.sh:
This script is useful if you e.g. sometimes use Yatse or Kore android remote apps or hotkeys to shutdown your Media Center. Those shutdown commands equal internal events similar to navigating to kodi shutdown menu. Without using this second script the system would safely shutdown, but the RemotePi Board would not get any indication to monitor GPIO225, thus it would not cut-off power after successful shutdown.


IV. Using RemotePi Board IR-Receiver (general GPIO IR-Receiver) instead of Odroid onboard IR-Receiver in LibreELEC

If you want to use the RemotePIs IR-Receiver instead of the onboard Odroid IR-Receiver you'll have to deactivate the built-in IR and activate GPIO IR Receiver:
Last edited by infinity85 on Fri Jun 10, 2016 7:04 am, edited 1 time in total.
infinity85
 
Posts: 228
Joined: Tue May 24, 2016 4:26 am
languages_spoken: english, german
ODROIDs: Odroid C2

Re: RemotePi Board now fully compatible (shutdown & boot via

Unread postby joerg » Fri Jun 10, 2016 3:22 am

Very, very well documented. Thank you.
joerg
 
Posts: 559
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, espaƱol
ODROIDs: C1, C1+, C2

Re: RemotePi Board now fully compatible (shutdown & boot via

Unread postby odroid » Fri Jun 10, 2016 11:54 am

Great instruction !
Thank you for sharing.
User avatar
odroid
Site Admin
 
Posts: 20662
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to Hardware and peripherals

Who is online

Users browsing this forum: No registered users and 2 guests