dandan7932 Posted January 8 Posted January 8 Hello and Happy New Year my lovely Armbian friends! I am aware that this topic is a reoccurring one, having abused the search function beyond its functional capabilities I have found the following threads that deal with somekind of sleep and wake with separate pins for each function: how to wake up OPi3 gpio to inform of system shutdown I would like to know if it is possible to have 1 pin act as both sleep and wake depending on its voltage? - if so how could i modify one of those dts in the first link? I am new to dts so not sure how the pin mappings are assigned. for example, I have a DRV5053 hall effect sensor that will act as a magnetic switch, when the magnet is near (sleep here) the output voltage increases to max of 2v, when the magnet is away (wake here) the output voltage drops to near 0v. I am using pygame to run a GUI for a small oled screen, it is ok if the GUI restarts as it is launched after autologin by .bashrc (which i assume gets reloaded on system wake?) .. however I would like to use sleep and wake to preserve the current state within the GUI, as the boot time from completely disconnecting power & reconnecting (as if a physical switch) is a little long at around a full minute.. Thank you so much for your help 0 Quote
dandan7932 Posted January 22 Author Posted January 22 (edited) hey, so i have the following dts (modified from wakeup-orange-pi3) that I think makes the power off button also work as a "wake from sleep".. However I am unsure how to set it so that when pin PG8 is pulled low, the device wakes up.. Am I correct in thinking it has to do with the '1' or '0' at the end of: "gpios = <&pio 6 8 1>"? also should it be set as "gpio_in"? as it will be an input pin? /* * Power On/Off button for NanoPi Neo (1.4/Core) * */ /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&pio>; __overlay__ { poweroff_pins:poweroff_pins { allwinner,pins = "PG8"; allwinner,function = "gpio_out"; }; }; }; fragment@1 { target-path = "/"; __overlay__ { poweroff: poweroff { compatible = "gpio-poweroff"; gpios = <&pio 6 8 1>; }; }; }; }; Edited January 22 by dandan7932 0 Quote
dandan7932 Posted January 28 Author Posted January 28 Hello everyone, I am still looking for help with this, if anyone can.. I have sleep function working with the magnet sensor but I am having issues with the wakeup.. I wonder if it is possible to use something like the following command: echo “+30” > /sys/class/rtc/rtc0/wakealarm but instead of adding 30, can it be triggered by a gpio pin going high or low? I am using pygame to trigger the sleep function by using os.system(echo mem > /sys/power/state).. 0 Quote
dandan7932 Posted January 31 Author Posted January 31 (edited) ok so I found this post by Deoptim that has this a dtoverlay that WORKS to poweroff the NanoPi Neo: /dts-v1/; /plugin/; / { compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5"; /* * This fragment is needed only for the internal pull-up activation, * external pull-up resistor is highly recommended if using long wires */ fragment@0 { target = <&pio>; __overlay__ { gpio_button_0: gpio_button_0 { pins = "PG6"; function = "gpio_in"; bias-pull-up; }; }; }; fragment@1 { target-path = "/"; __overlay__ { gpio-keys-user { /* * Use "gpio-keys" for EINT capable pins, "gpio-keys-polled" for other pins * add "poll-interval" property if using "gpio-keys-polled" */ compatible = "gpio-keys"; pinctrl-names = "default"; pinctrl-0 = <&gpio_button_0>; power_button { label = "GPIO Key Power"; linux,code = <116>; /* KEY_POWER, see include/uapi/linux/input-event-codes.h */ gpios = <&pio 6 6 1>; /* PG6 GPIO_ACTIVE_LOW */ }; }; }; }; }; I tried changing the linux,code=<116> to =<143> (for linux wakeup button) as per the link on the same line but it does not wake up the NanoPi from sleep when using either : os.system("echo mem > /sys/power/state") or os.system("sudo systemctl suspend") from my python file.. can anyone shed some light as to why the wake-up "number" doesn't work, yet the power-off "number" does? thank you EDIT: I am using the above as a user-overlay, should it perhaps be installed as a system-overlay to enable to EINT function? Edited January 31 by dandan7932 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.