dima I know this is a very old thread, but the squealing really drove me crazy, so hopefully someone googles their way here.
I found that the github script for fan control on the odroid xu4 was almost perfect for me. The fact that @nadenislamarre made the system run custom.sh at startup and shutdown was the way to incorporate it, so I just wrapped the github script with a very basic if statement to check to see if the start variable got passed and changed the lowest power level to be above my squealing threshold. The script can apply power anywhere between 0 and 255. My fan is pretty loud and squeals with any power level below about 80, so I edited the github script to make 80 as low as it goes. You can raise and lower that number to work best for your fan - just replace all the 80s with a different number in the following script and reboot. Here's how to set it up:
Create "/recalbox/share/system/custom.sh start" with the following contents:
#!/bin/bash
if test $1 = start
then
#set to false to suppress logs
DEBUG=false
if (( $EUID != 0 )); then
echo "This script muSt be run as root:" 1>&2
echo "sudo $0" 1>&2
exit 1
fi
TEMPERATURE_FILE="/sys/devices/10060000.tmu/temp"
FAN_MODE_FILE="/sys/devices/odroid_fan.14/fan_mode"
FAN_SPEED_FILE="/sys/devices/odroid_fan.14/pwm_duty"
TEST_EVERY=3 #seconds
new_fan_speed_default=80
LOGGER_NAME=odroid-xu4-fan-control
function cleanup {
${DEBUG} && logger -t $LOGGER_NAME "event: quit; temp: auto"
echo 1 > ${FAN_MODE_FILE}
}
trap cleanup EXIT
function exit_xu4_only_supported {
${DEBUG} && logger -t $LOGGER_NAME "event: non-xu4 $1"
exit 2
}
if [ ! -f $TEMPERATURE_FILE ]; then
exit_xu4_only_supported "a"
elif [ ! -f $FAN_MODE_FILE ]; then
exit_xu4_only_supported "b"
elif [ ! -f $FAN_SPEED_FILE ]; then
exit_xu4_only_supported "c"
fi
current_max_temp=cat ${TEMPERATURE_FILE} | cut -d: -f2 | sort -nr | head -1
echo "fan control started. Current max temp: ${current_max_temp}"
echo "For more logs see:"
echo "sudo tail -f /var/log/syslog"
while [ true ];
do
echo 0 > ${FAN_MODE_FILE}
current_max_temp=cat ${TEMPERATURE_FILE} | cut -d: -f2 | sort -nr | head -1
${DEBUG} && logger -t $LOGGER_NAME "event: read_max; temp: ${current_max_temp}"
new_fan_speed=80
if (( ${current_max_temp} >= 75000 )); then
new_fan_speed=255
elif (( ${current_max_temp} >= 70000 )); then
new_fan_speed=200
elif (( ${current_max_temp} >= 68000 )); then
new_fan_speed=130
elif (( ${current_max_temp} >= 66000 )); then
new_fan_speed=80
elif (( ${current_max_temp} >= 63000 )); then
new_fan_speed=80
elif (( ${current_max_temp} >= 60000 )); then
new_fan_speed=80
elif (( ${current_max_temp} >= 58000 )); then
new_fan_speed=80
elif (( ${current_max_temp} >= 55000 )); then
new_fan_speed=80
else
new_fan_speed=80
fi
${DEBUG} && logger -t $LOGGER_NAME "event: adjust; speed: ${new_fan_speed}"
echo ${new_fan_speed} > ${FAN_SPEED_FILE}
sleep ${TEST_EVERY}
done
fi