0
mabs

How to control FAN on Rockpro64?

Recommended Posts

Hi,

 

I have two rockpro64 boards.

One board runs Debian buster with a slightly extended ayufan 5.4.0-rc1 kernel where as the other runs a Armbian (Debian) buster with the current project supplied 5.4.0-rc1 kernel.

 

On the Debian on I have installed the nice ats solution (https://github.com/tuxd3v/ats#install)

On the Armbian one the fan is running all the time. I tried to install ats there as well but I failed.

 

Also I found that basically the  /sys/devices/platform/pwm-fan/hwmon is not there, only upto pwm-fan I have.

 

Is there some module I need to load or compile into the kernel to get ats working on the Armbian based one as well?

 

Any hints are highly appreciated.

 

Kind Regards

Martin

Share this post


Link to post
Share on other sites
Armbian is a community driven open source project. Do you like to contribute your code?

I have the same question.
Running the command 

luarocks build https://raw.githubusercontent.com/tuxd3v/ats/master/ats-master-0.rockspec

This warning comes:

 

Spoiler

root@RockHomeServer:~# ln -s /usr/bin/lua5.3 /usr/bin/lua
ln: failed to create symbolic link '/usr/bin/lua': File exists
root@RockHomeServer:~# ^C
root@RockHomeServer:~# luarocks build https://raw.githubusercontent.com/tuxd3v/ats/master/ats-master-0.rockspec
Cloning into 'ats'...
remote: Enumerating objects: 24, done.
remote: Counting objects: 100% (24/24), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 24 (delta 1), reused 8 (delta 0), pack-reused 0
Receiving objects: 100% (24/24), 106.18 KiB | 639.00 KiB/s, done.
Resolving deltas: 100% (1/1), done.
Warning: variable CFLAGS was not passed in build_variables
** PLATFORM = linux  **
** OS       = 64Bits **
** ARCH     = armv8-a+crc **
** TUNE     = cortex-a72.cortex-a53 **
gcc -c -march=armv8-a+crc -mtune=cortex-a72.cortex-a53 -fPIC -Wall -Werror -O3 -g -I/usr/include/lua5.3  -o debug.o src/debug.c
gcc -c -march=armv8-a+crc -mtune=cortex-a72.cortex-a53 -fPIC -Wall -Werror -O3 -g -I/usr/include/lua5.3  -o ats.o src/ats.c
gcc -shared -Wl,-soname,ats.so.0 -llua5.3  -o ats.so.0.9 debug.o ats.o
Install Method: LuaRocks ..
SystemD Detected ..
Searching for Previous Install, and Remove it:
Creating Library Path: /usr/local/lib/lua/5.3
mkdir: created directory '/usr/local/lib/lua'
mkdir: created directory '/usr/local/lib/lua/5.3'
Install ATS Service File ..........: ats.service in '/usr/local/lib/luarocks/rocks/ats/master-0'
Install ATS Config ................: ats.config in '/usr/local/lib/luarocks/rocks/ats/master-0'
Install ATS Tool ..................: ats in '/usr/local/lib/luarocks/rocks/ats/master-0'
Install new ATS Library ...........: ats.so.0.9 in '/usr/local/lib/luarocks/rocks/ats/master-0'
Creating soname symLink ........: ats.so in '/usr/local/lib/luarocks/rocks/ats/master-0'
Creating Service symLink .......: ats.service in '/lib/systemd/system'
Creating Binary symLink ........: ats in '/usr/local/sbin/ats'
Creating Config symLink ........: ats.conf in '/etc/ats.conf'
Creating SharedObject symLink ..: ats.so.0.9 in '/usr/local/lib/lua/5.3'
Created symlink /etc/systemd/system/basic.target.wants/ats.service → /usr/local/lib/luarocks/rocks/ats/master-0/ats.service.
Created symlink /etc/systemd/system/ats.service → /usr/local/lib/luarocks/rocks/ats/master-0/ats.service.
Starting ATS Service..
● ats.service - ATS - Active Thermal Service
   Loaded: loaded (/usr/local/lib/luarocks/rocks/ats/master-0/ats.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Thu 2019-12-05 18:42:38 CET; 8ms ago
  Process: 26327 ExecStart=/usr/local/sbin/ats (code=exited, status=1/FAILURE)
 Main PID: 26327 (code=exited, status=1/FAILURE)
make: *** [Makefile:236: install] Error 3

Error: Build error: Failed installing.
root@RockHomeServer:~#

 

Share this post


Link to post
Share on other sites

Hello,

At least for the tests done with 2 other colleagues,

 

Seems that Armbian kernel is missing a .config option..
'CONFIG_SENSORS_PWM_FAN=y'

 

Which is present in 'ayufan' kernels work..

 

ATS needs sysfs to communicate with the kernel driver, and is not there the pwm ctl: '/sys/class/hwmon/hwmon0/pwm1'

Share this post


Link to post
Share on other sites
On 12/6/2019 at 2:56 AM, Igor said:

 

On 12/6/2019 at 6:31 AM, Werner said:

 

On 12/6/2019 at 1:16 AM, tuxd3v said:

ATS needs sysfs to communicate with the kernel driver, and is not there the pwm ctl: '/sys/class/hwmon/hwmon0/pwm1'

Hello, Thanks for the quick fix of the problem.
(For stupid like me) Please create a step by step introduction, how and where I can find and correct the linux-rockchip64-dev.config!?! Or what do I have to do now after the update?

Share this post


Link to post
Share on other sites

Just wait for the next version bump, upgrade your kernel using apt and the module will be included. Then simply load the kernel module using modprobe pwm-fan .

Or build your own kernel package using the build script.

Share this post


Link to post
Share on other sites
15 minutes ago, Werner said:

Just wait for the next version bump, upgrade your kernel using apt and the module will be included. Then simply load the kernel module using modprobe pwm-fan .

Or build your own kernel package using the build script.

Many thanks. But wait is not my strength. ;)

Share this post


Link to post
Share on other sites

I've been trying to test ATS on a RockPro64 with Armbian, and with Werner's changes I can confirm that pwm_fan is now being loaded as a kernel module, but I was still getting the startup error from ATS complaining the FAN_CTL value was missing.

root@RockPro64:/# ats --test
getConditions: Warning, Values { THERMAL0_CTL, THERMAL1_CTL, FAN_CTL }: /sys/class/thermal/thermal_zone0/temp, /sys/class/thermal/thermal_zone1/temp, ERROR
exit 1

I found that pwm1 is now available under `hwmon1`, not `hwmon0`. I'm assuming this is because fan_pwm is loaded as a module, and not included in the kernel as it is with ayufan's kernel.

root@RockPro64:/# ll /sys/class/hwmon/
lrwxrwxrwx  1 root root 0 Jan 17 15:02 hwmon0 -> ../../devices/platform/ff3d0000.i2c/i2c-4/4-0022/power_supply/tcpm-source-psy-4-0022/hwmon0
lrwxrwxrwx  1 root root 0 Jan 17 15:12 hwmon1 -> ../../devices/platform/pwm-fan/hwmon/hwmon1
root@RockPro64:/# ls /sys/class/hwmon/hwmon1/
device  name  of_node  power  pwm1  subsystem  uevent

To fix this you have to edit `/etc/ats.config` line 64, changing `PWM_CTL = "/sys/class/hwmon/hwmon0/pwm1,` to `PWM_CTL = "/sys/class/hwmon/hwmon1/pwm1,`. Notice `hwmon0` to `hwmon1`.

 

This will fix the ATS error, but for me the fan will still not spin.

root@RockPro64:/# ats --test
info:'SYSTEM' Table
info:    'BOARD' Table
info:        'NAME' = ROCKPRO64
info:        'CPU'  = RK3399
info:    'THERMAL0_CTL' = /sys/class/thermal/thermal_zone0/temp
info:    'THERMAL1_CTL' = /sys/class/thermal/thermal_zone1/temp
info:    'PWM_CTL'      = /sys/class/hwmon/hwmon1/pwm1
info:    'MAX_CONTINUOUS_THERMAL_TEMP' = 60
info:    'MIN_CONTINUOUS_THERMAL_TEMP' = 40
info:    'MAX_PWM' = 255
info:    'MIN_PWM' = 40
info:    'ALWAYS_ON' = false
info:    'PROFILE_NAME' = profile0
info:    'PROFILE'      = 0
info:'Pratio' timers
info:    'Pratio[ -20 - 40 [' = 0
info:    'Pratio[ 40 ]'       = 40
info:    'Pratio[ 41 ]'       = 50
info:    'Pratio[ 42 ]'       = 61
info:    'Pratio[ 43 ]'       = 72
info:    'Pratio[ 44 ]'       = 83
info:    'Pratio[ 45 ]'       = 93
info:    'Pratio[ 46 ]'       = 104
info:    'Pratio[ 47 ]'       = 115
info:    'Pratio[ 48 ]'       = 126
info:    'Pratio[ 49 ]'       = 136
info:    'Pratio[ 50 ]'       = 147
info:    'Pratio[ 51 ]'       = 158
info:    'Pratio[ 52 ]'       = 169
info:    'Pratio[ 53 ]'       = 179
info:    'Pratio[ 54 ]'       = 190
info:    'Pratio[ 55 ]'       = 201
info:    'Pratio[ 56 ]'       = 212
info:    'Pratio[ 57 ]'       = 222
info:    'Pratio[ 58 ]'       = 233
info:    'Pratio[ 59 ]'       = 244
info:    'Pratio[ 60 ]'       = 255
info:    'Pratio[ 60 - 70 ['  = 255
Stopping for[ seconds ]............... 3
CPU Temperature[ max 70 °C ].......... 0
GPU Temperature[ max 70 °C ].......... 0
Fan PWM Duty Cycle value[ 0 - 255 ]... 190
--------------------
Running for[ seconds ]................ 60
CPU Temperature[ max 70 °C ].......... 56
GPU Temperature[ max 70 °C ].......... 55
Fan PWM Duty Cycle value[ 0 - 255 ]... 212

Manually reading pwm1 when running ATS as a service reveals that it is successfully writing a value (0-255):

root@RockPro64:/# cat /sys/class/hwmon/hwmon1/pwm1 
222

I've connected the official RockPro64 fan into the `+FAN-` pin header, shown as label 4 (J8) on the board layout https://wiki.pine64.org/index.php/ROCKPro64#Connectors.2C_sockets_and_headers, but it will still not spin.

 

I tried measuring the voltage across these pins with my terrible multimeter (expecting 10.8 - 13.2V based on the fan specification, or maybe a fraction of that corresponding to the PWM value), but I'm reading 0V. Not too sure where the issue is now.

Share this post


Link to post
Share on other sites

@Mathias I compiled the latest Armbian kernel a few days ago, which definitely has the pwm-fan config available as a module.

root@RockPro64:~$ uname -a
Linux RockPro 5.4.12-rockchip64 #19.11.8 SMP PREEMPT Fri Jan 17 14:07:39 AEST 2020 aarch64 GNU/Linux

Interesting to hear your fan is working. Some users have reported being able to get their fan spinning at a constant speed, even without pwm-fan, but I'm not even able to do that.

Share this post


Link to post
Share on other sites
On 1/17/2020 at 7:03 AM, deathisunknown said:

I've been trying to test ATS on a RockPro64 with Armbian, and with Werner's changes I can confirm that pwm_fan is now being loaded as a kernel module, but I was still getting the startup error from ATS complaining the FAN_CTL value was missing.


root@RockPro64:/# ats --test
getConditions: Warning, Values { THERMAL0_CTL, THERMAL1_CTL, FAN_CTL }: /sys/class/thermal/thermal_zone0/temp, /sys/class/thermal/thermal_zone1/temp, ERROR
exit 1

I found that pwm1 is now available under `hwmon1`, not `hwmon0`. I'm assuming this is because fan_pwm is loaded as a module, and not included in the kernel as it is with ayufan's kernel.


root@RockPro64:/# ll /sys/class/hwmon/
lrwxrwxrwx  1 root root 0 Jan 17 15:02 hwmon0 -> ../../devices/platform/ff3d0000.i2c/i2c-4/4-0022/power_supply/tcpm-source-psy-4-0022/hwmon0
lrwxrwxrwx  1 root root 0 Jan 17 15:12 hwmon1 -> ../../devices/platform/pwm-fan/hwmon/hwmon1
root@RockPro64:/# ls /sys/class/hwmon/hwmon1/
device  name  of_node  power  pwm1  subsystem  uevent

To fix this you have to edit `/etc/ats.config` line 64, changing `PWM_CTL = "/sys/class/hwmon/hwmon0/pwm1,` to `PWM_CTL = "/sys/class/hwmon/hwmon1/pwm1,`. Notice `hwmon0` to `hwmon1`.

 

This will fix the ATS error, but for me the fan will still not spin.


root@RockPro64:/# ats --test
info:'SYSTEM' Table
info:    'BOARD' Table
info:        'NAME' = ROCKPRO64
info:        'CPU'  = RK3399
info:    'THERMAL0_CTL' = /sys/class/thermal/thermal_zone0/temp
info:    'THERMAL1_CTL' = /sys/class/thermal/thermal_zone1/temp
info:    'PWM_CTL'      = /sys/class/hwmon/hwmon1/pwm1
info:    'MAX_CONTINUOUS_THERMAL_TEMP' = 60
info:    'MIN_CONTINUOUS_THERMAL_TEMP' = 40
info:    'MAX_PWM' = 255
info:    'MIN_PWM' = 40
info:    'ALWAYS_ON' = false
info:    'PROFILE_NAME' = profile0
info:    'PROFILE'      = 0
info:'Pratio' timers
info:    'Pratio[ -20 - 40 [' = 0
info:    'Pratio[ 40 ]'       = 40
info:    'Pratio[ 41 ]'       = 50
info:    'Pratio[ 42 ]'       = 61
info:    'Pratio[ 43 ]'       = 72
info:    'Pratio[ 44 ]'       = 83
info:    'Pratio[ 45 ]'       = 93
info:    'Pratio[ 46 ]'       = 104
info:    'Pratio[ 47 ]'       = 115
info:    'Pratio[ 48 ]'       = 126
info:    'Pratio[ 49 ]'       = 136
info:    'Pratio[ 50 ]'       = 147
info:    'Pratio[ 51 ]'       = 158
info:    'Pratio[ 52 ]'       = 169
info:    'Pratio[ 53 ]'       = 179
info:    'Pratio[ 54 ]'       = 190
info:    'Pratio[ 55 ]'       = 201
info:    'Pratio[ 56 ]'       = 212
info:    'Pratio[ 57 ]'       = 222
info:    'Pratio[ 58 ]'       = 233
info:    'Pratio[ 59 ]'       = 244
info:    'Pratio[ 60 ]'       = 255
info:    'Pratio[ 60 - 70 ['  = 255
Stopping for[ seconds ]............... 3
CPU Temperature[ max 70 °C ].......... 0
GPU Temperature[ max 70 °C ].......... 0
Fan PWM Duty Cycle value[ 0 - 255 ]... 190
--------------------
Running for[ seconds ]................ 60
CPU Temperature[ max 70 °C ].......... 56
GPU Temperature[ max 70 °C ].......... 55
Fan PWM Duty Cycle value[ 0 - 255 ]... 212

Manually reading pwm1 when running ATS as a service reveals that it is successfully writing a value (0-255):


root@RockPro64:/# cat /sys/class/hwmon/hwmon1/pwm1 
222

I've connected the official RockPro64 fan into the `+FAN-` pin header, shown as label 4 (J8) on the board layout https://wiki.pine64.org/index.php/ROCKPro64#Connectors.2C_sockets_and_headers, but it will still not spin.

 

I tried measuring the voltage across these pins with my terrible multimeter (expecting 10.8 - 13.2V based on the fan specification, or maybe a fraction of that corresponding to the PWM value), but I'm reading 0V. Not too sure where the issue is now.

Hi.

 

I did also got some troubles with the fan control. So i just decided to control the fan manual, it works with 'Armbian Strech - Kernel 4.4' :

echo disabled > /sys/devices/virtual/thermal/thermal_zone0/mode
echo 255 > /sys/devices/platform/pwm-fan/hwmon/hwmon0/pwm1

 

Do sombody has kernel 5.4 installed and could try: /sys/devices/platform/pwm-fan/hwmon/hwmon0/pwm1

Or maybe i can find time later today to check.

 

I use the big orginal NAS case with "orginal" fan + Medium sized or big sized heatsink (Not 100% sure about heatsink size, will check when i go home later today)

"255" -Max fan speed. I do not think full speed is need with "orginal" fan

Fan speed "80" - "100" will keep the CPU around 38-40 degress with CPU workload around 50-55%

 

With all my NAS servers i run with constant speed. With a speed suitable for my needs. It needs a little patience to find the ideal fan speed for your needs.

Share this post


Link to post
Share on other sites
On 1/23/2020 at 1:27 PM, soerenderfor said:

I did also got some troubles with the fan control. So i just decided to control the fan manual, it works with 'Armbian Strech - Kernel 4.4' :

echo disabled > /sys/devices/virtual/thermal/thermal_zone0/mode
echo 255 > /sys/devices/platform/pwm-fan/hwmon/hwmon0/pwm1

 

@soerenderfor I tried your commands here, replacing hwmon0 with hwmon1, since I have no 'pwm1' under hwmon0. My fan still does not spin.

 

It looks like both you and @Mathias have 'pwm1' available under 'hwmon0', but mine is on 'hwmon1'. Perhaps this is the reason?

Share this post


Link to post
Share on other sites

@deathisunknown just to make sure. Did you try the command without changing anything?

 

Will you please check, what is in: /sys/devices/platform/pwm-fan/

 

Thanks.

 

 

Share this post


Link to post
Share on other sites
2 minutes ago, soerenderfor said:

Did you try the command without changing anything?

 

@soerenderfor I did not attempt to write to hwmon0/pwm1, because I do not have hwmon0:

root@RockPro64:/# ll /sys/devices/platform/pwm-fan/hwmon/
total 0
drwxr-xr-x 3 root root 0 Jan 24 15:08 .
drwxr-xr-x 4 root root 0 Jan 24 15:08 ..
drwxr-xr-x 3 root root 0 Jan 24 15:08 hwmon1

 

3 minutes ago, soerenderfor said:

Will you please check, what is in: /sys/devices/platform/pwm-fan/

 

Sure:

root@RockPro64:/# ll /sys/devices/platform/pwm-fan/
total 0
drwxr-xr-x  4 root root    0 Jan 24 15:08 .
drwxr-xr-x 99 root root    0 Jan 24 15:08 ..
lrwxrwxrwx  1 root root    0 Jan 24 15:42 driver -> ../../../bus/platform/drivers/pwm-fan
-rw-r--r--  1 root root 4096 Jan 24 15:42 driver_override
drwxr-xr-x  3 root root    0 Jan 24 15:08 hwmon
-r--r--r--  1 root root 4096 Jan 24 15:42 modalias
lrwxrwxrwx  1 root root    0 Jan 24 15:42 of_node -> ../../../firmware/devicetree/base/pwm-fan
drwxr-xr-x  2 root root    0 Jan 24 15:42 power
lrwxrwxrwx  1 root root    0 Jan 24 15:08 subsystem -> ../../../bus/platform
-rw-r--r--  1 root root 4096 Jan 24 15:08 uevent

 

Share this post


Link to post
Share on other sites

@deathisunknown Thanks, what about:

echo disabled > /sys/devices/virtual/thermal/thermal_zone0/mode

echo 255 > /sys/devices/platform/pwm-fan/hwmon/hwmon1/pwm1 

 

The last echo line, is it a path you got? Try to run. 

A spining fan is better than no fan at all, right?

 

Will you please report back when you got time, thanks in advance.

Maybe i can put a simple script together.

Share this post


Link to post
Share on other sites
2 hours ago, soerenderfor said:

Thanks, what about:

echo disabled > /sys/devices/virtual/thermal/thermal_zone0/mode

echo 255 > /sys/devices/platform/pwm-fan/hwmon/hwmon1/pwm1

 

@soerenderfor I do have both of those paths, but still no luck with those commands. I made sure to disable ATS as well to prevent it from interfering with our tests.

root@RockPro64:/# systemctl disable ats
Removed /etc/systemd/system/basic.target.wants/ats.service.
root@RockPro64:/# cat /sys/devices/virtual/thermal/thermal_zone0/mode
enabled
root@RockPro64:/# echo disabled > /sys/devices/virtual/thermal/thermal_zone0/mode
root@RockPro64:/# cat /sys/devices/virtual/thermal/thermal_zone0/mode
disabled
root@RockPro64:/# cat /sys/devices/platform/pwm-fan/hwmon/hwmon1/pwm1 
0
root@RockPro64:/# echo 255 > /sys/devices/platform/pwm-fan/hwmon/hwmon1/pwm1 
root@RockPro64:/# cat /sys/devices/platform/pwm-fan/hwmon/hwmon1/pwm1 
255

Still no fan spin. :(

Share this post


Link to post
Share on other sites
On 1/24/2020 at 1:16 PM, deathisunknown said:

Still no fan spin. :(

@deathisunknown Is it possible to try the FAN on another machine just to make sure the FAN still work? Or another orginal you can connect? Thanks.

Share this post


Link to post
Share on other sites
23 hours ago, soerenderfor said:

@deathisunknown Is it possible to try the FAN on another machine just to make sure the FAN still work? Or another orginal you can connect? Thanks.

 

@soerenderfor I can confirm that the fan definitely works. I connected the fan to the 5V and GND (pins 2 and 4) of the PI-2 bus (GPIO) header and the fan spins! (The pinout can be found under "ROCKPro64 Pi-2 Pin assignment and definition" here: https://wiki.pine64.org/index.php/ROCKPro64#Board_Information.2C_Schematics_and_Certifications)

 

Actually, this will be a great temporary solution until I can figure out why my fan header isn't powered. Temperatures are half what they were!

Share this post


Link to post
Share on other sites
1 minute ago, deathisunknown said:

I connected the fan to the 5V and GND (pins 2 and 4) of the PI-2 bus (GPIO) header and the fan spins!

@deathisunknown it is the 12V fan right? I am aware it is not a problem at all. How fast is it spinning at the low voltage? Just curious. Thanks.

Share this post


Link to post
Share on other sites
Just now, soerenderfor said:

@deathisunknown it is the 12V fan right? I am aware it is not a problem at all. How fast is it spinning at the low voltage? Just curious. Thanks.

 

@soerenderfor The concept of PWM is to switch the 12V supply on and off to produce a lower average power. A 5V supply should be roughly equivalent to a 12V supply with PWM of ~106 (note: 5V / 12V = 41.67% -> 41.67% * 255 = 106.25).

 

There are reports online that if the supply voltage is too low, the fan won't start spinning, but 5V seems fine.

Share this post


Link to post
Share on other sites

@soerenderfor Do you have any ideas for anything else I might try to get my fan header to work again? This week I will flash a fresh Ayufan image on an SD card and make sure the hardware still works, but I am pretty certain it does - and it only stopped when I swapped the kernel to Armbian builds.

Share this post


Link to post
Share on other sites

@Mathias - I have run some tests now. With a Samsung Portabel T5 500GB connected to USB-C,  1x 4TB WD Red NAS HDD and 1x 8TB WD Red NAS HDD. I got 2 or 3 random reboots. I did wirte 10TB down, and did backup 2TB or so. Not sure why the reboots. CPU & HDD temp was acceptable.

 

I have found a chaep 4 port sata pcie, i can't find info on the board itself.  Will teste the 4port card now.

 

@deathisunknown - I have looked around, there is someone that has wrote a python simple fan control. I have not tried it out. You can check it here FAN control not 100% sure if it is only to ROCK64. Here is some patch made to work in Libre.. Maybe it could be to some use, to point out. This on is to LibreELEC FAN script ROCKPRO64 and HERE . Will you please report back if it helped you? Thanks.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
0