autocore: improve support for the mediatek target (#6)

support read cpu clock speed and wifi temperature

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2022-11-25 00:47:33 +08:00 committed by GitHub
parent c1ff9bd6ac
commit db262a5db7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View File

@ -12,6 +12,7 @@ PKG_RELEASE:=$(COMMITCOUNT)
PKG_CONFIG_DEPENDS:= \
CONFIG_TARGET_bcm27xx \
CONFIG_TARGET_bcm53xx \
CONFIG_TARGET_mediatek \
CONFIG_TARGET_mvebu
include $(INCLUDE_DIR)/package.mk
@ -23,7 +24,7 @@ define Package/autocore-arm
DEPENDS:=@(arm||aarch64) \
+TARGET_bcm27xx:bcm27xx-userland \
+TARGET_bcm53xx:nvram \
+TARGET_mvebu:mhz
+(TARGET_mediatek||TARGET_mvebu):mhz
VARIANT:=arm
endef
@ -43,7 +44,9 @@ define Package/autocore/install/Default
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) ./files/generic/cpuinfo $(1)/sbin/
ifeq ($(filter mediatek%, $(TARGETID)),)
$(INSTALL_BIN) ./files/generic/ethinfo $(1)/sbin/
endif
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
$(CP) ./files/generic/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/
@ -55,7 +58,7 @@ endef
define Package/autocore-arm/install
$(call Package/autocore/install/Default,$(1))
ifneq ($(filter ipq% %mt7622, $(TARGETID)),)
ifneq ($(filter ipq% mediatek%, $(TARGETID)),)
$(INSTALL_BIN) ./files/arm/tempinfo $(1)/sbin/
endif
endef

View File

@ -5,6 +5,10 @@ THERMAL_PATH="/sys/class/thermal"
if grep -Eq "ipq40xx|ipq806x" "/etc/openwrt_release"; then
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input | awk '$1=$1')"
elif grep -Eq "mediatek" "/etc/openwrt_release"; then
wifi_temp1="$(iwpriv ra0 stat | awk '/CurrentTemperature/ {printf("%d°C", $3)}')"
wifi_temp2="$(iwpriv rax0 stat | awk '/CurrentTemperature/ {printf("%d°C", $3)}')"
wifi_temp="$(echo "$wifi_temp1 $wifi_temp2" | xargs)"
else
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/hwmon*/temp1_input | awk '$1=$1')"
fi

View File

@ -21,12 +21,12 @@ case "$DISTRIB_TARGET" in
cpu_freq="$(( $(vcgencmd measure_clock arm | awk -F '=' '{print $2}') / 1000000 ))Mhz" ;;
"bcm53xx"/*)
cpu_freq="$(nvram get clkfreq | awk -F ',' '{print $1}')MHz" ;;
"mediatek"/*|"mvebu"/*)
cpu_freq="$(mhz | awk -F 'cpu_MHz=' '{printf("%.fMHz",$2)}')" ;;
"mvebu/cortexa72")
cpu_freq="$(awk '{printf("%.fMHz", $0 / 1000)}' "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq")"
big_cpu_freq="$(awk '{printf("%.fMHz ", $0 / 1000)}' "$CPUFREQ_PATH/policy2/cpuinfo_cur_freq")"
;;
"mvebu"/*)
cpu_freq="$(mhz | awk -F 'cpu_MHz=' '{printf("%.fMHz",$2)}')" ;;
"rockchip"/*)
cpu_freq="$(awk '{printf("%.fMHz", $0 / 1000)}' "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq")"
[ ! -e "$CPUFREQ_PATH/policy4/cpuinfo_cur_freq" ] || \
@ -59,7 +59,7 @@ esac
if [ -z "$big_cpu_freq$cpu_freq" ] && [ -n "$cpu_temp" ]; then
echo -n "$cpu_arch x $cpu_cores ($cpu_temp)"
elif [ -z "$cpu_temp" ] && [ -n "$big_cpu_freq$cpu_freq" ] || \
grep -Eq "ipq|mt7622" "/etc/openwrt_release"; then
grep -Eq "ipq|mediatek" "/etc/openwrt_release"; then
echo -n "$cpu_arch x $cpu_cores ($big_cpu_freq$cpu_freq)"
elif [ -n "$cpu_temp" ] && [ -n "$big_cpu_freq$cpu_freq" ]; then
echo -n "$cpu_arch x $cpu_cores ($big_cpu_freq$cpu_freq, ${cpu_temp})"