Argon one v3 power button and fan scripts issue

@HarryH

I installed 0.0.10 and the button doesn’t work as expected.

  1. Double press does nothing.
  2. Holding for two seconds or anything longer does a shut down.

double press should reboot right?
Also on version two of the case holding greater than 4 or 5 seconds did nothing.

2024-02-24 12:31:32.330 T:985 error : Thread-2 (thread_powerbutton)
2024-02-24 12:31:32.330 T:985 error : :

2024-02-24 12:31:32.330 T:985 error :
2024-02-24 12:31:32.330 T:985 error : Traceback (most recent call last):

2024-02-24 12:31:32.330 T:985 error :
2024-02-24 12:31:32.330 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/pins/pi.py”, line 101, in pin

2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 error : pin = self.pins[n]
2024-02-24 12:31:32.332 T:985 error :

2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 info : Skipped 9 duplicate messages…
2024-02-24 12:31:32.332 T:985 error : ~
2024-02-24 12:31:32.332 T:985 info : Skipped 8 duplicate messages…
2024-02-24 12:31:32.332 T:985 error : ^
2024-02-24 12:31:32.332 T:985 info : Skipped 2 duplicate messages…
2024-02-24 12:31:32.332 T:985 error :

2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 error : KeyError
2024-02-24 12:31:32.332 T:985 error : :
2024-02-24 12:31:32.332 T:985 error : 4
2024-02-24 12:31:32.332 T:985 error :

2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 error :

2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 error : During handling of the above exception, another exception occurred:

2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 error :

2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 error : Traceback (most recent call last):

2024-02-24 12:31:32.332 T:985 error :
2024-02-24 12:31:32.332 T:985 error : File “/usr/lib/python3.11/threading.py”, line 1038, in _bootstrap_inner

2024-02-24 12:31:32.336 T:985 error :
2024-02-24 12:31:32.336 T:985 error : File “/usr/lib/python3.11/threading.py”, line 975, in run

2024-02-24 12:31:32.337 T:985 error :
2024-02-24 12:31:32.337 T:985 error : File “/storage/.kodi/addons/script.service.argonforty-device/resources/lib/service.py”, line 16, in thread_powerbutton

2024-02-24 12:31:32.338 T:985 error :
2024-02-24 12:31:32.338 T:985 error :
2024-02-24 12:31:32.338 T:985 error : argon.shutdown_check(event)
2024-02-24 12:31:32.338 T:985 error :

2024-02-24 12:31:32.338 T:985 error :
2024-02-24 12:31:32.338 T:985 error : File “/storage/.kodi/addons/script.service.argonforty-device/resources/lib/argon.py”, line 86, in shutdown_check

2024-02-24 12:31:32.338 T:985 error :
2024-02-24 12:31:32.338 T:985 error :
2024-02-24 12:31:32.338 T:985 error : btn = Button(shutdown_pin, pull_up = False)
2024-02-24 12:31:32.338 T:985 error :

2024-02-24 12:31:32.338 T:985 error :
2024-02-24 12:31:32.338 T:985 error :
2024-02-24 12:31:32.338 T:985 info : Skipped 9 duplicate messages…
2024-02-24 12:31:32.338 T:985 error : ^
2024-02-24 12:31:32.338 T:985 info : Skipped 36 duplicate messages…
2024-02-24 12:31:32.338 T:985 error :

2024-02-24 12:31:32.338 T:985 error :
2024-02-24 12:31:32.338 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/devices.py”, line 108, in call

2024-02-24 12:31:32.340 T:985 error :
2024-02-24 12:31:32.340 T:985 error :
2024-02-24 12:31:32.340 T:985 error : self = super(GPIOMeta, cls).call(*args, **kwargs)
2024-02-24 12:31:32.340 T:985 error :

2024-02-24 12:31:32.340 T:985 error :
2024-02-24 12:31:32.340 T:985 error :
2024-02-24 12:31:32.340 T:985 info : Skipped 10 duplicate messages…
2024-02-24 12:31:32.340 T:985 error : ^
2024-02-24 12:31:32.340 T:985 info : Skipped 45 duplicate messages…
2024-02-24 12:31:32.340 T:985 error :

2024-02-24 12:31:32.340 T:985 error :
2024-02-24 12:31:32.340 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/input_devices.py”, line 414, in init

2024-02-24 12:31:32.341 T:985 error :
2024-02-24 12:31:32.341 T:985 error :
2024-02-24 12:31:32.341 T:985 error : super(Button, self).init(
2024-02-24 12:31:32.341 T:985 error :

2024-02-24 12:31:32.341 T:985 error :
2024-02-24 12:31:32.341 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/mixins.py”, line 433, in init

2024-02-24 12:31:32.343 T:985 error :
2024-02-24 12:31:32.343 T:985 error :
2024-02-24 12:31:32.343 T:985 error : super(HoldMixin, self).init(*args, **kwargs)
2024-02-24 12:31:32.343 T:985 error :

2024-02-24 12:31:32.343 T:985 error :
2024-02-24 12:31:32.343 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/input_devices.py”, line 165, in init

2024-02-24 12:31:32.343 T:985 error :
2024-02-24 12:31:32.343 T:985 error :
2024-02-24 12:31:32.343 T:985 error : super(DigitalInputDevice, self).init(
2024-02-24 12:31:32.343 T:985 error :

2024-02-24 12:31:32.343 T:985 error :
2024-02-24 12:31:32.343 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/mixins.py”, line 218, in init

2024-02-24 12:31:32.344 T:985 error :
2024-02-24 12:31:32.344 T:985 error :
2024-02-24 12:31:32.344 T:985 error : super(EventsMixin, self).init(*args, **kwargs)
2024-02-24 12:31:32.344 T:985 error :

2024-02-24 12:31:32.344 T:985 error :
2024-02-24 12:31:32.344 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/input_devices.py”, line 83, in init

2024-02-24 12:31:32.344 T:985 error :
2024-02-24 12:31:32.344 T:985 error :
2024-02-24 12:31:32.344 T:985 error : super(InputDevice, self).init(pin, pin_factory=pin_factory)
2024-02-24 12:31:32.344 T:985 error :

2024-02-24 12:31:32.344 T:985 error :
2024-02-24 12:31:32.344 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/devices.py”, line 549, in init

2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 error : pin = self.pin_factory.pin(pin)
2024-02-24 12:31:32.346 T:985 error :

2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 info : Skipped 9 duplicate messages…
2024-02-24 12:31:32.346 T:985 error : ^
2024-02-24 12:31:32.346 T:985 info : Skipped 24 duplicate messages…
2024-02-24 12:31:32.346 T:985 error :

2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/pins/pi.py”, line 103, in pin

2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 error : pin = self.pin_class(self, n)
2024-02-24 12:31:32.346 T:985 error :

2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 info : Skipped 9 duplicate messages…
2024-02-24 12:31:32.346 T:985 error : ^
2024-02-24 12:31:32.346 T:985 info : Skipped 22 duplicate messages…
2024-02-24 12:31:32.346 T:985 error :

2024-02-24 12:31:32.346 T:985 error :
2024-02-24 12:31:32.346 T:985 error : File “/storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/pins/rpigpio.py”, line 111, in init

2024-02-24 12:31:32.347 T:985 error :
2024-02-24 12:31:32.347 T:985 error :
2024-02-24 12:31:32.347 T:985 error : GPIO.setup(self.number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])
2024-02-24 12:31:32.347 T:985 error :

2024-02-24 12:31:32.347 T:985 error :
2024-02-24 12:31:32.347 T:985 error : RuntimeError
2024-02-24 12:31:32.347 T:985 error : :
2024-02-24 12:31:32.347 T:985 error : Cannot determine SOC peripheral base address
2024-02-24 12:31:32.347 T:985 error :

Please generate a full kodi.log like described here: Log Files - LibreELEC.wiki

Can you please send me the full uncensored output of this one-liner?

python -c 'import sys; sys.path.append("/storage/.kodi/addons/virtual.rpi-tools/lib"); from gpiozero import pi_info; print(pi_info().model)'

Model is ???

Here is the full output of pi_info:

PiBoardInfo(revision=‘c04170’, model=‘???’, pcb_revision=‘1.0’, released=‘Unknown’, soc=‘Unknown’, manufacturer=‘Sony’, memory=4096, storage=‘MicroSD’, usb=4, usb3=0, ethernet=1, eth_speed=0, wifi=False, bluetooth=False, csi=1, dsi=1, headers=…, board=…)

https://paste.libreelec.tv/perfect-rat.log

Thank you for providing the logs. This helps really to clarify some open questions. Do you have seen that you booted LibreELEC 11 and not 12 ?

System log output for: LibreELEC (official): 11.0.6
RPi Hardware Revision: 0000b900
RPi throttled=0x0
========== /storage/.kodi/temp/kodi.log ==========
2024-02-24 12:36:17.788 T:929      info <general>: -----------------------------------------------------------------------
2024-02-24 12:36:17.788 T:929      info <general>: Starting Kodi (20.3 (20.3.0) Git:20.3-Nexus). Platform: Linux ARM 32-bit
2024-02-24 12:36:17.788 T:929      info <general>: Using Release Kodi x32
2024-02-24 12:36:17.788 T:929      info <general>: Kodi compiled 2024-01-27 by GCC 12.2.0 for Linux ARM 32-bit version 6.1.74 (393546)
2024-02-24 12:36:17.788 T:929      info <general>: Running on LibreELEC (official): 11.0.6, kernel: Linux ARM 64-bit version 6.1.74
2024-02-24 12:36:17.788 T:929      info <general>: FFmpeg version/source: 4.4.1-Kodi

This is the reason why power button detection doesn’t work and throws these exception messages. I can try to catch this error message, but RPi5 GPIO support only works from LibreELEC 12 + RPi Tools from LE12.
For this reason the model information is probably “???”

@HarryH Sorry I have two SD cards one for LE11 and one for LE12 and I got them mixed up.
I tried installing version 10 of you script on LE12 and I get errors when I try to enable it.

https://paste.libreelec.tv/living-beetle.log

edit: Your one liner python now returns 5B

@smesser,

that this message comes again is a little bit unexpected to me, because I already had included a working fix against the lgpio bug (Scripts don't work if user doesn't have write permission to CWD · Issue #1106 · gpiozero/gpiozero · GitHub) - so I thought. But until now I had also no kodi.log from a LE12 installation. :thinking:

2024-02-25 18:20:19.349 T:1180    error <general>: /storage/.kodi/addons/virtual.rpi-tools/lib/gpiozero/devices.py:300: PinFactoryFallback: Falling back from lgpio: [Errno 2] No such file or directory: '.lgd-nfy-3'
                                                     warnings.warn(

Does the message remain if you reboot the RPi5 again? I currently wonder why no other LE12 user has already complaint about it?

The breaking part is here, so I can see that the planned workaround is enabled, but something is going wrong with the permissions:

Feb 25 18:20:19.347546 LibreELEC kodi.sh[946]: 2024-02-25 18:20:19 xCreatePipe: Can't set permissions (436) for /tmp/tmpvj0v_93c/.lgd-nfy3, No such file or directory

If the error remains after the reboot, please can you check if the /tmp directory is writeable?

touch /tmp/testfile

@HarryH

touch worked just fine

drwxrwxrwt 5 root root 120 Feb 25 21:39 tmp

Oh, yes I have rebooted multiple times with the same result.

Okay,

as a dirty fix you can try to change manually these lines (28 - 29) in the file ‘/storage/.kodi/addons/script.service.argonforty-device/resources/lib/argon.py’:

from

tmp_lgpio_work_dir = tempfile.TemporaryDirectory()
os.environ["LG_WD"] = tmp_lgpio_work_dir.name

to

# tmp_lgpio_work_dir = tempfile.TemporaryDirectory()
os.environ["LG_WD"] = '/tmp'

Reboot and see what happens.

Edit:
I have released version 0.0.11 with the above change.

@HarryH

Okay that was interesting.

If I apply the change and reboot without trying to disable/enable the addon the double press to reboot works fine.

When I disable the addon I get an red popup error after about 5 seconds. When I enable the addon I don’t get an error but the double press doesn’t work.

https://paste.libreelec.tv/open-spider.log

I can see my mistake, please wait some minutes to update to 0.0.11a

Please try the hotfix version 0.0.11a
In the meantime I have isolated another issue so I must fix that to, so the shutdown will work again. Sorry for the circumstances.

Getting closer.
After a reboot everything works fine.
If I disable/enable the addon the double press doesn’t do anything.
However, after a reboot all is fine.

I didn’t get any error popups in the UI

Sounds good, I have released hotfix version 2 → 0.0.11b
This should make the shutdown work again.

For me 11a and 11b work the same.

This info is good to know and I should assume that the One V3 uses another way to inform the RPi5 board about the shutdown wish. The One V1/V2 requires that the button recognition is working and additional a back channel through I2C to the MCU, depending on if the shutdown was initiated by OS, power button (backside of case) or the power button of a remote control.

Hi everyone & hi @wmorgan

I’m new to the Raspi 5 and maybe someone would be so kind to help me out?

If I understand wmorgan correctly by connecting the fan of the expansion board directly to the fan connector on the Raspi 5 the fan would behave exactly like the stock fan and I would not need to tinker with any scripts? Would I need an extra (longer) cable (or an extension) for connecting the fan to the Pi’s fan connector or is the fan’s default cable long enough?

I plan on using the Pi & ONE V3 mainly for preconfigured Retro Game Images… so I’d love to have the fan and the power buttion just work out of the box. :slight_smile:

Thanks so much for your help!

Enc

@HarryH

A little confused. You had some releases where the button worked just fine.

@smesser,

now you have confused me with:

For me 11a and 11b work the same.

As I published 0.0.11, it was additional intent to use the same bug fix for the power off command (I2C) like I have used from 0.0.8 to prevent the fan fluctuation with Argon One 3 firmware. It‘s possible that this is only a cosmetic thing to have a cleaner code and makes no functional difference in this case.
In parallel I have made the changes to fix the errors you reported.

Until your comment, I was believing that the Argon V1/V2/V3 behavior regarding the needs for a graceful shutdown are the same.

My first attempt to use a cleaner power off procedure starting with 0.0.11, was a fail in combination with my Argon One V2 case. I only discovered it with 0.0.11a and rolled this attempt back in 0.0.11b to fast get a known stable version.

You should normally have the same issue with 0.0.11a if you try to shutdown by using the kodi power menu. The RPi5 will shutdown the OS, but the red LED doesn‘t goes off because the MCU doesn’t know about, that a shutdown has executed.

@HarryH
Looking back I didn’t explain it very well.

Currently with 11b the shutdown works until you disable/enable the addon.
Then if you manually reboot via Kodi menu then the shutdown works again until you disable/enable the addon.

  1. Works until you disable/enable the addon
  2. Or if you reboot (not with button) after disable/enable of the addon