Take a look at our
ThinkPads.com HOME PAGE
For those who might want to contribute to the blog, start here: Editors Alley Topic
Then contact Bill with a Private Message

fan control for x62 on linux

Old(er) Thinkpads with New(er) Intestines: X62/T50/T70/X210/X330 etc.
Post Reply
Message
Author
bitonic
Posts: 16
Joined: Fri Nov 10, 2017 11:54 am
Location: Rome, Italy

fan control for x62 on linux

#1 Post by bitonic » Mon Nov 20, 2017 8:49 am

Hi,

I've reverse engineered the windows utility posted on 51nb so that I could control the fan speed on linux: https://github.com/bitonic/x62-fancontrol . I don't know what the fan speed numbers represent exactly, but it seems to work. It also reads the temperature in the same way that the windows utility does. It seems to be vaguely consistent with the package temperature from coretemp.

I didn't test if the behavior was consistent with windows since I never even ran the windows utility, but it's just setting IO ports so I'd be inclined to think that if it works at all it's doing the right thing.

Using that code it should be trivial to write a daemon that automatically regulates the fan speed based on the temperature in a way that is less fidgety than the default one. The windows utility polls the temp and adjust the fan accordingly every second, so I'll probably write it in the same style once I figure out what the fan speed numbers are.

Francesco

bitonic
Posts: 16
Joined: Fri Nov 10, 2017 11:54 am
Location: Rome, Italy

Re: fan control for x62 on linux

#2 Post by bitonic » Mon Nov 20, 2017 11:49 am

ok, i've added a "manager" mode, you can run it with:

Code: Select all

sudo ./x62-fancontrol manager
This is already _much better_ than the default, the laptop is silent most of the time and the fans are not as jumpy. I can tweak the daemon more to wait a bit between switching levels but this is probably enough for now.

NonesensE
Sophomore Member
Posts: 138
Joined: Mon May 29, 2017 6:28 am
Location: GF/BS/OHA, Germany

Re: fan control for x62 on linux

#3 Post by NonesensE » Mon Nov 20, 2017 2:52 pm

Great work, thank you!

An idea: On my 3rd batch X62s, the fan is pretty much perfect, but when the temperature is low, sometimes the fan turns on at a high speed for a second or so. After monitoring the temperature for longer periods of time, I think this is due to occasional erroneous temperature readings (up to 255°C, but can be anything from 0 to 255°C). Neither the EC fan control nor the 51nb fan control program seem to be designed to handle wrong readings. To cancel out those non-real temperature spikes, I'd recommend a moving average, e.g. over the last 5-10 temperature readings. Of course, this makes refresh rates faster than 1 per second necessary, thus it would be better to implement it in the EC, but I don't think we'll ever see this.
Sometimes coming over from the German forum...
X62s 3rd batch, [s]T61[/s] T70 14" 4:3 1st batch

bitonic
Posts: 16
Joined: Fri Nov 10, 2017 11:54 am
Location: Rome, Italy

Re: fan control for x62 on linux

#4 Post by bitonic » Mon Nov 20, 2017 2:54 pm

NonesensE wrote:
Mon Nov 20, 2017 2:52 pm
Great work, thank you!

An idea: On my 3rd batch X62s, the fan is pretty much perfect, but when the temperature is low, sometimes the fan turns on at a high speed for a second or so. After monitoring the temperature for longer periods of time, I think this is due to occasional erroneous temperature readings (up to 255°C, but can be anything from 0 to 255°C). Neither the EC fan control nor the 51nb fan control program seem to be designed to handle wrong readings. To cancel out those non-real temperature spikes, I'd recommend a moving average, e.g. over the last 5-10 temperature readings. Of course, this makes refresh rates faster than 1 per second necessary, thus it would be better to implement it in the EC, but I don't think we'll ever see this.
that'd be very easy to do, and a good idea. i'm not sure when i'll get around to it, but obviously PRs are welcome. i think we're far from being a performance drag, even once every 250ms would be perfectly fine.

bitonic
Posts: 16
Joined: Fri Nov 10, 2017 11:54 am
Location: Rome, Italy

Re: fan control for x62 on linux

#5 Post by bitonic » Tue Nov 21, 2017 1:02 pm

ok, i've written a small script that survives wakeups from suspend -- see readme. the script works great so i doubt i'll update anytime soon, but contributions are welcome!

NonesensE
Sophomore Member
Posts: 138
Joined: Mon May 29, 2017 6:28 am
Location: GF/BS/OHA, Germany

Re: fan control for x62 on linux

#6 Post by NonesensE » Tue Nov 21, 2017 5:08 pm

In theory, there is Notebook Fan Control (NBFC) for this purpose (and is available for Win&Linux), no need to re-invent the wheel. But I don't know yet how to condense your code into a NBFC config file :oops:
Tried to set a few registers and received surprise hibernation :lol:
Sometimes coming over from the German forum...
X62s 3rd batch, [s]T61[/s] T70 14" 4:3 1st batch

mifritscher
Posts: 9
Joined: Sun Nov 06, 2016 7:01 pm
Location: Langen, Germany

Re: fan control for x62 on linux

#7 Post by mifritscher » Fri Nov 24, 2017 6:58 pm

I've hacked something together for my board. For me, the fan starts at 50, 100 is the max.

Code: Select all

<?php

function getTemp() {
	$temp = exec('./x62-fancontrol temp');
	$temp=explode("\n",$temp);
	$temp=$temp[count($temp)-1];
	$temp=explode(" ",$temp);
	$temp=$temp[count($temp)-1];
	return $temp;
}

function setLuefter($staerke) {
	$temp = exec('./x62-fancontrol set-fan-speed ' . $staerke);
}

$wartezeit=5;

//vorspannen, damit beim start der Luefter eher zu viel dreht
$count_extrem=$wartezeit;
$count_heiss=$wartezeit;
$count_warm=$wartezeit;

while (true) {
	$luefter=0;
	
	$temp1=getTemp();
	sleep(1);
	$temp2=getTemp();

	$temp=min($temp1,$temp2);

	echo "Temp: $temp\n";

	if ($temp>85) {
		$count_extrem++;
		$count_heiss+=2;
		$count_warm+=3;
	} else if ($temp>80) {
		$count_extrem--;
		$count_heiss++;
		$count_warm+=2;
	} else if ($temp>75) {
		$count_extrem--;
		$count_heiss--;
		$count_warm++;
	} else {
		$count_extrem--;
		$count_heiss--;
		$count_warm--;
	}

	$count_extrem =min($wartezeit*2, $count_extrem);
	$count_extrem =max(0, $count_extrem);

	$count_heiss =min($wartezeit*2, $count_heiss);
	$count_heiss =max(0, $count_heiss);

	$count_warm =min($wartezeit*2, $count_warm);
	$count_warm =max(0, $count_warm);

	if ($count_extrem > $wartezeit) {
		echo "extrem\n";
		$luefter=85;
	} else if ($count_heiss > $wartezeit) {
		echo "heiss\n";
		$luefter=63;
	} else if ($count_warm > $wartezeit) {
		echo "warm\n";
		$luefter=51;
	} else {
		echo ("kalt\n");
		$luefter=0;
	}
	setLuefter($luefter);
}

?>

OhneHerren
Posts: 13
Joined: Thu Jul 03, 2014 12:53 am
Location: Footscray, Australia

Re: fan control for x62 on linux

#8 Post by OhneHerren » Thu Dec 14, 2017 5:00 am

Is it possible to read the fan speed?

Using your tool on my third batch X62, fan speed 0 is maximum, fan speed 1 is off and fan speeds 2 to 100 are increasing levels with 2 being the minimum and 100 being the maximum. Fan speeds 101-255 are equivalent to fan off.

bitonic
Posts: 16
Joined: Fri Nov 10, 2017 11:54 am
Location: Rome, Italy

Re: fan control for x62 on linux

#9 Post by bitonic » Thu Dec 14, 2017 5:03 am

OhneHerren wrote:
Thu Dec 14, 2017 5:00 am
Is it possible to read the fan speed?
nope, i just reverse-engineered the windows app -- it was quite clear from the binary what code sets the speed and reads the temperature. sadly the windows application doesn't include anything regarding reading the fan speed.

somebody with more familiarity with how these controllers usually work could probably spot some patterns and make a guess on how to read the fan speed, but i have no clue.

wujstefan
ThinkPadder
ThinkPadder
Posts: 1343
Joined: Fri Mar 04, 2011 8:38 am
Location: Tarnow, Poland

Re: fan control for x62 on linux

#10 Post by wujstefan » Sat Dec 23, 2017 6:10 am

Does this 51nb app work for you well?

I can't make it work under Windows. Did nnot try out the Linux version yet.
Too many thinkpads not enough time!
(stable under reduction)

bitonic
Posts: 16
Joined: Fri Nov 10, 2017 11:54 am
Location: Rome, Italy

Re: fan control for x62 on linux

#11 Post by bitonic » Sat Dec 23, 2017 6:12 am

wujstefan wrote:
Sat Dec 23, 2017 6:10 am
Does this 51nb app work for you well?

I can't make it work under Windows. Did nnot try out the Linux version yet.
yes, it works great. the only problem is that you have to restart it after resume, but the x62-fancontrol-manager.py script i added takes care of that. i have it start up on boot using a simple systemd service.

wujstefan
ThinkPadder
ThinkPadder
Posts: 1343
Joined: Fri Mar 04, 2011 8:38 am
Location: Tarnow, Poland

Re: fan control for x62 on linux

#12 Post by wujstefan » Sat Dec 23, 2017 9:37 am

Then I must do something wrong way. I set all the data in ThermalTable, run the .exe file, and it works OK... for a short while (5-10mins). I've set everything to keep my system silent until it reaches 60C, and then pump out the fan with speed that ommits the low-pitch noise.

EDIT: it seems that the application stops working properly when going down with temps. This is my termal table:
00,0,0,0,
49,0,0,0,
60,50,50,0,
73,70,20,0,
82,75,2,0,
255,0,100,0
I've got the app in the "autostart", generally a bit annoying I need to minimize or close the window directly after start, but it is as it is. The fan settings work OK just as long as they are going up - when they are turning back to the state where the fan shoud not spin at all, I've got the noisy, low-speed fan movement that should not occur with such settings at all.

I should move this one to another thread - sorry for hijack :)
Too many thinkpads not enough time!
(stable under reduction)

bitonic
Posts: 16
Joined: Fri Nov 10, 2017 11:54 am
Location: Rome, Italy

Re: fan control for x62 on linux

#13 Post by bitonic » Sat Dec 23, 2017 8:42 pm

wujstefan wrote:
Sat Dec 23, 2017 9:37 am
Then I must do something wrong way. I set all the data in ThermalTable, run the .exe file, and it works OK... for a short while (5-10mins). I've set everything to keep my system silent until it reaches 60C, and then pump out the fan with speed that ommits the low-pitch noise.

EDIT: it seems that the application stops working properly when going down with temps. This is my termal table:
00,0,0,0,
49,0,0,0,
60,50,50,0,
73,70,20,0,
82,75,2,0,
255,0,100,0
I've got the app in the "autostart", generally a bit annoying I need to minimize or close the window directly after start, but it is as it is. The fan settings work OK just as long as they are going up - when they are turning back to the state where the fan shoud not spin at all, I've got the noisy, low-speed fan movement that should not occur with such settings at all.

I should move this one to another thread - sorry for hijack :)
mhm, if i have the time i might take a look at the binary again to see if i spot a bug -- then maybe i can patch the windows binary to fix it :P .

however i'm not sure it's worth putting the time into the proprietary utility since i reproduced its functionality... it should be fairly easy to port the code to windows.

jaspen-meyer
Senior Member
Senior Member
Posts: 837
Joined: Wed May 19, 2010 11:21 pm
Location: Pardubice, Czech Republic
Contact:

Re: fan control for x62 on linux

#14 Post by jaspen-meyer » Sun Dec 24, 2017 1:23 pm

Code: Select all

void unknown_communication(void) {
  printf("Sending unknown commands\n");
  set_0x6C(0x33);
  outb(0x06, 0x68);
}
What do we know about this function?
T420 i7 3612QM seabios; T420 i7 3630QM; T400 Q9100 seabios; T61 P9600; T60 libreboot; x62; x60s libreboot, led; x24 xiphmont led

bitonic
Posts: 16
Joined: Fri Nov 10, 2017 11:54 am
Location: Rome, Italy

Re: fan control for x62 on linux

#15 Post by bitonic » Sun Dec 24, 2017 1:25 pm

jaspen-meyer wrote:
Sun Dec 24, 2017 1:23 pm

Code: Select all

void unknown_communication(void) {
  printf("Sending unknown commands\n");
  set_0x6C(0x33);
  outb(0x06, 0x68);
}
What do we know about this function?
nothing, i just replicated what the windows app does. for some parts of the code i can take i guess, but i have no clue what this does, hence the name.

vavet
Sophomore Member
Posts: 233
Joined: Mon Apr 15, 2013 8:32 am
Location: Geneva, Switzerland

Re: fan control for x62 on linux

#16 Post by vavet » Sun Jun 10, 2018 7:47 am

did anyone managed to come up with a table that eliminates the noise at all?
I have tried different combinations but the noise does come back every time.
X61 (T9300, 8gb RAM, 120gb SSD, LED SXGA+, integrated webcam, invisible touchpad, modded battery etc.)

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “51nb and other modded Thinkpads”

Who is online

Users browsing this forum: No registered users and 12 guests