From 9fbeabb5e546c18da9ed51da55571cc53b3677cb Mon Sep 17 00:00:00 2001 From: yoyojacky Date: Tue, 25 Jun 2024 15:11:39 +0800 Subject: [PATCH] update scripts Signed-off-by: yoyojacky --- Kali/install-kali.sh | 78 ------- README.md | 151 ++++--------- RaspberryPiOS/32bit/install_32bit_bullseye.sh | 84 ------- .../32bit/uninstall_32bit_bullseye.sh | 26 --- Ubuntu/install-ubuntu-64.sh | 85 -------- drivers/README.md | 62 ------ drivers/c/Makefile | 18 -- drivers/c/pwmFanControl64 | Bin 14184 -> 0 bytes drivers/c/safecutoffpower.c | 76 ------- installation/DietPi/install-dietPi-64bit.sh | 108 +++++++++ installation/DietPi/uninstall-dietPi-64bit.sh | 43 ++++ installation/Fedora/README.md | 2 + .../Fedora}/install-fedora.sh | 0 .../Fedora}/uninstall-fedora.sh | 0 .../Kali/install-kali.sh | 30 ++- {Kali => installation/Kali}/uninstall-kali.sh | 5 +- .../Manjaro}/install-manjaro.sh | 0 .../Manjaro}/uninstall-manjaro.sh | 0 installation/README.md | 57 ++++- .../64bit/install-raspios-64bit.sh | 63 ++---- .../64bit/uninstall-raspios-64bit.sh | 16 +- installation/Ubuntu/install-ubuntu-64.sh | 109 ++++++++++ .../Ubuntu}/uninstall-ubuntu-mate.sh | 0 .../drivers}/Deskpi-uninstall | 0 installation/drivers/README.md | 47 +++- installation/drivers/c/Makefile | 13 +- installation/drivers/c/pwmControlFan.c | 205 ------------------ .../drivers/c/pwmFanControl.c | 0 .../c/{pwmControlFan64 => pwmFanControl64} | Bin 71408 -> 71408 bytes installation/drivers/c/safeCutOffPower.c | 9 +- installation/drivers/c/safeCutOffPower64 | Bin 70856 -> 70808 bytes .../drivers}/deskpi-config | 0 .../drivers}/python/pwmControlFan.py | 0 .../drivers}/python/safecutoffpower.py | 0 installation/install.sh | 194 ----------------- 35 files changed, 440 insertions(+), 1041 deletions(-) delete mode 100755 Kali/install-kali.sh delete mode 100755 RaspberryPiOS/32bit/install_32bit_bullseye.sh delete mode 100755 RaspberryPiOS/32bit/uninstall_32bit_bullseye.sh delete mode 100755 Ubuntu/install-ubuntu-64.sh delete mode 100644 drivers/README.md delete mode 100644 drivers/c/Makefile delete mode 100644 drivers/c/pwmFanControl64 delete mode 100644 drivers/c/safecutoffpower.c create mode 100755 installation/DietPi/install-dietPi-64bit.sh create mode 100755 installation/DietPi/uninstall-dietPi-64bit.sh create mode 100644 installation/Fedora/README.md rename {Fedora => installation/Fedora}/install-fedora.sh (100%) rename {Fedora => installation/Fedora}/uninstall-fedora.sh (100%) rename Ubuntu/install-ubuntu-mate.sh => installation/Kali/install-kali.sh (73%) rename {Kali => installation/Kali}/uninstall-kali.sh (86%) rename {Manjaro => installation/Manjaro}/install-manjaro.sh (100%) rename {Manjaro => installation/Manjaro}/uninstall-manjaro.sh (100%) rename {RaspberryPiOS => installation/RaspberryPiOS}/64bit/install-raspios-64bit.sh (59%) rename {RaspberryPiOS => installation/RaspberryPiOS}/64bit/uninstall-raspios-64bit.sh (72%) create mode 100755 installation/Ubuntu/install-ubuntu-64.sh rename {Ubuntu => installation/Ubuntu}/uninstall-ubuntu-mate.sh (100%) rename {drivers => installation/drivers}/Deskpi-uninstall (100%) delete mode 100644 installation/drivers/c/pwmControlFan.c rename drivers/c/pwmControlFan.c => installation/drivers/c/pwmFanControl.c (100%) rename installation/drivers/c/{pwmControlFan64 => pwmFanControl64} (94%) rename {drivers => installation/drivers}/deskpi-config (100%) rename {drivers => installation/drivers}/python/pwmControlFan.py (100%) rename {drivers => installation/drivers}/python/safecutoffpower.py (100%) delete mode 100755 installation/install.sh diff --git a/Kali/install-kali.sh b/Kali/install-kali.sh deleted file mode 100755 index 233da5c..0000000 --- a/Kali/install-kali.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# -. /lib/lsb/init-functions - -daemonname="deskpi" -tempmonscript=/usr/bin/pmwFanControl -deskpidaemon=/lib/systemd/system/$daemonname.service -safeshutdaemon=/lib/systemd/system/$daemonname-safeshut.service -installationfolder=/home/kali/deskpi - -# install wiringPi library. -log_action_msg "DeskPi Fan control script installation Start." - -# Create service file on system. -if [ -e $deskpidaemon ]; then - sudo rm -f $deskpidaemon -fi - -# adding dtoverlay to enable dwc2 on host mode. -sudo sed -i '/dtoverlay=dwc2*/d' /boot/config.txt -sudo sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/config.txt - -# install PWM fan control daemon. -log_action_msg "DeskPi main control service loaded." -cd $installationfolder/drivers/c/ -sudo cp -rf $installationfolder/drivers/c/pwmFanControl /usr/bin/pwmFanControl -sudo cp -rf $installationfolder/drivers/c/fanStop /usr/bin/fanStop -sudo cp -rf $installationfolder/deskpi-config /usr/bin/deskpi-config -sudo cp -rf $installationfolder/Deskpi-uninstall /usr/bin/Deskpi-uninstall -sudo chmod 755 /usr/bin/pwmFanControl -sudo chmod 755 /usr/bin/fanStop -sudo chmod 755 /usr/bin/deskpi-config -sudo chmod 755 /usr/bin/Deskpi-uninstall - -# Build Fan Daemon -echo "[Unit]" > $deskpidaemon -echo "Description=DeskPi PWM Control Fan Service" >> $deskpidaemon -echo "After=multi-user.target" >> $deskpidaemon -echo "[Service]" >> $deskpidaemon -echo "Type=oneshot" >> $deskpidaemon -echo "RemainAfterExit=true" >> $deskpidaemon -echo "ExecStart=sudo /usr/bin/pwmFanControl &" >> $deskpidaemon -echo "[Install]" >> $deskpidaemon -echo "WantedBy=multi-user.target" >> $deskpidaemon - -# send signal to MCU before system shuting down. -echo "[Unit]" > $safeshutdaemon -echo "Description=DeskPi Safeshutdown Service" >> $safeshutdaemon -echo "Conflicts=reboot.target" >> $safeshutdaemon -echo "Before=halt.target shutdown.target poweroff.target" >> $safeshutdaemon -echo "DefaultDependencies=no" >> $safeshutdaemon -echo "[Service]" >> $safeshutdaemon -echo "Type=oneshot" >> $safeshutdaemon -echo "ExecStart=/usr/bin/sudo /usr/bin/fanStop" >> $safeshutdaemon -echo "RemainAfterExit=yes" >> $safeshutdaemon -echo "[Install]" >> $safeshutdaemon -echo "WantedBy=halt.target shutdown.target poweroff.target" >> $safeshutdaemon - -log_action_msg "DeskPi Service configuration finished." -sudo chown root:root $safeshutdaemon -sudo chmod 755 $safeshutdaemon - -sudo chown root:root $deskpidaemon -sudo chmod 755 $deskpidaemon - -log_action_msg "DeskPi Service Load module." -sudo systemctl daemon-reload -sudo systemctl enable $daemonname.service -sudo systemctl start $daemonname.service & -sudo systemctl enable $daemonname-safeshut.service - -# Finished -log_success_msg "DeskPi PWM Fan Control and Safeshut Service installed successfully." -# greetings and require rebooting system to take effect. -log_action_msg "System will reboot in 5 seconds to take effect." -sudo sync -sleep 5 -sudo reboot diff --git a/README.md b/README.md index d903b8a..eb105ab 100644 --- a/README.md +++ b/README.md @@ -3,115 +3,41 @@ The DeskPi Pro is a hardware kit for converting a standard Raspberry Pi 4 from a naked SBC, with limited storage, into a mini PC complete with a power button, cooling, better ports and, via SATA then USB3, 2.5" or M.2 SSD storage. ## Currently tested operating systems that can support Deskpi scripts -* Raspberry Pi OS(32bit) - tested +* Raspberry Pi OS(32bit) - Deprecated * RaspiOS (64bit) - tested -* Ubuntu-mate OS(32bit) - tested -* Ubuntu OS (64bit) - tested -* Manjaro OS (32bit) - tested -* Manjaro OS (64bit) - To be tested -* Kali-linux-arm OS (32bit) - tested -* Kali-linux-arm OS (64-Bit) - To be tested -* Twister OS v2.0.2 (32bit) - tested +* Ubuntu-mate OS(32bit) - Deprecated +* Ubuntu OS (64bit) - on testing (24.04) +* Manjaro OS (32bit) - Deprecated +* Manjaro OS (64bit) - tested +* Kali-linux-arm OS (32bit) - Deprecated +* Kali-linux-arm OS (64-Bit) - Deprecated +* Twister OS v2.0.2 (32bit) - Deprecated * DietPi OS (64bit) - tested * Volumio OS Version: 2021-04-24-Pi (32bit) - tested * RetroPie OS (32bit) - tested * Windows 10 IoT - NOT Supported -* Windows 11 - To be tested +* Windows 11 - NOT Supported ## Please Read this section carefully -* if you are using 64bit OS, The script to control the fan is in the `rivers/c/` directory. The file suffix with `64` means `64bit`, and the one without a `32bit` executable file. +* if you are using 64bit OS, The script to control the fan is in the `installation/drivers/c/` directory. The file suffix with `64` means `64bit`, and the `32bit` executable file has been removed, if you want to use 32bit, please download the repository and compile it by yourself. + * Before you install this script, please make sure your Raspberry Pi can access internet and can access github website. ## How to install it. +* 1. Download the Repository +* 2. Enter `installation` directory +* 3. Select Your OS type +* 4. Execute shell script inside the OS folder. + +For example: + ### For Raspbian OS 64bit (bookworm) -* Step 1. Enable Front USB port -Edit /boot/firmware/config.txt file and adding following parameter: -```bash -dtoverlay=dwc2,dr_mode=host +```bash +git clone https://github.com/DeskPi-Team/deskpi.git +cd ~/deskpi/installation/RaspberryPiOS/64bit/ +sudo ./install-raspios-64bit.sh ``` -Save it and reboot your Raspberry Pi. -* Step 2. Install fan driver -TO BE DONE, we are working on it... -### For Raspbian and RetroPie OS. -```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/ -chmod +x install.sh -sudo ./install.sh -``` -### For Ubuntu 64bit OS -```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/ -chmod +x install-ubuntu-64.sh -sudo ./install-ubuntu-64.sh -``` -### For Ubuntu-mate OS -```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/ -chmod +x install-ubuntu-mate.sh -sudo ./install-ubuntu-mate.sh -``` -### For Manjaro OS -```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/ -chmod +x install-manjaro.sh -sudo ./install-manjaro.sh -``` -### For Kali-linux-arm OS. -* Image Download URL: https://images.kali.org/arm-images/kali-linux-2020.3a-rpi3-nexmon.img.xz
-```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/ -chmod +x install-kali.sh -sudo ./install-kali.sh -``` -### For Twister OS v2.0.2 -`OS image: TwisterOSv2-0-2.img` -* Image Download URL:https://twisteros.com/twisteros.html
-```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/ -chmod +x install.sh -sudo ./install.sh -``` -### For 64 bit Raspberry Pi OS (aarm64) -* Image Download URL: http://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2021-05-28/ -```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/ -chmod +x install-raspios-64bit.sh -sudo ./install-raspios-64bit.sh -``` -* Uninstall: -``` -cd ~/deskpi/ -chmod +x install-raspios-64bit.sh -sudo ./uninstall-raspios-64bit.sh -``` -### For DietPi OS 64bit -* Make sure your OS can access internet and please install `git` first. -* Execute this command in terminal: -``` -apt-get update && apt-get -y install git -``` -* Image Download URL: https://dietpi.com/downloads/images/DietPi_RPi-ARMv8-Bullseye.7z -```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/ -./install.sh -``` ### For Volumio OS Version: 2021-04-24-Pi * Image Download URL: https://updates.volumio.org/pi/volumio/2.882/volumio-2.882-2021-04-24-pi.img.zip * Getting Start: https://volumio.github.io/docs/User_Manual/Quick_Start_Guide.html @@ -136,26 +62,23 @@ and then reboot your DeskPi. ``` sudo reboot ``` -* Download DeskPi driver from github: -``` -git clone https://github.com/DeskPi-Team/deskpi.git -cd deskpi/ -sudo ./install.sh -``` -* TEST it after rebooting. + +###Setting Fan Speed Manually +* Open a terminal and typing: ``` deskpi-config ``` Select `4` and press `Enter`, you would see the fan is spinning and the front USB port are now available. -## How to Uninstall deskpi -```bash -DeskPi-uninstall -``` -And then select the number against to your OS Type. -### For Windows IoT OS -* Unsupported due to lacking of driver. -* Testing version: Midnight falcon +> NOTE: Once you execute this `deskpi-config` command, the deskpi.service will be stopped at background. + +> you will need to execute `sudo systemctl restart deskpi.service` to re-activate it. + +> If `deskpi.service` is in a stopped state, it will not read the configuration in the `/etc/deskpi.conf` file to control the fan. + +> Therefore, if you want the fan to operate automatically according to your custom temperature settings, please ensure that the `deskpi.service` is always running in the background, especially after executing the deskpi-config command, you need to manually restart the `deskpi.service` by executing `sudo systemctl restart deskpi.service` command in a terminal. + + ## How to control fan speed mannualy. * Open a terminal and typing following command: ```bash @@ -186,7 +109,9 @@ TEMP : Fan_SPEED_LEVEL deskpi-config ``` Select `6` and then input `45` and enter, and then input `50` means setup the fan speed level to `50%` when CPU temp is above 45 degree it has 4 level to setup. -NOTE: 50% Speed level means you have already send `PWM50` to `/dev/ttyUSB0` port, and this port will available when you add `dtoverlay=dwc2,dr_mode=host` to `/boot/config.txt` file and `reboot` your DeskPi. + +> NOTE: 50% Speed level means you have already send `PWM50` to `/dev/ttyUSB0` port, and this port will available when you add `dtoverlay=dwc2,dr_mode=host` to `/boot/firmware/config.txt` file and `reboot` your DeskPi. + ## How to boot from USB SSD/HDD? After initial Raspberry Pi Configuration and once you have Internet Connectivity established, Install the DeskPi Pro Utilities from `https://github.com/DeskPi-Team/deskpi.git` @@ -208,6 +133,7 @@ sudo raspi-config * Select Boot Order, select #1 `USB Boot`, Return to Advanced Options, * Select Boot Loader Version, choose `Latest Version` * Save & exit + ### Reboot again (to restart with new settings) ```bash sudo reboot @@ -227,6 +153,7 @@ Depending on device the new SD Card Copier can transfer the SD-Card image to the Once your USB drive is imaged & ready to boot, shutdown your Deskpi-Pro, remove the SD-Card and power-up to boot from the USB Boot drive, once running & configured you can install your additional software and proceed as usual.
* Tutorial video: https://youtu.be/wUHZb9E_WDQ
+ ## How to Use IR function onboard. 1. You need to enable `gpio-ir` function by modify `/boot/config.txt` file. uncomment this line if not exsit please add it. diff --git a/RaspberryPiOS/32bit/install_32bit_bullseye.sh b/RaspberryPiOS/32bit/install_32bit_bullseye.sh deleted file mode 100755 index 900ef73..0000000 --- a/RaspberryPiOS/32bit/install_32bit_bullseye.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# -. /lib/lsb/init-functions -cd ~ -sh -c "git clone https://github.com/DeskPi-Team/deskpi.git" -cd $HOME/deskpi/ -daemonname="deskpi" -tempmonscript=/usr/bin/pmwFanControl -deskpidaemon=/lib/systemd/system/$daemonname.service -safeshutdaemon=/lib/systemd/system/$daemonname-safeshut.service -installationfolder=$HOME/$daemonname - -# install wiringPi library. -log_action_msg "DeskPi Fan control script installation Start." - -# Create service file on system. -if [ -e $deskpidaemon ]; then - sudo rm -f $deskpidaemon -fi - -# adding dtoverlay to enable dwc2 on host mode. -log_action_msg "Enable dwc2 on Host Mode" -sudo sed -i '/dtoverlay=dwc2*/d' /boot/config.txt -sudo sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/config.txt -if [ $? -eq 0 ]; then - log_action_msg "dwc2 has been setting up successfully" -fi -# install PWM fan control daemon. -log_action_msg "DeskPi main control service loaded." -cd $installationfolder/drivers/c/ -sudo cp -rf $installationfolder/drivers/c/pwmFanControl /usr/bin/ -sudo cp -rf $installationfolder/drivers/c/fanStop /usr/bin/ -sudo chmod 755 /usr/bin/pwmFanControl -sudo chmod 755 /usr/bin/fanStop -sudo cp -rf $installationfolder/deskpi-config /usr/bin/ -sudo cp -rf $installationfolder/Deskpi-uninstall /usr/bin/ -sudo chmod 755 /usr/bin/deskpi-config -sudo chmod 755 /usr/bin/Deskpi-uninstall - -# Build Fan Daemon -echo "[Unit]" > $deskpidaemon -echo "Description=DeskPi PWM Control Fan Service" >> $deskpidaemon -echo "After=multi-user.target" >> $deskpidaemon -echo "[Service]" >> $deskpidaemon -echo "Type=simple" >> $deskpidaemon -echo "RemainAfterExit=no" >> $deskpidaemon -echo "ExecStart=sudo /usr/bin/pwmFanControl" >> $deskpidaemon -echo "[Install]" >> $deskpidaemon -echo "WantedBy=multi-user.target" >> $deskpidaemon - -# send signal to MCU before system shuting down. -echo "[Unit]" > $safeshutdaemon -echo "Description=DeskPi Safeshutdown Service" >> $safeshutdaemon -echo "Conflicts=reboot.target" >> $safeshutdaemon -echo "Before=halt.target shutdown.target poweroff.target" >> $safeshutdaemon -echo "DefaultDependencies=no" >> $safeshutdaemon -echo "[Service]" >> $safeshutdaemon -echo "Type=oneshot" >> $safeshutdaemon -echo "ExecStart=/usr/bin/sudo /usr/bin/fanStop" >> $safeshutdaemon -echo "RemainAfterExit=yes" >> $safeshutdaemon -echo "TimeoutSec=1" >> $safeshutdaemon -echo "[Install]" >> $safeshutdaemon -echo "WantedBy=halt.target shutdown.target poweroff.target" >> $safeshutdaemon - -log_action_msg "DeskPi Service configuration finished." -sudo chown root:root $safeshutdaemon -sudo chmod 644 $safeshutdaemon - -sudo chown root:root $deskpidaemon -sudo chmod 644 $deskpidaemon - -log_action_msg "DeskPi Service Load module." -sudo systemctl daemon-reload -sudo systemctl enable $daemonname.service -sudo systemctl start $daemonname.service & -sudo systemctl enable $daemonname-safeshut.service - -# Finished -log_success_msg "DeskPi PWM Fan Control and Safeshut Service installed successfully." -# greetings and require rebooting system to take effect. -log_action_msg "System will reboot in 5 seconds to take effect." -sudo sync -sleep 5 -sudo reboot diff --git a/RaspberryPiOS/32bit/uninstall_32bit_bullseye.sh b/RaspberryPiOS/32bit/uninstall_32bit_bullseye.sh deleted file mode 100755 index a0abe22..0000000 --- a/RaspberryPiOS/32bit/uninstall_32bit_bullseye.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# uninstall deskpi script -. /lib/lsb/init-functions - -daemonname="deskpi" -deskpidaemon=/lib/systemd/system/$daemonname.service -safeshutdaemon=/lib/systemd/system/$daemonname-safeshut.service - -log_action_msg "Uninstalling DeskPi PWM Fan Control and Safeshut Service." -sleep 1 -log_action_msg "Diable DeskPi PWM Fan Control and Safeshut Service." -log_action_msg "Remove dtoverlay configure from /boot/config.txt file" -sudo sed -i '/dtoverlay=dwc2,dr_mode=host/d' /boot/config.txt -log_action_msg "Stop and disable DeskPi services" -sudo systemctl disable $daemonname.service 2&>/dev/null -sudo systemctl stop $daemonname.service 2&>/dev/null -sudo systemctl disable $daemonname-safeshut.service 2&>/dev/null -sudo systemctl stop $daemonname-safeshut.service 2&>/dev/null -log_action_msg "Remove DeskPi PWM Fan Control and Safeshut Service." -sudo rm -f $deskpidaemon 2&>/dev/null -sudo rm -f $safeshutdaemon 2&>/dev/null -sudo rm -f /usr/bin/fanStop 2&>/dev/null -sudo rm -f /usr/bin/pwmFanControl 2&>/dev/null -sudo rm -f /usr/bin/deskpi-config 2&>/dev/null -sudo rm -f /usr/bin/Deskpi-uninstall 2&>/dev/null -log_success_msg "Uninstall DeskPi Driver Successfully." diff --git a/Ubuntu/install-ubuntu-64.sh b/Ubuntu/install-ubuntu-64.sh deleted file mode 100755 index 8397437..0000000 --- a/Ubuntu/install-ubuntu-64.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -# -. /lib/lsb/init-functions - -daemonname="deskpi" -tempmonscript=/usr/bin/pmwFanControl -deskpidaemon=/lib/systemd/system/$daemonname.service -safeshutdaemon=/lib/systemd/system/$daemonname-safeshut.service -# Thanks for muckypaws' help, solve the location problem. -installationfolder=/home/$SUDO_USER/deskpi - -# install DeskPi stuff. -log_action_msg "DeskPi Fan control script installation Start." - -# Create service file on system. -if [ -e $deskpidaemon ]; then - sudo rm -f $deskpidaemon -fi - -# adding dtoverlay to enable dwc2 on host mode. -sudo sed -i '/dtoverlay=dwc2*/d' /boot/firmware/config.txt -sudo sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/firmware/config.txt - -# install PWM fan control daemon. -log_action_msg "DeskPi main control service loaded." -sudo apt-get install -qy gcc -cd $installationfolder/drivers/c/ -mv $installationfolder/drivers/c/pwmFanControl $installationfolder/drivers/c/pwmFanControl.old 2>/dev/null -gcc -o $installationfolder/drivers/c/pwmFanControl $installationfolder/drivers/c/pwmControlFan.c -gcc -o $installationfolder/drivers/c/fanStop $installationfolder/drivers/c/fanStop.c -sudo cp -rf $installationfolder/drivers/c/pwmFanControl /usr/bin/pwmFanControl -sudo cp -rf $installationfolder/drivers/c/fanStop /usr/bin/fanStop -sudo cp -rf $installationfolder/deskpi-config /usr/bin/deskpi-config -sudo cp -rf $installationfolder/Deskpi-uninstall /usr/bin/Deskpi-uninstall -sudo chmod 755 /usr/bin/pwmFanControl -sudo chmod 755 /usr/bin/fanStop -sudo chmod 755 /usr/bin/deskpi-config -sudo chmod 755 /usr/bin/Deskpi-uninstall - -# Build Fan Daemon -echo "[Unit]" > $deskpidaemon -echo "Description=DeskPi PWM Control Fan Service" >> $deskpidaemon -echo "After=multi-user.target" >> $deskpidaemon -echo "[Service]" >> $deskpidaemon -echo "Type=simple" >> $deskpidaemon -echo "RemainAfterExit=no" >> $deskpidaemon -echo "ExecStart=sudo /usr/bin/pwmFanControl" >> $deskpidaemon -echo "[Install]" >> $deskpidaemon -echo "WantedBy=multi-user.target" >> $deskpidaemon - -# send signal to MCU before system shuting down. -echo "[Unit]" > $safeshutdaemon -echo "Description=DeskPi Safeshutdown Service" >> $safeshutdaemon -echo "Conflicts=reboot.target" >> $safeshutdaemon -echo "Before=halt.target shutdown.target poweroff.target" >> $safeshutdaemon -echo "DefaultDependencies=no" >> $safeshutdaemon -echo "[Service]" >> $safeshutdaemon -echo "Type=oneshot" >> $safeshutdaemon -echo "ExecStart=/usr/bin/sudo /usr/bin/fanStop" >> $safeshutdaemon -echo "RemainAfterExit=yes" >> $safeshutdaemon -echo "TimeoutSec=1" >> $safeshutdaemon -echo "[Install]" >> $safeshutdaemon -echo "WantedBy=halt.target shutdown.target poweroff.target" >> $safeshutdaemon - -log_action_msg "DeskPi Service configuration finished." -sudo chown root:root $safeshutdaemon -sudo chmod 755 $safeshutdaemon - -sudo chown root:root $deskpidaemon -sudo chmod 755 $deskpidaemon - -log_action_msg "DeskPi Service Load module." -sudo systemctl daemon-reload -sudo systemctl enable $daemonname.service -sudo systemctl start $daemonname.service & -sudo systemctl enable $daemonname-safeshut.service - -# Finished -log_success_msg "DeskPi PWM Fan Control and Safeshut Service installed successfully." -# greetings and require rebooting system to take effect. -log_action_msg "System will reboot in 5 seconds to take effect." -sudo sync -sleep 5 -# sudo reboot -echo "Reboot system for changes to take effect" diff --git a/drivers/README.md b/drivers/README.md deleted file mode 100644 index 79f7731..0000000 --- a/drivers/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# Control Your Fan througn PWM signal via Serial port(OTG) -## Configure /boot/config.txt to enbale otg function. -```bash -sudo vim.tiny /boot/config.txt -``` -add: -```bash -dtoverlay=dwc2, dr_mode=host -``` -save it and reboot Raspberry Pi. -## C Language -* 1. At First, get the demo code from github. -```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/drivers/c/ -``` -* 2. How to compile it. -```bash -make -``` -* 3. How to run it. -```bash -sudo ./pwmFanControl -``` -* 4. How to stop it. -Press "Ctrl + C" -* 5. How to clean the source code directory. -```bash -make clean -``` -## How to change speed of the fan. -This program is send the pwm signal from Raspberry Pi to the extension board via OTG serial port, which will be recognized by your Raspberry Pi as "/dev/ttyUSB0" device. so if you want to control the fan as your wish, you can modify pwmControlFan.c code and recompile it. -* In the default code, we have set 4 level for you Fan on pwm signal: -* Level 0: 0% speed-> send "pwm_000" to /dev/ttyUSB0", means to turn off the fan -* Level 1: 25% speed-> send "pwm_025" to /dev/ttyUSB0", means to set fan speed to 25% -* Level 2: 50% speed-> send "pwm_050" to /dev/ttyUSB0", means to set fan speed to 50% -* Level 3: 75% speed-> send "pwm_075" to /dev/ttyUSB0", means to set fan speed to 75% -* Level 4:100% speed-> send "pwm_100" to /dev/ttyUSB0", means to set fan speed to 100% - -# Python -## How to control fan through PWM signal via serial port. -You can also control your fan with python script. -just remember to send "pwm_xxx" to "/dev/ttyUSB0" device. xxx means the level of your fan speed. from 0-100 (integer). -### 1. Install pyserial library. -* Python2.x -```bash -pip install pyserial -``` -* Python3.x -```bash -pip3 install pyserial -``` -### 2. Get the demo code from github and execute it. -```bash -cd ~ -git clone https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/drivers/python/ -sudo python3 pwmControlFan.py -``` -### Job Done. - diff --git a/drivers/c/Makefile b/drivers/c/Makefile deleted file mode 100644 index 9e8e49e..0000000 --- a/drivers/c/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -DEFAULT: all -.PHONY: install - -all: pwmControlFan64 safecutoffpower64 - -install: - sudo chmod 755 pwmControlFan fanStop safecutoffpower - sudo cp pwmControlFan fanStop safecutoffpower /usr/bin/ - sudo chcon -u system_u -t bin_t /usr/bin/pwmControlFan /usr/bin/fanStop /usr/bin/safecutoffpower - -pwmControlFan: pwmControlFan.c - gcc -o pwmControlFan pwmControlFan.c -fanStop: fanStop.c - gcc -o fanStop fanStop.c -safecutoffpower: safecutoffpower.c - gcc -o safecutoffpower safecutoffpower.c -clean: - rm -rf safecutoffpower pwmControlFan fanStop diff --git a/drivers/c/pwmFanControl64 b/drivers/c/pwmFanControl64 deleted file mode 100644 index 79a71e705bfcdde35fd59108de8afce2986392c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14184 zcmeHOeQ;FQbw9g{G3HZ%48&mcz^0+tNW!=Ve}$C<2wIE@$gMl+_w ztLX;(T|o0`BH#(QqNX`WFB#K9CmFd2DC?~bYamGH8#$rkA=B$jTP5;`b2KWH^xdex z?Cbdjy8ZkDZBgiIb_gYEsOYhKtariaT`+n=$@ni+?vL+{uQt;jq-)W}MJUU1+45sQ z!Sz>a63=~;5Ssk z`8F&0^Gp@|{wjEH75wQcIFE0oe%q_yH3*!8wqSV)z|0^B{x5JjngQFPlwg+*BqW^OKo0`EkH8-_KHKJeA3L6!SAlpiok1 zF6DVWP>c7)+|Fb=mP+pSwE2uSpYyXYnaM&1^E%G{WPP_gmQ2&5*`)84xVXJHmQ4`L z@qE9FDz5^qn>IGLxOddASViu}wg=pVm-V(MbH0~td!QwiNqcRvjuac--knLC4qYu; zQ4sOeC5)xE+CN@H#@oo$SucctXF++*ac~_TcpA%Pg#I0MF5LbPpt3IN_HeOXo)ZzX z;MPo2YLqw61Hp&Qb90yz2}STNv$gz%0REaus*3@<-8eGIDYYZ~t42Nqe~OPRbn%*n z8&_4w=PlgM(B7{+b;lPuhRKG#^d{d}5d;j-p)2abiyvy}0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-int main(void){ - while(1){ - int serial_port = open("/dev/ttyUSB0", O_RDWR); - if (serial_port < 0){ - printf("Can not access /dev/ttyUSB0, please check it out.\n"); - } - - struct termios tty; - - if(tcgetattr(serial_port, &tty) !=0){ - printf("serial port can not be accessed\n"); - } - - tty.c_cflag &= ~PARENB; - tty.c_cflag |= PARENB; - tty.c_cflag &= ~CSTOPB; - tty.c_cflag |= CSTOPB; - - tty.c_cflag |= CS5; - tty.c_cflag |= CS6; - tty.c_cflag |= CS7; - tty.c_cflag |= CS8; - - tty.c_cflag &= ~CRTSCTS; - tty.c_cflag |= CRTSCTS; - - tty.c_cflag |= CREAD | CLOCAL; - - tty.c_lflag &= ~ICANON; - tty.c_lflag &= ~ECHO; - tty.c_lflag &= ~ECHOE; - tty.c_lflag &= ~ECHONL; - tty.c_lflag &= ~ISIG; - - tty.c_iflag &= ~(IXON | IXOFF | IXANY); - tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); - - tty.c_oflag &= ~OPOST; - tty.c_oflag &= ~ONLCR; - - tty.c_cc[VTIME] = 10; - tty.c_cc[VMIN] = 0; - - cfsetispeed(&tty, B9600); - cfsetospeed(&tty, B9600); - - if (tcsetattr(serial_port, TCSANOW, &tty) !=0){ - printf("Please check out /boot/config.txt file\n"); - } - - char data[10]; - data[0] = 'p'; - data[1] = 'o'; - data[2] = 'w'; - data[3] = 'e'; - data[4] = 'r'; - data[5] = '_'; - data[6] = 'o'; - data[7] = 'f'; - data[8] = 'f'; - data[9] = '\0'; - write(serial_port, data, sizeof(data)); - close(serial_port); - } - return 0; -} diff --git a/installation/DietPi/install-dietPi-64bit.sh b/installation/DietPi/install-dietPi-64bit.sh new file mode 100755 index 0000000..cf51a12 --- /dev/null +++ b/installation/DietPi/install-dietPi-64bit.sh @@ -0,0 +1,108 @@ +#!/bin/bash +# Fit for raspiOS-arm-64bit-lite-buster + +# initializing functions +if [ -e /lib/lsb/init-functions ]; then + . /lib/lsb/init-functions + log_action_msg "Initializing functions..." +fi + + +# remove old daemon file +if [[ -f $fanDaemon ]]; then + systemctl stop deskpi.service + systemctl disable deskpi.service + rm -f $fanDaemon +fi + +if [[ -f $pwrCutOffDaemon ]]; then + + systemctl disable deskpi-cut-off-power.service + rm -f $pwrCutOffDaemon +fi + +# install git tool +pkgStatus=`dpkg-query -l git |grep git | awk '{print $1}'` +if [ $pkgStatus != 'ii' ]; then + apt-get update + apt-get -y install git-core +fi + +# check if dwc2 dtoverlay has been enabled. +checkResult=`grep dwc2 /boot/firmware/config.txt` +if [ $? -ne 0 ]; then + log_warning_msg "Adding dtoverlay=dwc2,dr_mode=host to /boot/firmware/config.txt file." + sed -i '/dtoverlay=dwc2*/d' /boot/firmware/config.txt + sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/firmware/config.txt + log_action_msg "check dwc2 overlay will be enabled after rebooting." +fi + +# Define systemd service name +fanDaemon="/etc/systemd/system/deskpi.service" +pwrCutOffDaemon="/etc/systemd/system/deskpi-cut-off-power.service" + +# copy pre-compiled binary file to /usr/bin/ folder +if [ -d /tmp/deskpi/ ]; then + cp -Rvf /tmp/deskpi/installation/drivers/c/pwmFanControl64 /usr/bin/pwmFanControl64 + cp -Rvf /tmp/deskpi/installation/drivers/c/safeCutOffPower64 /usr/bin/safeCutOffPower64 + cp -Rvf /tmp/deskpi/installation/deskpi-config /usr/bin/deskpi-config + chmod +x /usr/bin/pwmFanControl64 + chmod +x /usr/bin/safeCutOffPower64 + chmod +x /usr/bin/deskpi-config +fi + +# genreate systemd service file +if [ ! -e $fanDaemon ]; then +echo "[Unit]" >> $fanDaemon +echo "Description=DeskPi Fan Control Service" >> $fanDaemon +echo "After=multi-user.target" >> $fanDaemon +echo "[Service]" >> $fanDaemon +echo "Type=simple" >> $fanDaemon +echo "RemainAfterExit=true" >> $fanDaemon +echo "ExecStart=/usr/bin/pwmFanControl64 &" >> $fanDaemon +echo "[Install]" >> $fanDaemon +echo "WantedBy=multi-user.target" >> $fanDaemon +fi + +# send signal to MCU before system shutting down. +if [ ! -e $pwrCutOffDaemon ]; then + echo "[Unit]" >> $pwrCutOffDaemon + echo "Description=DeskPi-cut-off-power service" >> $pwrCutOffDaemon + echo "Conflicts=reboot.target" >> $pwrCutOffDaemon + echo "Before=halt.target shutdown.target poweroff.target" >> $pwrCutOffDaemon + echo "DefaultDependencies=no" >> $pwrCutOffDaemon + echo "[Service]" >> $pwrCutOffDaemon + echo "Type=oneshot" >> $pwrCutOffDaemon + echo "ExecStart= /usr/bin/safeCutOffPower64" >> $pwrCutOffDaemon + echo "RemainAfterExit=yes" >> $pwrCutOffDaemon + echo "[Install]" >> $pwrCutOffDaemon + echo "WantedBy=halt.target shutdown.target poweroff.target" >> $pwrCutOffDaemon +fi + +# grant privilleges to root user. +if [ -e $fanDaemon ]; then + chown root:root $fanDaemon + chmod 755 $fanDaemon + log_action_msg "Load DeskPi service and load modules" + systemctl daemon-reload + systemctl enable deskpi.service + systemctl start deskpi.service & +fi + +if [ -e $pwrCutOffDaemon ]; then + chown root:root $pwrCutOffDaemon + chmod 755 $pwrCutOffDaemon + systemctl enable deskpi-cut-off-power.service +fi + + +# Greetings +if [ $? -eq 0 ]; then + log_action_msg "Congratulations! DeskPi Pro driver has been installed successfully, Have Fun!" + log_action_msg "System will be reboot in 5 seconds to take effect." +else + log_action_warning "Could not download deskpi repository, please check the internet connection and try to execute it again. " + log_action_msg "Usage: sudo ./install-raspios-64bit.sh" +fi + +# sync && sleep 5 && reboot diff --git a/installation/DietPi/uninstall-dietPi-64bit.sh b/installation/DietPi/uninstall-dietPi-64bit.sh new file mode 100755 index 0000000..91d5b19 --- /dev/null +++ b/installation/DietPi/uninstall-dietPi-64bit.sh @@ -0,0 +1,43 @@ + +#!/bin/bash +# uninstall Fit for raspiOS-arm-64bit-lite-buster + +# Define systemd service name +fanDaemon="/etc/systemd/system/deskpi.service" +pwrCutOffDaemon="/etc/systemd/system/deskpi-cut-off-power.service" + +# initializing functions +if [ -e /lib/lsb/init-functions ]; then + . /lib/lsb/init-functions + log_action_msg "Initializing functions..." +fi + +# remove old repository. +if [ -d /tmp/deskpi ]; then + rm -rf /tmp/deskpi* +fi + +if [ -f $fanDaemon ]; then + systemctl stop deskpi.service + systemctl disable deskpi.service + rm -f $fanDaemon +fi + +if [ -f $pwrCutOffDaemon ]; then + systemctl disable deskpi-cut-off-power.service + rm -f $pwrCutOffDaemon +fi + +# delete pwmfancontrol64 and safecutoffpower64 execute binary file. +if [ -e /usr/bin/pwmFanControl64 ]; then + rm -f /usr/bin/pwmFanControl64 + rm -f /usr/bin/safeCutOffPower64 +fi + +# Greetings +if [ $? -eq 0 ]; then + log_action_msg "Congratulations! DeskPi Pro driver has been uninstalled successfully!" + log_action_msg "System will be reboot in 5 seconds to take effect." +fi + +sync && sleep 5 && reboot diff --git a/installation/Fedora/README.md b/installation/Fedora/README.md new file mode 100644 index 0000000..e15b7d8 --- /dev/null +++ b/installation/Fedora/README.md @@ -0,0 +1,2 @@ +## Depracated +Fedora OS support is Depracated from: 2023-12-31 diff --git a/Fedora/install-fedora.sh b/installation/Fedora/install-fedora.sh similarity index 100% rename from Fedora/install-fedora.sh rename to installation/Fedora/install-fedora.sh diff --git a/Fedora/uninstall-fedora.sh b/installation/Fedora/uninstall-fedora.sh similarity index 100% rename from Fedora/uninstall-fedora.sh rename to installation/Fedora/uninstall-fedora.sh diff --git a/Ubuntu/install-ubuntu-mate.sh b/installation/Kali/install-kali.sh similarity index 73% rename from Ubuntu/install-ubuntu-mate.sh rename to installation/Kali/install-kali.sh index aa0498d..f17fff0 100755 --- a/Ubuntu/install-ubuntu-mate.sh +++ b/installation/Kali/install-kali.sh @@ -6,10 +6,9 @@ daemonname="deskpi" tempmonscript=/usr/bin/pmwFanControl deskpidaemon=/lib/systemd/system/$daemonname.service safeshutdaemon=/lib/systemd/system/$daemonname-safeshut.service -# Thanks for muckypaws' help, solve the location problem. -installationfolder=/home/$SUDO_USER/deskpi +installationfolder=/home/kali/deskpi -# install DeskPi stuff. +# install wiringPi library. log_action_msg "DeskPi Fan control script installation Start." # Create service file on system. @@ -23,14 +22,14 @@ sudo sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/firmware/config.txt # install PWM fan control daemon. log_action_msg "DeskPi main control service loaded." -cd $installationfolder/drivers/c/ -sudo cp -rf $installationfolder/drivers/c/pwmFanControl /usr/bin/pwmFanControl -sudo cp -rf $installationfolder/drivers/c/fanStop /usr/bin/fanStop -sudo cp -rf $installationfolder/deskpi-config /usr/bin/deskpi-config -sudo cp -rf $installationfolder/Deskpi-uninstall /usr/bin/Deskpi-uninstall -sudo chmod 755 /usr/bin/pwmFanControl -sudo chmod 755 /usr/bin/fanStop -sudo chmod 755 /usr/bin/deskpi-config +cd $installationfolder/installation/drivers/c/ +sudo cp -rf $installationfolder/installation/drivers/c/pwmFanControl64 /usr/bin/pwmFanControl64 +sudo cp -rf $installationfolder/installation/drivers/c/safeCutOffPower64 /usr/bin/safeCutOffPower64 +sudo cp -rf $installationfolder/installation/deskpi-config /usr/bin/deskpi-config +sudo cp -rf $installationfolder/installation/Deskpi-uninstall /usr/bin/Deskpi-uninstall +sudo chmod 755 /usr/bin/pwmFanControl64 +sudo chmod 755 /usr/bin/safeCutOffPower64 +sudo chmod 755 /usr/bin/deskpi-config sudo chmod 755 /usr/bin/Deskpi-uninstall # Build Fan Daemon @@ -38,9 +37,9 @@ echo "[Unit]" > $deskpidaemon echo "Description=DeskPi PWM Control Fan Service" >> $deskpidaemon echo "After=multi-user.target" >> $deskpidaemon echo "[Service]" >> $deskpidaemon -echo "Type=oneshot" >> $deskpidaemon +echo "Type=simple" >> $deskpidaemon echo "RemainAfterExit=true" >> $deskpidaemon -echo "ExecStart=sudo /usr/bin/pwmFanControl &" >> $deskpidaemon +echo "ExecStart=sudo /usr/bin/pwmFanControl64 &" >> $deskpidaemon echo "[Install]" >> $deskpidaemon echo "WantedBy=multi-user.target" >> $deskpidaemon @@ -52,7 +51,7 @@ echo "Before=halt.target shutdown.target poweroff.target" >> $safeshutdaemon echo "DefaultDependencies=no" >> $safeshutdaemon echo "[Service]" >> $safeshutdaemon echo "Type=oneshot" >> $safeshutdaemon -echo "ExecStart=/usr/bin/sudo /usr/bin/fanStop" >> $safeshutdaemon +echo "ExecStart=/usr/bin/sudo /usr/bin/safeCutOffPower64" >> $safeshutdaemon echo "RemainAfterExit=yes" >> $safeshutdaemon echo "[Install]" >> $safeshutdaemon echo "WantedBy=halt.target shutdown.target poweroff.target" >> $safeshutdaemon @@ -76,5 +75,4 @@ log_success_msg "DeskPi PWM Fan Control and Safeshut Service installed successfu log_action_msg "System will reboot in 5 seconds to take effect." sudo sync sleep 5 -# sudo reboot -echo "Reboot system for changes to take effect" +sudo reboot diff --git a/Kali/uninstall-kali.sh b/installation/Kali/uninstall-kali.sh similarity index 86% rename from Kali/uninstall-kali.sh rename to installation/Kali/uninstall-kali.sh index a0abe22..e054483 100755 --- a/Kali/uninstall-kali.sh +++ b/installation/Kali/uninstall-kali.sh @@ -10,7 +10,7 @@ log_action_msg "Uninstalling DeskPi PWM Fan Control and Safeshut Service." sleep 1 log_action_msg "Diable DeskPi PWM Fan Control and Safeshut Service." log_action_msg "Remove dtoverlay configure from /boot/config.txt file" -sudo sed -i '/dtoverlay=dwc2,dr_mode=host/d' /boot/config.txt +sudo sed -i '/dtoverlay=dwc2,dr_mode=host/d' /boot/firmware/config.txt log_action_msg "Stop and disable DeskPi services" sudo systemctl disable $daemonname.service 2&>/dev/null sudo systemctl stop $daemonname.service 2&>/dev/null @@ -20,7 +20,8 @@ log_action_msg "Remove DeskPi PWM Fan Control and Safeshut Service." sudo rm -f $deskpidaemon 2&>/dev/null sudo rm -f $safeshutdaemon 2&>/dev/null sudo rm -f /usr/bin/fanStop 2&>/dev/null -sudo rm -f /usr/bin/pwmFanControl 2&>/dev/null +sudo rm -f /usr/bin/pwmFanControl64 2&>/dev/null +sudo rm -f /usr/bin/safeCutOffPower64 2&>/dev/null sudo rm -f /usr/bin/deskpi-config 2&>/dev/null sudo rm -f /usr/bin/Deskpi-uninstall 2&>/dev/null log_success_msg "Uninstall DeskPi Driver Successfully." diff --git a/Manjaro/install-manjaro.sh b/installation/Manjaro/install-manjaro.sh similarity index 100% rename from Manjaro/install-manjaro.sh rename to installation/Manjaro/install-manjaro.sh diff --git a/Manjaro/uninstall-manjaro.sh b/installation/Manjaro/uninstall-manjaro.sh similarity index 100% rename from Manjaro/uninstall-manjaro.sh rename to installation/Manjaro/uninstall-manjaro.sh diff --git a/installation/README.md b/installation/README.md index 7ad2593..c7f8d02 100644 --- a/installation/README.md +++ b/installation/README.md @@ -1,9 +1,50 @@ -# Installation script for Raspberry Pi OS 64bit bookworm -## How to install driver by using shell script -```bash -cd ~ -git clone -b feature/bookworm https://github.com/deskpi-team/deskpi -cd deskpi/installation/ -sudo ./install.sh -``` +# NOTE: +## About OS Selection +Please select the correct operating system and platform architecture for installation. + +> Support for 32-bit systems has been discontinued; Use a 64-bit system to fully leverage the performance of the Raspberry Pi. + +> Additionally, due to the official operating system of the Raspberry Pi providing hardware-based optimizations for the Raspberry Pi, it is strongly recommended to use Raspberry Pi OS. + +## The Current file structure is as follows: +. +├── deskpi-config +├── DietPi +│   ├── install-dietPi-64bit.sh +│   └── uninstall-dietPi-64bit.sh +├── drivers +│   ├── c +│   │   ├── Makefile +│   │   ├── pwmFanControl64 +│   │   ├── pwmFanControl.c +│   │   ├── safeCutOffPower64 +│   │   └── safeCutOffPower.c +│   ├── deskpi-config +│   ├── Deskpi-uninstall +│   ├── python +│   │   ├── pwmControlFan.py +│   │   └── safecutoffpower.py +│   └── README.md +├── Fedora +│   ├── install-fedora.sh +│   ├── README.md +│   └── uninstall-fedora.sh +├── Kali +│   ├── install-kali.sh +│   └── uninstall-kali.sh +├── Manjaro +│   ├── install-manjaro.sh +│   └── uninstall-manjaro.sh +├── RaspberryPiOS +│   └── 64bit +│   ├── install-raspios-64bit.sh +│   └── uninstall-raspios-64bit.sh +├── README.md +├── Ubuntu +│   ├── install-ubuntu-64.sh +│   └── uninstall-ubuntu-mate.sh +└── uninstall.sh +## Get Support +If you have any trouble on using our product,please kindly send E-mail to: support@deskpi.com + diff --git a/RaspberryPiOS/64bit/install-raspios-64bit.sh b/installation/RaspberryPiOS/64bit/install-raspios-64bit.sh similarity index 59% rename from RaspberryPiOS/64bit/install-raspios-64bit.sh rename to installation/RaspberryPiOS/64bit/install-raspios-64bit.sh index 8ca2b03..cf51a12 100755 --- a/RaspberryPiOS/64bit/install-raspios-64bit.sh +++ b/installation/RaspberryPiOS/64bit/install-raspios-64bit.sh @@ -1,10 +1,6 @@ #!/bin/bash # Fit for raspiOS-arm-64bit-lite-buster -# Define systemd service name -fanDaemon="/lib/systemd/system/deskpi.service" -pwrCutOffDaemon="/lib/systemd/system/deskpi-cut-off-power.service" - # initializing functions if [ -e /lib/lsb/init-functions ]; then . /lib/lsb/init-functions @@ -12,60 +8,46 @@ if [ -e /lib/lsb/init-functions ]; then fi -# remove old repository. -# if [ -d /tmp/deskpi ]; then -# rm -rf /tmp/deskpi* -# cd /tmp/ && git clone https://github.com/deskpi-team/deskpi -# fi - - +# remove old daemon file if [[ -f $fanDaemon ]]; then - sudo sh -c "sudo systemctl stop deskpi.service" - sudo sh -c "sudo systemctl disable deskpi.service" - sudo sh -c "rm -f $fanDaemon" + systemctl stop deskpi.service + systemctl disable deskpi.service + rm -f $fanDaemon fi if [[ -f $pwrCutOffDaemon ]]; then - sudo sh -c "sudo systemctl disable deskpi-cut-off-power.service" - sudo sh -c "sudo rm -f $pwrCutOffDaemon" + systemctl disable deskpi-cut-off-power.service + rm -f $pwrCutOffDaemon fi # install git tool pkgStatus=`dpkg-query -l git |grep git | awk '{print $1}'` if [ $pkgStatus != 'ii' ]; then - sudo sh -c "sudo apt-get update" - sudo sh -c "sudo apt-get -y install git-core" + apt-get update + apt-get -y install git-core fi # check if dwc2 dtoverlay has been enabled. -checkResult=`grep dwc2 /boot/config.txt` +checkResult=`grep dwc2 /boot/firmware/config.txt` if [ $? -ne 0 ]; then - log_warning_msg "Adding dtoverlay=dwc2,dr_mode=host to /boot/config.txt file." - sudo sh -c "sudo sed -i '/dtoverlay=dwc2*/d' /boot/firmware/config.txt - sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/firmware/config.txt - log_action_msg "check dwc2 overlay will be enabled after rebooting." -fi -# download deskpi driver -cd /tmp/ -sh -c "git clone https://github.com/DeskPi-Team/deskpi.git" -if [ -d /tmp/deskpi ]; then - cd /tmp/deskpi/ -else - log_warning_msg "Could not able to download deskpi repo,please check the network and try again." + log_warning_msg "Adding dtoverlay=dwc2,dr_mode=host to /boot/firmware/config.txt file." + sed -i '/dtoverlay=dwc2*/d' /boot/firmware/config.txt + sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/firmware/config.txt + log_action_msg "check dwc2 overlay will be enabled after rebooting." fi # Define systemd service name -fanDaemon="/lib/systemd/system/deskpi.service" -pwrCutOffDaemon="/lib/systemd/system/deskpi-cut-off-power.service" +fanDaemon="/etc/systemd/system/deskpi.service" +pwrCutOffDaemon="/etc/systemd/system/deskpi-cut-off-power.service" # copy pre-compiled binary file to /usr/bin/ folder if [ -d /tmp/deskpi/ ]; then - cp -Rvf /tmp/deskpi/drivers/c/pwmFanControl64 /usr/bin/pwmFanControl64 - cp -Rvf /tmp/deskpi/drivers/c/safecutoffpower64 /usr/bin/safecutoffpower64 - cp -Rvf /tmp/deskpi/deskpi-config /usr/bin/deskpi-config + cp -Rvf /tmp/deskpi/installation/drivers/c/pwmFanControl64 /usr/bin/pwmFanControl64 + cp -Rvf /tmp/deskpi/installation/drivers/c/safeCutOffPower64 /usr/bin/safeCutOffPower64 + cp -Rvf /tmp/deskpi/installation/deskpi-config /usr/bin/deskpi-config chmod +x /usr/bin/pwmFanControl64 - chmod +x /usr/bin/safecutoffpower64 + chmod +x /usr/bin/safeCutOffPower64 chmod +x /usr/bin/deskpi-config fi @@ -75,7 +57,7 @@ echo "[Unit]" >> $fanDaemon echo "Description=DeskPi Fan Control Service" >> $fanDaemon echo "After=multi-user.target" >> $fanDaemon echo "[Service]" >> $fanDaemon -echo "Type=oneshot" >> $fanDaemon +echo "Type=simple" >> $fanDaemon echo "RemainAfterExit=true" >> $fanDaemon echo "ExecStart=/usr/bin/pwmFanControl64 &" >> $fanDaemon echo "[Install]" >> $fanDaemon @@ -91,7 +73,7 @@ if [ ! -e $pwrCutOffDaemon ]; then echo "DefaultDependencies=no" >> $pwrCutOffDaemon echo "[Service]" >> $pwrCutOffDaemon echo "Type=oneshot" >> $pwrCutOffDaemon - echo "ExecStart= /usr/bin/safecutoffpower64" >> $pwrCutOffDaemon + echo "ExecStart= /usr/bin/safeCutOffPower64" >> $pwrCutOffDaemon echo "RemainAfterExit=yes" >> $pwrCutOffDaemon echo "[Install]" >> $pwrCutOffDaemon echo "WantedBy=halt.target shutdown.target poweroff.target" >> $pwrCutOffDaemon @@ -102,6 +84,7 @@ if [ -e $fanDaemon ]; then chown root:root $fanDaemon chmod 755 $fanDaemon log_action_msg "Load DeskPi service and load modules" + systemctl daemon-reload systemctl enable deskpi.service systemctl start deskpi.service & fi @@ -122,4 +105,4 @@ else log_action_msg "Usage: sudo ./install-raspios-64bit.sh" fi -sync && sleep 5 && reboot +# sync && sleep 5 && reboot diff --git a/RaspberryPiOS/64bit/uninstall-raspios-64bit.sh b/installation/RaspberryPiOS/64bit/uninstall-raspios-64bit.sh similarity index 72% rename from RaspberryPiOS/64bit/uninstall-raspios-64bit.sh rename to installation/RaspberryPiOS/64bit/uninstall-raspios-64bit.sh index 7154369..91d5b19 100755 --- a/RaspberryPiOS/64bit/uninstall-raspios-64bit.sh +++ b/installation/RaspberryPiOS/64bit/uninstall-raspios-64bit.sh @@ -3,8 +3,8 @@ # uninstall Fit for raspiOS-arm-64bit-lite-buster # Define systemd service name -fanDaemon="/lib/systemd/system/deskpi.service" -pwrCutOffDaemon="/lib/systemd/system/deskpi-cut-off-power.service" +fanDaemon="/etc/systemd/system/deskpi.service" +pwrCutOffDaemon="/etc/systemd/system/deskpi-cut-off-power.service" # initializing functions if [ -e /lib/lsb/init-functions ]; then @@ -18,24 +18,20 @@ if [ -d /tmp/deskpi ]; then fi if [ -f $fanDaemon ]; then - sudo systemctl stop deskpi.service - sudo systemctl disable deskpi.service + systemctl stop deskpi.service + systemctl disable deskpi.service rm -f $fanDaemon fi if [ -f $pwrCutOffDaemon ]; then - sudo systemctl disable deskpi-cut-off-power.service - rm -f $pwrCutOffDaemon -fi - -if [ -e $pwrCutOffDaemon ]; then systemctl disable deskpi-cut-off-power.service + rm -f $pwrCutOffDaemon fi # delete pwmfancontrol64 and safecutoffpower64 execute binary file. if [ -e /usr/bin/pwmFanControl64 ]; then rm -f /usr/bin/pwmFanControl64 - rm -f /usr/bin/safecutoffpower64 + rm -f /usr/bin/safeCutOffPower64 fi # Greetings diff --git a/installation/Ubuntu/install-ubuntu-64.sh b/installation/Ubuntu/install-ubuntu-64.sh new file mode 100755 index 0000000..19249b6 --- /dev/null +++ b/installation/Ubuntu/install-ubuntu-64.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# Fit for ubuntu 64bit + +# initializing functions +if [ -e /lib/lsb/init-functions ]; then + . /lib/lsb/init-functions + log_action_msg "Initializing functions..." +fi + + +# remove old daemon file +if [[ -f $fanDaemon ]]; then + systemctl stop deskpi.service + systemctl disable deskpi.service + rm -f $fanDaemon +fi + +if [[ -f $pwrCutOffDaemon ]]; then + + systemctl disable deskpi-cut-off-power.service + rm -f $pwrCutOffDaemon +fi + +# install git tool +pkgStatus=`dpkg-query -l git |grep git | awk '{print $1}'` +if [ $pkgStatus != 'ii' ]; then + apt-get update + apt-get -y install git-core +fi + +# check if dwc2 dtoverlay has been enabled. +checkResult=`grep dwc2 /boot/firmware/config.txt` +if [ $? -ne 0 ]; then + log_warning_msg "Adding dtoverlay=dwc2,dr_mode=host to /boot/firmware/config.txt file." + sed -i '/dtoverlay=dwc2*/d' /boot/firmware/config.txt + sed -i '$a\dtoverlay=dwc2,dr_mode=host' /boot/firmware/config.txt + log_action_msg "check dwc2 overlay will be enabled after rebooting." +fi + +# Define systemd service name +fanDaemon="/etc/systemd/system/deskpi.service" +pwrCutOffDaemon="/etc/systemd/system/deskpi-cut-off-power.service" + +# copy pre-compiled binary file to /usr/bin/ folder +if [ -d /tmp/deskpi/ ]; then + cp -Rvf /tmp/deskpi/installation/drivers/c/pwmFanControl64 /usr/bin/pwmFanControl64 + cp -Rvf /tmp/deskpi/installation/drivers/c/safeCutOffPower64 /usr/bin/safeCutOffPower64 + cp -Rvf /tmp/deskpi/installation/deskpi-config /usr/bin/deskpi-config + chmod +x /usr/bin/pwmFanControl64 + chmod +x /usr/bin/safeCutOffPower64 + chmod +x /usr/bin/deskpi-config +fi + +# genreate systemd service file +if [ ! -e $fanDaemon ]; then +echo "[Unit]" >> $fanDaemon +echo "Description=DeskPi Fan Control Service" >> $fanDaemon +echo "After=multi-user.target" >> $fanDaemon +echo "[Service]" >> $fanDaemon +echo "Type=simple" >> $fanDaemon +echo "RemainAfterExit=true" >> $fanDaemon +echo "ExecStart=/usr/bin/pwmFanControl64 &" >> $fanDaemon +echo "[Install]" >> $fanDaemon +echo "WantedBy=multi-user.target" >> $fanDaemon +fi + +# send signal to MCU before system shutting down. +if [ ! -e $pwrCutOffDaemon ]; then + echo "[Unit]" >> $pwrCutOffDaemon + echo "Description=DeskPi-cut-off-power service" >> $pwrCutOffDaemon + echo "Conflicts=reboot.target" >> $pwrCutOffDaemon + echo "Before=halt.target shutdown.target poweroff.target" >> $pwrCutOffDaemon + echo "DefaultDependencies=no" >> $pwrCutOffDaemon + echo "[Service]" >> $pwrCutOffDaemon + echo "Type=oneshot" >> $pwrCutOffDaemon + echo "ExecStart= /usr/bin/safeCutOffPower64" >> $pwrCutOffDaemon + echo "RemainAfterExit=yes" >> $pwrCutOffDaemon + echo "[Install]" >> $pwrCutOffDaemon + echo "WantedBy=halt.target shutdown.target poweroff.target" >> $pwrCutOffDaemon +fi + +# grant privilleges to root user. +if [ -e $fanDaemon ]; then + chown root:root $fanDaemon + chmod 755 $fanDaemon + log_action_msg "Load DeskPi service and load modules" + systemctl daemon-reload + systemctl enable deskpi.service + systemctl start deskpi.service & +fi + +if [ -e $pwrCutOffDaemon ]; then + chown root:root $pwrCutOffDaemon + chmod 755 $pwrCutOffDaemon + systemctl enable deskpi-cut-off-power.service +fi + + +# Greetings +if [ $? -eq 0 ]; then + log_action_msg "Congratulations! DeskPi Pro driver has been installed successfully, Have Fun!" + log_action_msg "System will be reboot in 5 seconds to take effect." +else + log_action_warning "Could not download deskpi repository, please check the internet connection and try to execute it again. " + log_action_msg "Usage: sudo ./install-ubuntu-64.sh" +fi + +sync && sleep 5 && reboot + diff --git a/Ubuntu/uninstall-ubuntu-mate.sh b/installation/Ubuntu/uninstall-ubuntu-mate.sh similarity index 100% rename from Ubuntu/uninstall-ubuntu-mate.sh rename to installation/Ubuntu/uninstall-ubuntu-mate.sh diff --git a/drivers/Deskpi-uninstall b/installation/drivers/Deskpi-uninstall similarity index 100% rename from drivers/Deskpi-uninstall rename to installation/drivers/Deskpi-uninstall diff --git a/installation/drivers/README.md b/installation/drivers/README.md index 31e0c4e..79f7731 100644 --- a/installation/drivers/README.md +++ b/installation/drivers/README.md @@ -1,19 +1,19 @@ # Control Your Fan througn PWM signal via Serial port(OTG) ## Configure /boot/config.txt to enbale otg function. ```bash -sudo vim.tiny /boot/firmware/config.txt +sudo vim.tiny /boot/config.txt ``` add: ```bash -dtoverlay=dwc2,dr_mode=host +dtoverlay=dwc2, dr_mode=host ``` save it and reboot Raspberry Pi. ## C Language * 1. At First, get the demo code from github. ```bash cd ~ -git clone -b feature/bookworm https://github.com/DeskPi-Team/deskpi.git -cd ~/deskpi/installation/drivers/c/ +git clone https://github.com/DeskPi-Team/deskpi.git +cd ~/deskpi/drivers/c/ ``` * 2. How to compile it. ```bash @@ -21,19 +21,42 @@ make ``` * 3. How to run it. ```bash -sudo ./pwmControlFan64 +sudo ./pwmFanControl ``` * 4. How to stop it. -Press "Ctrl + C" on keyboard. +Press "Ctrl + C" * 5. How to clean the source code directory. ```bash make clean ``` ## How to change speed of the fan. -This program is send the pwm signal from Raspberry Pi to the extension board via OTG serial port, which will be recognized by your Raspberry Pi as "/dev/DeskPi_FAN" device which is symboliclink to /dev/ttyUSB0. so if you want to control the fan as your wish, you can modify pwmControlFan.c code and recompile it. +This program is send the pwm signal from Raspberry Pi to the extension board via OTG serial port, which will be recognized by your Raspberry Pi as "/dev/ttyUSB0" device. so if you want to control the fan as your wish, you can modify pwmControlFan.c code and recompile it. * In the default code, we have set 4 level for you Fan on pwm signal: -* Level 0: 0% speed-> send "pwm_000" to /dev/DeskPi_FAN", means to turn off the fan -* Level 1: 25% speed-> send "pwm_025" to /dev/DeskPi_FAN", means to set fan speed to 25% -* Level 2: 50% speed-> send "pwm_050" to /dev/DeskPi_FAN", means to set fan speed to 50% -* Level 3: 75% speed-> send "pwm_075" to /dev/DeskPi_FAN", means to set fan speed to 75% -* Level 4:100% speed-> send "pwm_100" to /dev/DeskPi_FAN", means to set fan speed to 100% +* Level 0: 0% speed-> send "pwm_000" to /dev/ttyUSB0", means to turn off the fan +* Level 1: 25% speed-> send "pwm_025" to /dev/ttyUSB0", means to set fan speed to 25% +* Level 2: 50% speed-> send "pwm_050" to /dev/ttyUSB0", means to set fan speed to 50% +* Level 3: 75% speed-> send "pwm_075" to /dev/ttyUSB0", means to set fan speed to 75% +* Level 4:100% speed-> send "pwm_100" to /dev/ttyUSB0", means to set fan speed to 100% + +# Python +## How to control fan through PWM signal via serial port. +You can also control your fan with python script. +just remember to send "pwm_xxx" to "/dev/ttyUSB0" device. xxx means the level of your fan speed. from 0-100 (integer). +### 1. Install pyserial library. +* Python2.x +```bash +pip install pyserial +``` +* Python3.x +```bash +pip3 install pyserial +``` +### 2. Get the demo code from github and execute it. +```bash +cd ~ +git clone https://github.com/DeskPi-Team/deskpi.git +cd ~/deskpi/drivers/python/ +sudo python3 pwmControlFan.py +``` +### Job Done. + diff --git a/installation/drivers/c/Makefile b/installation/drivers/c/Makefile index b5cfe64..c446acc 100644 --- a/installation/drivers/c/Makefile +++ b/installation/drivers/c/Makefile @@ -1,16 +1,15 @@ DEFAULT: all .PHONY: install -all: pwmControlFan64 safeCutOffPower64 +all: pwmFanControl64 safeCutOffPower64 install: - sudo sh -c "sudo chmod 755 pwmControlFan64 safeCutOffPower64" - sudo sh -c "sudo cp pwmControlFan64 safeCutOffPower64 /usr/bin/" - sudo sh -c "sudo chcon -u system_u -t bin_t /usr/bin/pwmControlFan64 /usr/bin/safeCutOffPower64" + sudo chmod 755 pwmFanControl64 safeCutOffPower64 + sudo cp pwmFanControl64 safeCutOffPower64 /usr/bin/ -pwmControlFan64: pwmControlFan.c - gcc -o pwmControlFan64 pwmControlFan.c +pwmFanControl64: pwmFanControl.c + gcc -o pwmFanControl64 pwmFanControl.c safeCutOffPower64: safeCutOffPower.c gcc -o safeCutOffPower64 safeCutOffPower.c clean: - rm -rf safeCutOffPower64 pwmControlFan64 + rm -rf safeCutOffPower64 pwmFanControl64 diff --git a/installation/drivers/c/pwmControlFan.c b/installation/drivers/c/pwmControlFan.c deleted file mode 100644 index d4f544b..0000000 --- a/installation/drivers/c/pwmControlFan.c +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#define TEST_MODE -#define PERCENTAGE 10 // switch over percentage range - - -static int serial_port=0; -/* initialized the serial port*/ -int init_serial( char *serial_name) -{ - serial_port = open(serial_name, O_RDWR); - - if (serial_port < 0){ - printf("Can not open /dev/DeskPi_FAN serial port ErrorCode: %s\n", strerror(errno)); - printf("Please check udev file in /etc/udev/rules.d/10-deskpi.rules"); - printf("Please check the /boot/firmware/config.txt file and add dtoverlay=dwc2, dr_mode=host and reboot RPi \n"); - } - - struct termios tty; - - if(tcgetattr(serial_port, &tty) !=0){ - printf("Please check serial port over OTG\n"); - } - - tty.c_cflag &= ~PARENB; - tty.c_cflag |= PARENB; - tty.c_cflag &= ~CSTOPB; - tty.c_cflag |= CSTOPB; - - tty.c_cflag |= CS5; - tty.c_cflag |= CS6; - tty.c_cflag |= CS7; - tty.c_cflag |= CS8; - - tty.c_cflag &= ~CRTSCTS; - tty.c_cflag |= CRTSCTS; - - tty.c_cflag |= CREAD | CLOCAL; - - tty.c_lflag &= ~ICANON; - tty.c_lflag &= ~ECHO; - tty.c_lflag &= ~ECHOE; - tty.c_lflag &= ~ECHONL; - tty.c_lflag &= ~ISIG; - - tty.c_iflag &= ~(IXON | IXOFF | IXANY); - tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); - - tty.c_oflag &= ~OPOST; - tty.c_oflag &= ~ONLCR; - - tty.c_cc[VTIME] = 10; - tty.c_cc[VMIN] = 0; - - cfsetispeed(&tty, B9600); - cfsetospeed(&tty, B9600); - - if (tcsetattr(serial_port, TCSANOW, &tty) !=0){ - printf("---Serial Port Can not detected---\n"); - } - return 0; -} - -/* send data to serial port function*/ -int send_serial(char *data,size_t data_len) -{ - return write(serial_port, data, data_len); -} - -/* close the serial port function*/ -int __init_serial() -{ - return close(serial_port); -} -/* read cpu temperature function */ -unsigned int read_cpu_tmp() -{ - FILE *fp=NULL; - unsigned int cpu_temp=0; - char buff[255]; - bzero(buff, sizeof(buff)); - fp = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); - if( NULL != fp) - { - if (fgets(buff, 255, (FILE*)fp) != NULL){ - cpu_temp = atoi(buff) /1000 ; - } - fclose(fp); - } - return cpu_temp; -} - -/* main loop */ -int main(void){ - int i=0; - FILE *fp=NULL; - char buffer[100]; - bzero(buffer, sizeof(buffer)); - - char data[8]={0}; - unsigned int conf_info[8]; - unsigned int cpu_temp=0; - unsigned int last_cpu_temp = 0; // last temperature level recorded - unsigned int min_temp = 0; // calculated minimum temperature based on percentage - init_serial("/dev/DeskPi_FAN"); - /* default configuration if /etc/deskpi.conf dose not exist */ - conf_info[0]=40; - conf_info[1]=25; - - conf_info[2]=50; - conf_info[3]=50; - - conf_info[4]=65; - conf_info[5]=75; - - conf_info[6]=75; - conf_info[7]=100; - - while(1) - { - fp = fopen("/etc/deskpi.conf", "r"); - if(fp != NULL) - { - for(i=0;i<8;i++) - { - bzero(buffer, sizeof(buffer)); - if (fgets(buffer, 100, fp) != NULL) - { - conf_info[i] = atoi(buffer); - } - } - fclose(fp); - } - - /* Testing section - for(i=0;i<8;i++) - { - printf("temp:%d\n",conf_info[i]); - i++; - printf("pwm:%d\n",conf_info[i]); - } - */ - cpu_temp = read_cpu_tmp(); - #ifdef TEST_MODE - printf("cpu_temp:%d / last_cpu_temp:%d / fan_speed:", cpu_temp, last_cpu_temp); - #endif - - if (last_cpu_temp == 0 || cpu_temp > last_cpu_temp) { - if(cpu_temp < conf_info[0]) - { - memcpy( (char *) &data, "pwm_000", sizeof("pwm_000")); - last_cpu_temp = 0; - } - else if(cpu_temp >= conf_info[0] && cpu_temp < conf_info[2]) - { - sprintf((char *)&data, "pwm_%03d", conf_info[1]); - last_cpu_temp = conf_info[0]; - } - else if(cpu_temp >= conf_info[2] && cpu_temp < conf_info[4]) - { - sprintf((char *)&data, "pwm_%03d", conf_info[3]); - last_cpu_temp = conf_info[2]; - } - else if(cpu_temp >= conf_info[4] && cpu_temp < conf_info[6]) - { - sprintf((char *)&data, "pwm_%03d", conf_info[5]); - last_cpu_temp = conf_info[4]; - } - else if(cpu_temp >= conf_info[6]) - { - sprintf((char *)&data, "pwm_%03d", conf_info[7]); - last_cpu_temp = conf_info[6]; - } - send_serial((char *) &data, sizeof(data)); - #ifdef TEST_MODE - printf("*"); - #endif - } - - // leave fan speed as is if not within pre defined percentage - min_temp = last_cpu_temp - round(last_cpu_temp * PERCENTAGE / 100); - if (cpu_temp < min_temp) { - last_cpu_temp = 0; // reset level - } - - #ifdef TEST_MODE - printf("%s", data); - printf(" until min_temp:%d", min_temp); - printf("\n"); - #endif - - sleep(1); - } - __init_serial(); - return 0; -} diff --git a/drivers/c/pwmControlFan.c b/installation/drivers/c/pwmFanControl.c similarity index 100% rename from drivers/c/pwmControlFan.c rename to installation/drivers/c/pwmFanControl.c diff --git a/installation/drivers/c/pwmControlFan64 b/installation/drivers/c/pwmFanControl64 similarity index 94% rename from installation/drivers/c/pwmControlFan64 rename to installation/drivers/c/pwmFanControl64 index 3c1fffc7b557936209da61cab8900b09689aae8e..b534a8618ed04de3f327448bde1f777a0e98769c 100755 GIT binary patch delta 1007 zcmZ9LT}TvB6vywG9ar6*9d~wSDbv~^wR$jC(^4YvvrOp2YJ-A;wpy@~UCYg~7mcJR zv4$I536z3Bj0AO~jf}A9K_4m&F%7DHh}f6Vg(9_bILrWNhu3&|rddn=@UFs$@8mdy6P>lw1_(*lTIqE`b{@bT7auzgnzXwHz9=6@f_eL>Da4-QqrB#Hz(BMXcI1?G{}Uznm631;i7nBHAc@ zBW{Lg^ru+Iw+Y$~TAQ(VC2K^`x@dPsl{CB*?<_`)EE8bAv5X?{(>!~7nrhP`Cey<* zI%qFXI$P<&efGu+9+M#y}fIJ!xBdi*7W5H@ClD_F6DhZ};0Kx{-;TC=!tF*vpM|@PMJZV~%{jjlZR+zEu@%pO*{@|rRL)a<6Z!>l*$>2^; lmXESp8A_y;kt9ZQh-rpu<-)QtR9OZR!x)gm76ra>{{Wh1A1wd? delta 1056 zcmZXTYitZr6oBuU9c!P{o!MEG#*VZoq1&owvXWMt(s*s8#1CRO?KItVRc*cFM@1z< zgX@yZ53i(tpc1TDA`v9STqocApiy&x-px z9Qi(yUim)y{F>b6?bim$PQg`m*n{$8XKvru)^^keA-44O^b6v+#3o_6D2Q2!N7gMv z;2vA(8c|+iqk9a4V~KM_v(w#!?+&`vdmmrVG#MA$_&_Rd`lPL?hCp^wdy7PyET_cVKQ z)5nZTei{1Hdcr`eI?D*X#coLBA;~^UA@RDK7PHw|^9HksL=Q5WRVH7?MzG%=oTIAK z0(2{TmsJe)EZfs!3rn=qVmTdTCp{$@Wg`3hM;XDU$%Pq@gRPdEz|OklQTvsVj&i-J zJ``P5QM!nYQF4Nzm>y};wdy*(x?Wpfqi@h^qcL5JHfRBTU3I{;1mf#sdQ(A7pr~+i z4Q4k+3(^+Cg32gcZ8W}mVZA}Xv7m~N46keAP*sPz8OY4 zGKTCxHX`35S9~`N5eR8T<{{gW<;XBQ<<0fI{bCqXF^ZH99qmC(LeW^4*Xs*n-Jt2g zrJ>-T12!#Tqc##0Zvuz6I{2pD!6$h5R5U^*;r+B3oX2_ZOGd#?x88vvr S`CW{15Ots@HR({{z3?08{xG-z diff --git a/installation/drivers/c/safeCutOffPower.c b/installation/drivers/c/safeCutOffPower.c index a5e009d..f0b09f9 100644 --- a/installation/drivers/c/safeCutOffPower.c +++ b/installation/drivers/c/safeCutOffPower.c @@ -8,14 +8,11 @@ #include #include -#define serial_fan "/dev/DeskPi_FAN" - int main(void){ while(1){ - int serial_port = open(serial_fan, O_RDWR); + int serial_port = open("/dev/ttyUSB0", O_RDWR); if (serial_port < 0){ - printf("Can not access /dev/DeskPi_FAN which links to /dev/ttyUSB0, please check it out.\n"); - printf("Check /etc/udev/rules.d/10-deskpi.rules file"); + printf("Can not access /dev/ttyUSB0, please check it out.\n"); } struct termios tty; @@ -58,7 +55,7 @@ int main(void){ cfsetospeed(&tty, B9600); if (tcsetattr(serial_port, TCSANOW, &tty) !=0){ - printf("Please check out /boot/firmware/config.txt file\n"); + printf("Please check out /boot/config.txt file\n"); } char data[10]; diff --git a/installation/drivers/c/safeCutOffPower64 b/installation/drivers/c/safeCutOffPower64 index b31f8ccea9a890289e7cd8cd61b7bbc10f5051ba..d943050a815626f84a31f1230034c7c7a95b606a 100755 GIT binary patch delta 1986 zcmcIlUrd`-6hEimSK1HS(NBtPvk4#5j1kFN3}h@$DY8fxCxQJj_+m?hNzF351hooA z@C7!fX>)P6CO$}F6pRlw)G#z=bSB35GWMWRqe;8?vN!rR;z~XD`|d{;;;T2g{oQl! z@7!~~bI-Z`X+_PgsF|QX>jrZ~Er8K%#}`_s*OEH3z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GyI)OeuWFv+LI^m&dF zO|O6lV&KIE9wcm2q0Y^lB>b5CPYHcmh-&_qgs9d!*1a4TX51aZBAGT2_Yxk^a zqQ1nm44)=5E#a;W+wc|-+Of^o{-4>`K$`1z^!rw8%5-L=?S>f)P9_!z;}+h|qpPF@g`tjnC`K@YLkUcp6v z#zVZ}UU7cAHb?)(RRXl)n9) '$deskpi_rules_file' - ACTION==\"add\",SUBSYSTEM==\"tty\",ATTRS{\"$idVendor\"},ATTRS{\"$idProduct\"},SYMLINK+=\"DeskPi_FAN\" - EOF" - sudo sh -c "sudo chmod 0666 $deskpi_rules_file" - sudo sh -c "sudo udevadm control --reload-rules" - sudo sh -c "sudo udevadm trigger" -fi - -# Adding /etc/deskpi.conf file -deskpi_config="/etc/deskpi.conf" -if [[ ! -e $deskpi_config ]]; then - sh -c "cat < '$deskpi_config' - 40 - 100 - 50 - 100 - 55 - 100 - 60 - 100 - EOF" -fi - -# Remove old repository. -if [[ -d /tmp/deskpi ]]; then - rm -rf /tmp/deskpi* -fi - -if [[ -f $deskpi_service_file ]]; then - sudo sh -c "sudo systemctl stop deskpi.service" - sudo sh -c "sudo systemctl disable deskpi.service" - sudo sh -c "sudo rm -f $deskpi_service_file" - sudo sh -c "sudo systemctl daemon-reload" -fi - -if [[ -f $deskpi_powermanager_file ]]; then - sudo sh -c "sudo systemctl disable deskpi-cutoffpower.service" - sudo sh -c "sudo rm -f $deskpi_powermanager_file" -fi - -# Install git tool -pkgStatus=`sudo dpkg-query -l git |grep git | awk '{print $1}'` -if [[ $pkgStatus != 'ii' ]]; then - sudo sh -c "sudo apt-get update" - sudo sh -c "sudo apt-get -y install git-core" - -fi - -# Check if dwc2 dtoverlay has been enabled. -checkResult=`grep dwc2 /boot/firmware/config.txt` -if [[ $? -ne 0 ]]; then - log_action_msg "Adding dtoverlay=dwc2,dr_mode=host to /boot/firmware/config.txt file." - sudo sh -c "sudo sed -i '/dtoverlay=dwc2*/d' /boot/firmware/config.txt" - sudo sh -c "sudo sed -i '\$a\dtoverlay=dwc2,dr_mode=host' /boot/firmware/config.txt" - log_action_msg "check dwc2 overlay will be enabled after rebooting." -fi - -# Download deskpi driver -cd /tmp/ -if [[ ! -d /tmp/deskpi ]]; then - while [[ ! -d /tmp/deskpi ]]; - do - log_warning_msg "Could not able to download deskpi repo,will retry again." - sh -c "git clone -b feature/bookworm https://github.com/DeskPi-Team/deskpi.git" - done -fi - - -# copy pre-compiled binary file to /usr/bin/ folder -# -if [[ -d /tmp/deskpi ]]; then - sudo sh -c "sudo mkdir -pv /usr/bin/deskpi/" - if [[ -e /tmp/deskpi/installation/drivers/c/pwmControlFan64 ]]; then - sudo sh -c "sudo cp -Rvf /tmp/deskpi/installation/drivers/c/pwmControlFan64 /usr/bin/deskpi/pwmControlFan64 && echo 'Copy ok'" - sudo sh -c "sudo cp -Rvf /tmp/deskpi/installation/drivers/c/safeCutOffPower64 /usr/bin/deskpi/safeCutOffPower64 && echo 'Copy ok'" - fi - - sudo sh -c "sudo cp -Rvf /tmp/deskpi/installation/deskpi-config /usr/bin/deskpi-config" - sudo sh -c "sudo chmod +x /usr/bin/deskpi/pwmControlFan64" - sudo sh -c "sudo chmod +x /usr/bin/deskpi/safeCutOffPower64" - sudo sh -c "sudo chmod +x /usr/bin/deskpi-config" -fi - -# Genreate systemd service file -if [[ ! -e $deskpi_service_file ]]; then -sudo sh -c "sudo cat < '$deskpi_service_file' -[Unit] -Description=DeskPi Fan Control Service -After=multi-user.target -[Service] -Type=simple -RemainAfterExit=true -ExecStart=/usr/bin/sudo /usr/bin/deskpi/pwmControlFan64 -[Install] -WantedBy=multi-user.target - -EOF" - -fi - -# Send signal to MCU before system shutting down. -if [[ ! -e $deskpi_powermanager_file ]]; then - sudo sh -c "sudo cat < '$deskpi_powermanager_file' -[Unit] -Description=DeskPi cutoffpower service -Conflicts=reboot.target -Before=halt.target shutdown.target poweroff.target -DefaultDependencies=no -[Service] -Type=oneshot -ExecStart=/usr/bin/sudo /usr/bin/deskpi/safeCutOffPower64 -RemainAfterExit=yes -[Install] -WantedBy=halt.target shutdown.target poweroff.target - -EOF" - -fi - -# Grant privilleges to root user. -if [[ -e $deskpi_service_file ]]; then - sudo sh -c "sudo chown root:root $deskpi_service_file" - sudo sh -c "sudo chmod 755 $deskpi_service_file" - log_action_msg "Load DeskPi service and load modules" - sudo sh -c "sudo systemctl daemon-reload" - sudo sh -c "sudo systemctl enable deskpi.service" - sudo sh -c "sudo systemctl start deskpi.service" -fi - -if [[ -e $deskpi_powermanager_file ]]; then - sudo sh -c "sudo chown root:root $deskpi_powermanager_file" - sudo sh -c "sudo chmod 755 $deskpi_powermanager_file" - sudo sh -c "sudo systemctl daemon-reload" - sudo sh -c "sudo systemctl enable deskpi-cutoffpower.service" -fi - - -# Greetings -if [[ $? -eq 0 ]]; then - log_success_msg "Congratulations! DeskPi Pro driver has been installed successfully, Have Fun!" - log_success_msg "System will be reboot in 5 seconds to take effect." -else - log_success_warning "Could not download deskpi repository, please check the internet connection and try to execute it again!" - log_success_msg "Usage: ./install.sh" -fi -echo "DESKPI PRO" |figlet -c -echo "INSTALLATION SUCCESSFULL!" | figlet -c -echo "REBOOT IN 5 SECONDS" | figlet -c -sudo sh -c "sudo sync && sleep 5 && sudo reboot"