DeskPi-Team / deskpi

DeskPi Pro is the Ultimate Case Kit for Raspberry Pi 4 with Full Size HDMI/2.5 Hard Disk Support and Safe Power Button, It has QC 3.0 Power Supply inside and New ICE Tower Cooler inside.
GNU General Public License v3.0
143 stars 46 forks source link

How to fully power down DeskPi Pro from software (OS)? Power button light, board in general, does not shutdown #59

Closed inspector71 closed 2 years ago

inspector71 commented 3 years ago

How to shutdown the DeskPi Pro fully in software, meaning:

  1. power button LED changes from blue to red
  2. ALL on board LEDs switch off

In other words, the same full shutdown experience I currently get when holding in the power button for a few seconds.

That should be what happens when shutdown -h now is executed, ideally, isn't it?

I'm not interested in any sort of standby state.

FWIW, I've yet to update any firmware and have not installed any shutdown script that may be required as has been with other RPi power button HATs.

pkr1771 commented 3 years ago

Posted in to another thread:

I encountered the issue of the power LED not going red on halt/shutdown/poweroff which also traced back to fanStop not functioning correctly. I'm running on 64-bit Ubuntu which I was happy to see now has installer support. The pwmFanControl works correctly (unlike previous releases) because it is recompiled during the installation process.

I needed to manually recompile the fanStop.c using gcc for the 64 bit platform and then copy the new binary to the /usr/bin directory. This file is not recompiled in the installation process and appears that it needs to be added.

One other difference I noted from earlier releases is the definition of the deskpi-safeshut.service. I can't say for sure that this makes a difference, but I noticed it as a change from earlier releases that included the line:

TimeoutSec=1

When I made these two changes, the system shuts down as expected and the power LED goes red.

inspector71 commented 3 years ago

@pkr1771 Thanks! There sounds like bugs here that @yoyojacky needs to fix. Having discovered the shitty nature of support for the DeskPi (OSMC cannot boot from USB; LibreELEC 9.. not fully supported and 10 is an unusable sea change; DietPi Kodi image has hardware decoding, reliability issues despite it being limited to 18.9; etc etc) I've become a bit stuck and demotivated.

Would be great if at least one boot-to-kodi OS was properly, smoothly supported in every respect.

yoyojacky commented 2 years ago

wer button HATs.

if you have installed the driver, it will cut off power from Raspberry Pi to deskpi daughterboard after OS is shutting down. deskpi pi daughterboard is connected to power supply, the red led on power botton will always light up. it can not turn off.

yoyojacky commented 2 years ago

@pkr1771 Thanks! There sounds like bugs here that @yoyojacky needs to fix. Having discovered the shitty nature of support for the DeskPi (OSMC cannot boot from USB; LibreELEC 9.. not fully supported and 10 is an unusable sea change; DietPi Kodi image has hardware decoding, reliability issues despite it being limited to 18.9; etc etc) I've become a bit stuck and demotivated.

Would be great if at least one boot-to-kodi OS was properly, smoothly supported in every respect.

KODI is just a OSMC software can be installed on Raspberry Pi OS, and If you want to hack it by yourself, i'd like to share my idea to you, as we know, the fan is controlled by MCU on deskpi daughterboard by "PWM" signal which is sending from Raspberry Pi via USB-C port, but some of those OS needs to enable dwc2 function, I mean, make raspberry Pi's USB-C port as a serial port device, once done, it will generate a serial device named /dev/ttyUSB0 and we can control the fan's speed by sending "PWM_XXX" signal to this serial port, XXX must be replaced by "000 to 100", for example : if you send "PWM_050" to /dev/ttyUSB0, the signal will send to MCU on daughterboard and the MCU will control the fan spinning at 50% PWM signal, it means the fan will spin in half speed of full speed. and once you shutdown the system, our script is to send "Power_off" signal to MCU, MCU will cut off the power of Raspberry pi after 5-10 seconds. and some of system like recalbox is not even a linux system, so it is a little bit difficult to finish those two parts, (enable dwc2 and adding systemd service) . so, it is so hard to satisfied everyone....

inspector71 commented 2 years ago

red led on power botton will always light up. it can not turn off.

FWIW, although LEDs generally much too bright for easy night time relaxing whilst watching a video, for example, I'm not than OK with a meaningful status colour change that actually indicates the unit is in a powered but 'off' state.

That seems to mirror the behaviour of the Pi4 board itself but the Pi4 board's LEDs are hidden from the user. So it makes sense to have that LED visible to the user for the inevitable times when the Pi locks up, as it often settings to do due to arguably a lack of power filtering.

Ideal world a light

egooner commented 1 year ago

Posted in to another thread:

I encountered the issue of the power LED not going red on halt/shutdown/poweroff which also traced back to fanStop not functioning correctly. I'm running on 64-bit Ubuntu which I was happy to see now has installer support. The pwmFanControl works correctly (unlike previous releases) because it is recompiled during the installation process.

I needed to manually recompile the fanStop.c using gcc for the 64 bit platform and then copy the new binary to the /usr/bin directory. This file is not recompiled in the installation process and appears that it needs to be added.

One other difference I noted from earlier releases is the definition of the deskpi-safeshut.service. I can't say for sure that this makes a difference, but I noticed it as a change from earlier releases that included the line:

TimeoutSec=1

When I made these two changes, the system shuts down as expected and the power LED goes red.

Great - thanks for this now Feb 2023 and the bug is still there ... did exactly as you mention here and voila ... thanks for documenting this

jzazo commented 1 year ago

I pulled from master, and reinstalled. After recompiling fanStop.c and moving it to /usr/bin, and adding TimeoutSec=1 to the shutdown service, when I shut down the raspberry it actually shuts down, and the led turns red.

However, the fan service does not seem to work:

$ systemctl status deskpi.service
     Loaded: loaded (/lib/systemd/system/deskpi.service; enabled; vendor preset: enabled)
     Active: failed (Result: signal) since Sat 2023-03-25 11:31:45 UTC; 20s ago
    Process: 2811 ExecStart=sudo /usr/bin/pwmFanControl & (code=killed, signal=SEGV)
   Main PID: 2811 (code=killed, signal=SEGV)
        CPU: 33ms

Mar 25 11:31:44 raspberry systemd[1]: Starting DeskPi PWM Control Fan Service...
Mar 25 11:31:44 raspberry sudo[2811]:     root : PWD=/ ; USER=root ; COMMAND=/usr/bin/pwmFanControl &
Mar 25 11:31:44 raspberry sudo[2811]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Mar 25 11:31:45 raspberry sudo[2811]: pam_unix(sudo:session): session closed for user root
Mar 25 11:31:45 raspberry systemd[1]: deskpi.service: Main process exited, code=killed, status=11/SEGV
Mar 25 11:31:45 raspberry systemd[1]: deskpi.service: Failed with result 'signal'.
Mar 25 11:31:45 raspberry systemd[1]: Failed to start DeskPi PWM Control Fan Service.

Do you know why it doesn't work, and do you know how to fix? Thanks.

jzazo commented 1 year ago

I created this PR to solve the service-shutdown problems discussed above