Chadster766 / McDebian

Linksys WRT3200ACM, WRT1900AC, WRT1900ACS, WRT1200AC and WRT32X Router Debian Implementation
98 stars 14 forks source link

McDebian 4.4.16 WRT1900AC Fancontrol #11

Closed Chadster766 closed 8 years ago

Chadster766 commented 8 years ago

My previous fancontrol script for the WRT1900AC doesn't work.

ValCher1961 commented 8 years ago

Specify, a script of management or a patch of a kernel?

Chadster766 commented 8 years ago

I discovered that fancontrol is already built into McDebian 4.4.16 and it's not an issue. I'm just going through the configuration of it now and will update the Thermal Protection Wiki page.

apt-get install fancontrol pwmconfig

If you figure out how best to have this configured I would appreciate your suggestions.

ValCher1961 commented 8 years ago

As I have understood from translation, the program searches for the gauge of frequency of rotation of the fan, but in the scheme wrt1900ac v1 it is not present. Here result.

root@wrt1900ac:/usr/sbin# ./pwmconfig
# pwmconfig revision 6166 (2013-05-01)
This program will search your sensors for pulse width modulation (pwm)
controls, and test each one to see if it controls a fan on
your motherboard. Note that many motherboards do not have pwm
circuitry installed, even if your sensor chip supports pwm.

We will attempt to briefly stop each fan using the pwm controls.
The program will attempt to restore each fan to full speed
after testing. However, it is ** very important ** that you
physically verify that the fans have been to full speed
after the program has completed.

./pwmconfig: There are no fan-capable sensor modules installed

I can am mistaken?

Chadster766 commented 8 years ago

You need to setup lm-sensors first.  See the McDebian thermal wiki for details. 

Chadster766 commented 8 years ago

https://github.com/Chadster766/McDebian/wiki/B.-Thermal-Protection

ValCher1961 commented 8 years ago

Lm-sensors it is established, the program waits for the response from the fan, frequency of rotation.

root@wrt1900ac:/usr/sbin# sensors
tmp421-i2c-0-4c
Adapter: mv64xxx_i2c adapter
temp1:        +54.6°C
temp2:        +56.5°C

armada_thermal-virtual-0
Adapter: Virtual device
temp1:        +68.9°C

eth0_dsa0-virtual-0
Adapter: Virtual device
temp1:        +59.0°C  (high = +100.0°C)
Chadster766 commented 8 years ago

This should work as a starting point:

root@MCDEBIAN:~# cat /etc/fancontrol
# Configuration file generated by pwmconfig, changes will be lost
INTERVAL=10
DEVPATH=hwmon0=devices/platform/gpio_fan hwmon2=
DEVNAME=hwmon0=gpio_fan hwmon2=armada_thermal
FCTEMPS= hwmon0/pwm1=hwmon2/temp1_input
FCFANS= hwmon0/pwm1=hwmon0/fan1_input
MINTEMP= hwmon0/pwm1=45
MAXTEMP= hwmon0/pwm1=70
MINSTART= hwmon0/pwm1=4
MINSTOP= hwmon0/pwm1=0
Chadster766 commented 8 years ago

With my initial fancontrol setting as soon as the MINTEMP is hit the fan goes on full speed which isn't ideal.

ValCher1961 commented 8 years ago

No, something does not work.

jbsky commented 8 years ago

@Chadster766 You must patch kernel for fancontrol working.

Chadster766 commented 8 years ago

I was hoping to keep the kernel unpatched and as clean as possible. My hope is as the kernel progresses these sorts of issues will eventually disappear.

Our previous fancontrol script was:

cat <<'EOF' >> /usr/local/sbin/fancontrol
#!/bin/sh

START=80        #start fan
STOP=75         #stop fan

echo 24 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio24/direction

sleep 5

while true ; do

        K=`cat /sys/class/gpio/gpio24/value`

        for TEMP in `cut -c 1-2 /sys/class/thermal/thermal_zone0/temp`; do
                if [ $TEMP -ge $START ]; then
                        if [ $K -eq 0 ]; then
                                DATE=`date`;
                                echo "$DATE: On Fan" >> /root/overheat.log
                                echo `sensors|grep +` >> /root/overheat.log
                                echo 1 > /sys/class/gpio/gpio24/value;
                                break;
                        fi
                fi
        done

        for TEMP in `cut -c 1-2 /sys/class/thermal/thermal_zone0/temp`; do
        if [ $TEMP -le $STOP ]; then
                if [ $K -eq 1 ]; then
                        DATE=`date`;
                        echo "$DATE: Off Fan" >> /root/overheat.log
                        echo `sensors|grep +` >> /root/overheat.log
                        echo 0 > /sys/class/gpio/gpio24/value;
                        break;
                fi
        fi
        done
        sleep 5
done
EOF

We can modify this using the below to do fancontrol:

Turn fan control off: echo 0 >/sys/class/hwmon/hwmon0/pwm1_enable

Turn fan control on: echo 1 >/sys/class/hwmon/hwmon0/pwm1_enable

Turn fan off: echo 0 >/sys/class/hwmon/hwmon0/pwm1

Turn fan on: (any value greater than zero works) echo 255 >/sys/class/hwmon/hwmon0/pwm1

CPU temps in Celsius: cat /sys/class/hwmon/hwmon2/temp1_input

Chadster766 commented 8 years ago

How does this look:

#!/bin/sh

START=80        #start fan
STOP=75         #stop fan

echo 0 > /sys/class/hwmon/hwmon0/pwm1_enable

sleep 5

while true ; do

        K=`cat /sys/class/hwmon/hwmon2/temp1_input`

        for TEMP in `cut -c 1-2 /sys/class/hwmon/hwmon2/temp1_input`; do
                if [ $TEMP -ge $START ]; then
                        if [ $K -eq 0 ]; then
                                DATE=`date`;
                                echo "$DATE: On Fan" >> /root/overheat.log
                                echo `sensors|grep +` >> /root/overheat.log
                                echo 1 > /sys/class/hwmon/hwmon0/pwm1_enable;
                                echo 255 > /sys/class/hwmon/hwmon0/pwm1;
                                echo 0 > /sys/class/hwmon/hwmon0/pwm1_enable;
                                break;
                        fi
                fi
        done

        for TEMP in `cut -c 1-2 /sys/class/hwmon/hwmon2/temp1_input`; do
                if [ $TEMP -le $STOP ]; then
                        if [ $K -eq 1 ]; then
                                DATE=`date`;
                                echo "$DATE: Off Fan" >> /root/overheat.log
                                echo `sensors|grep +` >> /root/overheat.log
                                echo 1 > /sys/class/hwmon/hwmon0/pwm1_enable;
                                echo 0 > /sys/class/hwmon/hwmon0/pwm1;
                                echo 0 > /sys/class/hwmon/hwmon0/pwm1_enable;
                                break;
                        fi
                fi
        done
        sleep 5
done
Chadster766 commented 8 years ago

Updated McDebian Thermal Protection wiki with the WRT1900AC V1 McDebian 4.4.16 Fancontrol:

https://github.com/Chadster766/McDebian/wiki/B.-Thermal-Protection