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:Minimum steps to reproduce (compiled with g++):Gives:
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
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;}
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