Artem Shakirov Posted April 19, 2023 Share Posted April 19, 2023 (edited) I can't set up gpio-poweroff feature described here. I tried made overlays from here and here - no effect. U-boot boots with no errors. Then i am tried to edit DT (armbian-config > System > Dtc), - manually add node at pinctrl@1c20800: Скрытый текст pwr_off_pins: pwr_off_pins { pins = "PA21"; function = "gpio_out"; }; and node at "/": Скрытый текст gpio-poweroff { compatible = "gpio-poweroff"; pinctrl-names = "default"; pinctrl-0 = <&pwr_off_pins>; gpios = <&pio 0 21 0>; }; where 0 21 0 means "PA 21 drive_active_high", i assume. So "Reference to non-existent node or label "pio"" error is occured. Then I use gpios = <0x0e 0x00 0x15 0x00>; for PA21 (like it used in leds node for pwr_led on PA10 by changing 0x0a to 0x15 (PA21)). No errors occured but it still not work. Also pwr_off_pins labels in Dtc was repaced by phandle = <0x7f>; and pinctrl-0 = <0x7f>; after compilation. PA21 is free pin. How to make it work? Welcome message: Скрытый текст ___ ____ _ ____ ____ / _ \| _ \(_) | _ \ / ___| _ | | | | |_) | | | |_) | | _| |_ | |_| | __/| | | __/| |___ |_ _| \___/|_| |_| |_| \____| |_| Welcome to Armbian 23.02.2 Jammy with Linux 5.15.93-sunxi System load: 2% Up time: 29 min Local users: 3 Memory usage: 27% of 967M IP: :-) CPU temp: 47°C Usage of /: 68% of 7.0G Edited April 21, 2023 by Artem Shakirov 0x0e port 0 Quote Link to comment Share on other sites More sharing options...
Artem Shakirov Posted April 20, 2023 Author Share Posted April 20, 2023 As workaround, now I am using "gpio-leds" to copy power led to PA21 😄 Скрытый текст /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target-path = "/leds"; __overlay__ { pwr_led_1 { label = "orangepi:blue:pwr"; gpios = <0x0e 0x00 0x15 0x00>; default-state = "on"; }; }; }; }; So, when halt message appears, PA21 turns off. And I can turn off the whole device by relay. 0 Quote Link to comment Share on other sites More sharing options...
going Posted April 20, 2023 Share Posted April 20, 2023 (edited) 19.04.2023 в 16:10, Artem Shakirov сказал: where 0 21 0 means "PA 21 drive_active_high", i assume. So "Reference to non-existent node or label "pio"" error is occured. Then I use gpios = <0x3e 0x00 0x15 0x00>; for PA21 (like it used in leds node for pwr_led on PA10 by changing 0x0a to 0x15 (PA21)). No errors occured but it still not work. Also pwr_off_pins labels in Dtc was repaced by phandle = <0x7f>; and pinctrl-0 = <0x7f>; after compilation. PA21 is free pin. How to make it work? Good health! I think I may misunderstand because of the translation. Please state the problem in simpler phrases and only text, and give the overlay code that does not work for you in its entirety. That's before compilation. P.S. @Artem Shakirov Artem, The problem may be inversion. It is necessary to look at how the power button should be connected on the device. Edited April 20, 2023 by going P.S. 0 Quote Link to comment Share on other sites More sharing options...
Artem Shakirov Posted April 21, 2023 Author Share Posted April 21, 2023 (edited) 13 часов назад, going сказал: Good health! Good health, going! Thank you for you answer! And sorry for my English😓 What I want: When OPi PC turns off, "reboot: System halted" is displayed on the screen. I want the PA21 to turn on at this moment. What I did with overlays: 1) I found "gpio-poweroff", described in the first link of my first message. 2) I found a thread at this forum (second link in my first message) with overlay code and changed gpio pin to PA21. Here is my overlay code that does not work: Скрытый текст /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&pio>; __overlay__ { poweroff_pins:poweroff_pins { allwinner,pins = "PA21"; allwinner,function = "gpio_out"; }; }; }; fragment@1 { target-path = "/"; __overlay__ { poweroff: poweroff { compatible = "gpio-poweroff"; gpios = <&pio 0 21 0>; }; }; }; }; 3) I found a pull request (third link in my first message) with overlay code and changed gpio pin to PA21. Here is my overlay code that does not work too: Скрытый текст /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&pio>; __overlay__ { pwr_off_pins: pwr_off_pins { pins = "PA21"; function = "gpio_out"; }; }; }; fragment@1 { target-path = "/"; __overlay__ { gpio-poweroff { compatible = "gpio-poweroff"; pinctrl-names = "default"; pinctrl-0 = <&pwr_off_pins>; gpios = <&pio 0 21 0>; }; }; }; }; What I did with armbian-config: Armbian-config menu has "Dtc" entry that opens huge file in the nano editor. I tried to change entries in this file instead of make overlays. And pasted only changes in the my first message. The end result was the same. No errors occured but it still does not work. What I expected: PA21 is configured as output. And it turned on (for 100ms) when OPi PC halted. What is happening now: PA21 isn't configured at all. And nothing happens when OPi PC halted. Edited April 21, 2023 by Artem Shakirov 0 Quote Link to comment Share on other sites More sharing options...
going Posted April 21, 2023 Share Posted April 21, 2023 5 часов назад, Artem Shakirov сказал: What I expected: PA21 is configured as output. And it turned on (for 100ms) when OPi PC halted. The buttons on the device are designed for the system's response to external influences. The button was pressed and the system did something. This also applies to the power off button. The driver reads the pin status and, when it changes, sends a signal to the system to shut down. It is assumed that the pin should be configured as an input and a button connection scheme and a device that responds to pressing the button with a delay should be implemented in order to physically turn off the supply voltage. If the button is not pressed, but there will be a signal to the system to turn off the power (sudo poweroff), then the driver emulates pressing the button. I.e., it will switch the pin as an output on its own and change the state three times. To start debugging, check whether the driver has been loaded: lsmod | grep power dmesg | grep power dmesg | grep -i warn 23 часа назад, Artem Shakirov сказал: As workaround, now I am using "gpio-leds" to copy power led to PA21 😄 Показать содержимое /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target-path = "/leds"; __overlay__ { pwr_led_1 { label = "orangepi:blue:pwr"; gpios = <0x0e 0x00 0x15 0x00>; default-state = "on"; }; }; }; }; So, when halt message appears, PA21 turns off. And I can turn off the whole device by relay. This functionality assumes the system's response to its internal state. The device is working the LED is on. You did everything right. This is not a workaround, but the right solution. In my opinion. I'll try to check on the weekend what I wrote here for you. 0 Quote Link to comment Share on other sites More sharing options...
Artem Shakirov Posted April 22, 2023 Author Share Posted April 22, 2023 8 часов назад, going сказал: The driver reads the pin status and, when it changes, sends a signal to the system to shut down. The gpio-poweroff driver is not about buttons 🙂 See https://www.kernel.org/doc/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt (first link of my first message). 0 Quote Link to comment Share on other sites More sharing options...
going Posted April 22, 2023 Share Posted April 22, 2023 @Artem Shakirov Please publish the output of the command on your device: grep -n POWER_RESET_GPIO /boot/conf* I have a suspicion that the kernel is built without this gpio-poweroff module and you will see: config:3457:# CONFIG_POWER_RESET_GPIO is not set 0 Quote Link to comment Share on other sites More sharing options...
Artem Shakirov Posted April 24, 2023 Author Share Posted April 24, 2023 22.04.2023 в 17:56, going сказал: Please publish the output of the command on your device: grep -n POWER_RESET_GPIO /boot/conf* You are absolutely right!: user@orangepipcplus:~$ grep -n POWER_RESET_GPIO /boot/conf* 3457:# CONFIG_POWER_RESET_GPIO is not set 3458:# CONFIG_POWER_RESET_GPIO_RESTART is not set I will continue to use the power LED driver. It's even more suitable. ----------------------------------------------------------------------------------------------- 22.04.2023 в 00:52, going сказал: lsmod | grep power dmesg | grep power dmesg | grep -i warn Nothing about this driver. 0 Quote Link to comment Share on other sites More sharing options...
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.