Skip to content

Instantly share code, notes, and snippets.

@jhit
Created November 10, 2023 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhit/31ac97c15952c9acaf30142766a7f5b2 to your computer and use it in GitHub Desktop.
Save jhit/31ac97c15952c9acaf30142766a7f5b2 to your computer and use it in GitHub Desktop.
Set minimum fan speed on Fujitsu/Kontron motherboards with Teutates BMC
#!/bin/bash
# Copyright (C) 2020 Kia
# Licensed under Zero Clause BSD License
# Copy of original Gist from https://gist.github.com/superbaud/651d898b3958be552e8d3c403c988fad
if [[ $# -ne 3 ]]; then
echo "usage: $0 (BMC I2C BUS NUMBER) (FAN PAGE) (DUTY CYCLE FLOOR)"
echo ""
echo "BMC I2C BUS NUMBER can be found as follows"
echo "$ ls /sys/bus/i2c/devices/*/hwmon/hwmon*/fan1_input"
echo ""
echo "if the output of that command is:"
echo "/sys/bus/i2c/devices/7-0073/hwmon/hwmon4/fan1_input"
echo "that means that the I2C bus number is 7"
echo "Check /sys/module/ftsteutates/drivers/i2c\:ftsteutates/ to be sure"
echo ""
echo "FAN PAGE = 0x48 + index of fan"
echo "On my system, FAN PAGE can be (0x48, 0x49, 0x4a, 0x4b)"
echo ""
echo "DUTY CYCLE FLOOR can be any number from 0 to 255, but please"
echo "don't set it lower than it already is."
echo ""
echo "This tool asks the Teutates BMC (in a way that does not survive"
echo "reboots/power-cycles/shutdowns) to keep the PWM waveform that is"
echo "fed to the fan corresponding to FAN PAGE to have a duty cycle that"
echo "is greater or equal to (DUTY CYCLE FLOOR) / 255"
echo ""
echo "A fan that runs at MAX_RPM without a PWM signal (or with a DC PWM"
echo "signal) will never run slower than MAX_RPM * (DUTY CYCLE FLOOR) / 255"
echo ""
echo "#########################################################################"
echo " ☢CAUTION!!☢"
echo "The supplied I2C bus number MUST correspond to the bus where the"
echo "Teutates BMC lives on."
echo ""
echo "The supplied fan page must be between 0x48-0x4f inclusive and"
echo "must correspond to a fan in your system connected to the Teutates BMC."
echo ""
echo "Incorrectly specifying the I2C bus number or fan page may BRICK"
echo "or IRREVERSIBLY DESTROY your system!"
echo " ☢CAUTION!!☢"
echo "#########################################################################"
echo ""
echo "It is likely that this tool will not produce expected results if"
echo "SilentFanConfig-Manager has been run -- which writes fan config stuff"
echo "into nonvolatile storage. The aforementioned fan config stuff might"
echo "set a different set of control modes, causing the write to 0x86 to"
echo "not have the desired effect. I don't have the full Teutates"
echo "documentation, so i do not know any of the control laws are."
echo ""
echo "However, if you have access to SilentFanConfig-Manager, why do you even"
echo "need this?"
echo ""
echo "This tool has only been tested on a single motherboard:"
echo "FUJITSU /D3641-S1, BIOS V5.0.0.13 R1.7.0 for D3641-S1x"
echo "with FTS Teutates chip revision: 3.11"
echo ""
echo "FOR USE ONLY ON FUJITSU/KONTRON MOTHERBOARDS WITH TEUTATES BMC"
echo ""
exit 1
fi
case $2 in
0x48|0x49|0x4a|0x4b|0x4c|0x4d|0x4e|0x4f)
echo "supplied fan page is "$2
;;
*)
echo "INVALID FAN PAGE!!"
exit 2
;;
esac
set -e
echo -n "Testing for Teutates BMC presence... "
# test that we have a teutates bmc, ideally this modprobe fails otherwise
sudo modprobe ftsteutates
# but we need it not be loaded, so we can have the i2c bus to ourselves
sudo rmmod ftsteutates
echo "present"
# this lets us do i2cset
sudo modprobe i2c-dev
# switch the page for the fan in question. the user is responsible
# for making sure this is between 0x48 and 0x4f
echo "writing to the i2c bus; hope you gave us the correct one!"
sudo i2cset -y $1 0x73 0x7f $2
# set PWM duty cycle
sudo i2cset -y $1 0x73 0x86 $3
# set the page back to 0x00 just to be kind to whoever (the kernel module) talks with the BMC after us
sudo i2cset -y $1 0x73 0x7f 0x00
echo "writes done"
# let us look at our handiwork via sensors(1).
# be patient, i think the BMC only updates RPM every second or so
sudo modprobe ftsteutates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment