gpio-shutdown device tree overlay
Hi
The gpio-shutdown overlay is included in the Emteria distribution but when enabled via config.txt it doesn't seem to work. Your help would be appreciated.
Best,
Manuel
Tagged:
0
Comments
How is it supposed to work? I don't think Android provides default handlers for RPi-specific events. If it can generate HID keys, you will probably need an own key layout file: https://source.android.com/devices/input/key-layout-files
How should I know what is supposed to work and what not? There is no documentation and I think it is rather normal to assume that the things that are included in a commercial distribution should also work...
Anyway, I'm now using the gpio-key overlay. The kernel module this overlay depends on unfortunately doesn't get loaded automatically but is part of the distribution (to be found in /boot/modules/), so it can be inserted and afterwards the key events appear.
I didn't say you have to know what is working in emteria.OS and what is not. I was asking you about which functionality you expect from this overlay, since our platform may implement it in another (Android-specific, rather than Linux-specific) way. And if it doesn't yet, we will be glad to add it in our future releases.
You can add your own shell script to load the module at boot time to
/data/init.d
. Take a look at existing scripts in that folder, the official documentation is coming soon.Sorry, the intended functionality is as described in the documentation of the overlay: https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README
Hello kalkov. First i want to thank you and your Team for making Android on rpi3b possible.
Will my experimental androided raspi shutdown automatically if i include the gpio-shutdown.dtbo with correct parameters into config.txt? My expectation is to shutdown emteria automatically by a fallijng Signal on a gpio pin.
If Not: what to do to implement this?
Thank you in advance for an answer!
As already mentioned just enabling the overlay won't do. You'll need to load the gpio-keys kernel module (to be found in /boot/modules/). As you can see in the dto it will simply send a KEY_POWER event. The keylayouts present on Emteria will map this to Android's KEYCODE_POWER. That's the very same event as generated by the power button of your android phone. So you'll also get the exactly same functionality: Short press will turn on/off the display while long press shows you the shutdown/reboot menu.
Hello Manuel,
thank you for your Answer, very nice. Could you explain to me how to load the kernel module?
Is there any Chance to replace KEYCODE_POWER by a direct shutdown command?
I need a little bit of jump-start here. Would be very nice if you could do me this favor.
use
insmod
I don't think this overlay is designed for doing something else than sending key codes. Did you think about writing your own module for that purpose? May be faster and easier than trying to adapt the existing one to something it wasn't originally designed for.
https://sites.google.com/a/mtu.edu/max-jin-home-page/hints/buildandloadakernelmoduleinandroidsystem/build-and-load-a-kernel-module-in-android-system
Hi folks. Has anyone made any progress with this? I also am developing a system for my car and am planning to use an RPI with Emteria. To power the RPI board, I am planning to use this: https://www.tindie.com/products/picotouch/raspberry-pi-automatic-onoff-v21-new-version/
To power down the PI, it sets GPIO21 to low for 2 seconds. It comes with a raspbian python script that executes the shutdown command when this is detected (see here: https://drive.google.com/file/d/1Cs2k4Sl5oTCfqYB9mH8vIgbGtFc-qwQT/view) and I need to be able to replicate this in Emteria. Based on the above discussion, it looks like I will need to develop a kernel module to do this. I haven't done any development in android at all, so this will be a pretty interesting exercise - it would be useful if anyone has done something similar if they could share here?
Hi folks,
To elaborate a little further, this is the python script that is used to shutdown the PI when GPIO21 is pulled low for 2 seconds (my power control module does this):
Can a similar script be used in Emteria and loaded at boot time?
I am also trying to do the same thing, only with a 12V to 5V converter. So anything would be helpful!
Have a look at this topic: https://forum.emteria.com/discussion/752/raspberry-gpio-buttons-as-input-keys
Define a GPIO key and assign KEYCODE_POWER to it. A script to load the necessary kernel module is included. It should work just fine and it doesn't need python or any other package/app.
PS:
If you use 116 as kernel keycode (116 = KEY_POWER), a keyboard layout might not be needed.
Hey guys I am trying to convert a script meant to be run on rasbian to emteria, when I try to run it, it says sudo: not found, it is not compatible withe android 7.1.2/emteria 1.0
the file is named carsetup.sh and I bought the car switch from mausberrycircuits.com, it shuts of my raspberry pi automatically when the ignition is turned off and powers it on when ignition is turned on, here is the script copied and pasted:
echo '#!/bin/bash
this is the GPIO pin connected to the lead on switch labeled OUT
GPIOpin1=23
this is the GPIO pin connected to the lead on switch labeled IN
GPIOpin2=24
Enter the shutdown delay in minutes
delay=2
echo "$GPIOpin1" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction
echo "$GPIOpin2" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$GPIOpin2/direction
echo "1" > /sys/class/gpio/gpio$GPIOpin2/value
let minute=$delay60
SD=0
SS=0
SS2=0
while [ 1 = 1 ]; do
power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
uptime=$(</proc/uptime)
uptime=${uptime%%.}
current=$uptime
if [ $power = 1 ] && [ $SD = 0 ]
then
SD=1
SS=${uptime%%.*}
fi
if [ $power = 1 ] && [ $SD = 1 ]
then
SS2=${uptime%%.*}
fi
if [ "$((uptime - SS))" -gt "$minute" ] && [ $SD = 1 ] && [ $power = 1 ]
then
poweroff
SD=3
fi
if [ "$((uptime - SS2))" -gt '20' ] && [ $SD = 1 ]
then
SD=0
fi
sleep 1
done' > /etc/switch.sh
sudo chmod 777 /etc/switch.sh
sudo sed -i '$ i /etc/switch.sh &' /etc/rc.local