Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Netgate 6100 - devd firing an event on power button press?

    Scheduled Pinned Locked Moved Official Netgate® Hardware
    9 Posts 4 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • luckman212L
      luckman212 LAYER 8
      last edited by luckman212

      This thread got me tinkering around with devd and I wanted to ask:

      Is there any event we can tap into for when the hardware buttons are pressed?

      something like

      notify 100 {
        match "system"         "ACPI";
        match "subsystem"      "Button";
        action "/usr/bin/logger -t test $notify";
      };
      
      GertjanG 1 Reply Last reply Reply Quote 0
      • GertjanG
        Gertjan @luckman212
        last edited by

        @luckman212
        Good question.

        I wasn't sure, never thought about it, but saw something equivalent last week :
        What happens when you press "Ctrl Alt Del" on most keyboard ?
        In the past, a soft reboot was initiated. And the very known TSR sidekick never propose me to re route that short cut to some other functionality. Like asking "are you sure ?" ?

        This (key board) sequence (was) and still is intercepted by hardware. It triggers an non maskable interrupt. The processor will jump to 'code in ROM' and do what it is told to do without any modifications possible.
        Your question blois down to : is this event interceptable ? Or, or least, can you be signalled when it happens ?
        See here : Freebsd acpi powerbutton

        The power button is probably the same thing. It's probably low level kernel (driver) stuff that handles that button, with a known result.
        See it as a security thing that can't get remapped to something else.
        But some behaviour might be customizable.

        These are my thoughts of course. I don't own a "6100".

        No "help me" PM's please. Use the forum, the community will thank you.
        Edit : and where are the logs ??

        1 Reply Last reply Reply Quote 0
        • stephenw10S
          stephenw10 Netgate Administrator
          last edited by

          The buttons are connected via an onboard microcontroller so you can't see the button status directly. You can see the output from it on the GPIO pins for the short and long press function on the power and reset buttons:

          [22.01-BETA][admin@6100.stevew.lan]/root: gpioctl -lv
          pin 00:	1	red1<OUT>, caps:<OUT>
          pin 01:	1	green1<OUT>, caps:<OUT>
          pin 02:	0	blue1<OUT>, caps:<OUT>
          pin 03:	1	amber1<OUT>, caps:<OUT>
          pin 04:	1	red2<OUT>, caps:<OUT>
          pin 05:	1	green2<OUT>, caps:<OUT>
          pin 06:	1	blue2<OUT>, caps:<OUT>
          pin 07:	1	amber2<OUT>, caps:<OUT>
          pin 08:	1	red3<OUT>, caps:<OUT>
          pin 09:	1	green3<OUT>, caps:<OUT>
          pin 10:	1	blue3<OUT>, caps:<OUT>
          pin 11:	1	amber3<OUT>, caps:<OUT>
          pin 12:	0	reset-l<IN>, caps:<IN>
          pin 13:	0	reset-s<IN>, caps:<IN>
          pin 14:	0	power-l<IN>, caps:<IN>
          pin 15:	0	power-s<IN>, caps:<IN>
          

          Steve

          1 Reply Last reply Reply Quote 0
          • luckman212L
            luckman212 LAYER 8
            last edited by

            @stephenw10 Thanks, I tried

            while true; do clear; gpioctl -l | grep power; sleep 0.1; done
            

            but when short pressing the power button I didn't see any change. Anyway, if it doesn't get hooked by devd there isn't much we can do with this anyway, right? Thanks for the info though.

            1 Reply Last reply Reply Quote 0
            • stephenw10S
              stephenw10 Netgate Administrator
              last edited by

              The short press is 3s I believe. The uc then set's the gpio to 1. Long press is 12s.

              Yeah I'm not sure how you might use it.

              Steve

              M 1 Reply Last reply Reply Quote 0
              • M
                mer @stephenw10
                last edited by

                @stephenw10 I know this thread is about the 6100, but on the 5100 isn't the power button tied to a graceful shutdown?
                Something like that would be a useful thing to do on the 6100 if it's not already done.

                1 Reply Last reply Reply Quote 0
                • luckman212L
                  luckman212 LAYER 8
                  last edited by

                  @stephenw10 Any chance that in the future we could get the power button to fire notify events to devd upon a momentary press (< 3s)? It would be cool to be able to execute a custom command.

                  E.g. if you lock yourself out of the firewall you could do something like this to hook the enableallowallwan script:

                  /usr/local/etc/devd/custom.conf:

                  notify 100 {
                    match "system"         "ACPI";
                    match "subsystem"      "PwrButton";
                    action "/usr/local/sbin/pfSsh.php playback enableallowallwan";
                  };
                  

                  (security risk understood -- just an example!)

                  stephenw10S 1 Reply Last reply Reply Quote 0
                  • stephenw10S
                    stephenw10 Netgate Administrator
                    last edited by

                    The power button on the 6100 does power the device down like 5100 except you have to hold it down for 3s rather than momentary press. It then triggers the ACPI shutdown like any other device. The long press triggers immediate power off in a similar way to other devices.

                    Steve

                    1 Reply Last reply Reply Quote 1
                    • stephenw10S
                      stephenw10 Netgate Administrator @luckman212
                      last edited by

                      @luckman212 said in Netgate 6100 - devd firing an event on power button press?:

                      Any chance that in the future we could get the power button to fire notify events to devd upon a momentary press (< 3s)?

                      Since the button is only connected to the uc it would require a code update for the controller and that requires reflashing the SPI chip. It have to be a really good reason! 😉

                      Steve

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.