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
140 stars 46 forks source link

Ubuntu Server 22.04 power led keeps blue after halt #128

Open jzazo opened 1 year ago

jzazo commented 1 year ago

I have installed Ubuntu Server 22.04 and I also installed drivers for Deskpi Pro. I think fan is working, and secondary USBs are also working.

However, when I shutdown the rpi4, all services turn off but the blue led keeps been lit and it does not turn red. Before Ubuntu I was using Raspbian and it was working fine. Any idea why this happens? Thank you.

jzazo commented 1 year ago

Hi again. Any help regarding automatic flipping of led to red after sudo shutdown -h now? Do I need to change the eeprom config? Does it happen with other distributions? Thanks.

jzazo commented 1 year ago

Nobody can help? Thanks.

beforeyouknowit commented 1 year ago

I'm also having this issue, on my Pi 4 / 4GB, under Ubuntu 22.04; pressing the power button on my DeskPi Pro does not trigger a safe shutdown. I've had a look at your various installation scripts, and I'm trying to make sense of the patterns used.

In the /drivers/c/ folder, I see a safecutoffpower.c and it's compiled binarysafecutoffpower. In the same folder, I see a safecutoffpower64 binary but without its corresponding C file. Is this 64-bit-oriented C file missing?

Also, following your installation script patterns, in the install-ubuntu-64.sh script, (that I used for Ubuntu 22.04 (64-bit) ARM,) I don't see a similar pattern you used to compile the pwmControlFan.c file into the pwmFanControl binary, which might correspond to a gcc compilation step for the 64-bit safecutoffpower64 binary, nor a similar step for compiling the fanStop.c file for 64-bit.

Could you please help us understand if we should be focusing on manually compiling (and copying into place) the binaries rendered from fanStop.c or missing safecutoffpower64.c ? Thanks!

yoyojacky commented 1 year ago

Hi there, the power led turn to red means that your system has been sent "POWER_OFF" signal via serial port to /dev/ttyUSB0 device , once you shut down your system , deskpi service will send the "power_off" signal to /dev/ttyUSB0 serial port , it will be detected by MCU on mainboard, so it will cut off the power from mainboard to raspberry pi. it seems like the ubuntu_installation script dose not work properly, i am going to fix this issue ASAP.

yoyojacky commented 1 year ago

It is the same source code ,but compiled in both 32bit and 64bit system .

lfhoward commented 1 year ago

Hello, the same issue still exists as of May 14, 2023. It is a fresh install of Ubuntu 22.04, 64 bit. Soft shutdown does not work and the power button stays blue after shutting down via the on-screen menu. Thanks for addressing this bug.

lfhoward commented 1 year ago

I've been doing a little investigating, seeing where the requisite files are located for the safe shutdown service.

The necessary files seem to be: (which get installed by setup) /usr/bin/fanStop /usr/lib/systemd/system/deskpi-safeshut.service /etc/systemd/system/halt.target.wants/deskpi-safeshut.service /etc/systemd/system/shutdown.target.wants/deskpi-safeshut.service /etc/systemd/system/poweroff.target.wants/deskpi-safeshut.service

probably missing: safecutoffpower64 (located in ~/deskpi/drivers/c/ and could be moved to /usr/bin/, which would be where the pwmFanControl64 file goes.) This likely sends the ‘Power_Off’ signal to the serial port at /dev/ttyUSB0, which is the same serial used by the fan control. I suspect this because the code is probably derived from safecutoffpower.py in ~/deskpi/drivers/python/.

The deskpi-safeshut.service file, found in 4 locations above, looks like:

[Unit] Description=DeskPi Safeshutdown Service Conflicts=reboot.target Before=halt.target shutdown.target poweroff.target DefaultDependencies=no [Service] Type=oneshot ExecStart=/usr/bin/sudo /usr/bin/fanStop RemainAfterExit=yes TimeoutSec=1 [Install] WantedBy=halt.target shutdown.target poweroff.target

I wonder if the problem is in this line of code: ExecStart=/usr/bin/sudo /usr/bin/fanStop

I can see how it calls fanstop, but it doesn’t call safecutoffpower64. The parallel line of code in deskpi.service is: ExecStart=sudo /usr/bin/pwmFanControl64

I do not know where the safecutoffpower64 should be called in this line of code, whether before or after fanStop. Can anyone on here shed some light on how and when safeCutoffPower64 should be called inside of deskpi-safeshut.service?

lfhoward commented 1 year ago

Partial Solution:

I checked in /usr/bin and safecutoffpower64 was not there.

I then copied safecutoffpower64 from ~/deskpi/drivers/c/ to /usr/bin/

I then edited /lib/systemd/system/deskpi-safeshut.service to run the safecutoffpower64 function after fanStop:

[Unit] Description=DeskPi Safeshutdown Service Conflicts=reboot.target Before=halt.target shutdown.target poweroff.target DefaultDependencies=no [Service] Type=oneshot ExecStart=/usr/bin/sudo /usr/bin/fanStop /usr/bin/safecutoffpower64 RemainAfterExit=yes TimeoutSec=1 [Install] WantedBy=halt.target shutdown.target poweroff.target

Make sure the ExecStart line is edited in these 4 locations: /usr/lib/systemd/system/deskpi-safeshut.service /etc/systemd/system/halt.target.wants/deskpi-safeshut.service /etc/systemd/system/shutdown.target.wants/deskpi-safeshut.service /etc/systemd/system/poweroff.target.wants/deskpi-safeshut.service

sudo shutdown now

The light should turn red a few seconds after shutdown.

After booting back up, I tried using the button (short press) to initiate a safe shutdown and still nothing happens. I am not sure how to get the button to initiate the shutdown process. The function /usr/bin/poweroff could be called somehow, but I am not sure how to assign that to pressing the button. However the light behind the button acts like it should now, and the power does not have to be cut manually after shutdown anymore.

Hope this helps someone!

lfhoward commented 1 year ago

While looking at the drivers for an earlier version of DeskPi (Lite, V1), I noticed that there is a function for turning the Pi off when the power button is pressed twice. There does not seem to be such a file included in the DeskPi Pro (V2) drivers.

The earlier driver's code can be found here: https://github.com/DeskPi-Team/deskpi_v1/blob/main/drivers/python/safe_shutdown.py

It listens for a ‘poweroff’ signal from the MCU (button), and returns a power off signal to /dev/ttyUSB0 to run the safe shutdown service if it gets the message. I have not tried to run that old driver in my DeskPi Pro. I don’t know if the button will send the ‘poweroff’ (no underscore) signal properly, nor do I know if the shutdown script might need to be modified: the power off signal sent to /dev/ttyUSB0 in the old driver is the all lowercase 'power_off', but in the new DeskPi Pro drivers it is 'Power_Off'. I don’t know if the change to upper case letters matters. It then shuts down the system using the command sudo init 0, which closes all programs before shutting down cleanly.

Anyone want to create an updated driver from the old code? Chances are it should go in /usr/bin/ like the others.

cchulo commented 1 year ago

are you at least able to run the fans, I'm having an issue with both the power button staying blue and fans not running

jzazo commented 1 year ago

A PR has been merged that should have fixed the blue led staying on. Latest master should include the fix.

cchulo commented 1 year ago

A PR has been merged that should have fixed the blue led staying on. Latest master should include the fix.

it does not, I tried it on Ubuntu server/desktop 22.04, and raspberry pi OS all 64 bit, and on shutdown the blue LED stays on

I was able to get the fans to work on raspberry pi OS, but nothing else works. I am going to be RMA'ing it, I am disappointed by the state of these setup scripts

yoyojacky commented 1 year ago

I am working on it, it will comming soon.

yoyojacky commented 3 days ago

A PR has been merged that should have fixed the blue led staying on. Latest master should include the fix.

it does not, I tried it on Ubuntu server/desktop 22.04, and raspberry pi OS all 64 bit, and on shutdown the blue LED stays on

I was able to get the fans to work on raspberry pi OS, but nothing else works. I am going to be RMA'ing it, I am disappointed by the state of these setup scripts

It seems like your system did not send power_off signal to the MCU so that it will not cut off the power, and could you please check the always on switch on deskpi daughter board ?