Shutdown BPI-M2 zero with a GPIO

Hi,

I am currently replacing a raspberry Pi Zero by a BPI-M2 zero in a carrier board for an application.

I would like to be able to shutdown properly the BPI-M2 zero with the GPIO at the position 40.

image

The goal is when this GPIO is tied to ground, then the BPI-M2 Zero shutdown properly. There are a lot of examples for Raspberrypi but I can’t find any example for BPI-M2 Zero.

Does anybody made a similar feature ?

I am running Ubuntu 16.04 with kernel 5.3.4

Thanks

1 Like

hi, afaik the poweroff-feature works with device-tree-overlays

http://www.stderr.nl/static/files/Hardware/RaspberryPi/gpio-shutdown-overlay.dts

as loading a dto in uboot is a bit tricky,you can add the needed parts directly to your boards dts. you need to find the sections described in target of each fragment (for rpi &gpio and /soc) and add the nodes below __ overlay __

for bpi you need to compile kernel (as it includes your dtb) after making the modifications. have you compiled your own kernel? BPI-bsp as far as i see uses kernel 3.4…

m2 zero already have a gpio power key (gpio PL3) for shutdown

actually shutdown with gpio is add a gpio-key driver to report a power_key event to userspace. Both bpi kernel 4.4 and kernel mainline already enable this driver.

You can modify the gpio_keys node in sys_config.fex of bpi bsp source code, or sun8i-h2-plus-bananapi-m2-zero.dts of mainline kernel, change the gpio property to position 40 pin which is gpio PA20.

1 Like

Forgive me my ignorance but I really can’t find the PL3 pin on the 40 pins header