petrockblog / PowerBlock

Driver for petrockblock.com PowerBlock
43 stars 10 forks source link

rpi5 updates breaks install for rpi2 & 3 #15

Open grondar69 opened 4 months ago

grondar69 commented 4 months ago

Had this up and running forever, rebuilt a rpi2 and 3 tonight and neither would work (light continuously flashing and switch did nothing. Also noticed that after the install neither pi shutdown.

Noticed changes were made a couple days ago, I ran the uninstall script, rebooted, made the following reversions, re-installed and everything is working fine now.

file /PowerBlock/install.sh

comment line 'updateBootConfig'

file /PowerBlock/scripts/powerblockservice - change as follows

setPinValue() {
  echo $2 > $BASE_GPIO_PATH/gpio$1/value
#-  gpioset $chip $1=$2
}

getPinValue() {
  echo $(cat $BASE_GPIO_PATH/gpio$1/value)
#-  echo $(gpioget $chip $1)
}
grondar69 commented 4 months ago

Also had to comment out this section

file /PowerBlock/scripts/powerblockservice

#- Determine Raspberry Pi GPIO access chip
#- chip=4 for RPi5, chip=0 for older models
#-if gpiodetect | grep -q "pinctrl-rp"; then
#-  chip=4
#-else
#-  chip=0
#-fi
geekawhyte commented 4 months ago

Faced the same problem. Unfortunately neither your changes nor the old driver version work for me (anymore). I am running Raspberry Pi OS Lite 12 64bit with Kernel 6.6.20+rpt-rpi-v8. Before the last OS updates, which also included the current kernel, I think, I was at least able to get the old driver version working again. I'm still trying to figure out how to boot into the older kernel to explore this theory.

geekawhyte commented 4 months ago

It seems my theory was right. I prepared a new SD card with latest Raspberry Pi OS 12 Lite 64bit image from December 2023, cloned the PowerBlock repository and made the changes mentioned above. Everything worked fine. Then I did an apt upgrade. Kernel was updated from 6.1.0-rpi7-rpi-v8 to 6.6.20+rpt-rpi-v8. Powerblock service starts and runs all the time, but the LED keeps flashing and the switch does not work. Any ideas?

Could it have something to do with this? https://github.com/raspberrypi/linux/issues/6037

grondar69 commented 4 months ago

Not sure, I just saw that there were updates to the code and reverted them, I'm using the standard 32-bit legacy install of raspbian

geekawhyte commented 4 months ago

It doesn't matter if 32-bit or 64-bit. The new kernel in Bookworm is the "problem". It seems like I've found a solution, even if I don't know if it's a good solution.

In /etc/powerblockconfig.cfg I've made these changes: statuspin=529 shutdownpin=530

grondar69 commented 4 months ago

In /etc/powerblockconfig.cfg I've made these changes: statuspin=529 shutdownpin=530

I'm curious how you came up with those values? I've done some looking online but havent been able to find anything. I am going to try your fix as well.

grondar69 commented 4 months ago

Closed by accident, reopening ....

geekawhyte commented 4 months ago

In /etc/powerblockconfig.cfg I've made these changes: statuspin=529 shutdownpin=530

I'm curious how you came up with those values? I've done some looking online but havent been able to find anything. I am going to try your fix as well.

From this site: https://github.com/raspberrypi/linux/issues/6037

I did a "cat /sys/kernel/debug/gpio" on my RPi3 with old and new kernel.

Old kernel (6.1.x): gpio-17 (GPIO17... gpio-18 (GPIO18...

New kernel (6.6.x): gpio-529 (GPIO17... gpio-530 (GPIO18...

So, it works, but I don't know if it could have any side effects.

PS: your changes in PowerBlock/install.sh and PowerBlock/scripts/powerblockservice are still necessary for me.

ZachPL commented 3 months ago

I'm on a pi 3b+ using the retropie img and I had to revert the last 2 commits and rerun the install script for the shutdown script to run. I checked the GPI pins the retropie image is still using 17 and 18 so I didn't need to make those changes.

petrockblog commented 3 months ago

Thanks for this information. I need to update the installation script, obviously.

petrockblog commented 3 months ago

@ZachPL @geekawhyte @grondar69 @ontje I just updated the driver: It tries to install the GPIO tools during installation now. The driver checks at runtime the availability of the GPIO tools and falls back to sysfs in case the GPIO tools cannot be found. This should restore the compatibility with the older RPi models.