{"id":4263,"date":"2015-12-22T13:59:33","date_gmt":"2015-12-22T11:59:33","guid":{"rendered":"http:\/\/www.kameli.net\/marq\/?page_id=4263"},"modified":"2016-01-19T22:38:15","modified_gmt":"2016-01-19T20:38:15","slug":"meifand-control-fan-speeds-on-intel-amtmei-mobos-with-linux","status":"publish","type":"page","link":"http:\/\/www.kameli.net\/marq\/?page_id=4263","title":{"rendered":"Meifand: control fan speeds on Intel AMT\/ME mobos with Linux"},"content":{"rendered":"<p>I happened to buy an Intel DH57JG motherboard for a project, only to discover it is not possible to control the fans using the normal <em>lm-sensors\/fancontrol<\/em> method. To make a long story short, the fans sit behind the\u00a0<em>Management Engine<\/em>, which is part of Intel&#8217;s <em>Active Management Technology<\/em>. There exists some Linux support for the ME in the form of the <em>MEI<\/em> (\/dev\/mei), but no tools for doing anything with it. Some of the acronyms involved are:<\/p>\n<ul>\n<li><em>AMT<\/em> \u2013 Intel&#8217;s Active Management Technology. Remote access and all sorts of related monitoring services.<\/li>\n<li><em>ME<\/em> \u2013 Management Engine. The separate (co)processor in charge of the above.<\/li>\n<li><em>MEI<\/em> \u2013 Management Engine Interface. A PCI-based programming interface to the above.<\/li>\n<li><em>QST<\/em> \u2013 Quiet System Technology. The subset of ME that controls and monitors temperatures, fans, voltages and such.<\/li>\n<\/ul>\n<p>A probable indicator that you might have the same problem is that you have a mobo with an Intel chipset and running <em>sensors<\/em>\u00a0after <em>sensors-detect<\/em> reports 0 RPM for all fans. Likewise, <em>pwmconfig<\/em> will not find any fan controllers.<\/p>\n<p>So, what to do? The CPU fan runs too slow, so the cores reach temperatures up to 90\u00b0C, which is way beyond the recommended Tjunction in the long run. On the other hand, the case fan runs too fast for my taste. There is some example code available <a href=\"https:\/\/github.com\/gigaplex\/Intel_QST_SDK\">here<\/a> (Gigaplex&#8217;s patched version for new kernels), but that&#8217;s still far from an end-user solution.<\/p>\n<p>Getting the examples to compile and run gave at least some hope that something could be done: at least the interface worked and read realistic values from the sensors. With a few hours of tweaking I found a way to set the duty cycles for fan controllers, after which it was no biggie to write a simple daemon that adjusts them according to the CPU temperature. All looked good until\u00a0I discovered how unreliable\u00a0either ME or its Linux kernel support is and had to spend many hours more trying to work around the problems.<\/p>\n<p>After several days of fiddling and testing I&#8217;m (somewhat) proud to present <a href=\"http:\/\/www.kameli.net\/~marq\/kode\/meifand.tar.gz\">meifand<\/a>, which may or may not remedy your similar situation. I won&#8217;t accept complaints if you happen to fry your mobo\/CPU with it.<\/p>\n<h3>Installation<\/h3>\n<p><em>Meifand<\/em>\u00a0requires some compiling and tweaking according to your particular system, so consider it more of an experiment rather than a turnkey\u00a0solution. To get it installed follow these steps:<\/p>\n<ol>\n<li>Make sure you can read core temperatures by running <em>sensors.<\/em>\u00a0Usually ok by default these days.<\/li>\n<li>Check that\u00a0<em>mei<\/em> and <em>mei_me<\/em> modules are loaded\u00a0(<em>lsmod | grep mei<\/em>).<\/li>\n<li>Download\u00a0<a href=\"https:\/\/github.com\/gigaplex\/Intel_QST_SDK\">Gigaplex&#8217;s version<\/a> of the QST SDK.<\/li>\n<li>Compile and install the libraries \u2013 the example programs won&#8217;t compile straight away, but they&#8217;re not needed either. In case you want to fix them, move the library linking parameters, such as &#8220;-lQstComm&#8221; to the end of the gcc command line in the Makefiles.<\/li>\n<li>On 64-bit systems it&#8217;s useless to create anything under \/usr\/lib64, so in src\/libraries\/Linux\/makefile it&#8217;s probably a good idea to change LIBDIR to \/usr\/lib<\/li>\n<li>Unpack <a href=\"http:\/\/www.kameli.net\/~marq\/kode\/meifand.tar.gz\">meifand<\/a>, <em>make<\/em> and <em>sudo make install.<\/em>\u00a0Add -DDEBUG to the Makefile if you want to experiment a bit.<\/li>\n<li>Add\u00a0to \/etc\/rc.local the following line: <em>\/usr\/local\/bin\/meifan_watchdog.sh &amp;<\/em><\/li>\n<li>It seems recently there&#8217;s no <em>\/dev\/mei<\/em> even if the libs expect that \ud83d\ude41 As a quick fix precede the previous line in \/usr\/rc.local with this: <em>ln -s \/dev\/mei0 \/dev\/mei<\/em><\/li>\n<\/ol>\n<p>The meifan_watchdog.sh script starts\u00a0meifand and keeps it alive when needed.<\/p>\n<h3>Configuration<\/h3>\n<p>The default values are probably off for your setup, so some tweaks are needed. Run as root <em>meifand &#8211;detect<\/em> to show your core temperature sensors and fan controllers. The settings\u00a0reside in \/etc\/meifand.conf and contain three kinds of items \u2013 better\u00a0be careful with whitespace, as the parser is not too forgiving.<\/p>\n<ol>\n<li><em>interval<\/em>. Simply the number of seconds between\u00a0polling the temperatures.<\/li>\n<li><em>sensor<\/em>. Add on separate lines all temperature sensors you want to involve in\u00a0fan speed setting. The highest temperature\u00a0will be used for the calculations.<\/li>\n<li><em>fan<\/em>. Fan (controller). Contains the fan number as shown by &#8211;detect, whether it should be dynamic (likely a CPU fan) or run at constant speed (likely a case fan). For a constant speed fan specify the wanted duty cycle, and for a dynamic one the minimum and maximum temperatures followed by the corresponding duty cycles.<\/li>\n<\/ol>\n<p>Duty cycles range from 0 to 100 and their values depend on your particular setup. In practice\u00a0zero is <em>not<\/em> the minimum speed (e.g. values less than 40 might provide exactly the same results). You&#8217;ll find the optimal values only by experimenting and making compromises between noise and heat.<\/p>\n<p>If the core temperature is less than the minimum you specified, the fan will run at the constant minimum speed. Likewise, if it&#8217;s hotter than the maximum, the fan will run at the given maximum speed. Between the extremes meifand will scale the duty cycles linearly according to the temperature.<\/p>\n<h3>Usage<\/h3>\n<p>In general you shouldn&#8217;t need to worry about the background processes. When trying to find the optimal values you can edit meifand.conf and do a <em>killall meifand<\/em> \u2013 the watchdog will restart it soon again. Maybe one day I&#8217;ll make it possible to reload the config a bit more conveniently. To return back to automatic fan control, try this as root: <em>killall\u00a0meifan_watchdog.sh &amp;&amp; killall meifand<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I happened to buy an Intel DH57JG motherboard for a project, only to discover it is not possible to control the fans using the normal lm-sensors\/fancontrol method. To make a long story short, the fans sit behind the\u00a0Management Engine, which is part of Intel&#8217;s Active Management Technology. There exists some Linux support for the ME [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":974,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4263","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/pages\/4263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4263"}],"version-history":[{"count":15,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/pages\/4263\/revisions"}],"predecessor-version":[{"id":4298,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/pages\/4263\/revisions\/4298"}],"up":[{"embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/pages\/974"}],"wp:attachment":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}