General NAS-Central Forums

Welcome to the NAS community
It is currently Fri Dec 15, 2017 2:46 am

All times are UTC




Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Mon Jan 21, 2013 6:04 pm 
Offline

Joined: Wed Dec 19, 2012 11:46 am
Posts: 39
https://github.com/lzap/fan3xxnsa

This is very simple and lightweight daemon that reads case temperature of Zyxel NSA-310 and sets fan speed according to the temperature.

How does it work
The NSA 310 provides three temperatures. The first two are most likely case temperatures, because according to all my measurements, they were always the same (+- one degree) as the disc temperature reported by SMART. The third temperature is from the CPU.

Please note the daemon only reads the case temperature (temp1), it ignores CPU or HDD temperatures. Because it does not make any sense to measure it (and also SMART spins up disc). Fan speed depends only on temp1, nothing else.

I use WD GreenPower in my NAS and the disc is 42 degrees Celsius when idle or light work, so the threasold is 43 degrees. Also I have noticed this cheap and small fan creates noise when rotating bellow 140 value, so the lowest is 160. Make sure screws in the back side are loose, do not tighen them much as it can put a pressure on the fan and create even more noise.

This is how it sets pwm according to temperature:

Code:
Temp: 41 Pwm: 0
Temp: 42 Pwm: 0
Temp: 43 Pwm: 160
Temp: 44 Pwm: 165
Temp: 45 Pwm: 170
Temp: 46 Pwm: 175
Temp: 47 Pwm: 180
Temp: 48 Pwm: 185
Temp: 49 Pwm: 190
Temp: 50 Pwm: 195
Temp: 51 Pwm: 200
Temp: 52 Pwm: 205
Temp: 53 Pwm: 210
Temp: 54 Pwm: 215
Temp: 55 Pwm: 220
Temp: 56 Pwm: 225
Temp: 57 Pwm: 230
Temp: 58 Pwm: 235
Temp: 59 Pwm: 240
Temp: 60 Pwm: 245
Temp: 61 Pwm: 250
Temp: 62 Pwm: 255
Temp: 63 Pwm: 255


How to install
Very simple. First, you need Go language (golang). Please note Go 1.0 WILL NOT compile on ARM5, you either need some development snapshot or you can checkout master (called "default") branch. Then install and set GOROOT and PATH variables.

To install fan3xxnsa, just do:

Code:
git clone
go build


And copy the binary file to a destination directory. If you are fine with ~/bin there is a script install.sh that does this for you (and also strips debug information from the binary).

Before you start the daemon, you need to enable fan control with:

Code:
echo 1 > /sys/class/i2c-dev/i2c-0/device/0-002e/pwm1_enable


Then you can start it on background using nohup for example:

Code:
nohup /root/bin/fan3xxnsa 1>/dev/null 2>&1 &


Must be executed as root, or you can change permissions on the pwm1 file.

Hacking
The code is very easy to understand, feel free to send patches. If you want to play with fans and temperatures, go to /sys/class/i2c-dev/i2c-0/device/0-002e directory (it can be different according to your NSA model or kernel version - try to find "pwm1_enable" file in the /sys/class directory).

Patches for other NSA models or kernel versions appreciated.

Please use github for updates, I will try to post important info here.


Top
 Profile  
 
PostPosted: Tue Jan 22, 2013 6:56 am 
Offline

Joined: Sun Apr 29, 2012 5:24 pm
Posts: 2314
It would be interesting to check, just a pity that I do not have a fan :)


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 7:08 am 
Offline
User avatar

Joined: Tue Feb 05, 2013 6:46 am
Posts: 44
Location: Germany
hello lzap,
hello all,

it will only work for nsa31x series.
nsa32x the row does not work because there the temp and rpm control is regulated differently.

someone has an idea to solve this for nsa32x :idea:

thank you pic

_________________
FR32K | LINUX | EigenHosting | NAS Hacking | NAS im Eigenbau | ALARM


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 9:04 am 
Offline

Joined: Wed Dec 19, 2012 11:46 am
Posts: 39
Can you do find /sys/class/i2c-dev and paste the output? I think it must be on a different path. Also which kernel are you using? It depends on the kernel version rather than hardware - I think the hardware is the same.


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 9:23 am 
Offline

Joined: Sun Apr 29, 2012 5:24 pm
Posts: 2314
Almost the same, but not identical.


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 9:34 am 
Offline
User avatar

Joined: Tue Feb 05, 2013 6:46 am
Posts: 44
Location: Germany
lzap wrote:
Can you do find /sys/class/i2c-dev and paste the output? I think it must be on a different path. Also which kernel are you using? It depends on the kernel version rather than hardware - I think the hardware is the same.


Code:
root@NSA325:~# find /sys/class/i2c-dev
/sys/class/i2c-dev
/sys/class/i2c-dev/i2c-0


Code:
root@NSA325:~# uname -a
Linux NSA325 2.6.31.8 #3 Mon Nov 12 15:27:15 CST 2012 armv5tel GNU/Linux


thanks for help :P

_________________
FR32K | LINUX | EigenHosting | NAS Hacking | NAS im Eigenbau | ALARM


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 10:35 am 
Offline

Joined: Wed Dec 19, 2012 11:46 am
Posts: 39
Ok please do this:

Code:
find /sys/class/i2c-adapter


You probably have it on a wrong path.


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 1:29 pm 
Offline
User avatar

Joined: Tue Feb 05, 2013 6:46 am
Posts: 44
Location: Germany
Code:
root@NSA325:~# find /sys/class/i2c-adapter
/sys/class/i2c-adapter
/sys/class/i2c-adapter/i2c-0


and
Code:
root@NSA325:~# find /sys/class/i2c-adapter/i2c-0/
/sys/class/i2c-adapter/i2c-0/
/sys/class/i2c-adapter/i2c-0/uevent
/sys/class/i2c-adapter/i2c-0/subsystem
/sys/class/i2c-adapter/i2c-0/device
/sys/class/i2c-adapter/i2c-0/name
/sys/class/i2c-adapter/i2c-0/new_device
/sys/class/i2c-adapter/i2c-0/delete_device
/sys/class/i2c-adapter/i2c-0/0-0051
/sys/class/i2c-adapter/i2c-0/0-0051/uevent
/sys/class/i2c-adapter/i2c-0/0-0051/name
/sys/class/i2c-adapter/i2c-0/0-0051/modalias
/sys/class/i2c-adapter/i2c-0/0-0051/subsystem
/sys/class/i2c-adapter/i2c-0/0-0051/driver
/sys/class/i2c-adapter/i2c-0/0-0051/rtc
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0/uevent
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0/dev
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0/subsystem
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0/device
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0/name
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0/date
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0/time
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0/since_epoch
/sys/class/i2c-adapter/i2c-0/0-0051/rtc/rtc0/max_user_freq
/sys/class/i2c-adapter/i2c-0/i2c-0
/sys/class/i2c-adapter/i2c-0/i2c-0/uevent
/sys/class/i2c-adapter/i2c-0/i2c-0/dev
/sys/class/i2c-adapter/i2c-0/i2c-0/subsystem
/sys/class/i2c-adapter/i2c-0/i2c-0/device
/sys/class/i2c-adapter/i2c-0/i2c-0/name


i have found /sys/class/i2c-adapter/i2c-0/0-0051, but I do not know ... nothing there shows me temp or rpm :(

_________________
FR32K | LINUX | EigenHosting | NAS Hacking | NAS im Eigenbau | ALARM


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 5:03 pm 
Offline

Joined: Sat Jan 26, 2013 7:25 pm
Posts: 2
Hi,

I can confirm that 'issue' for NSA320.

Code:
/sys# find /sys/class/i2c*
/sys/class/i2c-dev
/sys/class/i2c-dev/i2c-0


As you can see, the directory is named i2c-dev. But it seems to be the same. I also have a module 0-0051, its the RTC of the board.

Code:
/sys/class/i2c-dev/i2c-0/device/0-0051# cat name
pcf8563
/sys/class/i2c-dev/i2c-0/device/0-0051/rtc/rtc1# cat name
rtc-pcf8563


I can't find anything that looks like a PWM controller :(
I'm running a self compiled Kernel 3.2.0. I used the config of Peeter123 KLICK, with slight changes. (Debian 6.0)
Module "LM85" is enabled in kernel config.

It would be awesome to find a workaround.


Top
 Profile  
 
PostPosted: Wed Feb 06, 2013 5:45 am 
Offline

Joined: Sun Apr 29, 2012 5:24 pm
Posts: 2314
Philips microchip PCF8563 is real time clock/calendar (btw NSA 310 doesn't has this chip) http://www.datasheetcatalog.org/datasheet/philips/PCF8563-02.pdf and has no relationship with fan control.


Top
 Profile  
 
PostPosted: Wed Feb 06, 2013 7:23 am 
Offline
User avatar

Joined: Tue Feb 05, 2013 6:46 am
Posts: 44
Location: Germany
hello barmalej2,

interesting, thanks for your help.

So we can not read RPM and TEMP and control :?:

pic

_________________
FR32K | LINUX | EigenHosting | NAS Hacking | NAS im Eigenbau | ALARM


Top
 Profile  
 
PostPosted: Wed Feb 06, 2013 10:02 am 
Offline

Joined: Wed Dec 19, 2012 11:46 am
Posts: 39
Maybe you miss a driver in kernel. Maybe copypaste your lsmod output and kernel config so I can compare to mine.


Top
 Profile  
 
PostPosted: Wed Feb 06, 2013 11:47 am 
Offline

Joined: Sun Apr 29, 2012 5:24 pm
Posts: 2314
lzap wrote:
The first two are most likely case temperatures, because according to all my measurements, they were always the same (+- one degree) . The third temperature is from the CPU.

Is it logical to relate fan control with case temperature and not with CPU? I'm not criticizing, but I asking for your opinion, why you have chosen so :?:


Top
 Profile  
 
PostPosted: Wed Feb 06, 2013 3:51 pm 
Offline

Joined: Sat Jan 26, 2013 7:25 pm
Posts: 2
picard wrote:
hello barmalej2,

interesting, thanks for your help.

So we can not read RPM and TEMP and control :?:

pic


For me its possible to read RPM and TEMP from /proc/mcu.
You can use this: (By AA666, here at the end of his post)

Quote:
Here is a script to show current temperature and FAN speed:
/usr/local/sbin/hw
Code:
#!/bin/bash
for line in `cat /proc/mcu` ; do
    case $line in
        'MagicNumber:'*)
            if [ ${line#MagicNumber:} != 85 ] ; then
                exit
            fi
        ;;
        'Rpss:'*)
            declare -i fan1=${line#Rpss:}
            declare -i fan=1000/$fan1*60
            echo fan1=$fan rpm
        ;;
        'Temperature:'*)
            temp1=${line#Temperature:}
            temp=${temp1:0:2}.${temp1:2:1}
            echo temp1=$temp *C
        ;;
    esac
done



Top
 Profile  
 
PostPosted: Wed Feb 06, 2013 9:06 pm 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6091
/proc/mcu is not available on the NSA325. The CPU temp and fan rpm in the webinterface are read by zyshd. By intercepting the system calls of this daemon using strace, I found that the read is actually done by i2cget.
Code:
i2cget -y 0x0 0x0a 0x07
reads the temperature (possibly in degrees Celsius) and
Code:
i2cgey -y 0x0 0x0a 0x08
reads the fan rpm. The unit is not clear to me. The read value is 0x17 (23), and the rotation is 2608 rpm in the webinterface. I cannot remember I ever saw another value.

BTW, I've added a package i2c-tools to my slacker repository, as spin-off of these investigations.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 48 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group