Khadas Guides For Interacting With The GPIO

The GPIO on the VIMs has always sparked my interest. I have used the GPIO pins, but only to connect to the USB2, SPDIF, 5Volt, etc.
I have never interacted with them from a software standpoint. I am not fluent in command line(Cli) on Linux or others, but can generally follow guides and directions…We shall see.:laughing:

As a novice in this area, I was glad to see Khadas Docs has added some guides to help with understanding how to get started on the VIM3.
For those interested, here are the links to the info and guides(from Khadas Docs, VIM3 section).
The GPIO Pinout.
How to access the GPIO.
How to use RPi.GPIO, used to control
the GPIO.
How to use WiringPi, a GPIO controller.

2 Likes

@RDFTKV You can try both with it . And tell us if you find bugs.

I intend to give it a go. However, any bugs I found would likely be caused by operator error. :laughing:
I am a total noobie in this area.:slightly_smiling_face:

Thanks for the info
I managed to find GPIOH_4 as gpio431 , 40pin connector pin 37
but where do I find the other gpios? eg where is GPIOH_3 , 5 etc
on the 40 pin connector?
Appreciate any help.

Some info here.

Excerpt from that page…
Pins:

cat /sys/kernel/debug/pinctrl/c1109880.pinmux/pins


pin 5 (GPIOAO_5)
pin 6 (GPIOAO_6)

pin 28 (GPIOH_2)
pin 29 (GPIOH_3)
pin 30 (GPIOH_4)
pin 31 (GPIOH_5)
pin 32 (GPIOH_6)
pin 33 (GPIOH_7)
pin 34 (GPIOH_8)
pin 35 (GPIOH_9)

Thanks
These pins are not the 40pin connectorss pin.

khadas@Khadas:~$ sudo cat /sys/kernel/debug/pinctrl/pinctrl@14/gpio-ranges
cat: /sys/kernel/debug/pinctrl/pinctrl@14/gpio-ranges: 没有那个文件或目录 not found

root@Khadas:/sys/kernel/debug/pinctrl# ls -l
总用量 0
-r–r--r-- 1 root root 0 Jan 1 1970 pinctrl-devices
drwxr-xr-x 2 root root 0 Jan 1 1970 pinctrl@ff634480
drwxr-xr-x 2 root root 0 Jan 1 1970 pinctrl@ff800014
-r–r--r-- 1 root root 0 Jan 1 1970 pinctrl-handles
-r–r--r-- 1 root root 0 Jan 1 1970 pinctrl-maps
not found c1109880.pinmux or pinctrl@14
khadas@Khadas:~$ cd /usr/local/lib/python3.6/dist-packages/
khadas@Khadas:/usr/local/lib/python3.6/dist-packages$ ls -l
总用量 0 not found
khadas@Khadas:/usr/local/lib/python3.6/dist-packages$ ls -l /usr/local/lib/python2.7/dist-packages/
总用量 4 not found
drwxr-xr-x 4 khadas khadas 4096 Aug 30 04:48 kodi
khadas@Khadas:/usr/local/lib/python3.6/dist-packages$

This is how I got gpio41 being GPIOH_4

at /sys/kernel/debug/pinctrl/pinctrl@ff634480/gpio-ranges
GPIO ranges handled:
0: periphs-banks GPIOS [410 - 495] PINS [0 - 85]
Khadas:/imps/bin# cat /sys/kernel/debug/pinctrl/pinctrl@ff634480/pins
registered pins: 86

pin 21 (GPIOH_4) pinctrl@ff634480

gpio = 410 -0 + 21 = 431

To use as output
echo 431 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio431/direction
echo 0 > /sys/class/gpio/gpio431/value

=============

GPIOH_4 is clearly marked here https://discourse.coreelec.org/uploads/default/original/2X/0/0aaff0f56f896b2f2f0d6f759ca4968c13c9870a.png

Also marked is GPIODZ_15 but I cldnt find it from the gpio_ranges/pins.

Where is the GPIO to 40pin connector mapping???

Is Khadas support reading this forum?

China is in a national holiday until 08 October. After that Khadas should be able to help.

found another gpio by testing
this will blink pin 35 ( physical ) on the 40 pin connector

cat blinkoutput
#!/bin/csh -fv
if ( ! -e /sys/class/gpio/gpio432/direction) then
echo 432 > /sys/class/gpio/export
endif
echo out > /sys/class/gpio/gpio432/direction
#!/bin/csh -fv
xstart:
#echo 432 > /sys/class/gpio/export
#echo out > /sys/class/gpio/gpio432/direction
echo 0 > /sys/class/gpio/gpio432/value
cat /sys/class/gpio/gpio432/value
sleep 1
echo 1 > /sys/class/gpio/gpio432/value
cat /sys/class/gpio/gpio432/value
sleep 1
echo 0 > /sys/class/gpio/gpio432/value
cat /sys/class/gpio/gpio432/value
goto xstart

==