mattjlewis / diozero

Java Device I/O library that is portable across Single Board Computers and microcontrollers. Tested with Raspberry Pi, Odroid C2, BeagleBone Black, Next Thing CHIP, Asus Tinker Board and Arduinos / Pico. Supports GPIO, I2C, SPI as well as Serial communication. Also known to work with Udoo Quad.
https://www.diozero.com
MIT License
261 stars 59 forks source link

MINOR: Possible invalid info in Raspberry Pi hardware definition #121

Closed EAGrahamJr closed 1 year ago

EAGrahamJr commented 1 year ago

This is (obviously) handled without issue (nice one!), but I have been seeing these warnings:

Raspberry Pi 3 Model B Rev 1.2

09:36:34.081 [main] WARN com.diozero.internal.provider.builtin.DefaultDeviceFactory.lambda$start$0 - Configured pin chip and line offset (1-0) doesn't match that detected (2-0), line name 'BT_ON' - updating
09:36:34.113 [main] WARN com.diozero.internal.provider.builtin.DefaultDeviceFactory.lambda$start$0 - Configured pin chip and line offset (1-1) doesn't match that detected (2-1), line name 'WL_ON' - updating

Since I only have one Pi to test with, I'm not sure this is an actual issue that needs adjustment.

mattjlewis commented 1 year ago

Can you share the output of these commands please:

gpiodetect
uname -a
mattjlewis commented 1 year ago

For reference I get:

gpiochip0 [pinctrl-bcm2711] (58 lines)
gpiochip1 [raspberrypi-exp-gpio] (8 lines)

Then gpioinfo 1 outputs:

gpiochip1 - 8 lines:
    line   0:      "BT_ON"       unused  output  active-high
    line   1:      "WL_ON"       unused  output  active-high
    line   2: "PWR_LED_OFF" "led1" output active-low [used]
    line   3: "GLOBAL_RESET" unused output active-high
    line   4: "VDD_SD_IO_SEL" "vdd-sd-io" output active-high [used]
    line   5:   "CAM_GPIO" "cam1_regulator" output active-high [used]
    line   6:  "SD_PWR_ON" "sd_vcc_reg"  output  active-high [used]
    line   7:    "SD_OC_N"       unused   input  active-high

It would appear you have gpiochip1 configured as gpiochip2. The code gracefully handles this so I will downgrade the warning to a debug message.

mattjlewis commented 1 year ago

Now that's odd - Pi3 gives this hence the warning (not sure where brcmvirt-gpio is coming from):

gpiochip0 [pinctrl-bcm2835] (54 lines)
gpiochip1 [brcmvirt-gpio] (2 lines)
gpiochip2 [raspberrypi-exp-gpio] (8 lines)

Leave it with me.

EAGrahamJr commented 1 year ago

Concur with the above output for gpiodetect

$ uname -a
Linux marvin 5.15.76-v8+ #1597 SMP PREEMPT Fri Nov 4 12:16:41 GMT 2022 aarch64 GNU/Linux
EAGrahamJr commented 1 year ago

gpioinfo 1

Opened Chip: gpiochip1 [brcmvirt-gpio] - (2 lines)
line   0:                 ""          "led0" output active-high [used]
line   1:                 ""          unused  input active-high
mattjlewis commented 1 year ago

FYI this is actually an interesting error. I had naively assumed gpiochip numbers would be consistent at least across 2B/3B/4B models. I’m in the process of adding functionality to map by gpiochip label, eg “pinctrl-bcm2835”, “raspberrypi-exp-gpio”.

EAGrahamJr commented 1 year ago

Verified.