A20 GPIO access

Started by jk553, December 19, 2016, 02:28:51 PM

Previous topic - Next topic

jk553

Hello!

I'm trying use GPIO ports PE0-PE2 on A20 under Debian Linux, but it doesn't work or I can't identify gpio number:

root@A20-OLinuXino:/sys/class/gpio# echo 128 > export
-bash: echo: write error: Invalid argument
root@A20-OLinuXino:/sys/class/gpio#

Other gpio works as expected. I.e.:

root@A20-OLinuXino:/sys/class/gpio# echo 48 > export
root@A20-OLinuXino:/sys/class/gpio# ls -l
export  gpio48_pi0  gpiochip1  unexport

What's wrong ?

Gerrit

Did you assign them as GPIO pins in the fex file ?

ericb

One my LIME2 running Android the GPIO number for PE0 is 119.

PE0 119
PE1 120
PE2 121

Eric

gsbMechatr

Hello,

A GPIO pin is assigned a number in the script.bin file.

You can usually find it located under /boot. you wont be able to read the bin file, so you will need to convert it to a fex file (standard text we can read) using bin2fex tool. in terminal, type in (make sure you are super user)

# cd /boot
# bin2fex script.bin script.fex

Open it with a standard editor (like leafpad) and scroll down until you see the [gpio_para] heading. you will see a list of gpio numbers and ports assigned to them.

for example,

gpio_pin_1 = port:PG00<0><default><default><default>

this is pin PG00 which has been assigned GPIO number 1. you can export is by typing

# echo 1 > /sys/class/gpio/export


Alternatively, you may attempt to export all available GPIO pins by typing in the following (make sure you are using terminal as root!)

# for i in {1..100} ; do echo $i > /sys/class/gpio/export ; done

You will get a couple of invalid argument errors, which is okay. If you only have 60 gpio's assigned, numbers 61 to 100 will return an invalid argument from bash.

you will see which numbers were exported and which weren't, and their associated port numbers under /sys/class/gpio

also note that some pins may be multiplexed and as such, may be used for other peripherals such as communication. Reading the script.bin file will tell you everything you need to know

I hope this helps,

Cheers