Difference between revisions of "CPU"
Line 1: | Line 1: | ||
[[CPU/zh|查看中文]] | [[CPU/zh|查看中文]] | ||
+ | |||
+ | ==RK3399== | ||
+ | ===查看cpu0-3 支持的频率=== | ||
+ | <syntaxhighlight lang="text"> | ||
+ | cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies | ||
+ | </syntaxhighlight> | ||
+ | ===锁定cpu0-3 的最高频率为816 mhz=== | ||
+ | <syntaxhighlight lang="text"> | ||
+ | echo 816000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ===查看cpu4-5 支持的频率=== | ||
+ | <syntaxhighlight lang="text"> | ||
+ | cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_available_frequencies | ||
+ | </syntaxhighlight> | ||
+ | ===锁定cpu4-5 的最高频率为1008 mhz=== | ||
+ | <syntaxhighlight lang="text"> | ||
+ | echo 1008000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ===查看当前频率=== | ||
+ | <syntaxhighlight lang="text"> | ||
+ | cat /sys/devices/system/cpu/cpu[04]/cpufreq/cpuinfo_cur_freq | ||
+ | </syntaxhighlight> | ||
+ | |||
==S5P4418/S5P6818== | ==S5P4418/S5P6818== |
Revision as of 12:00, 20 August 2019
Contents
1 RK3399
1.1 查看cpu0-3 支持的频率
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
1.2 锁定cpu0-3 的最高频率为816 mhz
echo 816000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
1.3 查看cpu4-5 支持的频率
cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_available_frequencies
1.4 锁定cpu4-5 的最高频率为1008 mhz
echo 1008000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq
1.5 查看当前频率
cat /sys/devices/system/cpu/cpu[04]/cpufreq/cpuinfo_cur_freq
2 S5P4418/S5P6818
2.1 Setting CPU's Max Clock
2.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
2.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, }, };
2.2 CPU thermal
Get CPU's working temperature by reading the following files:
S5P4418/S5P6818:
/sys/class/hwmon/hwmon0/device/temp_label
Allwinner H3/H5/A64:
/sys/class/thermal/thermal_zone0/temp
RK3399, get CPU's working temperature and clock:
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
3 H3
3.1 CPU DVFS
3.1.1 Linux-4.14
All H3 based boards have the same DVFS setting and the setting is in the "arch/arm/boot/dts/sun8i-h3-nanopi.dtsi" file:
&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>; }; }; };
3.2 CPU ID
3.2.1 Linux-4.14
As for Allwinner H2+/H3/H5/ SoCs each of these CPUs has an internal 16-btye CHIP ID which can be read by running the following commands in the Linux-4.14 kernel:
$ 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" is the 16-byte CHIP ID.
3.3 CPU thermal
3.3.1 Linux-4.14
$ cat /sys/class/thermal/thermal_zone0/temp 30489
The reading means the working temperature is 30.489 degrees Celsius.
4 H5
4.1 CPU DVFS
4.1.1 Linux-4.14
For H5 based boards different boards have different DVFS settings. Let's take the NanoPi NEO2 as an example the setting is in the "arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts" file:
&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>; }; }; };
4.2 CPU ID
4.2.1 Linux-4.14
As for Allwinner H2+/H3/H5/ SoCs each of these CPUs has an internal 16-btye CHIP ID which can be read by running the following commands in the Linux-4.14 kernel:
$ 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" is the 16-byte CHIP ID.
4.3 CPU thermal
4.3.1 Linux-4.14
$ cat /sys/class/thermal/thermal_zone0/temp 30489
The reading means the working temperature is 30.489 degrees Celsius.