cze 8, 2010

ASUS M6N Notebook


Here you will find system sensors configuration for my old ASUS M6N Notebook. This configuration includes kernel module and core lm_sensors configuration.
Kategoria: lm_sensors
Napisał: kardasa

Foreword

System sensor configuration is extremely important especially on mobile computers. One of most common cause of computers failure is overheating. Thanks to Linux lm_sensors tools we can effectively monitor state of our machine, and if necessary thanks to additional tools like cpufrequtils we can prevent overheating by automatically lowering CPU voltage and performance. This way we can use our computer effectively for a very long time.

Configuration of system sensors in Linux is not difficult, but configuration may vary from one piece of hardware to another. What I found out is the fact that most likely sensors configuration provided by core lm_sensors packet will always require a little tune up to make them work perfectly. I will try to share here configuration that is coming from my ASUS M6N notebook, quite old but still working piece of hardware. Described below configuration is applicable to Gentoo Linux distribution but most important thing the lm_sensors configuration file should work on any Linux distribution. I will start with kernel configuration.

Kernel Configuration

My ASUS M6N has sensor chip adm1021. I had to mark more then just this chip options in kernel to make lm_sensors work properly. To configure my kernel I had to enter kernel catalog and start menuconfig by running following commands in terminal:

cd /usr/src/linux
make menuconfig

Next I had to mark all modules needed to make my sensors work. Many distributions will mark all possible hardware sensor modules but this is not the Gentoo way. I want to show directly which modules are needed. Take a look at belows list of modules.

Linux Kernel Configuration: Sensor Kernel modules
Device Drivers  --->
    [*] Misc devices  --->
        EEPROM support  --->
             <M> Old I2C EEPROM reader
    <M> I2C support  --->
        <M> I2C device interface
            I2C Hardware Bus support --->  
                <M> Intel 82801 (ICH/PCH)
    <M> Hardware Monitoring Support --->
        <M> Analog Devices ADM1021 and compatibles

As you can see most of the sensors support will be build as modules. This is highly important because this modules will be loaded by lm_sensors system service. Now we are ready to recompile, install and use new kernel. I usually do it by running this commands in terminal:

cd /usr/src/linux
make && make modules_install install

Now it's good time to reboot the machine with new kernel and install lm_sensors.

Lm Sensors Configuration

I use lm_sensors 3.x and I would not recommend using older version. To install lm_sensors in Gentoo system you need to run this commands in terminal:

emerge -av sys-apps/lm_sensors

Next thing we should do is to make sure that programs able to use system sensors will be compiled with this support. To do it we need to add lm_sensors use flag to our /etc/make.conf file. After doing this it is good idea to check which of installed programs should be recompiled. You can do it by using gentoolkit equery utility like this:

equery hasuse lm_sensors
 * Searching for USE flag lm_sensors ... 
[IP-] [  ] kde-base/ksysguard-4.4.4:4.4
[IP-] [  ] net-analyzer/net-snmp-5.4.2.1-r4:0
[IP-] [  ] sys-power/cpufreqd-2.4.2:0

After rebuilding all packages we may go to lm_sensors configuration. First thing we need to provide is sensors module configuration. There is sensors-detect utility provided with lm_sensors unfortunately it wasn't able to probe sensors for my notebook. I did my configuration manually by editing /etc/conf.d/lm_sensors configuration file. You can see the file below.

View the full /etc/conf.d/lm_sensors configuration file
  1. # The format of this file is a shell script that simply defines variables:
  2. # HWMON_MODULES for hardware monitoring driver modules, and optionally
  3. # BUS_MODULES for any required bus driver module (for example for I2C or SPI).
  4.  
  5. # Load modules at startup
  6. LOADMODULES=yes
  7.  
  8. # Initialize sensors at startup
  9. INITSENSORS=yes
  10.  
  11. #HWMON_MODULES="adm1021"
  12.  
  13. # For compatibility reasons, modules are also listed individually as variables
  14. # MODULE_0, MODULE_1, MODULE_2, etc.
  15. # Please note that the numbers in MODULE_X must start at 0 and increase in
  16. # steps of 1. Any number that is missing will make the init script skip the
  17. # rest of the modules. Use MODULE_X_ARGS for arguments.
  18. #
  19. # You should use BUS_MODULES and HWMON_MODULES instead if possible.
  20. MODULE_0=i2c-i801
  21. MODULE_1=i2c-dev
  22. MODULE_2=eeprom
  23. MODULE_3=adm1021
  24. MODULE_3_ARGS=force_max1617a=0,0x4c

As you can see the most important things in this file are lines on the bottom part which are responsible for loading modules. You can see here the names of modules I mark in the kernel above. Highly important thing for ASUS M6N sensor configuration is passing additional arguments to main sensors adm1021 module. Without argument force_max1617a=0,0x4c the sensor chip for ASUS M6N will not be initialized.

Last thing we need to do is to provide our sensor configuration. The generic configuration for lm_sensors is kept in /etc/sensors3.conf file. I found out that kept there configuration are far from being perfect for my notebook. Thats why I created my own configuration. The important thing is to remember not to change default file, because you will loose your configuration with every lm_sensors update. You should create your personal configuration in /etc/sensors.d/ catalog. Below you can see file created for my notebook sensors.

View the full /etc/sensors.d/asus_notebook configuration file
  1. chip "max1617a-*"
  2.  
  3. label temp1 "Board Temp"
  4. label temp2 "CPU Temp"
  5. set temp1_max 66
  6. set temp1_min 40
  7. set temp2_max 90
  8. set temp2_min 50

As you can see the configuration file is vary basic. My chip has two sensors one for CPU and second one for Motherboard. In configuration file I'm providing sensor chip name, labels for my sensors and minimum and maximum possible temperatures.

Now I'm ready to use my sensors. I can start them by running following command in terminal:

/etc/init.d/lm_sensors start

To make my lm_sensors start as system service I have to run following command in terminal:

rc-update add lm_sensors default

To check my machine temperature state I have to run this simple command in terminal:

sensors
max1617a-i2c-0-4c
Adapter: SMBus I801 adapter at 0540
Board Temp:  +49.0°C  (low  = +40.0°C, high = +66.0°C)
CPU Temp:    +84.0°C  (low  = +75.0°C, high = +105.0°C)

Prove that it's working

Sources

titlepl: Notebook ASUS M6N
summarypl: Tutaj znajdziesz konfigurację sensorów systemowych dla mojego starego notebooka ASUS M6N. Ta konfiguracja obejmuje moduły kernela oraz zasadniczą konfigurację lm_sensors.
contentpl: 

Wstęp

Konfiguracja sensorów systemowych jest szczególnie istotna na komputerach mobilnych. Jedną z najczęściej spotykanych przyczyn awarii komputerów jest przegrzanie. Dzięki Linuxowym narzędziom lm_sensors możemy efektywnie monitorować stan naszego komputera, a jeśli to konieczne dzięki dodatkowym narzędziom takim jak cpufrequtils możemy zapobiegać przegrzaniu komputera poprzez obniżenie napięcia i poziomu wydajności procesora. W ten sposób możemy efektywnie używać nasz komputer nawet przez bardzo długi okres czasu.

Konfiguracja sensorów systemowych w Linuxie nie jest trudna, ale może się różnić w zależności od modelu sprzętu. Przekonałem się, że duża część konfiguracji zapewnianej przez pakiet lm_sensors wymaga dodatkowej optymalizacji, bez niej nie działała doskonale. Postaram się tutaj podzielić moją konfiguracją pochodząca z mojego notebooka ASUS M6N, który jest dość starym ale ciągle działającym komputerem. Opisana poniżej konfiguracja dotyczy Gentoo Linuxa, ale jej najważniejsza część czyli plik konfiguracyjny lm_sensors powinien działać w dowolnej dystrybucji. Rozpocznę swój opis od konfiguracji kernela.

Konfiguracja kernela

Mój ASUS M6N posiada czujnik adm1021. Musiałem zaznaczyć w kernelu więcej opcji niż tylko moduł dla czujnika jaki posiadam aby sprawić, że lm_sensors będą działać poprawnie. Aby skonfigurować kernel musiałem wejść do katalogu z jego źródłami i uruchomić menuconfig wykonując następujące komendy w terminalu:

cd /usr/src/linux
make menuconfig

Następnie musiałem zaznaczyć wszystkie moduły potrzebne aby moje sensory zadziałały. Wiele dystrybucji dostarcza wszystkie możliwe moduły czujników, ale w Gentoo tak nie postępujemy. Chcę tutaj pokazać dokładnie, które moduły są wymagane. Rzuć okiem na poniższa listę modułów.

Konfiguracja Kernela Linuxa: moduły Czujników Kernela
Device Drivers  --->
    [*] Misc devices  --->
        EEPROM support  --->
             <M> Old I2C EEPROM reader
    <M> I2C support  --->
        <M> I2C device interface
            I2C Hardware Bus support --->  
                <M> Intel 82801 (ICH/PCH)
    <M> Hardware Monitoring Support --->
        <M> Analog Devices ADM1021 and compatibles

Jak widzisz większa część obsługi sensorów będzie budowana jako moduły. To jest bardzo ważne, gdyż te moduły będą ładowane przez usługę systemową lm_sensors. Teraz możemy skompilować, zainstalować i wykorzystać nowy kernel. Zwykle dokonuję tego wykonując następujące komendy w terminalu:

cd /usr/src/linux
make && make modules_install install

Teraz należy zrestartować komputer z nowym kernelem i zainstalować lm_sensors.

Konfiguracja Lm Sensors

Ja używam lm_sensors 3.x i nie polecam używania starszych wersji. Aby zainstalować lm_sensors w systemie Gentoo należy wydać następującą komendę w terminalu::

emerge -av sys-apps/lm_sensors

Następną rzeczą jaką trzeba zrobić to upewnić się, że programy, które są w stanie wykorzystać czujniki systemowe będą skompilowane, ze wsparciem dla tej funkcji. Aby tego dokonać musimy dodać flagę use lm_sensors do naszego pliku /etc/make.conf. Po dopisaniu tej flagi, dobrze jest sprawdzić, które z zainstalowanych programów powinny zostać ponownie skompilowane. Można to sprawdzić wykorzystując narzędzie equery z pakietu gentoolkit w ten sposób:

equery hasuse lm_sensors
 * Searching for USE flag lm_sensors ... 
[IP-] [  ] kde-base/ksysguard-4.4.4:4.4
[IP-] [  ] net-analyzer/net-snmp-5.4.2.1-r4:0
[IP-] [  ] sys-power/cpufreqd-2.4.2:0

Po przebudowaniu wszystkich pakietów możemy przejśc do konfiguracji lm_sensors. Najpierw należy dokonać konfiguracji modułów lm_sensors. Wraz z pakietem lm_sensors jest dostarczany program sensors-detect, niestety nie mógł on odnaleźć czujników na moim notebooku. Dokonałem konfiguracji ręcznie edytując plik konfiguracyjny /etc/conf.d/lm_sensors. Możesz obejrzeć plik poniżej.

Wyświetl pełny plik konfiguracyjny /etc/conf.d/lm_sensors
  1. # The format of this file is a shell script that simply defines variables:
  2. # HWMON_MODULES for hardware monitoring driver modules, and optionally
  3. # BUS_MODULES for any required bus driver module (for example for I2C or SPI).
  4.  
  5. # Load modules at startup
  6. LOADMODULES=yes
  7.  
  8. # Initialize sensors at startup
  9. INITSENSORS=yes
  10.  
  11. #HWMON_MODULES="adm1021"
  12.  
  13. # For compatibility reasons, modules are also listed individually as variables
  14. # MODULE_0, MODULE_1, MODULE_2, etc.
  15. # Please note that the numbers in MODULE_X must start at 0 and increase in
  16. # steps of 1. Any number that is missing will make the init script skip the
  17. # rest of the modules. Use MODULE_X_ARGS for arguments.
  18. #
  19. # You should use BUS_MODULES and HWMON_MODULES instead if possible.
  20. MODULE_0=i2c-i801
  21. MODULE_1=i2c-dev
  22. MODULE_2=eeprom
  23. MODULE_3=adm1021
  24. MODULE_3_ARGS=force_max1617a=0,0x4c

Jak widzisz najważniejsze linie w tym pliku znajdują się na samym dole i są odpowiedzialne za ładowanie modułów. Możesz tu zobaczyć nazwy modułów, które zaznaczyłem powyżej w kernelu. Bardzo ważną rzeczą dla sensorów ASUS M6N jest przekazanie dodatkowego argumentu do głównego modułu czujników adm1021. Bez argumentu force_max1617a=0,0x4c układ czujnika dla ASUS M6N nie będzie zainicjalizowany.

Ostatnią rzeczą jaką musimy zrobić to skonfigurować czujniki. Domyślna konfiguracja dla lm_sensors jest trzymana w pliku /etc/sensors3.conf. Przekonałem się, że konfiguracje przechowywane tam dotyczące sensorów mojego notebooka są dalekie od doskonałości. Dlatego stworzyłem własną konfigurację. Ważną rzeczą jest aby pamiętać o nie dokonywaniu zmian w domyślnym pliku, ponieważ stracisz swoją konfigurację przy każdej aktualizacji lm_sensors. Powinno się stworzyć osobną konfigurację w katalogu /etc/sensors.d/. Poniżej możesz zobaczyć plik konfiguracyjny stworzony na potrzeby czujników mojego notebooka.

Wyświetl pełny plik konfiguracyjny /etc/sensors.d/asus_notebook
  1. chip "max1617a-*"
  2.  
  3. label temp1 "Board Temp"
  4. label temp2 "CPU Temp"
  5. set temp1_max 66
  6. set temp1_min 40
  7. set temp2_max 90
  8. set temp2_min 50

Jak widzisz konfiguracja jest stosunkowo nieskomplikowana. Mój układ posiada dwa czujniki jeden dla procesora drugi dla płyty głównej. W pliku konfiguracyjnym podaje nazwę układu czujnika, etykiety każdego z sensorów oraz wartość minimalnych i maksymalnych dopuszczalnych temperatur.

Teraz mogę wykorzystać moje sensory. Mogę je uruchomić wykonując następującą komendę w terminalu:

/etc/init.d/lm_sensors start

Aby sprawić żeby moje lm_sensors startowały jako usługa systemowa muszę wykonać następującą komendę w terminalu:

rc-update add lm_sensors default

Aby sprawdzić stan temperatury mojego komputera muszę wykonać następującą komendę w terminalu:

sensors
max1617a-i2c-0-4c
Adapter: SMBus I801 adapter at 0540
Board Temp:  +49.0°C  (low  = +40.0°C, high = +66.0°C)
CPU Temp:    +84.0°C  (low  = +75.0°C, high = +105.0°C)

Dowód, że to działa

Źródła