Lightweight Installation (SATA HAT only, no cpu fan, no lcd, no buttons)

After reading the code in more detail it seems that the pigpiod is really only used for the fan control, the actual drive control uses the RPi.GPIO library instead. I am actually a bit confused why pigpio is needed at all, since RPi.GPIO also offers PWM control and could have been used in fan.py

For the standalone case I think only main.py and the misc.py would be needed, these need to be modified to not call fan or oled. Essentially just a main.py which calls misc.disk_turn_on()

I would give it a try myself however since you wrote the code I think you would do a better job :slight_smile:

RPi.GPIO is not used because it does not offer hardware PWM functionality… it offers software PWM functionality, but that was causing fan whine…

That’s why Setq switched over to pigpio because the lib offers hardware PWM functionality.

1 Like

I see… I am currently using the PWM from RPi.GPIO with a Noctua PWM fan without issues.

https://gpiozero.readthedocs.io/en/stable/migrating_from_rpigpio.html?highlight=pwm#pwm-pulse-width-modulation

gpiozero looks like it may be another option.

https://gpiozero.readthedocs.io/en/stable/api_pins.html

The hardware PWM of gpiozero via RPIO or PiGPIO, and the RPIO is not available in Raspberry Pi 4 at present.

@quadnas

I’ve provided you with a new script that uses pure bash and doesn’t rely on anything.

Use the following command to install:

curl -sL https://rock.sh/get-rockpi-sata-lite | sudo -E bash -

2 Likes

Works perfectly, thank you!

One issue I encountered with this, the system hangs on boot waiting to mount the drives (via /etc/fstab) since the service is not running yet and the drives are not yet powered.

My fix was to edit the service so that it runs before the system tries to mount the drives

I modified /lib/systemd/system/quad-sata-lite.service

[Unit]
Description=ROCK Pi SATA Hat
Before=local-fs.target

1 Like

Thanks for sharing, I added it to the script.

Would this work for the regular quad sata with top hat? I do note that there is dependency on pigpio service starting first…

Yes should work, I had done the same with the original script while I tested it before setq made the lite script. Just edit the pigpiod service located at:

/lib/systemd/system/pigpiod.service

[Unit]
Description=Daemon required to control GPIO pins via pigpio
Before=local-fs.target
[Service]
ExecStart=/usr/local/bin/pigpiod -l
ExecStop=/bin/systemctl kill pigpiod
Type=forking
[Install]
WantedBy=multi-user.target

So it turns out neither RPi.GPIO nor pigpiod are needed to get hardware PWM from the Pi, you can load a pwm kernel overlay and access the BCM2835 hardware PWM directly, see below

https://jumpnowtek.com/rpi/Using-the-Raspberry-Pi-Hardware-PWM-timers.html

I am now using this method and have a simple bash script running the PWM, 0% CPU load compared to the ~7% I was seeing with pigpiod and the ~17% I was seeing with RPi.GPIO

actually for PiGPIO, the 7% was due to alerts and sampling… if u set the flag -m to the service, the CPU load from PiGPIO drops to 0…

but good find though…

It is quite nice, because if you combine this with the lite script that setq wrote, no additional packages are needed to run the SATA Hat and to control the fans.

But for those that need the top hat oled… I think there’s probably a way to change the pwm implementation… doesn’t seem like much change to the code, just the calls would be different… the main arguments Ike dutycycle are largely there already…

Hi all,
great thread. I am looking at doing the very same thing that the op is doing - ie lightweight installation, so this is very valuable :).
@setq would you mind sharing the script you wrote for a minimal install?
Thanks!

Apologies, I forgot the other part of the question, which is can I run the hat without GPIO connections at all, ie with only the USB links between the two? Purpose would be to improve heat dissipation for the Pi.
Thanks.

@tgc The current version must connect to GPIO.

Thanks for the prompt answer @setq, appreciate it. What happens if I don’t connect them? Anything bad hardware wise, or sw just won’t work?
Also I guess I can extend the gpio to increase airflow… Do you know which pins are used?
Thanks!

setq posted the script earlier in the thread, it’s hosted here:
https://rock.sh/get-rockpi-sata-lite

Reading the script you can see that GPIO 26 (pin 37) and GPIO 25 (pin 22) are used to turn on/off the sata controller:

SATA0=26
SATA1=25

You can also see it on the pinout section of the wiki:
Pin 37 (GPIO 26) = SATA 3/4
Pin 22 (GPIO 25) = SATA 1/2
https://wiki.radxa.com/Dual_Quad_SATA_HAT

If you don’t connect the GPIO then it won’t work, those pins turn on the jms561 sata controller. Without the controller the USB bus wont connect to the sata ports .