CommentStreams:61403e0ed5fcd0940bc4230e264b0dd7: Difference between revisions

Migrated comment #6478
 
No edit summary
 
Line 1: Line 1:
Trixie / libgpiod 2.x issues
The Trixie-branch xPWR.sh and xSoft.sh updated for libgpiod 2.2.x have a behavioral bug that prevents them from holding GPIO12 and GPIO26 as intended. The scripts run without errors, but the GPIO lines they appear to set are not actually held — the consequences range from the X728 never seeing a "Pi is alive" signal on GPIO12, to GPIO26 being left in an undefined state at shutdown. This post documents the root cause and the corrected scripts.
The Trixie-branch xPWR.sh and xSoft.sh updated for libgpiod 2.2.x have a behavioral bug that prevents them from holding GPIO12 and GPIO26 as intended. The scripts run without errors, but the GPIO lines they appear to set are not actually held — the consequences range from the X728 never seeing a "Pi is alive" signal on GPIO12, to GPIO26 being left in an undefined state at shutdown. This post documents the root cause and the corrected scripts.


Line 30: Line 28:
Verification. After rebooting with the overlay added: gpioinfo -c 0 26 should show output consumer="power_ctrl". While the daemon is running: gpioinfo -c 0 12 should show output consumer="gpioset". Both being present is the prerequisite for any further testing of X728 behavior.
Verification. After rebooting with the overlay added: gpioinfo -c 0 26 should show output consumer="power_ctrl". While the daemon is running: gpioinfo -c 0 12 should show output consumer="gpioset". Both being present is the prerequisite for any further testing of X728 behavior.


Battery reader. The sample x728-v2.x-bat.py (and asd.py) uses import RPi.GPIO and GPIO.setup(26, GPIO.OUT) despite reading the fuel gauge entirely over I2C — the GPIO26 setup is vestigial. With the gpio-poweroff overlay in place, RPi.GPIO poking GPIO26 will clash with the kernel and throw an error. The fix is to delete the RPi.GPIO imports and calls; the reader is then pure I2C and has no GPIO involvement at all. The same applies to any script that drives GPIO26 to trigger shutdown (plsd.py, plsd-gpiod.py, the low-voltage shutdown branch in bat.py/asd.py): with the overlay, GPIO26 is owned by the kernel and these scripts should call shutdown -h now directly instead. The plsd-gpiod.py sample additionally uses the libgpiod 1.x Python API (gpiod.Chip(), chip.get_line(), LINE_REQ_EV_BOTH_EDGES, LineEvent), which does not exist in libgpiod 2.x — it needs to be rewritten against the 2.x API or replaced with gpiomon in shell.
Battery reader. The sample x728-v2.x-bat.py (and asd.py) uses import RPi.GPIO and GPIO.setup(26, GPIO.OUT) despite reading the fuel gauge entirely over I2C — the GPIO26 setup is vestigial. With the gpio-poweroff overlay in place, RPi.GPIO poking GPIO26 will clash with the kernel and throw an error. The fix is to delete the RPi.GPIO imports and calls; the reader is then pure I2C and has no GPIO involvement at all. The same applies to any script that drives GPIO26 to trigger shutdown (plsd.py, plsd-gpiod.py, the low-voltage shutdown branch in bat.py/asd.py): with the overlay, GPIO26 is owned by the kernel and these scripts should call shutdown -h now directly instead. The plsd-gpiod.py sample additionally uses the libgpiod 1.x Python API (gpiod.Chip(), chip.get_line(), LINE_REQ_EV_BOTH_EDGES, LineEvent), which does not exist in libgpiod 2.x — it needs to be rewritten against the 2.x API or replaced with gpiomon in shell.<!-- migrated from Comments; original IP: 135.180.174.172 -->{{DISPLAYTITLE:
 
Trixie / libgpiod 2.x issues
<!-- migrated from Comments; original IP: 135.180.174.172 -->
}}