GPio conflict at boot

Hi there,

I experience an annoying bug at the startup of the Pironman 5.
On one of the USB-ports I have connected a serial to USB cable, witch is connected to a smart meter. When I have this connection at startup, the Pironman service won’t start. I get the following messages in the logs:

Traceback (most recent call last):
  File "/opt/pironman5/venv/bin/pironman5-service", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/pironman5/venv/lib/python3.11/site-packages/pironman5/__init__.py", line 47, in main
    from pm_auto.ws2812 import RGB_STYLES
  File "/opt/pironman5/venv/lib/python3.11/site-packages/pm_auto/ws2812.py", line 5, in <module>
    import board
  File "/opt/pironman5/venv/lib/python3.11/site-packages/board.py", line 45, in <module>
    from adafruit_blinka.board.raspberrypi.raspi_5 import *
  File "/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/board/raspberrypi/raspi_5.py", line 6, in <module>
    from adafruit_blinka.microcontroller.bcm2712 import pin
  File "/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/bcm2712/pin.py", line 7, in <module>
    from adafruit_blinka.microcontroller.generic_linux.lgpio_pin import Pin
  File "/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/lgpio_pin.py", line 30, in <module>
    CHIP = _get_gpiochip()
           ^^^^^^^^^^^^^^^
  File "/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/lgpio_pin.py", line 18, in _get_gpiochip
    drivers = set((dev / "of_node/compatible").read_text().split("\0"))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 1059, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 1045, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/sys/bus/gpio/devices/gpiochip14/of_node/compatible'
Traceback (most recent call last):
  File "/opt/pironman5/venv/bin/pironman5-service", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/pironman5/venv/lib/python3.11/site-packages/pironman5/__init__.py", line 47, in main
    from pm_auto.ws2812 import RGB_STYLES
  File "/opt/pironman5/venv/lib/python3.11/site-packages/pm_auto/ws2812.py", line 5, in <module>
    import board
  File "/opt/pironman5/venv/lib/python3.11/site-packages/board.py", line 45, in <module>
    from adafruit_blinka.board.raspberrypi.raspi_5 import *
  File "/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/board/raspberrypi/raspi_5.py", line 6, in <module>
    from adafruit_blinka.microcontroller.bcm2712 import pin
  File "/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/bcm2712/pin.py", line 7, in <module>
    from adafruit_blinka.microcontroller.generic_linux.lgpio_pin import Pin
  File "/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/lgpio_pin.py", line 30, in <module>
    CHIP = _get_gpiochip()
           ^^^^^^^^^^^^^^^
  File "/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/lgpio_pin.py", line 18, in _get_gpiochip
    drivers = set((dev / "of_node/compatible").read_text().split("\0"))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 1059, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 1045, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/sys/bus/gpio/devices/gpiochip14/of_node/compatible'

When I disconnect the USB to serial cable at startup the Pironman service starts correctly and if I reconnect the USB-cable after startup everything works fine. But this is annoying, because an other service depends on the serial connection.

So I hope you can help me to solve this problem.

Marcel Kooijman

You can try to remove usb in boot order. In terminal, enter : sudo rpi-eeprom-config --edit and remove 4 in the boot order, save it and reboot.

boot_order is now 0xf16.

Same error

Ok, all system and kernel are up-to-date? sudo apt-get update , sudo apt full-upgrade , sudo rpi-update .

Did all of that. No change. Pironman5 service won’t start with SerialToUsb-cable connected.

Maybe the issue come from your serialtousb-cable. Have you try to plug it into usb2.0 and usb3.0?

Please let us know if your service uses any GPIO pins that may conflict with those used by the Pironman5 program. Pironman5 utilizes the following GPIO pins (see attached image).

Actually I don’t use the GPio-pins at all.
This is what I can tell you.
In my application/systemd-service the Serial-to-Usb connection is identified as /dev/ttyUSB0, but the problem also arises when I disable this service before reboot, with the cable connected. So the problem is not caused by my application, something goes wrong at startup.

My reference tot the GPio pins comes from the error-messages in the log:

FileNotFoundError: [Errno 2] No such file or directory: ‘/sys/bus/gpio/devices/gpiochip14/of_node/compatible’
Traceback (most recent call last):
File “/opt/pironman5/venv/bin/pironman5-service”, line 8, in
sys.exit(main())
^^^^^^
File “/opt/pironman5/venv/lib/python3.11/site-packages/pironman5/init.py”, line 47, in main
from pm_auto.ws2812 import RGB_STYLES
File “/opt/pironman5/venv/lib/python3.11/site-packages/pm_auto/ws2812.py”, line 5, in
import board
File “/opt/pironman5/venv/lib/python3.11/site-packages/board.py”, line 45, in
from adafruit_blinka.board.raspberrypi.raspi_5 import *
File “/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/board/raspberrypi/raspi_5.py”, line 6, in
from adafruit_blinka.microcontroller.bcm2712 import pin
File “/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/bcm2712/pin.py”, line 7, in
from adafruit_blinka.microcontroller.generic_linux.lgpio_pin import Pin
File “/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/lgpio_pin.py”, line 30, in
CHIP = _get_gpiochip()
^^^^^^^^^^^^^^^
File “/opt/pironman5/venv/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/lgpio_pin.py”, line 18, in _get_gpiochip
drivers = set((dev / “of_node/compatible”).read_text().split(“\0”))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/pathlib.py”, line 1059, in read_text
with self.open(mode=‘r’, encoding=encoding, errors=errors) as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/pathlib.py”, line 1045, in open
return io.open(self, mode, buffering, encoding, errors, newline)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: ‘/sys/bus/gpio/devices/gpiochip14/of_node/compatible’

This first and last lines reference to GPio port 14, which, if I understand yiou correctly, isn’t used by the Pironman at all, so this is quite mysterious :wink: .
Something seems to go wrong in your “adafruit_blinka” module. I don’t know wat that is, do’n use that.

Hope you can fix this!

[In answer to WeirdyGuy]

UBS 2 or USB3 port makes no difference.

Any solution for this error so far?

After thorough testing, we haven’t been able to reproduce the problem on our end.

To help resolve this, we suggest the following steps:

  1. Modify the startup sequence in the Pironman5 service by editing:
    /pironman5/bin/pironman5.service
  2. Then re-run the installation script:
    /pironman5/install.py

No change after these adjustments.

Even if I disable all my services (including Docker, Samba and Pironman5), and start the Pironman service after boot with nothing else running, I stil get this error:

Apr 16 19:38:29 yukocontrol pironman5[897]: FileNotFoundError: [Errno 2] No such file or directory: ‘/sys/bus/gpio/devices/gpiochip14/of_node/compatible’

Apr 16 19:38:29 yukocontrol systemd[1]: pironman5.service: Main process exited, code=exited, status=1/FAILURE

Marcel

Some extra information:

  • the serial-to-usb cable has an FTDI-chip and uses the (Linux) ftdi_sio driver
  • the interface is FT232R USB UART

To better assist you with the issue, we kindly request you to:
Provide complete photos of your device connections, or
Share detailed information about the specific problem you’re encountering

Additionally, we recommend reinstalling the Pironman5 software to verify if this resolves the functionality issue.

I just published this issue on GitHub, I think it contains all the info you need.
I have reinstalled y9u9r software multiple times, with no effect.


Pironman5` crashes on boot when USB-serial cable is connected — attempts to access non-existent gpiochip14


Description:

When booting a Raspberry Pi 5 with a Pironman 5 case, the pironman5 systemd service fails to start if a USB-to-serial cable (FTDI) is connected at boot time.

The following error appears in the logs:

FileNotFoundError: [Errno 2] No such file or directory: '/sys/bus/gpio/devices/gpiochip14/of_node/compatible'

This error does not occur when the USB cable is not connected at boot, and the service starts successfully.


Analysis:

It appears that pironman5 attempts to access /sys/bus/gpio/devices/gpiochip14/of_node/compatible, regardless of whether that chip exists. On my Raspberry Pi 5 system, there is no gpiochip14 at all. The available GPIO chips are:

/sys/class/gpio/gpiochip512
/sys/class/gpio/gpiochip529
/sys/class/gpio/gpiochip535
/sys/class/gpio/gpiochip567
/sys/class/gpio/gpiochip571
/sys/class/gpio/gpiochip625

The behavior suggests a hardcoded or incorrect GPIO detection mechanism within pironman5 that assumes the presence of gpiochip14, possibly triggered by the detection of the USB FTDI device.


Steps to reproduce:

  1. Connect a USB-to-serial FTDI cable to the Raspberry Pi 5.
  2. Reboot the system.
  3. Observe that pironman5.service fails to start.
  4. Disconnect the cable and reboot again — the service now starts normally.

Expected behavior:

The service should not crash if a GPIO chip is not present. GPIO access should be conditional on the chip’s actual availability, or handled gracefully.


System Info:

  • Device: Raspberry Pi 5
  • Case: Pironman 5
  • OS: Raspberry Pi OS (64-bit)
  • pironman5 installed via default systemd service
  • USB-serial cable using FTDI (idVendor: 0403, idProduct: 6001)