GPIO issue with some pins
Hi all,
I have to set some pins of the gpio to use them as output with the mraa library (with python) to use a hat; the pins are:
MRAA no. | Function | Rpi GPIO | Sysfs GPIO | mraa device |
---|---|---|---|---|
11 | UART_RTS | 17 | 478 | UART0 |
13 | GPIO(27) | 27 | 432 | |
15 | GPIO(22) | 22 | 431 | |
16 | PWM3 | 23 | 471 | PWM3 |
Extract from https://github.com/eclipse/mraa/blob/master/docs/up2.md#pin-mapping
I'm using ubuntu 20.04 and kernel 5.4
uname -a:
Linux es 5.4.0-1-generic #0~upboard5-Ubuntu SMP Fri Jan 7 11:53:57 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
lsb_release -a:
Distributor ID: Ubuntu Description: Ubuntu 20.04.6 LTS Release: 20.04 Codename: focal
mraa-gpio version:
Version v2.1.0 on Unknown platform
I followed the kernel installation guide (https://github.com/up-board/up-community/wiki/Ubuntu_20.04#install-ubuntu-kernel-540-from-ppa-on-ubuntu-2004) and the mraa guide (https://github.com/eclipse/mraa#installing-on-ubuntu *except for node-mraa for which the installer couldn't find a candidate)
I have also set in bios the pins as gpio (and not pwn3 or uart) and configured this as output:
As I wrote before I need to command the 4 gpio pins, but 2 works correctly (pin 11, 16) and two do not (pin 13, 15)
This is the script:
#!/usr/bin/env python # Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> # Copyright (c) 2018 Linaro Ltd. # # SPDX-License-Identifier: MIT # # Example Usage: Toggles GPIO 23 and 24 continuously in an alternative pattern import mraa import time # initialise gpio gpio_1 = mraa.Gpio(432, owner=False, raw = True) gpio_2 = mraa.Gpio(430, owner=False, raw = True) # set gpio to output gpio_1.dir(mraa.DIR_OUT) # set gpio to input gpio_2.dir(mraa.DIR_IN) # toggle gpio while True: gpio_1.write(1) time.sleep(1) print(gpio_2.read()) gpio_1.write(0) time.sleep(1) print(gpio_2.read())
I tried with system command too
echo 432 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio432/direction echo 1 > /sys/class/gpio/gpio432/value
For pin 11 and 16 all works and I see the output to 3,3V but for pin 13 and 15 the command seems to be written but the output remain to 0V
Someone can help me?
Thanks a lot for your help
Answers
-
@lucarossetto
the pin13,15 is ADC 2,3 also, you may need disable ADC channel 2&3 in BIOS too.the other simple way is using the latest pinctrl-upboard driver (no need up kernel),
you can refer my comment in other thread, it's fully control under OS no need modify BIOS in the latest pinctrl-upboard driver.https://forum.up-community.org/discussion/comment/13367#Comment_13367
-
@garyw
Hi, thanks for the replies
My board is a UPS-APLX7F-A20-0464, and from this documentation (https://github.com/up-board/up-community/wiki/40Pin-Header) only the pro version have the adc input, anyway i search in all pages of BIOS and
except for the screens in the previous post I don't find other settings for gpio/ADCI tried also the steps in the other thread but mraa don't find any pin, i attach all commands and console output
-
@lucarossetto
try to restore BIOS default and please check does the pinctrl-upboard driver loaded as below screenshot -
@garyw
After bios reset all works, but i have only one problem the pin 16 is a pwm output and during boot it's set (probably) at 50%. It's possible set a boot (default) value and type (gpio/uart/pwm) for each pin?Thank you
-
@lucarossetto
about pin 16 boot default value you can try to set pin 16 output high in BIOS, then boot into OS when pinctrl driver loaded you can control it by your app. -
@garyw
I tried to make a service to set at boot the gpio pin to 0, but the service is executed to late, there is a file or a method to configure the default value for pin at boot? -
@garyw said:
@lucarossetto
the pin13,15 is ADC 2,3 also, you may need disable ADC channel 2&3 in BIOS too.the other simple way is using the latest pinctrl-upboard driver (no need up kernel),
you can refer my comment in other thread, it's fully control under OS no need modify BIOS in the latest pinctrl-upboard driver.https://forum.up-community.org/discussion/comment/13367#Comment_13367
I'm new for here, I also got same issue and fixed it via this discussion. Thanks for the admins. 👍