fan control again

Discussion in 'Linux' started by oti, May 30, 2009.

  1. oti

    oti

    Joined:
    Oct 13, 2008
    Messages:
    2
    Likes Received:
    0
    I´ve got: UNR 9.04, BIOS 0.3310 and I´m not able to run fan control .
    Firstly I performed these steps (from https://help.ubuntu.com/community/AspireOne):
    Code:
    (19/02/09) This is an update to the following fan control section below. The user space script "acerfand" originaly used to fix the noisy fan problem can cause race conditions and lockups as it accesses registers asynchronous to the kernel. A kernel module to do the fan control has recently been created and this avoids the race condition problem.
    
    You can install the kernel module in the following way. These instructions also work for 8.10.
    
    wget [url]http://piie.net/files/acerhdf_kmod-0.4.0.tar.gz[/url]
    tar zxvf acerhdf_kmod-0.4.0.tar.gz
    cd acerhdf_kmod
    make
    sudo make install
    
    Now load the kernel module using
    
    modprobe acerhdf
    And the segmentation error appears (this the console returns).
    When I perform well known acerfand trick, my AA1 crashed after couple of minutes (switched off by itself). Note: I changed the content of the file to fit my BIOS version as well.
    Any suggestion how to operate fan? THX
     
    oti, May 30, 2009
    #1
  2. oti

    oti

    Joined:
    Oct 13, 2008
    Messages:
    2
    Likes Received:
    0
    Thank you for your useful help ;) now I resolved it. Finally I used acerfand again with text:
    Code:
    LOGGER=$(which logger)
    if [ ! -x $LOGGER ] ; then
    	LOGGER="/usr/bin/logger"
    fi
    if [ ! -x $LOGGER ] ; then
    	echo "Warning, logger can't be found. Will log to stdout"
    	unset LOGGER
    fi
    
    LOGLEVEL="info"
    
    log() {
    	if [ ! -z "$LOGGER" ] ; then
    		$LOGGER -p daemon.$LOGLEVEL -t acerfand "$@"
    	else
    		echo "$@"
    	fi
    }
    
    info() {
    	LOGLEVEL="info"
    	log "$@"
    }
    
    notice() {
    	LOGLEVEL="notice"
    #	log "$@"
    }
    
    err() {
    	LOGLEVEL="err"
    	log "$@"
    }
    
    info "acerfand $ACERFAND_VERSION starting"
    
    if pgrep acerfand  | grep -v $$ > /dev/null; then
    	info "acerfand already running"
    	exit 0
    fi
    
    ME=$(readlink -f $0)
    
    BIOS_VERSION_3109="v0.3109"
    BIOS_VERSION_3114="v0.3114"
    BIOS_VERSION_3304="v0.3304"
    BIOS_VERSION_3305="v0.3305"
    BIOS_VERSION_3309="v0.3309"
    BIOS_VERSION_3310="v0.3310"
    
    
    BIOS_VERSION_DEFAULT=$BIOS_VERSION_3310
    
    getBiosVersion() {
    	DMIDECODE=$(which dmidecode)
    	if [ -z $DMIDECODE ] ; then
    		info "Can't find dmidecode. Assuming bios $BIOS_VERSION_DEFAULT"
    		BIOS_VERSION=$BIOS_VERSION_DEFAULT
    	else
    		BIOS_VERSION=$($DMIDECODE -s bios-version)
    		info "Detected bios version $BIOS_VERSION"
    	fi
    }
    
    ACEREC=$(which acer_ec.pl)
    if [ -z $ACEREC ] ; then
    	ACEREC=$(dirname $ME)/acer_ec.pl
    fi
    
    if [ ! -r $ACEREC ] ; then
    	err "acer_ec.pl can't be found"
    	exit 1
    fi
    
    INTERVAL=5
    FANOFF=60
    FANAUTO=70
    
    getBiosVersion
    
    if [ -r "/etc/acerfand.conf" ] ; then
    	source "/etc/acerfand.conf"
    fi
    
    case "$BIOS_VERSION" in
    
    	"${BIOS_VERSION_3310}")
    		#change: handle 3310 seperate 0xAF -> 0x21
          		R_FAN=55
          		R_TEMP=58
          		FAN_CMD_OFF=21
          		FAN_CMD_AUTO=00
          		RAW_FAN_STATE_OFF="0x21"	
    		;;
    	"${BIOS_VERSION_3309}")
    		#change: handle 3309 seperate 0xAF -> 0x20
    		R_FAN=55
    		R_TEMP=58
    		FAN_CMD_OFF=20
    		FAN_CMD_AUTO=00
    		RAW_FAN_STATE_OFF="0x20"
    		;;
    	"${BIOS_VERSION_3304}" | "${BIOS_VERSION_3305}" )
    		R_FAN=55
    		R_TEMP=58
    		FAN_CMD_OFF=af
    		FAN_CMD_AUTO=00
    		RAW_FAN_STATE_OFF="0xaf"
    		;;
    	"${BIOS_VERSION_3114}" | "${BIOS_VERSION_3109}")
    		R_FAN=55
    		R_TEMP=58
    		FAN_CMD_OFF=1f
    		FAN_CMD_AUTO=00
    		RAW_FAN_STATE_OFF="0x1f"
    		;;
    	*)
    		err "Unsupported bios version ${BIOS_VERSION} found. Aborting."
    		exit 1
    	;;
    esac
    
    FAN_STATE_UNRECOGNIZED=0
    FAN_STATE_AUTO=1
    FAN_STATE_OFF=2
    FAN_STATE_NAMES=("Unrecognized" "Auto" "Off")
    FAN_STATE_CMDS=("$FAN_CMD_OFF" "$FAN_CMD_AUTO" "$FAN_CMD_OFF")
    
    acer_ec() {
    	perl $ACEREC $@
    }
    
    getTemp() {
    	TEMP=$[$(acer_ec ?= $R_TEMP | cut -f 3 -d' ')]
    	notice "temp: $TEMP"
    }
    
    getRawFanState() {
    	RAW_FAN_STATE=$(acer_ec ?= $R_FAN | cut -f 3 -d' ')
    }
    
    getFanState() {
    	FAN_STATE=$FAN_STATE_UNRECOGNIZED
    	getRawFanState
    	if [ "$RAW_FAN_STATE" == "$RAW_FAN_STATE_OFF" ]; then
    		FAN_STATE=$FAN_STATE_OFF
    	else
    		let A="$RAW_FAN_STATE & 0x10" || true
    		if [ "$A == 0" ] ; then
    			# ASSUMPTION: All values with nybble 1==0 denote auto
    			FAN_STATE=$FAN_STATE_AUTO
    		fi
    	fi
    	notice "read fan state ${FAN_STATE_NAMES[$FAN_STATE]}"
    }
    
    setFan() {
    	info "Set fan ${FAN_STATE_NAMES[$1]}"
    	acer_ec := $R_FAN ${FAN_STATE_CMDS[$1]} > /dev/null
    }
    
    govern() {
    trap "info exiting;setFan $FAN_STATE_AUTO; exit" INT TERM EXIT
    info "Starting to govern acer fan speed. Interval: $INTERVAL, fan-off: $FANOFF, fan-auto: $FANAUTO"
    while true; do
    	getTemp
    	getFanState
    #	info "Raw fan state: $RAW_FAN_STATE ; fan state: $FAN_STATE ; auto: $FAN_STATE_AUTO ; off: $FAN_STATE_OFF ; temp: $TEMP ; autotemp: $FANAUTO"
    	case "$FAN_STATE" in
    		$FAN_STATE_AUTO)
    			if [ "$TEMP" -le "$FANOFF" ] ; then
    				setFan $FAN_STATE_OFF
    			fi
    			;;
    		$FAN_STATE_OFF)
    			if [ "$TEMP" -ge "$FANAUTO" ] ; then
    				setFan $FAN_STATE_AUTO
    			fi
    			;;
    		*)
    			# weird state. Let's turn it off,
    			# then decide next time around
    			info "Unexpected fan state $FAN_STATE"
    			setFan $FAN_STATE_OFF
    			;;
    	esac
    	sleep $INTERVAL
    done
    }
    
    set -e
    
    govern &
    
    There is a little change. But this way it seems to work well.

    AND now my AA1 works perfect.
     
    oti, Jun 2, 2009
    #2
  3. oti

    hasfrochbuster

    Joined:
    Aug 16, 2008
    Messages:
    30
    Likes Received:
    0
    I had the same problem.

    Now I'm trying your change, So far so good (5 minutes whitout shooting down)...

    Many thanks I'll let you know.

    Saludos from Mexico.
     
    hasfrochbuster, Aug 16, 2009
    #3
  4. oti

    hasfrochbuster

    Joined:
    Aug 16, 2008
    Messages:
    30
    Likes Received:
    0
    It has been working greate after apply your mods "oti" many thanks.

    Saludos and thanks again.
     
    hasfrochbuster, Aug 18, 2009
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.