J2 Jumper on Raspberry Pi 5

Hi folks,

today I was playing around a bit with OpenWRT on the Raspberry Pi 5 and the J2 Jumper which I connected a power switch to. As you know the RPi 5 also has a built-in power button and a device connected to the jumper replicates the function of the built-in button.

However, I think turning the pi off using said button is not the appropriate way since the "poweroff" command should actually be used.

Is there a way in OpenWRT, maybe in /boot/config.txt, to configure that the input coming from the J2 jumpers be used for shutdown ? I know I can use a GPIO pin however afaik those jumpers are not part of the GPIO architecture.

Your help is greatly appreciated !

There doesn't appear to be a ton of documentation (I didn't see schematics for the pi5 on the rapsberry pi site), but it is highly likely that the J2 signal goes directly into the PMIC (power management IC) causing a hardware reset/shutdown command. If that's the case, it is probably not monitored by the main SoC.

One way to find out is to monitor the output of the system log while running Raspberry Pi OS -- if it performs a graceful shutdown/reboot, that suggests that there is a signal that can be monitored by software. If it immediately reboots/shuts down, that would probably be hardware based.

So what happens on the Pi OS side is on singular button press it opens up a menu with 3 options to either shutdown, reboot or logout.

Only a double button press it would do a direct shutdown however that one is "soft", it takes a little while which makes it seem to be software directed. Holding it pressed down for 5 seconds is what probably relates it directly to the PMIC and that causes a "hard" shutdown.

Oh... that's good! So if it goes to the PMIC, theoretically a signal is sent from there to a software monitored pin on the SoC.

Probably a bit of digging through the Raspberry Pi OS and/or documentation could uncover what pin to monitor in OpenWrt.

You refer to a pin on the GPIO header ?

Probably not on the header... it's probably a pin directly between the PMIC and the SoC.

Let's hypothetically say we know which one it is, what would the command in /boot/config.txt look like dtoverlay=?

But besides that, I'll look into it and try to find out which one it is.

I honestly don't know... hopefully someone else can jump in who has some ideas. But obviously please report whatever you find!

Will do, thank you so far !

1 Like

Found something. It appears the power button is actually connected to GPIO pin 20 (Physical 38 nearest ground would be 39), take a look at this: https://github.com/raspberrypi/linux/blob/6137fb168c08bd8c41c8421bf26f09ed29479f08/arch/arm/boot/dts/bcm2712-rpi-5-b.dts#L384

So shutdown via dtoverlay=gpio-shutdown,gpio_pin=20 should in theory be possible and also booting it back up...

Do you have a multimeter? Can you check to see if there is continuity?

no, I don't have a multimeter...

Ok. Next best option might be to try shorting that pin to ground while running raspberry pi os to see if it has the same action.

yep, can try that. Would + to 29 and ground to 30 be all right (does it even matter which ground pin you use) ?

In theory, yes, that should work.

It worked ! Connect your power button to the J2 jumpers, in /boot/config.txt set dtoverlay=gpio-shutdown,gpio_pin=20 and one button press will turn it off (via OpenWRT) and one button press back on.

What proves you that shutdown is routed through OpenWRT is that normally one button press doesn't do anything on the Pi itself (only opens a prompt in the desktop GUI) and it works this way now.

Caveat: Powering the RPi back on does not work via a button connected to GPIO20 directly, that has to happen via a button connected to J2.

Great work!!!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.