GPIO mapping on Onion Omega2+ (MT7688)
Mike Bernardo
mike at aion.cx
Mon Aug 30 14:05:28 PDT 2021
Hi,
Does anyone know how to get GPIO working on the Omega2+, I seem to have 3 GPIO chips but I can't create a GPIO for example "15", just getting invalid argument:
root at onion1:~# echo 15 > /sys/class/gpio/export
ash: write error: Invalid argument
I guess the number I specify to export would need to be at least 416?
root at onion1:~# gpiodetect
gpiochip0 [10000600.gpio-bank0] (32 lines)
gpiochip1 [10000600.gpio-bank1] (32 lines)
gpiochip2 [10000600.gpio-bank2] (32 lines)
root at onion1:~# grep '' /sys/class/gpio/gpiochip*/ngpio
/sys/class/gpio/gpiochip416/ngpio:32
/sys/class/gpio/gpiochip448/ngpio:32
/sys/class/gpio/gpiochip480/ngpio:32
root at onion1:~# dmesg | grep gpio
[ 0.269491] mt7621_gpio 10000600.gpio: registering 32 gpios
[ 0.275193] mt7621_gpio 10000600.gpio: registering 32 gpios
[ 0.280867] mt7621_gpio 10000600.gpio: registering 32 gpios
All of the GPIOs are unlableled, am I missing some type of ACPI mapping table? Or some kind of mapping in U-boot?
root at onion1:~# gpioinfo
gpiochip0 - 32 lines:
line 0: unnamed unused input active-high
line 1: unnamed unused input active-high
line 2: unnamed unused input active-high
line 3: unnamed unused input active-high
line 4: unnamed unused input active-high
line 5: unnamed unused input active-high
line 6: unnamed unused input active-high
line 7: unnamed unused input active-high
<snip>
I can create all of the GPIOs from 416-511 and they show in /sys/kernel/debug/gpio but most are labeled with "sysfs", I guess I was looking for one to be labeled like "GPIO15"?
What I'm actually trying to do is be able to flash the atmel AVR microcontroller on the onion omega2 dock which is an arduino uno that the onion can plug into, the stock firmware sets GPIOs 15,16,17,19 to output direction to be able to reset the AVR (and maybe other functions as well?)
https://github.com/OnionIoT/arduino-dock/blob/master/arduino-dock-2/bin/arduino-dock-lib.sh#L46
It seems crazy it would have 3 GPIO chips with 32 lines each, so something seems wrong.
I've also tried libmraa via python but that doesn't seem to have any magic in it either.
I was reading this but I can't figure out anything about how to get the GSGN?
https://stackoverflow.com/questions/55532410/how-do-linux-gpio-numbers-get-their-values
Is it possible this might help?
http://patchwork.ozlabs.org/project/linux-gpio/patch/20210727152026.31019-3-sergio.paracuellos@gmail.com/
I've been looking at the kernel docs for GPIO and the onion firmware source (modified openwrt/LEDE) but have not found anything useful yet.
Thanks for reading and thanks for any help. Also thanks for all your work on OpenWRT!
Mike
More information about the openwrt-devel
mailing list