Raspberry Pi code that "just uses RPi.GPIO" is the usual hope when moving to a Banana Pi. The libraries exist, but they are ports with limits.
What Banana Pi's docs point to
| Board | GPIO libraries linked from the official docs |
|---|---|
| BPI-M4 Zero | WiringPi port, RPi.GPIO port, WiringPi-Python port |
| BPI-M5 | Amlogic WiringPi port (BPI-SINOVOIP/amlogic-wiringPi) |
The RPi.GPIO port's README lists these boards: M5, M2Pro, M2S, CM4, CM5IO, M4B (M4 Berry), M4Z (M4 Zero), F3, F5.
Limits of the RPi.GPIO port (from its README)
- Simple I/O only. PWM, edge events (
add_event_detectand callbacks) and analog read are not implemented. Code using those fails. - Root required. Apps run with
sudo. - BCM numbers are translated. In BCM mode you pass Raspberry Pi BCM numbers and the library maps them to the Banana Pi's GPIO numbers. Compare the Raspberry Pi BCM chart with your board's pinout to make sure the pin you mean is the one you get.
- License: it combines RPi.GPIO (MIT) with WiringPi (LGPL v3), so the port is LGPL v3. Check that fits your product.
WiringPi port
The WiringPi port provides the C library and the gpio tool. gpio readall prints a table per board with three numbering schemes: the kernel GPIO number (I/O), the wiringPi number (wPi) and the physical header pin. Use the table from the board you actually have, because the mapping differs per model.
Header sizes differ
| Board | Header (Banana Pi specification) |
|---|---|
| BPI-M5 | 40-pin, 28 GPIO |
| BPI-M4 Zero | 40-pin, 28 GPIO |
| BPI-F3 | 26-pin |
| BPI-R3, BPI-R4 | 26-pin |
Practical advice
- For edge detection or PWM, use the Linux kernel interfaces instead of the port:
libgpiod/ the gpiochip character device for inputs and events, and the kernel's PWM sysfs interface with the right device-tree overlay. - Test the exact functions your code uses on the target board early, before porting a whole project.