Open main menu

Changes

XScript

1,864 bytes removed, 9 April
{{GD Template Impl}}
==Overview==__NOTOC__This page only provides scripts on how to install '''power management & safety switch & PWM fan''' based on different OSis script installation tutorial for [[NASPi]], [[NASPi Gemini 2. 5]], [[NASPi CM4-M2]] and [[NASPi CM4-2.5]]
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''':* This script also works on [https://www.raspberrypi.com/documentationsoftware/computersoperating-systems/getting-started.html Getting startedbookworm]* [https://wwwOS, and test it on Jan.raspberrypi9th 2024.com/documentation/computers/compute-module.html#flashing-the-compute-module-emmc Flashing the Compute Module eMMC]
==For Raspbian OS=='''Test this The original key pwm fan control script based on the following OS:'''* is from [https://downloadsgithub.raspberrypi.org/raspios_arm64com/imagespimlie/raspios_arm64geekworm-2023x-05-03c1 pimlie/2023-05-03-raspios-bullseye-arm64.img.xz 2023-05-03geekworm-raspiosx-bullseye-arm64.img.xzc1]* [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, pimlie implements the pwm fan shell script, which does not depend on third-1-2party python libraries at all.imgThanks to pimlie.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://githubNow we think you have successfully flashed the OS Image into Micro SD and and power on the device, and you have also completed the operations such as creating new user required in some Raspberry Pi OS.com/geekworm-com/xscript.git
cd xscriptsudo chmod +x *.shsudo cp -f .After your system boots, then you need to open <code>Terminal</pwr.sh /etc/pwr.shsudo cp -f ./softsd.sh /usr/local/bin/softsd.shcode> prpgram, then type the following command to complete the installation of the script
sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local
echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc'[Update]'''
sudo reboot now</pre>1. NASPi series does '''not support Raspberry Pi 5 hardwared''' due to different hardware interface.
If you find the following information when executing the above command:2. Use gpiod instead of obsolete interface, and suuports ubuntu 23.04 also
3. The script now supports the Raspberry Pi OS '''BOOKWORM'''0 upgraded, 0 newly installed, 0 version. You just need to remove '''uninstall''' the original script and 0 not upgraded.'''reinstall'''it. Please refer to the following:
Please ignore itOPen ternimal window, it just means that your OS already contains these software, nothing more.then run the following command:<pre>mv xscript xcript-oldIf reboot fails, please force shutdown or power off and restartgit clone https://github.com/geekworm-com/xscriptcd xscriptchmod +x *.sh''' PWM fan control''' (This is optional)./uninstall.sh</pre>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 Then just follow the trouble of fan noise, it is included in [[NASPi CM4-M2]] and [[NASPi CM4-2installation process below.5]]
Run the below command to get the fan running==OS that has been tested==* Raspbian* DietPi* Manjaro* Ubuntu (Testing based on '''Ubuntu 23.04''')* myNode python3 /home/pi/xscript/fan-rpi.py &* Umbrel* Volumio* RetroPieBut when you reboot the device, the PWM fans won't run unless you run the above command again,* Twister
There '''Note:''' Not tested with '''Home Assistant''', for some reason, we are serveral methods not able to enable fan run after upgrade and use the device rebootsHome Assistant to test, recommend please pay attention to check if there is any update in the first methodfuture.(If you have successfully tested Home Assistant, welcome to share your experience via email at:support@geekworm.com)
1==Preconfigured <code>config. Create a crontab jobtxt</code>==To install pwm fan, place first add <code>dtoverlay=pwm-2chan</code> to <code>/boot/firmware/config.txt</code> or <code>/boot/config.txt</code> under [all] or the command 'python3 end of file and <code>reboot</homecode>: sudo nano /geekwormboot/xscriptfirmware/fan-rpiconfig.py&txtSome OS' into s config.txt may be in the crontab/boot/ directory, refer so that you need to [[How to add crontab job]]run the following command: sudo nano /boot/config.txtUsing <code>ls /boot/firmware/config.txt</code> you can check if the file is in the /boot/firmware/ directory
2Save & exit. 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.localrebootNOTEPS: Please make sure Only appending to the fan-rpilast line not replace.py file path is correct;
'''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 ubuntu mate / ubuntun desktop / ubuntu serverInstall gpiod package=== est this script based on the following OS:* ubuntu-22.04.1-preinstalled-desktop sudo apt install -arm64+raspi.img.xz '''Install'''y gpiod
==Download the script==
<pre>
cd ~sudo apt-get updatesudo apt-get upgrade -ysudo apt-get install -y git i2c-tools wiringpi python3-setuptools python3-distutils python3-rpi.gpio python3-smbus git clone https://github.com/geekworm-com/xscript.git
cd xscript
sudo chmod +x *.sh rc.localsudo cp -f ./pwr.sh /etc/pwr.shsudo cp -f ./softsd.sh /usr/local/bin/softsd.sh #Enable rc.localsudo 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>
'''PS''': For some OS such as ''Raspberry Pi OS Lite'', the '''''git''''' tool is not installed by default, if you get an error like ''error: -bash: git: command not found'', please run the following command to install the git tool.
sudo apt install -y git
==Create the x-c1-fan service==<span class="tb_red_bold"> Note: If your device does not support pwm fans or you are not using pwm, you find the following information when executing the above command:can skip this step</span>
'''''0 upgraded, 0 newly installed, 0 Run the following command to remove and 0 not upgradedinstall fan service script; sudo ./install-fan-service.shThen the pwm fan starts running.'''''
Please ignore it, it just means that your OS already contains these software, nothing more==Create the x-c1-pwr service== sudo ./install-pwr-service.sh
If reboot fails, please force ==Prepair software shutdown or power off and restartscript== sudo ./install-sss.sh
After the installation is complete, an <code>xoff</code> command will be created to shut down the software.Then you can run <code>xoff</code> to execute software shutdown.
''' PWM fan control''' (This is optional)==Uninstall==Run the following command to uninstall all. sudo ./uninstall.sh
PS==Test safe shutdown=='''Software safe shutdown command''': You can ignore this step if you don xoff<span class="tb_red">DON't use T run the 3-Pin PWM fan 'shutdown' linux command to cool the CM4. In fact, the [[C235]] passive cooler can provide enough cooling capacityshut down, and you can also avoid otherwise the trouble power of fan noise, it is included in [[NASPi CM4-M2]] and [[NASPi CM4-2shield will not be shut down.5]]</span>
Run the below command to get the fan running. python3 /home/geekworm/xscript/fan-rpi.py&NOTE: You need change the 'geekworm' to your username;'Hardware safe shutdown operation''':
But when you reboot You can verify the safety switch through the onboard switch, press and hold the deviceswitch for <code>3</code> seconds, then the blue LED will flash slowly and the PWM fans won't run unless you run shutdown is going then all LEDs will be off until the above command againdevice is completely powered off.* press on-board button switch <code>1-2</code> seconds to reboot* press button switch <code>3</code> seconds to safe shutdown, * press <code>7-8</code> seconds to force shutdown.
There are '''serveral methods''' to enable ==Sample==#The code for fan run after speed control is now in the device reboots:<code>x-c1-fan.sh</code> file.#<code>fan-rpi.py</code> and <code>fan-pigpio.py</code> are no longer used, and are reserved here for research and use by python lovers only.
1. Create a crontab job, place the command 'python3 /home/==Support==Email: support@geekworm/xscript/fan-rpi.py&' into the crontab, refer to [[How to add crontab job]].com
2. Place If you have any problems during use, please contact us by email and tell us the running command into product model you are using and the /etc/rc.local file, OS version you can run the following command: sudo sed -i '$ i python3 /home/geekworm/xscript/fan-rpi.py&' /etc/rcare using.local NOTE: You need change the 'geekworm' to your username;
'''Test safe shutdown'''==FAQ==<html> xoff<details>* Please run 'xoff' <summary>Q: How to shut down or press the on-board button switch to shut downlogin <b>volumio</b> via SSH?</summary><p>1. Enable SSH:</p><span style="colorp>Visit http:red;"//volumio.local/dev/, then click <b>ENABLE SSH</b> button</p><p>DON'T run the 'shutdown' linux command to shut down2. URL connection is IP address, otherwise and the power of device will not be shut down.default user name is <b>volumio</spanb>* press button switch `1-2` seconds to reboot* press button switch `3` seconds to safe shutdown,default password is <b>volumio</b></p>* press `7-8` seconds to force shutdown.</details>
'''uninstall'''<details> sudo <summary>Q: How to login to <b>Umbrel</b> via SSH?</summary>A: ssh umbrel@umbrel.local (or ssh umbrel@<IP address of your Umbrel>). the default user name is <b>umbrel</uninstall.shb>, default password is <b>moneyprintergobrrr</b> sudo reboot now</details>
== For DietPi==<details>* [https<summary>Q:How to login to <b>myNode</b> via SSH?</dietpi.com/#download DietPi_RPi-ARMv8-Bullseye.7z]summary>
'''Install'''A: URL connection is IP address, and the default user name is <b>admin</b>, default password is <b>bolt</b></details>
<details><summary>Q: How to login to <b>DietPi</b> via teminal window, the default user name is `root`, password is `dietpi`, then run the following command:SSH?<pre/summary>cd ~sudo apt-get updatesudo apt-get -y upgradesudo apt-get -y install git i2c-tools python3 python3-smbus python3-rpi.gpio
git clone httpsA:URL connection is IP address, and the default user name is <b>root</b>, default password is <b>dietpi</github.comb></geekworm-com/xscript.gitdetails>
cd xscript<details>sudo chmod +x *.sh rc.localsudo cp -f ./pwr.sh /etc/pwr.shsudo cp -f ./softsd.sh /usr/local<summary>Q: Is <b>LibreELEC</binb> supported?</softsd.shsummary>
sudo cp -f .A: TODO</rc.local /etc/rc.localdetails>
sudo sed -i '$ i </etc/pwr.sh &' /etc/rc.localecho "alias xoff='sudo /usr/local/bin/softsd.sh'" >html> ~/.bashrc
sudo reboot now
</pre>
 
''' 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 /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
* 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
<!--Add review function! -->