|
|
Line 1: |
Line 1: |
| {{GD Template Impl}} | | {{GD Template Impl}} |
− | ==Overview==
| |
− | This page only provides scripts and tutorial on how to install '''power management & safety switch & PWM fan''' based on different OS.
| |
| | | |
− | If you need to know how to flash raspberry pi OS image into micro sd card or nvme ssd, please refer to the following '''official document''':
| + | __NOTOC__ |
− | * [https://www.raspberrypi.com/documentation/computers/getting-started.html Getting started]
| |
− | * [https://www.raspberrypi.com/documentation/computers/compute-module.html#flashing-the-compute-module-emmc Flashing the Compute Module eMMC]
| |
| | | |
− | ==For Raspbian OS==
| + | This is script installation tutorial for [[NASPi]], [[NASPi Gemini 2.5]], [[NASPi CM4-M2]] and [[NASPi CM4-2.5]] |
− | '''Test this script based on the following OS:'''
| + | <hr/> |
− | * [https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2023-05-03/2023-05-03-raspios-bullseye-arm64.img.xz 2023-05-03-raspios-bullseye-arm64.img.xz]
| + | The original code is from [https://github.com/pimlie/geekworm-x-c1 pimlie/geekworm-x-c1], pimlie implements the pwm fan shell script, which does not depend on third-party python libraries at all. Thanks to pimlie. |
− | * [https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2023-05-03/2023-05-03-raspios-bullseye-arm64-lite.img.xz 2023-05-03-raspios-bullseye-arm64-lite.img.xz]
| |
− | * [https://retropie.org.uk/download/ retropie-buster-4.8-rpi4_400.img.gz]
| |
− | * [https://twisteros.com/download.html TwisterOSv2-1-2.img.xz]
| |
− | ===Install===
| |
− | <pre>
| |
− | cd ~
| |
− | sudo apt-get update
| |
− | sudo apt-get -y upgrade
| |
− | sudo apt-get -y install git i2c-tools python3-smbus python3-rpi.gpio
| |
| | | |
− | git clone https://github.com/geekworm-com/xscript.git
| + | ==OS that has been tested== |
| + | * Raspbian |
| + | * DietPi |
| + | * Manjaro |
| + | * Ubuntu |
| + | * myNode |
| + | * Umbrel |
| + | * Volumio |
| | | |
− | cd xscript
| + | ==Preconfigured <code>config.txt</code>== |
− | sudo chmod +x *.sh
| + | To install pwm fan, first add <code>dtoverlay=pwm-2chan</code> to <code>/boot/config.txt</code> under [all] or the end of file and <code>reboot</code>: |
− | sudo cp -f ./pwr.sh /etc/pwr.sh
| + | sudo nano /boot/config.txt |
− | sudo cp -f ./softsd.sh /usr/local/bin/softsd.sh | |
| | | |
− | sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local
| + | '''Or''' (it's <code>/boot/firmware/config.txt</code> if you are using <code>ubuntu</code>) |
| + | sudo nano /boot/firmware/config.txt |
| + | Save & exit. |
| + | sudo reboot |
| | | |
− | echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc
| + | ==Clone the script== |
| + | <pre> |
| + | git clone https://github.com/geekworm-com/script-test |
| | | |
− | sudo reboot now
| + | cd script-test |
| + | chmod +x *.sh |
| </pre> | | </pre> |
| + | ==Create the x-c1-fan service== |
| + | <pre> |
| + | sudo cp -f ./x-c1-fan.sh /usr/local/bin/ |
| + | sudo cp -f ./x-c1-fan.service /lib/systemd/system |
| + | sudo systemctl daemon-reload |
| + | sudo systemctl enable x-c1-fan |
| + | sudo systemctl start x-c1-fan |
| + | </pre> |
| + | Then the pwm fan starts running. |
| | | |
− | If you find the following information when executing the above command:
| + | '''PS: If your device does not support pwm fans or you are not using pwm, you can skip this step''' |
− | | |
− | '''''0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.''''' | |
− | | |
− | Please ignore it, it just means that your OS already contains these software, nothing more.
| |
− | | |
− | If reboot fails, please force shutdown or power off and restart.
| |
− | | |
− | | |
− | ===Test safe shutdown===
| |
− | xoff
| |
− | * Please run 'xoff' to shut down or press the on-board button switch to shut down. <span style="color:red;">DON'T run the 'shutdown' linux command to shut down, otherwise the power of device will not be shut down.</span>
| |
− | * press button switch `1-2` seconds to reboot
| |
− | * press button switch `3` seconds to safe shutdown,
| |
− | * press `7-8` seconds to force shutdown.
| |
− | | |
− | ===How to enable OLED display===
| |
− | Please refer to [[How to enable OLED display]]
| |
− | | |
− | === PWM fan control''' (This is optional)===
| |
− | | |
− | PS: You can ignore this step if you don't use the 3-Pin PWM fan to cool the CM4. In fact, the [[C235]] passive cooler can provide enough cooling capacity, and you can also avoid the trouble of fan noise, it is included in [[NASPi CM4-M2]] and [[NASPi CM4-2.5]]
| |
− | | |
− | Run the below command to get the fan running.
| |
− | python3 /home/pi/xscript/fan-rpi.py &
| |
− | But when you reboot the device, the PWM fans won't run unless you run the above command again,
| |
− | | |
− | There are serveral methods to enable fan run after the device reboots, recommend the first method:
| |
− | | |
− | 1. Create a crontab job, place the command 'python3 /home/geekworm/xscript/fan-rpi.py&' into the crontab, refer to [[How to add crontab job]].
| |
− | | |
− | 2. Place the running command into the /etc/rc.local file, you can run the following command:
| |
− | sudo sed -i '$ i python3 /home/pi/xscript/fan-rpi.py &' /etc/rc.local
| |
− | NOTE: Please make sure the fan-rpi.py file path is correct;
| |
− | | |
− | | |
− | ===Uninstall===
| |
− | sudo ./uninstall.sh
| |
− | sudo reboot now
| |
− | | |
− | ==For ubuntu mate / ubuntun desktop / ubuntu server==
| |
− | | |
− | Test this script based on the following OS:
| |
− | * ubuntu-22.04.1-preinstalled-desktop-arm64+raspi.img.xz
| |
− | | |
− | '''Install'''
| |
| | | |
| + | ==Create the x-c1-pwr service== |
| <pre> | | <pre> |
− | cd ~
| + | sudo cp -f ./x-c1-pwr.sh /usr/local/bin/ |
− | sudo apt-get update | + | sudo cp -f x-c1-pwr.service /lib/systemd/system |
− | sudo apt-get upgrade -y
| + | sudo systemctl daemon-reload |
− | sudo apt-get install -y git i2c-tools wiringpi python3-setuptools python3-distutils python3-rpi.gpio python3-smbus
| + | sudo systemctl enable x-c1-pwr |
− | | + | sudo systemctl start x-c1-pwr |
− | git clone https://github.com/geekworm-com/xscript.git
| |
− | | |
− | cd xscript
| |
− | sudo chmod +x *.sh rc.local
| |
− | sudo cp -f ./pwr.sh /etc/pwr.sh
| |
− | sudo cp -f ./softsd.sh /usr/local/bin/softsd.sh
| |
− | | |
− | #Enable rc.local
| |
− | sudo cp -f ./rc.local /etc/rc.local | |
− | | |
− | sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local | |
− | | |
− | echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc
| |
− | | |
− | sudo reboot now
| |
| </pre> | | </pre> |
| | | |
− | If you find the following information when executing the above command:
| + | Then the pwm fan starts running |
− | | |
− | '''''0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.'''''
| |
− | | |
− | Please ignore it, it just means that your OS already contains these software, nothing more.
| |
− | | |
− | If reboot fails, please force shutdown or power off and restart.
| |
− | | |
− | | |
− | ''' PWM fan control''' (This is optional)
| |
| | | |
− | PS: You can ignore this step if you don't use the 3-Pin PWM fan to cool the CM4. In fact, the [[C235]] passive cooler can provide enough cooling capacity, and you can also avoid the trouble of fan noise, it is included in [[NASPi CM4-M2]] and [[NASPi CM4-2.5]]
| + | ==Prepair software shutdown== |
− | | + | sudo cp -f ./x-c1-softsd.sh /usr/local/bin/ |
− | Run the below command to get the fan running.
| + | Create a alias <code>xoff</code> command to execute the software shutdown |
− | python3 /home/geekworm/xscript/fan-rpi.py& | |
− | NOTE: You need change the 'geekworm' to your username;
| |
− | | |
− | But when you reboot the device, the PWM fans won't run unless you run the above command again,
| |
− | | |
− | There are '''serveral methods''' to enable fan run after the device reboots:
| |
− | | |
− | 1. Create a crontab job, place the command 'python3 /home/geekworm/xscript/fan-rpi.py&' into the crontab, refer to [[How to add crontab job]].
| |
− | | |
− | 2. Place the running command into the /etc/rc.local file, you can run the following command:
| |
− | sudo sed -i '$ i python3 /home/geekworm/xscript/fan-rpi.py&' /etc/rc.local
| |
− | NOTE: You need change the 'geekworm' to your username;
| |
− | | |
− | '''Test safe shutdown'''
| |
− | xoff
| |
− | * Please run 'xoff' to shut down or press the on-board button switch to shut down. <span style="color:red;">DON'T run the 'shutdown' linux command to shut down, otherwise the power of device will not be shut down.</span>
| |
− | * press button switch `1-2` seconds to reboot
| |
− | * press button switch `3` seconds to safe shutdown,
| |
− | * press `7-8` seconds to force shutdown.
| |
− | | |
− | '''uninstall'''
| |
− | sudo ./uninstall.sh
| |
− | sudo reboot now
| |
− | | |
− | == For DietPi==
| |
− | * [https://dietpi.com/#download DietPi_RPi-ARMv8-Bullseye.7z]
| |
− | | |
− | '''Install'''
| |
− | | |
− | login via teminal window, the default user name is `root`, password is `dietpi`, then run the following command:
| |
| <pre> | | <pre> |
− | cd ~
| + | echo "alias xoff='sudo /usr/local/bin/x-c1-softsd.sh'" >> ~/.bashrc |
− | sudo apt-get update
| + | source ~/.bashrc |
− | sudo apt-get -y upgrade
| |
− | sudo apt-get -y install git i2c-tools python3 python3-smbus python3-rpi.gpio
| |
− | | |
− | git clone https://github.com/geekworm-com/xscript.git
| |
− | | |
− | cd xscript
| |
− | sudo chmod +x *.sh rc.local
| |
− | sudo cp -f ./pwr.sh /etc/pwr.sh
| |
− | sudo cp -f ./softsd.sh /usr/local/bin/softsd.sh
| |
− | | |
− | sudo cp -f ./rc.local /etc/rc.local
| |
− | | |
− | sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local
| |
− | echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc | |
− | | |
− | sudo reboot now
| |
| </pre> | | </pre> |
| + | Then you can run <code>xoff</code> to execute software shutdown. |
| | | |
− | ''' PWM fan control''' (This is optional)
| + | ==Test safe shutdown== |
− | | + | '''Software safe shutdown command''': |
− | PS: You can ignore this step if you don't use the 3-Pin PWM fan to cool the CM4. In fact, the [[C235]] passive cooler can provide enough cooling capacity, and you can also avoid the trouble of fan noise, it is included in [[NASPi CM4-M2]] and [[NASPi CM4-2.5]]
| |
− | | |
− | Run the below command to get the fan running.
| |
− | python3 /root/xscript/fan-rpi.py&
| |
− | But when you reboot the device, the PWM fans won't run unless you run the above command again, so you need to create a crontab job to keep the fans running when the device reboots, Please refer to [[How to add crontab job]].
| |
− | | |
− | | |
− | '''Test safe shutdown''' | |
| xoff | | xoff |
− | * Please run 'xoff' to shut down or press the on-board button switch to shut down. <span style="color:red;">DON'T run the 'shutdown' linux command to shut down, otherwise the power of device will not be shut down.</span>
| + | '''Hardware safe shutdown operation''': |
− | * press button switch `1-2` seconds to reboot
| + | * press on-board button switch <code>1-2</code> seconds to reboot |
− | * press button switch `3` seconds to safe shutdown, | + | * press button switch <code>3</code> seconds to safe shutdown, |
− | * press `7-8` seconds to force shutdown. | + | * press <code>7-8</code> seconds to force shutdown. |
− | | |
− | '''uninstall'''
| |
− | sudo ./uninstall.sh
| |
− | sudo reboot now
| |
− | | |
− | ==For Manjaro==
| |
− | Test this script base on the following OS:
| |
− | * [https://manjaro.org Manjaro-ARM-gnome-rpi4-23.02.img.xz]
| |
− | | |
− | ===1. Install===
| |
− | | |
− | '''Update system & install dependent packages'''
| |
− | cd ~
| |
− | sudo pacman -Syyu
| |
− | sudo pacman -S python python-setuptools
| |
− | | |
− | '''Install RPi.GPIO Python Library'''
| |
− | | |
− | The script that the fan runs depends on the RPi.GPIO Python library. Since this OS does not include this package by default, we need to install it manually.
| |
− | | |
− | Refer to [[How to Install RPi.GPIO Python Library]], and you need use the ''''Method 2 – Manual Installation''''
| |
− | | |
− | '''Download script'''
| |
− | cd ~
| |
− | git clone https://github.com/geekworm-com/xscript.git
| |
− | | |
− | If the current OS does not include the git tool, then you need to use the following command to install it firstly
| |
− | sudo pacman -S git
| |
− | | |
− | '''Install script'''
| |
− | cd ~/xscript
| |
− | sudo chmod +x *.sh rc.local
| |
− | sudo cp -f ./pwr.sh /etc/pwr.sh
| |
− | sudo cp -f ./softsd.sh /usr/local/bin/softsd.sh
| |
− | | |
− | '''Enable rc.local service'''
| |
− | sudo cp -f ./rc.local /etc/rc.local
| |
− | sudo cp rc.local.service /lib/systemd/system
| |
− | sudo systemctl enable rc.local
| |
− | | |
− | sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local
| |
− | sudo sed -i '$ i sudo python3 ~/xscript/fan-rpi.py &' /etc/rc.local
| |
| | | |
− | '''Create a alias xoff''' | + | ==FAQ== |
− | echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc
| + | Q: How to login '''volumio''' via SSH? |
− | Then reboot the device
| |
− | sudo reboot now
| |
| | | |
− | ===2. Test safe shutdown===
| + | A: |
− | xoff
| |
− | * Please run 'xoff' to shut down or press the on-board button switch to shut down. DON'T run the 'shutdown' linux command to shut down, otherwise the power of device will not be shut down.
| |
− | * press button switch `1-2` seconds to reboot
| |
− | * press button switch `3` seconds to safe shutdown,
| |
− | * press `7-8` seconds to force shutdown.
| |
| | | |
− | ===3. PWM fan control (Optional)===
| + | 1. Enable SSH: |
| | | |
− | PS: You can ignore this step if you don't use the 3-Pin PWM fan to cool the CM4. In fact, the C235 passive cooler can provide enough cooling capacity, and you can also avoid the trouble of fan noise, it is included in [[NASPi CM4-M2]] and [[NASPi CM4-2.5]]
| + | Visit http://volumio.local/dev/, then click 'ENABLE SSH' button |
| | | |
− | Run the below command to get the fan running.
| + | 2. URL connection is IP address, and the default user name is '''volumio''', default password is '''volumio''' |
− | sudo python3 ~/xscript/fan-rpi.py &
| |
− | But when you reboot the device, the PWM fans won't run unless you run the above command again,
| |
| | | |
− | ON Manjaro OS, Place the running command into the '/etc/rc.local file', then this command will be execute after the device reboot, you can run the following command:
| |
− | sudo sed -i '$ i echo "your password" | sudo -S python3 ~/xscript/fan-rpi.py &' /etc/rc.local
| |
− | NOTE: Please make sure the fan-rpi.py file path is correct;
| |
| | | |
− | ===4. Uninstall===
| + | Q: How to login to '''Umbrel''' via SSH? |
− | cd ~/xscript
| |
− | sudo ./uninstall.sh
| |
− | sudo reboot now
| |
| | | |
− | ==For myNode OS and Umbrel==
| + | A: ssh umbrel@umbrel.local (or ssh umbrel@<IP address of your Umbrel>). the default user name is '''umbrel''', default password is '''moneyprintergobrrr''' |
− | * [https://mynodebtc.com/ mynode_raspi4_arm64_0-3-18.img.gz], the default user name is `'''admin'''`, default password is `'''bolt'''`
| |
− | * [https://umbrel.com/ umbrel-os-v0.5.3.zip],the default user name is `'''umbrel'''`, default password is `'''moneyprintergobrrr'''`
| |
| | | |
− | ===1. Install===
| |
| | | |
− | sudo apt-get update
| + | Q: How to login to '''myNode''' via SSH? |
− | sudo apt-get install pigpio python-pigpio python-smbus wiringpi -y
| |
− | cd ~
| |
− | git clone https://github.com/geekworm-com/xscript.git
| |
− | sudo chmod +x *.sh rc.local
| |
− | sudo cp -f ./pwr.sh /etc/pwr.sh
| |
− | sudo cp -f ./softsd.sh /usr/local/bin/softsd.sh
| |
− | sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local
| |
| | | |
− | echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc
| + | A: URL connection is IP address, and the default user name is '''admin''', default password is '''bolt''' |
| | | |
− | Then reboot the device
| |
− | sudo reboot now
| |
| | | |
− | ===2. Test safe shutdown===
| + | Q: How to login to '''DietPi''' via SSH? |
− | xoff
| |
− | * Please run 'xoff' to shut down or press the on-board button switch to shut down. DON'T run the 'shutdown' linux command to shut down, otherwise the power of device will not be shut down.
| |
− | * press button switch `1-2` seconds to reboot
| |
− | * press button switch `3` seconds to safe shutdown,
| |
− | * press `7-8` seconds to force shutdown.
| |
| | | |
− | ===3. PWM fan control (Optional)===
| + | A: URL connection is IP address, and the default user name is '''root''', default password is '''dietpi''' |
| | | |
− | PS: You can ignore this step if you don't use the 3-Pin PWM fan to cool the CM4. In fact, the C235 passive cooler can provide enough cooling capacity, and you can also avoid the trouble of fan noise, it is included in [[NASPi CM4-M2]] and [[NASPi CM4-2.5]]
| |
| | | |
− | Run the below command to get the fan running.
| + | Q: Is LibreELEC supported? |
− | sudo systemctl enable pigpiod
| |
− | sudo sed -i '$ i sudo pigpiod' /etc/rc.local
| |
− | sudo python ~/xscript/fan.py &
| |
− | But when you reboot the device, the PWM fans won't run unless you run the above command again,
| |
| | | |
− | ON myNode OS, create a crontab,place the following command into the crontab file, then this command will be execute after the device reboot, refer to [[How to add crontab job]].
| + | A: TODO |
− | * * * * * python ~/xscript/fan.py &
| |
| | | |
− | NOTE: Please make sure the fan.py file path is correct;
| |
| | | |
| <!--Add review function! --> | | <!--Add review function! --> |
This is script installation tutorial for NASPi, NASPi Gemini 2.5, NASPi CM4-M2 and NASPi CM4-2.5
The original code is from pimlie/geekworm-x-c1, pimlie implements the pwm fan shell script, which does not depend on third-party python libraries at all. Thanks to pimlie.
OS that has been tested
- Raspbian
- DietPi
- Manjaro
- Ubuntu
- myNode
- Umbrel
- Volumio
Preconfigured config.txt
To install pwm fan, first add dtoverlay=pwm-2chan
to /boot/config.txt
under [all] or the end of file and reboot
:
sudo nano /boot/config.txt
Or (it's /boot/firmware/config.txt
if you are using ubuntu
)
sudo nano /boot/firmware/config.txt
Save & exit.
sudo reboot
Clone the script
git clone https://github.com/geekworm-com/script-test
cd script-test
chmod +x *.sh
Create the x-c1-fan service
sudo cp -f ./x-c1-fan.sh /usr/local/bin/
sudo cp -f ./x-c1-fan.service /lib/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable x-c1-fan
sudo systemctl start x-c1-fan
Then the pwm fan starts running.
PS: If your device does not support pwm fans or you are not using pwm, you can skip this step
Create the x-c1-pwr service
sudo cp -f ./x-c1-pwr.sh /usr/local/bin/
sudo cp -f x-c1-pwr.service /lib/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable x-c1-pwr
sudo systemctl start x-c1-pwr
Then the pwm fan starts running
Prepair software shutdown
sudo cp -f ./x-c1-softsd.sh /usr/local/bin/
Create a alias xoff
command to execute the software shutdown
echo "alias xoff='sudo /usr/local/bin/x-c1-softsd.sh'" >> ~/.bashrc
source ~/.bashrc
Then you can run xoff
to execute software shutdown.
Test safe shutdown
Software safe shutdown command:
xoff
Hardware safe shutdown operation:
- press on-board button switch
1-2
seconds to reboot
- press button switch
3
seconds to safe shutdown,
- press
7-8
seconds to force shutdown.
FAQ
Q: How to login volumio via SSH?
A:
1. Enable SSH:
Visit http://volumio.local/dev/, then click 'ENABLE SSH' button
2. URL connection is IP address, and the default user name is volumio, default password is volumio
Q: How to login to Umbrel via SSH?
A: ssh umbrel@umbrel.local (or ssh umbrel@<IP address of your Umbrel>). the default user name is umbrel, default password is moneyprintergobrrr
Q: How to login to myNode via SSH?
A: URL connection is IP address, and the default user name is admin, default password is bolt
Q: How to login to DietPi via SSH?
A: URL connection is IP address, and the default user name is root, default password is dietpi
Q: Is LibreELEC supported?
A: TODO
Enable comment auto-refresher
Anonymous user #24
Permalink |
Anonymous user #24
Lisa
Anonymous user #24
Permalink |
Lisa
Anonymous user #25
Anonymous user #23
Permalink |
Anonymous user #22
Permalink |
Lisa
Anonymous user #20
Permalink |
Anonymous user #21
Anonymous user #19
Permalink |
Anonymous user #18
Permalink |
Harry
Anonymous user #17
Permalink |
Harry
Anonymous user #16
Permalink |
Harry
Anonymous user #9
Permalink |
Anonymous user #9
Permalink |
Anonymous user #14
Permalink |
Anonymous user #13
Permalink |
Walker
Anonymous user #11
Permalink |
Anonymous user #11
Walker
Anonymous user #14
Anonymous user #10
Permalink |
Walker
Anonymous user #9
Permalink |
Anonymous user #9
Walker
Anonymous user #8
Permalink |
Walker
Anonymous user #15
Anonymous user #7
Permalink |
Anonymous user #7
Walker
Anonymous user #6
Permalink |
Harry
Anonymous user #5
Permalink |
Harry
Anonymous user #4
Permalink |
Walker
Anonymous user #12
Anonymous user #3
Permalink |
Harry
Anonymous user #3
Permalink |
Harry
Anonymous user #2
Permalink |
Harry
Anonymous user #2
Anonymous user #2
Anonymous user #1
Permalink |
Harry