Package: libgpiod2
Version: 1.2-3
Severity: important
Dear Maintainer,
=== Short version ===
I'm trying to use libgpiod to set or clear a GPIO pin on a Beaglebone Black
compatible device (BeagleCore ETR1, to be specific). This fails due to the
output from the pin not being enabled - the pin is left in some input or high
impedance mode. On the same system the old sysfs interface under
/sys/class/gpio works as inteded.
I'm working with pin P9_23, which is pin 17 on gpiochip1. I'm measuring its
output voltage to verify pin state. Here are the steps (all executed as root
user)
1. Boot the system into a clean state.
2. Set pin to 1 using gpiod. Pin output remains in some invalid state
(expecting it to be 3.3 V)
# gpioset gpiochip1 17=1
3. Set pin to low using gpiod. Pin output remains in some invalid state
(expecting it to be 0 V)
# gpioset gpiochip1 17=0
4. As verification, set pin to high using sysfs. Pin output changes to 3.3 V
(as expected).
Looking at the GPIO control register I see that the output enable bit is not
set. This would appear to be the immediate cause for the pin output not
changing.
=== Long version ===
To look at what's really going on inside the CPU, I'm using devmem2 to read the
AM3358 GPIO control registers for pin 17 on gpiochip1. I'm using the following
commands to read the registers:
conf_gpmc_a1: # devmem2 0x44E10844
GPIO_OE: # devmem2 0x4804C134
GPIO_DATAOUT: # devmem2 0x4804C13C
1. Immediately after boot
Pin is muxed as GPIO, configured as input and has value 0:
conf_gpmc_a1 = 0x27
GPIO_OE = 0xFE1FFFFF
GPIO_DATAOUT = 0xA00000
Output voltage = 0.64 V
The gpioinfo command shows (irrelevant lines snipped):
# gpioinfo gpiochip1
gpiochip1 - 32 lines:
...
line 17: "GPMC_A1" unused input active-high
This is OK, as far as I can tell.
2. Attempting to set gpio1[17] to high, failure
Ran command and verified it succeeded:
# gpioset gpiochip1 17=1
# echo $?
0
Pin is muxed as GPIO and has value 1, but it's still configured as input:
conf_gpmc_a1 = 0x27
GPIO_OE = 0xFE1FFFFF
GPIO_DATAOUT = 0x820000
Output voltage = 0.58 V
# gpioinfo gpiochip1
gpiochip1 - 32 lines:
...
line 17: "GPMC_A1" unused output active-high
This is not OK - pin should be configured as an output in the GPIO_OE register
and it should have a voltage of around 3.3 V.
3. Attempting to set gpio1[17] to low, failure
# gpioset gpiochip1 17=0
# echo $?
0
Pin is muxed as GPIO and has value 0, but is configured as an input:
conf_gpmc_a1 = 0x27
GPIO_OE = 0xFE1FFFFF
GPIO_DATAOUT = 0x800000
Output voltage = 0.58 V
This is not OK either - pin should be an output and have a voltage of around 0
V.
4. Verification using sysfs, success
To compare and contrast, I exported the pin and set it high using the
"deprecated" sysfs interface:
# echo 49 > /sys/class/gpio/export
# echo high > /sys/class/gpio/gpio49/direction
Pin is muxed as GPIO, configured as output and has the value 1:
conf_gpmc_a1 = 0x27
GPIO_OE = 0xFE1DFFFF
GPIO_DATAOUT = 0x820000
Output voltage = 3.36 V
This is the expected result - GPIO_OE has output enabled for pin 17 and the
output is 3.36 V.
I also looked at the gpioinfo for this test:
# gpioinfo gpiochip1
gpiochip1 - 32 lines:
...
line 17: "GPMC_A1" "sysfs" output active-high [used]
It looks to me that libgpiod "gpioset" does not enable the pin as output in
GPIO_OE register. This register is described in section "25.4.1.16 GPIO_OE
Register (offset = 134h) [reset = FFFFFFFFh]" of "AM335x and AMIC110 Sitara
Processors Technical Reference Manual Rev. P" from
http://www.ti.com/lit/pdf/spruh73.
I have also tried writing a small C program directly against the kernel's
"linux/gpio.h" API to achieve the same result as gpioset does. It fails in the
same way as gpioset does.
=== Environment and hardware details ===
Hardware: BeagleCore BCM.ETR1 (compatible with a Beaglebone Black rev C)
CPU: Texas Instruments AM3358BZCZA100 (armv7l)
Debian: Buster/10 (BeagleBoard.org Debian Image 2018-12-10 from
https://rcn-ee.net/rootfs/bb.org/testing/2018-12-10/buster-iot/bone-debian-buster-iot-armhf-2018-12-10-4gb.img.xz)
Kernel: ver 4.14.79-ti-r86
libgpiod and gpiod packages: ver 1.2-3
-- System Information:
Debian Release: buster/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: armhf (armv7l)
Kernel: Linux 4.14.79-ti-r86 (SMP w/1 CPU core; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C.UTF-8
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages libgpiod2 depends on:
ii libc6 2.28-2
ii libgcc1 1:8.2.0-13
ii libstdc++6 8.2.0-13
libgpiod2 recommends no packages.
libgpiod2 suggests no packages.
-- no debconf information