Help/info for Controlling GPIO pins VOCORE2

BetweenBeltSizes
 
Posts: 3
Joined: Mon Dec 09, 2019 9:59 am

Help/info for Controlling GPIO pins VOCORE2

Mon Dec 09, 2019 4:09 pm

Hello,
i am very new to Vocore2 and would like to control the GPIO pins. I have tried Vongers Guide (http://vonger.cn/?p=473) where we can manually edit the special files which control the GPIO pins. Im having problem where some GPIO pins dont work, while some pins do work. This forum post is exactly my problem (viewtopic.php?f=16&t=3470) but no one solved this.

My question is, am i doing something wrong when entering the commands in shell to the GPIO files under /sys/class/gpio ?: "echo (gpio_pin) > export, echo out > direction, echo 1 > value" this works perfectly for some GPIO pins like pin 37, but does not for for pin 5. So is there some extra command needed to tell the Vocore2 that the pin5 should be GPIO and not i2c data pin? (like raspberry pi set BCM pins layout similiar situation?).

Also another question, If there is any python library to control GPIO pins on Vocore2 please let me know, would be amazing.

Any help is greatly appreciated.
thanks,
fritz

Vonger
 
Posts: 812
Joined: Sun Oct 19, 2014 6:00 am

Re: Help/info for Controlling GPIO pins VOCORE2

Mon Dec 09, 2019 5:27 pm

GPIO is reused in different function. It is called pin mux.
To change its function, have to modify it in source code, VOCORE2.dts, VOCORE2.dtsi, mt7628an.dtsi, then recompile the firmware.

For example: currently firmware our pin5 is used as I2C interface, so you can not export it.
Here is a trick to find pinmux detail by this command "cat /sys/kernel/debug/pinctrl/pinctrl/pinmux-pins"

This is my vocore2 pinmux.

Pinmux settings per pin
Format: pin (name): mux_owner gpio_owner hog?
pin 0 (io0): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 1 (io1): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 2 (io2): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 3 (io3): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 4 (io4): 10000900.i2c (GPIO UNCLAIMED) function i2c group i2c
pin 5 (io5): 10000900.i2c (GPIO UNCLAIMED) function i2c group i2c
pin 6 (io6): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 7 (io7): 10000b00.spi (GPIO UNCLAIMED) function spi group spi
pin 8 (io8): 10000b00.spi (GPIO UNCLAIMED) function spi group spi
pin 9 (io9): 10000b00.spi (GPIO UNCLAIMED) function spi group spi
pin 10 (io10): 10000b00.spi (GPIO UNCLAIMED) function spi group spi
pin 11 (io11): pinctrl (GPIO UNCLAIMED) function gpio refclk group gpio0
pin 12 (io12): 10000c00.uartlite (GPIO UNCLAIMED) function uart0 group uart0
pin 13 (io13): 10000c00.uartlite (GPIO UNCLAIMED) function uart0 group uart0
pin 14 (io14): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 15 (io15): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 16 (io16): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 17 (io17): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 18 (io18): 10005000.pwm (GPIO UNCLAIMED) function pwm0 group pwm0
pin 19 (io19): 10005000.pwm (GPIO UNCLAIMED) function pwm1 group pwm1
pin 20 (io20): 10000e00.uart2 (GPIO UNCLAIMED) function pwm group uart2
pin 21 (io21): 10000e00.uart2 (GPIO UNCLAIMED) function pwm group uart2
pin 22 (io22): 10130000.sdhci (GPIO UNCLAIMED) function sdxc group sdmode
pin 23 (io23): 10130000.sdhci (GPIO UNCLAIMED) function sdxc group sdmode
pin 24 (io24): 10130000.sdhci (GPIO UNCLAIMED) function sdxc group sdmode
pin 25 (io25): 10130000.sdhci (GPIO UNCLAIMED) function sdxc group sdmode
pin 26 (io26): 10130000.sdhci (GPIO UNCLAIMED) function sdxc group sdmode
pin 27 (io27): 10130000.sdhci (GPIO UNCLAIMED) function sdxc group sdmode
pin 28 (io28): 10130000.sdhci (GPIO UNCLAIMED) function sdxc group sdmode
pin 29 (io29): 10130000.sdhci (GPIO UNCLAIMED) function sdxc group sdmode
pin 30 (io30): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 31 (io31): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 32 (io32): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 33 (io33): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 34 (io34): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 35 (io35): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 36 (io36): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 37 (io37): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 38 (io38): pinctrl (GPIO UNCLAIMED) function gpio group wdt
pin 39 (io39): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 40 (io40): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 41 (io41): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 42 (io42): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 43 (io43): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 44 (io44): pinctrl (GPIO UNCLAIMED) function gpio group wled_an
pin 45 (io45): 10000d00.uart1 (GPIO UNCLAIMED) function uart1 group uart1
pin 46 (io46): 10000d00.uart1 (GPIO UNCLAIMED) function uart1 group uart1


GPIO UNCLAIMED do not mean you can directly use it, still related to dts(device tree) pinmux setting.

BetweenBeltSizes
 
Posts: 3
Joined: Mon Dec 09, 2019 9:59 am

Re: Help/info for Controlling GPIO pins VOCORE2

Tue Dec 10, 2019 1:47 pm

Thank you for help Vonger :)

what i would like to do is use python to control GPIO pins and use 2 SPI devices: (1 port expander mpc 23017 and 1 ADC mpc3008).
Here i have problem to install python spidev package for managing spi devices in python.

Sorry i am not experienced with linux or openwrt and i am scared.

So if i want to use different allocated GPIO pins i have to edit the source of the VOCORE2 software to make for example pin5 not belong to i2c anymore, install spidev python library and compile my own custom openwrt.bin file which i then upload via luci web interface?

If if understand correct:

1. follow your video (https://www.youtube.com/watch?v=ocl6yFtKSNs)
2. when selecting packages for the openwrt firmware file in the virtual box i simply sudo apt-get install python-spidev
3. continue and compile the openwrt.bin
4. upload to VOCORE2 and im done?

is this correct approach?
please let me know what i should do or read to enable the GPIO pins and control SPI with python

thank you Vonger!

Vonger
 
Posts: 812
Joined: Sun Oct 19, 2014 6:00 am

Re: Help/info for Controlling GPIO pins VOCORE2

Fri Dec 13, 2019 10:21 am

better to compile from source in Linux computer, because some kmod is not compatible.
And default firmware did not contain spidev, this need a driver and need config in DTS.
Recently I am working on SPI, in this week or next week I will upload blog about how to test and use SPI.

Return to VoCore2/Lite/Ultimate

Who is online

Users browsing this forum: No registered users and 6 guests