packages: rewrite bpir3_mini-properties

fix #237
This commit is contained in:
hanwckf 2024-01-31 23:13:08 +08:00
parent 2f36f445bb
commit 5c535823ec
10 changed files with 77 additions and 68 deletions

View File

@ -14,10 +14,9 @@ PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
define Package/bpir3_mini-properties
SECTION:=BPI-R3-MINI Properties
CATEGORY:=BPI-R3-MINI Properties
SECTION:=firmware
CATEGORY:=Firmware
TITLE:=PHYs firmware & fan control for BPI-R3-MINI
MENU:=1
endef
define Package/bpir3_mini-properties/description
@ -31,16 +30,14 @@ define Build/Compile
endef
define Package/bpir3_mini-properties/install
$(INSTALL_DIR) $(1)/etc/
$(INSTALL_DIR) $(1)/sbin/
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_DIR) $(1)/etc/rc.d/
$(INSTALL_DIR) $(1)/lib/firmware/
$(INSTALL_BIN) ./files/etc/init.d/fanspeed $(1)/etc/init.d/
$(INSTALL_BIN) ./files/etc/rc.d/S99xfanspeed $(1)/etc/rc.d/
$(INSTALL_BIN) ./files/etc/init.d/ltecalling $(1)/etc/init.d/
$(INSTALL_BIN) ./files/etc/rc.d/S25xltecalling $(1)/etc/rc.d/
$(INSTALL_BIN) ./files/lib/firmware/EthMD32.dm.bin $(1)/lib/firmware/
$(INSTALL_BIN) ./files/lib/firmware/EthMD32.DSP.bin $(1)/lib/firmware/
$(INSTALL_BIN) ./files/bpir3_fanspeed $(1)/sbin/
$(INSTALL_BIN) ./files/fanspeed.init $(1)/etc/init.d/fanspeed
$(INSTALL_BIN) ./files/ltecalling.init $(1)/etc/init.d/ltecalling
$(INSTALL_DATA) ./files/EthMD32.dm.bin $(1)/lib/firmware/
$(INSTALL_DATA) ./files/EthMD32.DSP.bin $(1)/lib/firmware/
endef
$(eval $(call BuildPackage,bpir3_mini-properties))

View File

@ -0,0 +1,40 @@
#!/bin/sh
### enable fan ###
echo 0 > /sys/class/pwm/pwmchip0/export
echo 10000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 7000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo normal > /sys/class/pwm/pwmchip0/pwm0/polarity
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
while :
do
sleep 20
result=`cat /sys/class/thermal/thermal_zone0/temp`
temperature=$((result))
#echo $temperature
if [ ${temperature} -le 58000 ]; then
echo 5000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 58000 ]; then
echo 5000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 62000 ]; then
echo 4500 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 75000 ]; then
echo 3700 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 80000 ]; then
echo 2500 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 85000 ]; then
echo 1000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
done

View File

@ -1,45 +0,0 @@
#!/bin/sh /etc/rc.common
if [ ! -f /sys/class/pwm/pwmchip0/export ]; then
exit 0
fi
### enable fan ###
echo 0 > /sys/class/pwm/pwmchip0/export
echo 10000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 7000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo normal > /sys/class/pwm/pwmchip0/pwm0/polarity
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
while :
do
sleep 20
result=`cat /sys/class/thermal/thermal_zone0/temp`
temperature=$((result))
#echo $temperature
if [ ${temperature} -le 58000 ]; then
echo 5000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 58000 ]; then
echo 5000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 62000 ]; then
echo 4500 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 75000 ]; then
echo 3700 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 80000 ]; then
echo 2500 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
if [ ${temperature} -ge 85000 ]; then
echo 1000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
fi
done

View File

@ -1,10 +0,0 @@
#!/bin/sh /etc/rc.common
if [ ! -f /sys/class/gpio/export ]; then
exit 0
fi
### enable M.2 5G RM500U-CN Module Power ###
echo 431 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio431/direction
#echo 0 > /sys/class/gpio/gpio431/value

View File

@ -1 +0,0 @@
../init.d/ltecalling

View File

@ -1 +0,0 @@
../init.d/fanspeed

View File

@ -0,0 +1,16 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
start_service() {
if [ ! -f /sys/class/pwm/pwmchip0/export ]; then
return
fi
procd_open_instance
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param command "/sbin/bpir3_fanspeed"
procd_close_instance
}

View File

@ -0,0 +1,13 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
start_service() {
if [ -f /sys/class/gpio/export ]; then
### enable M.2 5G RM500U-CN Module Power ###
echo 431 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio431/direction
#echo 0 > /sys/class/gpio/gpio431/value
fi
}