Which code routines are handling the shutdown button?

I am trying to find the routine which is monitoring the shutdown button (input 6) on the Sonar board.

Also, which routine actually generates the system shutdown command?

I see where pi_sonar is using the GPIO signals from the sonar board to handle the sonar sensors, but I cannot find any code/script/module which is monitoring the shutdown button GPIO input.


Looks like it is handled by an overlay and some functionality intrinsic to Linux or systemd:



The Raspberry Pi info states that a shutdown button can be set up by:


so I assume that ‘dtoverlay=ubiquity-led-buttons’ is accomplishing the same thing in some manner.

This assumption is backed up by Ubiquity’s instruction to remove ‘dtoverlay=ubiquity-led-buttons’ to free up the GPIO 6 pin for other uses.

Now to find the source for ‘/boot/overlays/ubiquity-led-buttons.dtbo’ or convert it back to human-readable.

I found the source for ‘/boot/overlays/ubiquity-led-buttons.dtbo’ at:

I tested on our Noetic 04/02 beta, the buttons work, and open the GUI to the shutdown or network settings screen. I don’t know if they work if no screen is detected.

With a half of a certainty I had been under the impression it is not as graceful as a shutdown command and is more like a jump to reset. Take this as in informed rumor, not as fact. It is all at kernel level was my understanding thus the need for the overlay approach. I would like to see someday a root level background monitor that does a true shutdown outside of ROS. This is something I have done on my robots.

What I use is on my github but because we use most all GPIO lines on Magni this is not compatible with Magni so would require some hacking. MarkWorldCodeModules/RaspberryPiUtilities at master · mjstn/MarkWorldCodeModules · GitHub
See the sys_monitor.py as a starting point. Just sharing and not recommending, it is NOT magni compatible as it stands.