forum.gl-inet.cn

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
    查看: 637|回复: 0

    [经验分享] mt3000自编译固件风扇控制分享

    [复制链接]

    2

    主题

    3

    帖子

    44

    积分

    新手上路

    Rank: 1

    积分
    44
    发表于 2023-8-31 16:03:05 | 显示全部楼层 |阅读模式
    本帖最后由 yuyu01 于 2023-8-31 16:30 编辑

    入手了mt3000,到手直接刷了自己编译的固件(lede),之后发现风扇总是启动一会,停一会,温度总是停在60左右。推测风扇启动阈值是60度。

    折腾了一下,分享一下自己的方案。
    风扇控制相关的文件如下:
    1. root@OpenWrt:/sys/devices/virtual/thermal/thermal_zone0# ll
    2. drwxr-xr-x    4 root     root             0 Jan  1  1970 ./
    3. drwxr-xr-x    6 root     root             0 Jan  1  1970 ../
    4. -r--r--r--    1 root     root          4096 Aug 31 15:50 available_policies
    5. lrwxrwxrwx    1 root     root             0 Aug 31 06:01 cdev0 -> ../cooling_device0/
    6. -r--r--r--    1 root     root          4096 Aug 31 15:50 cdev0_trip_point
    7. -rw-r--r--    1 root     root          4096 Aug 31 15:50 cdev0_weight
    8. lrwxrwxrwx    1 root     root             0 Aug 31 15:50 cdev1 -> ../cooling_device0/
    9. -r--r--r--    1 root     root          4096 Aug 31 15:50 cdev1_trip_point
    10. -rw-r--r--    1 root     root          4096 Aug 31 15:50 cdev1_weight
    11. lrwxrwxrwx    1 root     root             0 Aug 31 15:50 cdev2 -> ../cooling_device0/
    12. -r--r--r--    1 root     root          4096 Aug 31 15:50 cdev2_trip_point
    13. -rw-r--r--    1 root     root          4096 Aug 31 15:50 cdev2_weight
    14. drwxr-xr-x    3 root     root             0 Jan  1  1970 hwmon0/
    15. -rw-r--r--    1 root     root          4096 Aug 31 15:50 integral_cutoff
    16. -rw-r--r--    1 root     root          4096 Aug 31 15:50 k_d
    17. -rw-r--r--    1 root     root          4096 Aug 31 15:50 k_i
    18. -rw-r--r--    1 root     root          4096 Aug 31 15:50 k_po
    19. -rw-r--r--    1 root     root          4096 Aug 31 15:50 k_pu
    20. -rw-r--r--    1 root     root          4096 Aug 31 15:50 mode
    21. -rw-r--r--    1 root     root          4096 Aug 31 15:50 offset
    22. -rw-r--r--    1 root     root          4096 Aug 31 15:50 policy
    23. drwxr-xr-x    2 root     root             0 Aug 31 15:50 power/
    24. -rw-r--r--    1 root     root          4096 Aug 31 15:50 slope
    25. lrwxrwxrwx    1 root     root             0 Aug 31 15:50 subsystem -> ../../../../class/thermal/
    26. -rw-r--r--    1 root     root          4096 Aug 31 15:50 sustainable_power
    27. -r--r--r--    1 root     root          4096 Aug 31 06:01 temp
    28. -rw-r--r--    1 root     root          4096 Aug 31 15:50 trip_point_0_hyst
    29. -rw-r--r--    1 root     root          4096 Aug 31 15:50 trip_point_0_temp
    30. -r--r--r--    1 root     root          4096 Aug 31 15:50 trip_point_0_type
    31. -rw-r--r--    1 root     root          4096 Aug 31 15:50 trip_point_1_hyst
    32. -rw-r--r--    1 root     root          4096 Aug 31 15:50 trip_point_1_temp
    33. -r--r--r--    1 root     root          4096 Aug 31 15:50 trip_point_1_type
    34. -rw-r--r--    1 root     root          4096 Aug 31 15:50 trip_point_2_hyst
    35. -rw-r--r--    1 root     root          4096 Aug 31 15:50 trip_point_2_temp
    36. -r--r--r--    1 root     root          4096 Aug 31 15:50 trip_point_2_type
    37. -rw-r--r--    1 root     root          4096 Aug 31 15:50 trip_point_3_hyst
    38. -rw-r--r--    1 root     root          4096 Aug 31 15:50 trip_point_3_temp
    39. -r--r--r--    1 root     root          4096 Aug 31 15:50 trip_point_3_type
    40. -rw-r--r--    1 root     root          4096 Aug 31 15:50 trip_point_4_hyst
    41. -rw-r--r--    1 root     root          4096 Aug 31 12:20 trip_point_4_temp
    42. -r--r--r--    1 root     root          4096 Aug 31 15:50 trip_point_4_type
    43. -r--r--r--    1 root     root          4096 Aug 31 15:50 type
    44. -rw-r--r--    1 root     root          4096 Aug 31 15:50 uevent
    复制代码
    trip_point_X_temp:这个是风扇启动几个档位的阈值,trip_point_4_temp是最低档,值为60,说明温度到了60度,触发第一档的风扇开关(后面几档基本用不到,不管)。

    所以写了个脚本:
    1. # 配置温度   
    2. temp_max=65000
    3. temp_min=55000

    4. # 当前风扇状态
    5. fan_cur_state=$(cat /sys/devices/virtual/thermal/thermal_zone0/cdev0/cur_state)
    6. # 温度阈值路径
    7. temp_point_4=/sys/devices/virtual/thermal/thermal_zone0/trip_point_4_temp
    8. # 温度阈值
    9. temp_point_4_before=$(cat $temp_point_4)
    10. # 当前温度
    11. curr_temp=$(cat /sys/devices/virtual/thermal/thermal_zone0/temp)
    12. # 当前时间
    13. current_time=$(date '+%Y-%m-%d %H:%M:%S')

    14. if [ "$curr_temp" -gt "$temp_max" ]; then

    15.     echo $temp_min > $temp_point_4

    16.     temp_point_4_after=$(cat $temp_point_4)

    17.     echo "current_time:$current_time  curr_temp:$curr_temp  temp_point_4:$temp_point_4_before -> $temp_point_4_after" >> /root/temp_control.log
    18. fi

    19. if [ "$curr_temp" -lt "$temp_min" ]; then

    20.     echo $temp_max > $temp_point_4

    21.     temp_point_4_after=$(cat $temp_point_4)

    22.     echo "current_time:$current_time  curr_temp:$curr_temp  temp_point_4:$temp_point_4_before -> $temp_point_4_after" >> /root/temp_control.log
    23. fi

    24. temp_point_4_after=$(cat $temp_point_4)
    25. echo "$current_time  cur_temp:$curr_temp  temp_point4:$temp_point_4_after  fan_cur_state:$fan_cur_state" >> /root/temp.log

    复制代码
    添加到计划任务,每分钟执行一次 * * * * * /bin/bash /root/temp_control.sh

    大致就是等温度到了65,将阈值设置为55度,风扇启动。温度降到55度之后,再将阈值调回65度,风扇关闭,如此往复。

    实测下来,一天之中风扇只会启动几次。
    注:本人固件是lede仓库编译的,openwrt应该也兼容,官方固件还没用过,不太清楚官方的风扇策略是怎样的。
    注:开机/重启的时候,要将trip_point_4_temp调为55或者65,不然还是会卡在60频繁开关风扇(可以在/etc/init.d/中写个简单服务)。






    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|gl-inet.cn ( 粤ICP备18130956号 )

    GMT+8, 2024-4-29 05:53 , Processed in 0.021060 second(s), 24 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表