gpio-shutdown device tree overlay

edited January 14 in General

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

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.

  • edited February 2018

    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.

  • Could you explain to me how to load the kernel module?

    use insmod

    replace KEYCODE_POWER by a direct shutdown command

    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.

    I need a little bit of jump-start here.

    https://sites.google.com/a/mtu.edu/max-jin-home-page/hints/buildandloadakernelmoduleinandroidsystem/build-and-load-a-kernel-module-in-android-system

  • Thanks for providing this info, very helpful.
  • edited August 13

    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):

    #!/usr/bin/env python3
    from gpiozero import Button
    from signal import pause
    import os, sys
    offGPIO = int(sys.argv[1]) if len(sys.argv) >= 2 else 21
    holdTime = int(sys.argv[2]) if len(sys.argv) >= 3 else 2
    # the function called to shut down the RPI
    def shutdown():
    os.system("sudo poweroff")
    btn = Button(offGPIO, hold_time=holdTime)
    btn.when_held = shutdown
    pause() # handle the button presses in the background
    

    Can a similar script be used in Emteria and loaded at boot time?

  • @Di11on said:
    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?

    I am also trying to do the same thing, only with a 12V to 5V converter. So anything would be helpful!

Sign In or Register to comment.