# Banana Pi-M1 GPIO pin assignments



## Phishfry (Dec 27, 2021)

I had to do some real work to get the FreeBSD GPIO pin numbers for Banana Pi -M1.
It uses a 26Pin header identical to Pi 1.
`gpioctl` shows 174 pins. I don't know why so many but I could not find the pins easily.
So included is the chart I made for myself.

Since BananaPi-M1 is so old I imagine FreeBSD 12.x might be the end of the line.


----------



## Phishfry (Jan 27, 2022)

I have moved to setting GPIO pin state in u-boot.
My rc.local script works OK but I like u-boots early intervention.

On the BananaPi-M1 the Pin numbers use a different scheme in U-boot.
Pin Banks. (Very similar to multiple gpioc nodes)
PA
PB
PH
PI

PI14 is Pin 14 on Pin Bank "PI"
As you can see from my above chart that header pin 26 is PI14

Here are the Banks Pin assignments to the Header Pins:
PB20=Header-Pin-16
PB21=Header-Pin-18

PH00=Header-Pin-8
PH01=Header-Pin-10
PH02=Header-Pin-12
PH20=Header-Pin-16
PH21=Header-Pin-18

PI03=Header-Pin-7
PI10=Header-Pin-24
PI11=Header-Pin-23
PI12=Header-Pin-19
PI13=Header-Pin-21
PI14=Header-Pin-26
PI16=Header-Pin-22
PI17=Header-Pin-15
PI18=Header-Pin-13
PI19=Header-Pin-11

Here is a glance at u-boots gpio settings and toggling a GPIO pin with u-boot command line on Pin 26


```
=> gpio
gpio - query and control gpio pins

Usage:
gpio <input|set|clear|toggle> <pin>
    - input/set/clear/toggle the specified pin
gpio status [-a] [<bank> | <pin>]  - show [all/claimed] GPIOs
```


```
=> gpio status -a PI14
Bank PI:
PI14: input: 0 [ ]
```

I notice when I toggle the pin its state changes from input to output.

```
=> gpio toggle PI14
gpio: pin PI14 (gpio 270) value is 1
```


```
=> gpio status -a PI14
Bank PI:
PI14: output: 1 [ ]
```
Weird that direction and value both toggled. I was only expecting value.
Logically I guess only an output would have 0 or 1 value. An input would fluctuate.
I need to look at that.


----------



## Phishfry (Jan 27, 2022)

Status of an entire bank. Note not all pins are user accessible. You can see my change to PI14 here in contrast.

```
=> gpio status -a PI 
Bank PI:
PI0: input: 1 [ ]
PI1: input: 1 [ ]
PI2: input: 0 [ ]
PI3: input: 0 [ ]
PI4: input: 0 [ ]
PI5: input: 0 [ ]
PI6: input: 0 [ ]
PI7: input: 0 [ ]
PI8: input: 0 [ ]
PI9: input: 0 [ ]
PI10: input: 0 [ ]
PI11: input: 0 [ ]
PI12: input: 0 [ ]
PI13: input: 0 [ ]
PI14: output: 1 [ ]
PI15: input: 0 [ ]
PI16: input: 0 [ ]
PI17: input: 0 [ ]
PI18: input: 0 [ ]
PI19: input: 0 [ ]
PI20: input: 0 [ ]
PI21: input: 0 [ ]
PI22: input: 0 [ ]
PI23: input: 0 [ ]
PI24: input: 0 [ ]
PI25: input: 0 [ ]
PI26: input: 0 [ ]
PI27: input: 0 [ ]
PI28: input: 0 [ ]
PI29: input: 0 [ ]
PI30: input: 0 [ ]
PI31: input: 0 [ ]
```


----------

