LE 12 Nightly - RPI tools add-on issue

  • After upgrade from LE11 to LE12 nightly-20230522-794a8ad (RPi4.aarch64) Raspberry Pi Tools (Team LibreELEC - 11.0.0.0) is not working properly anymore and it looks there's no updated version yet.

    python /storage/downloads/shutdown.py &

    LE:~ # Traceback (most recent call last):

    File "/storage/downloads/shutdown.py", line 10, in <module>

    import RPi.GPIO as GPIO

    File "/storage/.kodi/addons/virtual.rpi-tools/lib/RPi/GPIO/__init__.py", line 23, in <module>

    from RPi._GPIO import *

    ImportError: /storage/.kodi/addons/virtual.rpi-tools/lib/RPi/_GPIO.so: wrong ELF class: ELFCLASS32

    [1]+ Done(1) python /storage/downloads/shutdown.py

  • Still the same issue after upgrade to LibreELEC-RPi4.aarch64-12.0-nightly-20230801-1c44a13.img.gz, there's no update to Raspberry Pi Tools add-on which is still release 11.0.0.0.

  • +1 on this issue.

    Service (argononed.service) for Argon One case relies on this dependency. So no fan control and clean shutdown for this one until fixed.

  • Quick Followup:

    I've replaced the old (x86) _GPIO.so with this one from current raspianOS (64bit) image: (2023-05-03-raspios-bullseye-arm64.img)

    /usr/lib/python3/dist-packages/RPi/_GPIO.cpython-39-aarch64-linux-gnu.so

    (rename needed)

    Seems to do the trick at least for the needs of argononed.service. Advance with caution.

    Raspberry Pi Tools (Team LibreELEC - 11.0.0.0) needs to be updated none the less. Architecture changed to aarch64 with LE12

  • We are still waiting for an updated rpi.gpio package which finally uses the standard libgpiod method instead of the ancient, hacky direct memory access which is soon going to break.

    Once that's released we'll update the package and the RPi tools addon and make it available for RPi4/aarch64 as well.

    so long,

    Hias

  • Quick heads up: I've just updated the rpi-tools addon and if builds go well it should be available from the repo in the next few days.

    rpi-tools: update addon and build for aarch64 as well by HiassofT · Pull Request #8230 · LibreELEC/LibreELEC.tv
    update gpiozero to 2.0 and switch from RPI.GPIO to the libgpiod-based lg-gpio, like RPiOS did in it's bookworm release Also drop the ancient adafruit libraries…
    github.com

    It updates gpiozero to the current 2.0 version and RPI.GPIO is now gone for good (being replaced by the libgpiod based lg-gpio), aligning with current RPiOS bookworm packages.

    Any out-of-tree addons and scripts that are still using RPI.GPIO should switch to gpiozero, otherwise they won't work on LE12.

    so long,

    Hias

  • OK, it works after some struggling.

    10. Migrating from RPi.GPIO — GPIO Zero 1.6.2 Documentation

    To control the GPIOs from shell:

    # gpiodetect

    gpiochip0 [pinctrl-bcm2711] (58 lines)

    gpiochip1 [raspberrypi-exp-gpio] (8 lines)

    # gpioinfo

    gpiochip0 - 58 lines:

    line 0: "ID_SDA" input

    line 1: "ID_SCL" input

    line 2: "SDA1" input

    line 3: "SCL1" input

    line 4: "GPIO_GCLK" output consumer="lg"

    line 5: "GPIO5" input bias=pull-down edges=both consumer="lg"

    line 6: "GPIO6" output consumer="lg"

    line 7: "SPI_CE1_N" input

    line 8: "SPI_CE0_N" input

    line 9: "SPI_MISO" input

    line 10: "SPI_MOSI" input

    line 11: "SPI_SCLK" input

    line 12: "GPIO12" input

    line 13: "GPIO13" input

    line 14: "TXD1" input

    line 15: "RXD1" input

    line 16: "GPIO16" input

    line 17: "GPIO17" input

    line 18: "GPIO18" input active-low consumer="ir-receiver@12"

    line 19: "GPIO19" input

    line 20: "GPIO20" input

    line 21: "GPIO21" input

    line 22: "GPIO22" input

    line 23: "GPIO23" input

    line 24: "GPIO24" input

    line 25: "GPIO25" input

    line 26: "GPIO26" output consumer="gpio-ir-transmitter@1a"

    line 27: "GPIO27" output consumer="lg"

    line 28: "RGMII_MDIO" input

    line 29: "RGMIO_MDC" input

    line 30: "CTS0" input

    line 31: "RTS0" input

    line 32: "TXD0" input

    line 33: "RXD0" input

    line 34: "SD1_CLK" input

    line 35: "SD1_CMD" input

    line 36: "SD1_DATA0" input

    line 37: "SD1_DATA1" input

    line 38: "SD1_DATA2" input

    line 39: "SD1_DATA3" input

    line 40: "PWM0_MISO" input

    line 41: "PWM1_MOSI" input

    line 42: "STATUS_LED_G_CLK" output consumer="ACT"

    line 43: "SPIFLASH_CE_N" input

    line 44: "SDA0" input

    line 45: "SCL0" input

    line 46: "RGMII_RXCLK" input

    line 47: "RGMII_RXCTL" input

    line 48: "RGMII_RXD0" input

    line 49: "RGMII_RXD1" input

    line 50: "RGMII_RXD2" input

    line 51: "RGMII_RXD3" input

    line 52: "RGMII_TXCLK" input

    line 53: "RGMII_TXCTL" input

    line 54: "RGMII_TXD0" input

    line 55: "RGMII_TXD1" input

    line 56: "RGMII_TXD2" input

    line 57: "RGMII_TXD3" input

    gpiochip1 - 8 lines:

    line 0: "BT_ON" output consumer="shutdown"

    line 1: "WL_ON" output

    line 2: "PWR_LED_OFF" output active-low consumer="PWR"

    line 3: "GLOBAL_RESET" output

    line 4: "VDD_SD_IO_SEL" output consumer="vdd-sd-io"

    line 5: "CAM_GPIO" output consumer="cam1_regulator"

    line 6: "SD_PWR_ON" output consumer="sd_vcc_reg"

    line 7: "SD_OC_N" input


    # gpioget GPIO17

    "GPIO17"=inactive

    # gpioset -t 0 GPIO17=1

    # gpioget -a GPIO17

    "GPIO17"=active

    Edited 9 times, last by ghtester (October 23, 2023 at 9:50 AM).

  • Hi chewitt ,

    As you suggested, I opened a repo on GitHub. There are the changes for both versions (0.0.4 and 0.0.5). I actually didn't want to take this step until I could successfully build the plugin from scratch, without using the old ZIP as a basis... ;)

  • A strange issue started to happen after upgrade to latest Nightly builds with kernel 6.6.2

    The python script to run in background from autostart.sh now does not work due to error generated after Button configuration:

    btn = Button(5, pull_up=False)

    the kernel log:

    export_store: invalid GPIO 5

    But when the same script is started manually from SSH console after OS boot, it works without issue.

    Could somebody explain this behaviour and give an advice how to fix it please?

    I tried to put a time.sleep (30) before the Button command but it did not help, so it looks like some access rights issue?

  • Thanks but it looks gpiod is not present in LE12.

    As mentioned earlier, I have already updated the python script to use gpiozero instead of RPi.GPIO.

    It worked fine until recent nightly builds. Now it still works but not from autostart.sh and I can't find the reason.

  • Make sure both PYTHONPATH and LD_LIBRARY_PATH are setup correctly to include the rpi-tools addon lib dir. The latter is automatically set up if you ssh in, but not in systemd services or autostart.sh

    so long,

    Hias

  • Thanks as well but I believe there's no issue with the path. In fact the script works even in autostart.sh (LED can be turned on/off) except the input button.


    btn = Button(5, pull_up=False)

    the kernel log:

    export_store: invalid GPIO 5


    When the path is wrong, the script fails at import command which is not the case.