Difference between revisions of "CPU"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
Line 1: Line 1:
 
[[CPU/zh|查看中文]]
 
[[CPU/zh|查看中文]]
  
==S5P4418/S5P6818 锁定CPU的最高频率==
+
==S5P4418/S5P6818==
===Method 1===
+
===锁定CPU的最高频率===
 +
====Method 1====
 
The following command is used to temporarily limit the maximum CPU frequency to 1GHz:  
 
The following command is used to temporarily limit the maximum CPU frequency to 1GHz:  
 
echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
 
echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  
  
===Method 2===
+
====Method 2====
 
Modify the kernel source code:
 
Modify the kernel source code:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 27: Line 28:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==H3 DVFS==
+
===CPU thermal===
===Linux-4.14===
+
读取以下文件获得当前的CPU温度:<br />
 +
S5P4418/S5P6818:<br />
 +
/sys/class/hwmon/hwmon0/device/temp_label<br />
 +
Allwinner H3/H5/A64:<br />
 +
/sys/class/thermal/thermal_zone0/temp<br />
 +
RK3399,获取CPU温度和运行频率:<br />
 +
<syntaxhighlight lang="bash">
 +
while true; do
 +
t1=`cat /sys/class/thermal/thermal_zone0/temp`
 +
t2=`cat /sys/class/thermal/thermal_zone1/temp`
 +
f1=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq`
 +
f2=`cat /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_cur_freq`
 +
echo "$t1 $t2  $f1 $f2"
 +
sleep 1
 +
#cat /sys/class/thermal/thermal_zone[01]/temp
 +
#cat /sys/devices/system/cpu/cpu[04]/cpufreq/cpuinfo_cur_freq
 +
done
 +
</syntaxhighlight>
 +
 
 +
==H3==
 +
===CPU DVFS===
 +
====Linux-4.14====
 
对于H3系列的开发板,使用的都是同样的DVFS设置,相关代码位于arch/arm/boot/dts/sun8i-h3-nanopi.dtsi:
 
对于H3系列的开发板,使用的都是同样的DVFS设置,相关代码位于arch/arm/boot/dts/sun8i-h3-nanopi.dtsi:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 88: Line 110:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==H5 DVFS==
+
===CPU ID===
===Linux-4.14===
+
====Linux-4.14====
 +
{{FriendlyCoreAllwinner-CHIPID/zh}}
 +
 
 +
===CPU thermal===
 +
 
 +
==H5==
 +
===CPU DVFS===
 +
====Linux-4.14====
 
对于H5系列的开发板,不同型号的DVFS设置是不一样的。
 
对于H5系列的开发板,不同型号的DVFS设置是不一样的。
 
以NanoPi NEO2为例,相关代码位于arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts:
 
以NanoPi NEO2为例,相关代码位于arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts:
Line 148: Line 177:
 
};
 
};
 
};
 
};
</syntaxhighlight>
 
 
==获取CPU温度==
 
读取以下文件获得当前的CPU温度:<br />
 
S5P4418/S5P6818:<br />
 
/sys/class/hwmon/hwmon0/device/temp_label<br />
 
Allwinner H3/H5/A64:<br />
 
/sys/class/thermal/thermal_zone0/temp<br />
 
RK3399,获取CPU温度和运行频率:<br />
 
<syntaxhighlight lang="bash">
 
while true; do
 
t1=`cat /sys/class/thermal/thermal_zone0/temp`
 
t2=`cat /sys/class/thermal/thermal_zone1/temp`
 
f1=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq`
 
f2=`cat /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_cur_freq`
 
echo "$t1 $t2  $f1 $f2"
 
sleep 1
 
#cat /sys/class/thermal/thermal_zone[01]/temp
 
#cat /sys/devices/system/cpu/cpu[04]/cpufreq/cpuinfo_cur_freq
 
done
 
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 03:35, 14 January 2019

查看中文

1 S5P4418/S5P6818

1.1 锁定CPU的最高频率

1.1.1 Method 1

The following command is used to temporarily limit the maximum CPU frequency to 1GHz: echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq


1.1.2 Method 2

Modify the kernel source code:

arch/arm/plat-s5p4418/nanopi2/device.c

Delete the unwanted frequencies in the following array:

static unsigned long dfs_freq_table[][2] = {
    { 1400000, 1200000, },
    { 1200000, 1120000, },
    { 1000000, 1040000, },
    {  800000, 1000000, },
    {  700000,  940000, },
    {  600000,  940000, },
    {  500000,  940000, },
    {  400000,  940000, },
};

1.2 CPU thermal

读取以下文件获得当前的CPU温度:
S5P4418/S5P6818:
/sys/class/hwmon/hwmon0/device/temp_label
Allwinner H3/H5/A64:
/sys/class/thermal/thermal_zone0/temp
RK3399,获取CPU温度和运行频率:

while true; do
	t1=`cat /sys/class/thermal/thermal_zone0/temp`
	t2=`cat /sys/class/thermal/thermal_zone1/temp`
	f1=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq`
	f2=`cat /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_cur_freq`
	echo "$t1 $t2  $f1 $f2"
	sleep 1
	#cat /sys/class/thermal/thermal_zone[01]/temp
	#cat /sys/devices/system/cpu/cpu[04]/cpufreq/cpuinfo_cur_freq
done

2 H3

2.1 CPU DVFS

2.1.1 Linux-4.14

对于H3系列的开发板,使用的都是同样的DVFS设置,相关代码位于arch/arm/boot/dts/sun8i-h3-nanopi.dtsi:

&cpu0 {
	operating-points = <
		1008000	1300000
		816000	1100000
		624000	1100000
		480000	1100000
		312000	1100000
		240000	1100000
		120000	1100000
		>;
	#cooling-cells = <2>;
	cooling-min-level = <0>;
	cooling-max-level = <6>;
	cpu0-supply = <&vdd_cpux>;
};
 
&cpu_thermal {
	trips {
		cpu_warm: cpu_warm {
			temperature = <65000>;
			hysteresis = <2000>;
			type = "passive";
		};
		cpu_hot: cpu_hot {
			temperature = <75000>;
			hysteresis = <2000>;
			type = "passive";
		};
		cpu_very_hot: cpu_very_hot {
			temperature = <90000>;
			hysteresis = <2000>;
			type = "passive";
		};
		cpu_crit: cpu_crit {
			temperature = <105000>;
			hysteresis = <2000>;
			type = "critical";
		};
	};
 
	cooling-maps {
		cpu_warm_limit_cpu {
			trip = <&cpu_warm>;
			cooling-device = <&cpu0 THERMAL_NO_LIMIT 1>;
		};
		cpu_hot_limit_cpu {
			trip = <&cpu_hot>;
			cooling-device = <&cpu0 2 3>;
		};
		cpu_very_hot_limit_cpu {
			trip = <&cpu_very_hot>;
			cooling-device = <&cpu0 5 THERMAL_NO_LIMIT>;
		};
	};
};

2.2 CPU ID

2.2.1 Linux-4.14

对于全志H2+/H3/H5/芯片,CPU里内置了16 Byte的CHIP ID,在Linux-4.14下可以使用下列命令读取:

$ apt-get install bsdmainutils
$ hexdump /sys/bus/nvmem/devices/sunxi-sid0/nvmem 
0000000 8082 0447 0064 04c3 3650 ce0a 1e28 2202
0000010 0002 0000 0000 0000 0000 0000 0000 0000
0000020 0000 0000 0000 0000 0000 0000 0000 0000
0000030 0000 0008 0508 0000 0000 0000 0000 0000
0000040 0000 0000 0000 0000 0000 0000 0000 0000

"8082 0447 0064 04c3 3650 ce0a 1e28 2202"即为16 Byte的CHIP ID。

CHIP ID相关驱动代码位于: ./drivers/nvmem/sunxi_sid.c

2.3 CPU thermal

3 H5

3.1 CPU DVFS

3.1.1 Linux-4.14

对于H5系列的开发板,不同型号的DVFS设置是不一样的。 以NanoPi NEO2为例,相关代码位于arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts:

&cpu0 {
	operating-points = <
		1008000	1100000
		816000	1100000
		624000	1100000
		480000	1100000
		312000	1100000
		240000	1100000
		120000	1100000
		>;
	#cooling-cells = <2>;
	cooling-min-level = <0>;
	cooling-max-level = <6>;
	cpu0-supply = <&vdd_cpux>;
};
 
&cpu_thermal {
	trips {
		cpu_warm: cpu_warm {
			temperature = <65000>;
			hysteresis = <2000>;
			type = "passive";
		};
		cpu_hot: cpu_hot {
			temperature = <75000>;
			hysteresis = <2000>;
			type = "passive";
		};
		cpu_very_hot: cpu_very_hot {
			temperature = <90000>;
			hysteresis = <2000>;
			type = "passive";
		};
		cpu_crit: cpu_crit {
			temperature = <105000>;
			hysteresis = <2000>;
			type = "critical";
		};
	};
 
	cooling-maps {
		cpu_warm_limit_cpu {
			trip = <&cpu_warm>;
			cooling-device = <&cpu0 THERMAL_NO_LIMIT 1>;
		};
		cpu_hot_limit_cpu {
			trip = <&cpu_hot>;
			cooling-device = <&cpu0 2 3>;
		};
		cpu_very_hot_limit_cpu {
			trip = <&cpu_very_hot>;
			cooling-device = <&cpu0 5 THERMAL_NO_LIMIT>;
		};
	};
};