Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4417

Advanced users • New behaviour when closing I2C lines with the GPIO v2 API

$
0
0
Hi,

I updated my system recently and observed a strange new behaviour:

The I2C port is enabled at boot in config.txt (dtparam=i2c_arm=on)
For some reason I open the GPIO 2 line with the GPIO v2 API but I don’t do anything with it, and I can communicate with I2C devices.
However as soon as I close the line, its function now changes to “input” and I cannot use I2C anymore without explicitly restoring the I2C functions. Same with GPIO 3 (SCL1 becomes an input). I don’t know the exact kernel version I was using previously, but it was a 6.6 updated in March or April.
Is this normal? Is this documented?

System/hardware:

Code:

Linux raspberrypi 6.6.31+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/LinuxRaspberry Pi 5 Model B Rev 1.0
Minimum steps to reproduce (compiled with g++):

Code:

#include <linux/gpio.h>#include <sys/ioctl.h>#include <fcntl.h>#include <unistd.h>#include <cstdlib>int main (){auto fd = open ("/dev/gpiochip4", O_RDONLY);gpio_v2_line_request req {}; // Filled with 0req.offsets [0] = 2;req.num_lines   = 1;ioctl (fd, GPIO_V2_GET_LINE_IOCTL, &req);system ("pinctrl get 2");close (req.fd);system ("pinctrl get 2");close (fd);return 0;}
Gives:

Code:

 2: a3    pu | hi // GPIO2 = SDA1 2: ip    pu | hi // GPIO2 = input

Statistics: Posted by KillerBerthier — Tue Jul 02, 2024 10:13 am — Replies 2 — Views 37



Viewing all articles
Browse latest Browse all 4417

Trending Articles