Four Bits Per Nybble

On Base Sixteen, Interrupts, and Arithmetic Shift Rights

Linux on H87M-E & Haswell

I wanted to write down my notes for getting Ubuntu Linux fully running on an Asus H87M-E with a Intel Haswell processor. I use this on a media center, so I needed HDMI video and audio support.

Here is a script that I wrote to setup the fans in a way useful for my system. One fan sits on my HDs, so I wanted to regulate it based on their temperature.

H87M-E Fan Controller - fanctl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python

import daemon
import time
from subprocess import check_output

fan_driver = '/sys/devices/platform/nct6775.656/'

fan_setup = [
    ('pwm1_enable',5),
    ('pwm1_temp_sel',2),
    ('pwm1_auto_point1_temp',39000),
    ('pwm1_auto_point1_pwm',0),
    ('pwm1_auto_point2_temp',41000),
    ('pwm1_auto_point2_pwm',110),
    ('pwm1_auto_point4_temp',75000),
    ('pwm1_auto_point4_pwm',255),
    ('pwm3_enable',1),
    ('pwm3',90),
]

for s in fan_setup:
    with open(fan_driver+s[0],'w') as fdf:
        fdf.write(str(s[1]))

def get_hdd_temp(hdd):
    temp_lines = check_output(['smartctl','-A', hdd]).strip().split("\n")
    temp_line = filter(lambda l: 'Temperature' in l, temp_lines)[0]
    temp = temp_line.split()[-1]
    return int(temp)

def get_hdd_max_temp():
    drives = ['/dev/sdb', '/dev/sdc']
    temps = map((lambda l: get_hdd_temp(l)),drives)
    return max(temps)

def hdd_temp_to_pwm(t):
    if t<=31:
        return 0
    elif t<=48:
        return 110+(t-34)*10
    else:
        return 255

def hdd_fan_loop():
    while True:
        t = get_hdd_max_temp()
        pwm = hdd_temp_to_pwm(t)
        with open(fan_driver+'pwm3','w') as fdf:
            fdf.write(str(pwm))
        time.sleep(3)

def main():
    try:
        hdd_fan_loop()
    finally:
        with open(fan_driver+'pwm3','w') as fdf:
            fdf.write('170')

with daemon.DaemonContext():
    main()