msm8916-openwrt/target/linux/kirkwood/base-files/sbin/fan_ctrl.sh
Zoltan HERPAI 0dfc0495fc kirkwood: add support for Netgear Stora (MS2000/2110) NAS
Dual-slot NAS based on Marvell Kirkwood.

Specifications:
 - Marvell 88F6281 @1GHz
 - 128Mb RAM
 - 256Mb NAND
 - 1x GbE LAN (Marvell 88E1116)
 - 1x USB 2.0
 - 2x SATA
 - PCF8563 RTC
 - LM75 sensor
 - TC654 PWM fan controller
 - Serial on J2 (115200,8n1)
 - Newer bootROM so kwboot-ing via serial is possible

Installation:

1. Serial console
 - Connect your levelshifter to the serial console
   on J2 (refer to the wiki page for pinout)
2. Update u-boot
 - Download the u-boot.kwb image for the device
 - Powercycle the NAS
 - Run "kwboot -b ./u-boot.kwb /dev/ttyUSB0 -p"
 - Connect to the serial console with minicom
 - tftp 0x0800000 netgear_stora-u-boot.kwb
 - nand erase 0x0 100000
 - nand write 0x0800000 0x0 0x100000
 - reset
3. Install OpenWrt
 - Boot up the initramfs image
 - tftpboot 0x800000 openwrt-kirkwood-netgear_stora-initramfs-uImage; bootm 0x800000
 - Download the sysupgrade image and perform sysupgrade

The fan is controlled in 3 stages by a script running every minute
from cron, measuring the CPU temperature.

Snippets taken from bodhi <mibodhi@gmail.com>

Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
2024-03-17 00:19:22 +01:00

24 lines
590 B
Bash
Executable File

#!/bin/sh
CPU_TEMP=$(cut -c1-2 /sys/devices/platform/ocp@f1000000/f1011000.i2c/i2c-0/0-0048/hwmon/hwmon?/temp1_input)
CPU_LOW=45
CPU_MID=50
CPU_HIGH=55
if [ ! -e /sys/devices/platform/ocp@f1000000/f1011000.i2c/i2c-0/0-001b/hwmon/hwmon?/pwm1 ]; then
exit 0
else
FAN_CTRL=$(ls /sys/devices/platform/ocp@f1000000/f1011000.i2c/i2c-0/0-001b/hwmon/hwmon?/pwm1)
fi
if [ "$CPU_TEMP" -ge "$CPU_HIGH" ]; then
echo "255" > $FAN_CTRL
elif [ "$CPU_TEMP" -ge "$CPU_MID" ]; then
echo "100" > $FAN_CTRL
elif [ "$CPU_TEMP" -ge "$CPU_LOW" ]; then
echo "50" > $FAN_CTRL
else
echo "0" > $FAN_CTRL
fi