Showing posts with label install. Show all posts
Showing posts with label install. Show all posts

12.6.10

VIA Epia Homeserver Project - On-board Sensor Readings

The scope of this post is to make use of the onboard voltage and temperature sensors that can be useful to avoid dangerous operating conditions such as overheating.
In order to make them work, compiling a recent kernel was necessary so I first obtained the latest version from kernel.org (2.6.34 as of today).
On EN12000EG, the following hardware supports built-in sensors:
  • Temperature sensor in VIA Eden CPU;
  • Winbond W83697 SuperIO chip featuring power supply voltage and temperature readings. Link to datasheet is here.
The following kernel options have to be set (followed by the actual name of the option in the .config file):
  • ISA support: CONFIG_ISA=y
  • hardware monitoring support: CONFIG_HWMON=y
  • VID support: CONFIG_HWMON_VID=y
  • VIA CPU temp sensor support: CONFIG_SENSORS_VIA_CPUTEMP=y
  • Winbond driver: CONFIG_SENSORS_W83627HF=y
  • the ACPI drivers: CONFIG_THERMAL=y and CONFIG_THERMAL_HWMON=y
Note: these can be compiled as modules as well, in which case OPTION=m will be in the at the corresponding line.
Next, obtain latest lm-sensors (as of today, it is 3.1.2). Manual for compiling and installing is together with the source, it worked without any problem. Then the sensors can be detected with the sensors-detect tool.
If the options above were compiled as modules, then the following two lines should be add to /etc/modules.conf:
w83627hf
via_cputemp
which will cause the kernel to load these modules on startup.
We are almost ready, however because of recent changes in the kernel architecture (specific version is 2.6.31), some sensors cannot be read because the ACPI code claims the corresponding resources. More information and discussion on the topic is here. The point is, that if we try to load the module for the Winbond chip:
# modprobe w83627hf
we get a "FATAL: [...] Device or resource busy" error message.
The solution is considered to be dangerous, however, I did not notice any problem (yet :)): The option "acpi_enforce_resources=lax" has to be add to the kernel command line upon boot. For grub, this means that the default item in /boot/grub/menu.lst will look something like:
title        Debian GNU/Linux, kernel 2.6.34 for VIA C7 and lm-sensors root        (hd0,0) kernel       /boot/vmlinuz-2.6.34 root=/dev/sdb1  ro acpi_enforce_resources=lax
Now the modules should be able to load, and raw sensor values should read using
$ sensors
Yet, the actual voltage readings need to be calculated using the scheme provided in /etc/sensors3.conf and running sensors -s (as root!) to get the proper readings afterwards.
It is interesting, that for older versions of lm-sensors, the Winbond chip was included in the config file, but it is removed from the latest one. No problem, one can just copy it back:

  • chip "w83697hf-*"

  • # no in1 on this chip.
  •     label in0 "VCore"    
  •     label in2 "+3.3V"
  •     label in3 "+5V"
  •     label in4 "+12V"
  •     label in5 "-12V"
  •     label in6 "-5V"
  •     label in7 "V5SB"
  •     label in8 "VBat"


  •     compute in3 ((6.8/10)+1)*@ ,  @/((6.8/10)+1)
  •     compute in4 ((28/10)+1)*@  ,  @/((28/10)+1)
  •     compute in5 (5.14 * @) - 14.91  ,  (@ + 14.91) / 5.14
  •     compute in6 (3.14 * @) -  7.71  ,  (@ +  7.71) / 3.14
  •     compute in7 ((6.8/10)+1)*@ ,  @/((6.8/10)+1) 


  • # 697HF does not have VID inputs so you MUST set your core
  • # voltage limits below. Currently set for 1.8V core.
  • #               vvv
  •    set in0_min 0.6
  •    set in0_max 1.2
  •    set in2_min 3.3 * 0.95
  •    set in2_max 3.3 * 1.05
  •    set in3_min 5.0 * 0.95
  •    set in3_max 5.0 * 1.05
  •    set in4_min 12 * 0.90
  •    set in4_max 12 * 1.10
  •    set in5_max -12 * 0.90
  •    set in5_min -12 * 1.10
  •    set in6_max -5 * 0.95
  •    set in6_min -5 * 1.05
  •    set in7_min 5 * 0.90
  •    set in7_max 5 * 1.10
  •    set in8_min 3.0 * 0.80
  •    set in8_max 3.0 * 1.20

  • #   ignore temp2


  • The rest of the sample config file can even be removed, it makes no use. I also modified the limits of the line in7 as the standby 5V (5VSB) reading is known to scatter more than the others, so +/- 10% is more appropriate.
    Note: I am aware that now the lm-sensor policy is that platform-specific configuration is supposed to be in /etc/sensors.d, yet I believe that this way is easier. Moreover, I am not aware of any database that could be used for this purpose, and I have no idea what triggered this change of functionality.
    Another issue is that I cannot set the limits nor the type of temperature sensors, so lines in the config file like:
    set temp1 1 
    set set temp1_over 80
    set temp1_hyst 75
    will result in something like:
    # sensors -s
    Error: File /etc/sensors3.conf, line 95: Unknown feature name w83697hf-isa-0290: No such subfeature known
    Not only the limits but the sensor type cannot be set as well, therefore the second temperature sensor (temp2) always reads false values below even room temperature. I am not aware of the resolution of this issue, but I will update the post as soon as I find the proper solution.
    Omitting the invalid lines, now we get the actual readings:
    # sensors -s
    $ sensors
    acpitz-virtual-0
    Adapter: Virtual device
    temp1:       +15.5°C  (crit = +120.0°C)                 
  • w83697hf-isa-0290
    Adapter: ISA adapter
    VCore:       +0.83 V  (min =  +0.59 V, max =  +1.20 V)  
    +3.3V:       +3.31 V  (min =  +3.14 V, max =  +3.47 V)  
    +5V:         +5.11 V  (min =  +4.76 V, max =  +5.24 V)  
    +12V:       +12.34 V  (min = +10.82 V, max = +13.19 V)  
    -12V:       -14.83 V  (min = -13.18 V, max = -10.80 V)   ALARM
    -5V:         -7.66 V  (min =  -5.25 V, max =  -4.75 V)   ALARM
    V5SB:        +5.46 V  (min =  +4.49 V, max =  +5.51 V)
    VBat:        +3.22 V  (min =  +2.40 V, max =  +3.60 V)  
    fan1:          0 RPM  (min =   -1 RPM, div = 4)  ALARM
    fan2:          0 RPM  (min = 2109 RPM, div = 4)  ALARM
    temp1:       +55.0°C  (high = +12.0°C, hyst =  +2.0°C)  ALARM  sensor = transistor
    temp2:       +15.5°C  (high = +120.0°C, hyst = +115.0°C)  sensor = diode
    beep_enable:enabled
    via_cputemp-isa-0000
    Adapter: ISA adapter
    Core 0:      +50.0°C                                   
  • Note that temp2 and the ACPI virtual device has the same reading, both wrong. For temp2 the quick and dirty solution is to simply ignore it by uncommenting the following line in sensors3.conf:
    ignore temp2
    The rest however works now, so the only thing to do is to make sure that sensors -s is run on every boot of the system. A simple shell script shall do the trick:
    #! /bin/sh
    SENSORS=/usr/local/bin/sensors #just initializing lm-sensors $SENSORS --version $SENSORS -s $SENSORS
    Save it as Sensors.sh in /etc/init.d then chmod it to be executable and link it /etc/rc2.d/S40sensors:
    # chmod a+x Sensors.sh
    # ln -s /etc/init.d/Sensors.sh /etc/rc2.d/S40sensors
    Still, there are remaining issues with the lm-sensors that need to be resolved. For instance, the temp2 and acpitz-virtual-0 readings are both wrong, and you cannot even get rid of the second one! At least there is not option to disable it through /etc/sensors3.conf most likely, the corresponding kernel module needs to be unloaded. Also, the spurious readings of the -12V, -5V lines might not be the real things as most likely they not even used by the motherboard. It also worth mentioning that the new kernel policy of claiming all ACPI related resources resulting in the device drivers not to work anymore might need to be reconsidered, as this is a definite loss of functionality as well, resulting in additional hacking being necessary.

    23.5.10

    VIA Epia Homeserver Project - Installing Linux

    Upgrading the BIOS 

    This is optional: I however believe that it is better be safe than sorry :) The latest BIOS for EN12000EG is V1.09 available for download in the Downloads tab. The bad news is that the BIOS flash tool demands DOS. Because of this, I briefly plugged a CD drive to the system and installed FreeDOS on the CF drive. I burned the flash tool and BIOS binary after this, and copied it to CF disk. Note that the latter is necessary as the flash tool does not run from read-only media such as a CD. It is also important to make sure that the motherboard would not be unplugged from the mains during the flashing process!

    Preparing the install

    If the BIOS update is not necessary, one can install the system without using a CD/DVD drive, only a usb stick is to be used.
    As we anyhow build a server, we shall use Debian :)
    There is a good howto on debian.org on installing from usb sticks. The main points are the following:
    • You need to download two disk images: One for making the usb stick bootable (using syslinux). This can be obtained here (only boot.img.gz is needed). The second one will be the actual installer, for which we use the netinst image meaning that most of the packages will be downloaded from the internet during install. Iso image is available here (choose i386). 
    •  The boot image needs to be extracted and written to the flash drive. The device needs to be at least 256MB in size. No matter if it is larger, because the resulting partition will be of this size. The operation can be done via dd, which is available for windows as well by simply issuing in the command line:
           dd if=boot.img of=flash_drive
      with flash_drive being /dev/sdX on linux and \\?\Device\HarddiskY\Partition0 on windows. Note that X=[a,b,c...] or Y=[1,2,3...] for the flash drive that needs to be written. It is important to double-check the actual path before destroying data on another device by mistake! For the windows version this can be done via dd --list which lists all available devices with description. If boot.img is in another directory, then its path needs to be changed as well.
    • Replug the flash drive and copy the netinst iso image to flash drive, preferably to the root directory. Note that the iso file should not be extracted, but simply copied, as the installer will mount the image itself.
    The bootable flash drive is now ready, the only thing to do is to make sure that a wired internet connection is available so additional packages can be downloaded during install. The preferred way is to use an empty LAN port on a router and to use DHCP.

    Booting from the flash drive

    In principle this should be simple, yet I found it quite hard to make the motherboard boot from USB flash drive even after reading some earlier manuals on the topic. For me, the following steps worked with V1.09 BIOS:
    • Set the first boot device to be USB-ZIP in BIOS. 
    • Switch off the computer and unplug its mains. 
    • Remove all IDE or SATA hard disks, and USB keyboard and mice so that only the USB stick remains.
    • Replug the computer and switch it on.
    • At this point it will boot from the flash drive (most likely), but obviously there is nothing to install to :)
    • Switch off the computer and replug everything that is necessary.
    • Start install :)
    So,  in a nutshell, it is necessary to have one power cycle with only the flash drive plugged in. The funny thing is that a mere reboot is not enough, one has to unplug and replug the power supply.

    And finally, install

    Mostly, one can go with the default options. As I used a 4GB CF card as /dev/hda, I formatted 3.75 GB to be the root filesystem (using ext3), and the rest to be swap. Note that it is indeed not recommended to use any flash drive for swapping, yet my experience is that for the intended kind of operation it is rather seldom used, but sometimes it can be useful. As CF contains internal wear leveling algorithm, mainline filesystems, such as ext3 can be used for the system. The only thing that has to be taken care of  is to switch off the atime attribute using noatime mount option (this can be done during partitioning). The default atime causes write to the hard drive for each read operation as it updates the last access time for the files. This is useful for certain applications such as backup and mailing tools, but causes a great deal of unnecessary writing operation.
    The rest goes quite straightforward, I chose to install only the option Standard System in order to customize packages later on.

    Good-to-have packages

    Apart from the default packages that come with the default install, the following ones might be useful as well:
    • bzip2, less, mc, ssh-server for convenient use :)
    •  make, gcc, libncurses5-dev,  automake, psmisc to make kernel compiling and installing source packages possible;
    • ddclient to make the box accessible via its domain name with a dyndns.com account;
    • iptables for firewalling and/or routing: this is installed by default, although I prefer to have the latest stable version from http://www.netfilter.org/
    • lm-sensors to read on-board temperature and voltage sensor outputs. It was not straightforward to make it work, so I will write about the details in a separate post.
    •  samba server from samba.org. Here again make sense to compile from source and setup separately as the version in the debian stable repository is quite old.
    • Enhanced ctorrent a nice command-line based torrent client, might be useful as well. Obtained from here. 
    Packages in the first three bulletpoints can simply be optained by apt-get install, the rest however are downloaded from other sources and might need some hacking to make them work.