Pimoroni OnOff Shim working on Recalbox
-
Little contribution to get Pimoroni OnOff Shim working with Recalbox (tested with version 18.04.20 on RPi 3B).
OnOff Shim is an affordable $7, compact, well-designed SHIM for adding momentary on/off button with safe shutdown and cutting off power that's essential for running off of battery.
https://shop.pimoroni.com/products/onoff-shim
SSH into Recalbox and remount read/writable:
mount -o remount, rw /boot mount -o remount, rw /
Backup then add the following line to /boot/config.txt:
dtoverlay=gpio-poweroff,gpiopin=4,active_low=1,input=1
Backup then uncomment the following line in /recalbox/share/system/recalbox.conf by removing the semicolon at the beginning of the line:
system.power.switch=PIN56PUSH https://github.com/recalbox/recalbox-os/wiki/Add-a-start-stop-button-to-your-recalbox-(EN)
Backup then replace /recalbox/scripts/rpi-pin56-power.py with this modified version:
import RPi.GPIO as GPIO import os import argpa**e pa**er = argpa**e.ArgumentPa**er(description='power manager') pa**er.add_argument("-m", help="mode onoff or push", type=str, required=True) args = pa**er.pa**e_args() mode = args.m GPIO.setmode(GPIO.BCM) # GPIO on pin 11 is the GPIO 17 in BCM mode GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP) def shutdown(): os.system("shutdown -h now") try: if mode == "push" : GPIO.wait_for_edge(17, GPIO.FALLING) shutdown() else: print("Unrecognized mode") except KeyboardInterrupt: print "" finally: print "cleaning up gpio" GPIO.cleanup()
Finally, reboot with command 'shutdown -h -r now' to take effect and test OnOff Shim functionality.
Optionally, if you prefer the longer way to add a new entry instead of reusing an existing entry then refer this post:
https://forums.pimoroni.com/t/using-onoff-shim-with-recalbox/7981/3 -
@mi7chy hey nice !
was it just a GPIO number problem ?
-
@mi7chy
Very nice, but I see one problem concerning additional hardware or just simply a fan. As it occupy all 5V an 3,3V pins. There should be some breaking out pins for this. Or is there another solution ? -
was it just a GPIO number problem ?
Issue #1 Their one-line installer script only runs on Raspbian and not Recalbox and attempting to do so will generate missing command and syntax errors.
curl https://get.pimoroni.com/onoffshim | bash
Issue #2 Per Pimoroni recent versions of Raspbian support shutdown and cutting off power with the following two dt-overlay commands in /boot/config.txt but Recalbox is missing file /boot/overlays/gpio-shutdown.dtbo. Adding the file manually still doesn't work as there appears to be dependencies or hooks. Going forward this seems like the preferred and cleaner way than running background scripts that Recalbox may want to look at.
dtoverlay=gpio-poweroff,gpiopin=4,active_low=1,input=1 dtoverlay=gpio-shutdown,gpio_pin=17,active_low=1
@Dragu
It's a SHIM (shove hat in the middle) so designed to work with HATs and pHATs. You can either solder the OnOff Shim directly onto the GPIO header then place HAT/pHAT on top. Or, solder OnOff Shim to header and stack headers on top of each other for a non-permanent solution.Btw, anyone in the US and internationally outside of Europe can get it through major distributor Digikey.
https://www.digikey.com/product-detail/en/pimoroni-ltd/PIM269/1778-1117-ND/7386673 -
@mi7chy hey !
I didn't know about these overlays ! But as it's related to kernel, and we're 2 years late on that point, i'm not surprised they don't work.
BUT : this should be solved in the next 2-3 months