Doesn't seem to work with 1.8.3 on UDM-Pro
rb28z2 opened this issue · 27 comments
As the title says, running on the latest 1.8.3 firmware and following the instructions it doesn't seem to have any effect.
The on-device screen shows the fan speed at 50% (I've set it to 25% via the conf file) and it also no longer responds to the slider as well. As in, I can move the slider but the fan stays at the same 50% duty cycle as before.
More than happy to help debug so let me know if more info or testing help is required :)
Any interest in updating this for current FW? Happy to help debug also (wish I had the skills to help code). The fan is driving me nuts.
I just use this method: https://community.ui.com/questions/UDM-Pro-Fan-Speed-Question/4735dc49-43f2-4d01-b50d-0d10ec8b9057#answer/32ff52cf-fdff-434b-85df-6e3892126d24
it lowers the fan speed to 40% and keeps the UDM Pro quieter until the next reboot or firmware update.
FYI:
I've also installed the netdata docker/podman. It shows me the actual fan speeds and temps in a graph. It helped me a lot to solve this issue.
podman run --privileged -d --name=netdata --restart always \
--net="host" \
--pid="host" \
-v netdatalib:/var/lib/netdata \
-v netdatacache:/var/cache/netdata \
-v /etc/passwd:/host/etc/passwd:ro \
-v /etc/group:/host/etc/group:ro \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /etc/os-release:/host/etc/os-release:ro \
--cap-add SYS_PTRACE \
--security-opt apparmor=unconfined \
netdata/netdata
Fan1 === CPU fan === pwm2
Fan2 === Disk 40mm fan === pwm1
The CPU fan can't be fully stopped. It wil always run minimal at ~800 rpm.
The disk fan can be fully stopped. It wil obviously show 0 rpm when stopped.
The CPU fan minimum start offset is "77" and is ~800 rpm .
The disk fan minimum start offset is "35" and is ~800 rpm (if you would like to keep it running for airflow).
CPU fan:
echo 77 >/sys/class/hwmon/hwmon0/device/pwm2
Disk fan:
echo 35 >/sys/class/hwmon/hwmon0/device/pwm1
Making this survive a reboot does indeed need the on-boot-script. I've made a simple script which surives a reboot:
- Install on-boot-script
- Make a file with VI called "11-set-fan-speed.sh" in /mnt/data/on_boot.d/
- Make the boot script executable
chmod +x /mnt/data/on_boot.d/11-set-fan-speed.sh
- Reboot and enjoy the silence
11-set-fan-speed.sh:
#!/bin/sh
echo 77 >/sys/class/hwmon/hwmon0/device/pwm2
echo 35 >/sys/class/hwmon/hwmon0/device/pwm1
I can confirm that it DOES survive a reboot. Got it working on 1.8.5. Display also shows correct values. Running stable at 44 degrees Celsius on CPU and 41 degrees Celsius board-temp.
Here some more raw data I just pulled from my UDMP.
@renedis will fan control when temperature rises (in summer) still work? Sorry if I ask for the obvious.
Seems the board is using the ADT7475 kernel driver for monitoring fans, temps and setting PWM.
https://www.kernel.org/doc/html/v5.4/hwmon/adt7475.html (this is for 5.4, couldn't find 4.1.37)
Welcome to UniFi Dream Machine!
# dmesg | grep adt7475
[ 3.421487] adt7475 4-002e: ADT7475 device, revision 1
[ 3.421491] adt7475 4-002e: Optional features: fan4 pwm2
Excerpt on the fan speed control: (bold markup done by me)
The driver exposes two trip points per PWM channel.
point1: Set the PWM speed at the lower temperature bound
point2: Set the PWM speed at the higher temperature bound
The ADT747x will scale the PWM linearly between the lower and higher PWM speed when the temperature is between the two temperature boundaries. Temperature boundaries are associated to temperature channels rather than PWM outputs, and a given PWM output can be controlled by several temperature channels. As a result, the ADT747x may compute more than one PWM value for a channel at a given time, in which case the maximum value (fastest fan speed) is applied. PWM values range from 0 (off) to 255 (full speed).Fan speed may be set to maximum when the temperature sensor associated with the PWM control exceeds temp#_max.
At Tmin - hysteresis the PWM output can either be off (0% duty cycle) or at the minimum (i.e. auto_point1_pwm). This behaviour can be configured using the pwm[1-*]_stall_disable sysfs attribute. A value of 0 means the fans will shut off. A value of 1 means the fans will run at auto_point1_pwm.
The responsiveness of the ADT747x to temperature changes can be configured. This allows smoothing of the fan speed transition. To set the transition time set the value in ms in the temp[1-*]_smoothing sysfs attribute.
And from the ADT7475 data sheet:
Automatic Fan Control Overview
The ADT7475 can automatically control the speed of fans based upon the measured temperature. This is done
independently of CPU intervention once initial parameters are set up.
So maybe there is a way to steer the initial parameters? In my case - contrary to what @nekuz0r aspires to achieve - I want this thing to just shut up and be as silent as possible. Ideally without toasting something, so the fans spooling up when required would be nice.
I'm eying on the "Enhanced Acoustics Register", which is linked in the module source code to the pwm1_stall_disable sysfs attribute. At least there is a function addressing bit 5 to keep the HDD fan spinning.
In some cases, primarily for psycho-acoustic reasons, it is desirable that the fan never switch off below T MIN .
Bits <7:5> of Enhanced Acoustics Register 1 (0x62), when set,
keep the fans running at the PWM minimum duty cycle, if the temperature should fall below T MIN .
This may be the culprit for not stopping the HDD fan at all, when a drive is installed. I found a discussion around this topic, but I don't find a *_stall_disable on my system, so this may be a dead end.
For my UDM pro without HDD installed, the sysfs
values are:
HDD Fan
temp1_auto_point1_temp
45000
temp1_auto_point2_temp
77000
pwm1_auto_point1_pwm
128
pwm1_auto_point2_pwm
255
With HDD only these value change:
CPU Fan
pwm2 (current PWM setting) 0 -> 127
(with the speed going from 680 revs to annoying 2800 revs)
HDD Fan
pwm1 (current PWM setting) 0 -> 127
(with the speed going from stopped / 0 revs to annoying 4600 revs)
CPU Fan
temp2_auto_point1_temp
90000
temp2_auto_point2_temp
122000
pwm2_auto_point1_pwm
128
pwm2_auto_point2_pwm
255
How I interpret this):
HDD Fan:
minimum PWM is 50%, at or below 45°C
maximum PWM is 100%, at or above 77°C
no disk: PWM is set to completely off --> and set to 0
with disk: PWM is set to 50%, and set to 50%
CPU Fan:
minimum PWM is 50%, at or above 90°C
maximum PWM is 100%, at or above 122°C
no disk: PWM is set to completely off --> and set to a minimum speed, maybe via the Enhanced Acoustics Register
with disk: PWM is set to 50%, and set to 50% --> but can be manipulated (via the OLED touchscreen) to lower values than 50%!)
So my hope is to find a way of pulling `pwm[1-2]_auto_point1_pwm' down from 128 to something more reasonable for the HDD fan (30 to 50 seems to be nice enough to my ears).
Maybe this is as simple as putting a shell-script to on_boot.d
like @renedis did show before!
#!/bin/sh
echo 80 >/sys/class/hwmon/hwmon0/device/pwm2_auto_point1_pwm
echo 45
>/sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
Just replacing "pwm1" with "pwm1_auto_point1_pwm", trying to not set a fan speed directly but adjusting the limits without interfering.
Update
Tried it, probably does not show the impact I wanted to see. When setting the lower limit (temp1_auto_point1_temp
) to 10°C while the server is running at 46°C, the fans do not change speed.
Sorry for dropping all such detail without knowing how to implement it properly.
Update 2
There is a statement by a Ubiquiti employee.
heXeo has referred to this already and linked to this repo.
Based on further thermal testing, the minimum HDD fan speed needs to stay at 50% to cover the full rated ambient temperature range. Unfortunately, I don't have any further info regarding user customization in this area.
Thanks for your understanding.
Full dump of /sys/class/hwmon/hwmon0/ - no HDD.
Full dump of /sys/class/hwmon/hwmon0/ - with HDD
OK, if lockdown is good for anything... now I'm onto something.
I found an interface description for the ADT7475 driver.
This describes the interface for the ADT7475 driver:
(there are 4 fans, numbered fan1 to fan4):
fanX_input Read the current speed of the fan (in RPMs)
fanX_min Read/write the minimum speed of the fan. Dropping
below this sets an alarm.(there are three PWMs, numbered pwm1 to pwm3):
pwmX Read/write the current duty cycle of the PWM. Writes
only have effect when auto mode is turned off (see
below). Range is 0 - 255.pwmX_enable Fan speed control method:
0 - No control (fan at full speed) 1 - Manual fan speed control (using pwm[1-*]) 2 - Automatic fan speed control
This gives at least some hints:
- @renedis, you where right that the fan speed is static because Writes only have effect when auto mode is turned off.
- That seems pretty stupid to me, why do we have such a nice controller if we don't use it? So let's try switching
pwm1_enable
from1
to2
, hoping to get automatic control. - Result: fans very briefly spool up, then drop back to old level. Speed can still be manually set via
pwm1
andpwm2
.
No cigar, seems like the fan speed control is clamped to manual. Here's where my efforts end.
Update: yes it's clamped in /etc/init.d/S04ubnt-fan-speed
.
# more S04ubnt-fan-speed
#!/bin/sh
#
# ubnt-fan-speed
#
case "$1" in
start)
if ! pidof ubnt-fan-speed &>/dev/null; then
{ while true; do /usr/sbin/ubnt-fan-speed; sleep 1; done } &
fi
;;
stop)
echo "This is a critical service. Stopping it is unsupported."
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac
You can kill the process like this:
#pidof ubnt-fan-speed
<NUMBER>
kill <NUMBER>
I can set my pwm1_enable and pwm2_enable:
# cat /sys/class/hwmon/hwmon0/device/pwm1_enable
2
# cat /sys/class/hwmon/hwmon0/device/pwm2_enable
2
And after that I can also:
# cat /sys/class/hwmon/hwmon0/device/pwm2_auto_point1_pwm
120
# echo 80 >/sys/class/hwmon/hwmon0/device/pwm2_auto_point1_pwm
# cat /sys/class/hwmon/hwmon0/device/pwm2_auto_point1_pwm
80
# cat /sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
128
# echo 35 >/sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
# cat /sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
35
Netdata stats confirm this so far. I can't tell if it works because i haven't seen any loads yet on my UDM.
So something like this as a bash script should work in theory:
#!/bin/sh
if pidof ubnt-fan-speed &>/dev/null; then
INIT_SCRIPT_PID=`pidof S04ubnt-fan-speed`
kill ${INIT_SCRIPT_PID}
sleep 1
fi
echo 2 >/sys/class/hwmon/hwmon0/device/pwm1_enable
echo 2 >/sys/class/hwmon/hwmon0/device/pwm2_enable
echo 35 >/sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
echo 80 >/sys/class/hwmon/hwmon0/device/pwm2_auto_point1_pwm
Edit:
Changing temp1_auto_point1_temp does actually change fan speed for me on PWM1 and PWM2 (both to 100%).
So far i'm guessing this is my sweet spot:
echo 40000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point1_temp
echo 66000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point2_temp
That is:
40 degree celsius lower limit
66 degree celsius upper limit
I don't know if these settings are persistant. I they are not, then they need to be added to the bash script.
Edit2:
Tried it.. Sadly, my start up script does not work for killing the process. That's all, if we can automate the kill process on boot then it will possibly work.
Edit3:
Confirmed that setting to AUTO does work. But only for the 40mm fan at this point. Not the CPU fan. Maybe I forgot something or it isn't hot enough to go up in RPM.
Yes, setting the minimal PWM on the CPU from 0 to 60 also makes the CPU fan go up in RPM from ~800 RPM.
Still left is to figure out on how to automate killing the process.
In short:
I/We need to automate these commandlines:
pidof ubnt-fan-speed
<NUMBER>
kill <NUMBER>
echo 2 >/sys/class/hwmon/hwmon0/device/pwm1_enable
echo 2 >/sys/class/hwmon/hwmon0/device/pwm2_enable
echo 0 >/sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
echo 60 >/sys/class/hwmon/hwmon0/device/pwm2_auto_point1_pwm
echo 40000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point1_temp
echo 66000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point2_temp
echo 40000 >/sys/class/hwmon/hwmon0/device/temp2_auto_point1_temp
echo 66000 >/sys/class/hwmon/hwmon0/device/temp2_auto_point2_temp
echo 40000 >/sys/class/hwmon/hwmon0/device/temp3_auto_point1_temp
echo 66000 >/sys/class/hwmon/hwmon0/device/temp3_auto_point2_temp
I've got it working with shell boot script on firmware 1.8.5!
Excellent, thanks! Will test it during the next days on 1.8.6!
I don't have the 1.8.5 or 1.8.6 firmware on my UDM Pro installed, can one of you attach the stock ubnt-fan-speed binary to this issue so i can decompile it and figure out what's different about it ?
Thanks a lot ;)
@conligwx , could you SSH
in your run UDM with the beta 1.9.0 and run
# cat /sys/class/hwmon/hwmon0/device/pwm1_enable
1
# cat /sys/class/hwmon/hwmon0/device/pwm2_enable
1
# cat /sys/class/hwmon/hwmon0/device/pwm3_enable
2
#
# cat /sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
128
What are your settings then?
- 0 means no control, fan running full speed
- 1 is fixed (manual) setting, which is standard in v1.8.x
- 2 is automatic fan speed control
We are looking for a "2" in the first three settings, and a number around 30 to 50 in the last item.
There is a feature request to UI with very limited exposure, but maybe the right people at UI read and consider implementing it.
This is what I found.
# cat /sys/class/hwmon/hwmon0/device/pwm1_enable
1
# cat /sys/class/hwmon/hwmon0/device/pwm2_enable
1
# cat /sys/class/hwmon/hwmon0/device/pwm3_enable
2
# cat /sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
128
Hope that helps.
I tried the touch screen last night, which now seems to lower the fan speed from a default(after reboot) of 50% to 19% - most times. if however you try to raise the fan speed it gets stuck sometimes and runs at 100% or gets stuck at 80%(reported speed on screen) yet the fans are not running.
I'm guessing UI has done some work on the last beta build 1.9.0-12
Improvements and bug fixes for LCM.
but still far from perfect. at 19% temps were rising from an approx 36c to 43c in my location when running at 19% fan speed.
1.9.x has had changes to it. the 1.8.x firmware allowed you to lower to 40% by flicking downwards the fan speed 10 times until 40% was shown. this bug/feature has bsince been removed from the 1.9.0.x builds
1.9.0.x seems to automatically restart the ubnt-fan-speed process after it’s killed.
This fan noise is so frustrating. I upgraded the one fan to a Noctua, but that’s not enough to keep this thing relatively quiet at 50% speed. The old trick to get it down to 40% speed worked well enough for me — it’s noticeably quieter at that level. But of course that trick doesn’t work with 1.9.0.x.
I wasn’t able to get the fan to stick to anything other than returning to 50% using the LCD. When I change the slider it say “testing fan”. I did see the bug where once or twice the fan would cut off completely. But I couldn’t get it to stick to, say, 30% or 40%.
I had to upgrade to 1.9.0.x for an EA device I’m getting.
This works for me on 1.9.0 to write to the pwm values. You should just kill BOTH S04ubnt-fan-speed and ubnt-fan-speed first, which will prevent the ubnt-fan-speed program from restarting.
E.g.:
For auto fan mode according to @renedis' values:
killall -9 S04ubnt-fan-speed ubnt-fan-speed
echo 2 >/sys/class/hwmon/hwmon0/device/pwm1_enable
echo 2 >/sys/class/hwmon/hwmon0/device/pwm2_enable
echo 0 >/sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
echo 60 >/sys/class/hwmon/hwmon0/device/pwm2_auto_point1_pwm
echo 40000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point1_temp
echo 66000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point2_temp
echo 40000 >/sys/class/hwmon/hwmon0/device/temp2_auto_point1_temp
echo 66000 >/sys/class/hwmon/hwmon0/device/temp2_auto_point2_temp
echo 40000 >/sys/class/hwmon/hwmon0/device/temp3_auto_point1_temp
echo 66000 >/sys/class/hwmon/hwmon0/device/temp3_auto_point2_temp
For manual fan mode (adjust pwm1 and pwm2, 0->255 range, 0 for min fan speed, 255 for max fan speed):
killall -9 S04ubnt-fan-speed ubnt-fan-speed
echo 1 >/sys/class/hwmon/hwmon0/device/pwm1_enable
echo 1 >/sys/class/hwmon/hwmon0/device/pwm2_enable
echo 0 >/sys/class/hwmon/hwmon0/device/pwm1
echo 0 >/sys/class/hwmon/hwmon0/device/pwm2
This worked for me on boot as well by putting it in an on boot script. Adjust for your own fan speed values.
Aha I didn’t even see S04ubnt-fan-speed in there, thanks for the tip!
Looks like all PWM channels are controlled by temp 1. Do you know what temperatures temp1, 2 and 3 are tied with? ie. which one is for CPU, board and HDD (If any)?
# cat /sys/class/hwmon/hwmon0/device/pwm1_auto_channels_temp
1
# cat /sys/class/hwmon/hwmon0/device/pwm2_auto_channels_temp
1
# cat /sys/class/hwmon/hwmon0/device/pwm3_auto_channels_temp
1
Update - comparing the numbers in the UI for CPU temp and what I see in netdata, temp1 is CPU temp. So the only missing puzzle is temp 3 - not sure which temp is that
Having a few issues getting this to work on 1.10, when I run the above command it kicks in for almost a second before something overrides the sys class settings and the fans immediately kick back into gear at their jet turbine level.
Anyone want to provide a little assistance on how exactly to do this? I know how to ssh into my udmp. I just don't know exactly what to do from there if I want to set me fans to minimum.
I have used this settings now for a week, room is about 20C and UDM Pro stay below 40C with HDD installed. Sound is good almost silent, same noise level as when HDD seek. Much better than original settings which I have hard time to understand when installed in fairly cold place. Below 40C shall be good enough
killall -9 S04ubnt-fan-speed ubnt-fan-speed
echo 2 >/sys/class/hwmon/hwmon0/device/pwm1_enable
echo 2 >/sys/class/hwmon/hwmon0/device/pwm2_enable
echo 20 >/sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm
echo 60 >/sys/class/hwmon/hwmon0/device/pwm2_auto_point1_pwm
echo 33000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point1_temp
echo 60000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point2_temp
echo 30000 >/sys/class/hwmon/hwmon0/device/temp2_auto_point1_temp
echo 60000 >/sys/class/hwmon/hwmon0/device/temp2_auto_point2_temp
echo 30000 >/sys/class/hwmon/hwmon0/device/temp3_auto_point1_temp
echo 60000 >/sys/class/hwmon/hwmon0/device/temp3_auto_point2_temp
Thanks for you finding this settings
This works for me on 1.9.0 to write to the pwm values. You should just kill BOTH S04ubnt-fan-speed and ubnt-fan-speed first, which will prevent the ubnt-fan-speed program from restarting.
E.g.:
For auto fan mode according to @renedis' values:
killall -9 S04ubnt-fan-speed ubnt-fan-speed echo 2 >/sys/class/hwmon/hwmon0/device/pwm1_enable echo 2 >/sys/class/hwmon/hwmon0/device/pwm2_enable echo 0 >/sys/class/hwmon/hwmon0/device/pwm1_auto_point1_pwm echo 60 >/sys/class/hwmon/hwmon0/device/pwm2_auto_point1_pwm echo 40000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point1_temp echo 66000 >/sys/class/hwmon/hwmon0/device/temp1_auto_point2_temp echo 40000 >/sys/class/hwmon/hwmon0/device/temp2_auto_point1_temp echo 66000 >/sys/class/hwmon/hwmon0/device/temp2_auto_point2_temp echo 40000 >/sys/class/hwmon/hwmon0/device/temp3_auto_point1_temp echo 66000 >/sys/class/hwmon/hwmon0/device/temp3_auto_point2_tempFor manual fan mode (adjust pwm1 and pwm2, 0->255 range, 0 for min fan speed, 255 for max fan speed):
killall -9 S04ubnt-fan-speed ubnt-fan-speed echo 1 >/sys/class/hwmon/hwmon0/device/pwm1_enable echo 1 >/sys/class/hwmon/hwmon0/device/pwm2_enable echo 0 >/sys/class/hwmon/hwmon0/device/pwm1 echo 0 >/sys/class/hwmon/hwmon0/device/pwm2This worked for me on boot as well by putting it in an on boot script. Adjust for your own fan speed values.
Confirmed working on 1.11.4 - thanks to everyone contributing to this!
echo 2 >/sys/class/hwmon/hwmon0/device/pwm1_enable
I get this error -bash: echo: write error: Invalid argument
running v1.12.30 I can't get the HDD fan to change. No matter what settings I try i'ts always running at 100%