Power & Source of Big Ideas

OpenWRT build - modules needed for cpu_freq

Moderators: chensy, FATechsupport

Hello,
We have needed to build our own OpenWRT firmware for the Neo2 (working well). We are not sure what module(s) we need loaded to have /usr/bin/cpu_freq functional. We notice that in the FriendlyARM compiled firmware that cpu_freq is functional and we need it to measure cpu temperature in our code. We do not have luci or collectd loaded in our build. We have tried simply copying the binary across from a Neo2 running the FriendlyARM build but no luck (the measurement process is missing):

Current frequency(KHz):
cat: can't open '/sys/class/thermal/thermal_zone0/temp': No such file or directory
cat: can't open '/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor': No such file or directory
cat: can't open '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq': No such file or directory
CPU0 online=1 temp=C governor= freq=sh: invalid number ''
0KHz

If anyone could help with this it would be very much appreciated.

Cheers
Rob
Actually if the FriendlyARM folks who built the OpenWRT image could post their make menuconfig xx.config file it would be very helpful ;)
http://wiki.friendlyarm.com/wiki/index.php/CPU
2.1 CPU DVFS
2.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>;
};
};
};
2.2 CPU ID
2.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.

2.3 CPU thermal
2.3.1 Linux-4.14
$ cat /sys/class/thermal/thermal_zone0/temp
30489
The reading means the working temperature is 30.489 degrees Celsius.



Linux 5.2
arch/arm/boot/dts/sun8i-h3-nanopi.dtsi

opp_table0 {
compatible = "operating-points-v2";
opp-shared;
phandle = <0x1f>;

opp@648000000 {
opp-hz = <0x0 0x269fb200>;
opp-microvolt = <0xfde80 0xfde80 0x13d620>;
clock-latency-ns = <0x3b9b0>;
};

opp@816000000 {
opp-hz = <0x0 0x30a32c00>;
opp-microvolt = <0x10c8e0 0x10c8e0 0x13d620>;
clock-latency-ns = <0x3b9b0>;
};

opp@1008000000 {
opp-hz = <0x0 0x3c14dc00>;
opp-microvolt = <0x124f80 0x124f80 0x13d620>;
clock-latency-ns = <0x3b9b0>;
};
};

cpus {
#address-cells = <0x1>;
#size-cells = <0x0>;

cpu@0 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0x0>;
clocks = <0x3 0xe>;
clock-names = "cpu";
operating-points-v2 = <0x1f>;
#cooling-cells = <0x2>;
};

cpu@1 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0x1>;
operating-points-v2 = <0x1f>;
};

cpu@2 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0x2>;
operating-points-v2 = <0x1f>;
};

cpu@3 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0x3>;
operating-points-v2 = <0x1f>;
};
};

new driver - operating-points-v2

https://www.kernel.org/doc/Documentatio ... m/cpus.txt
Alekss,
Thanks but the reason for my question is that those are not available under OpenWRT (they are under Armbian/Ubuntu). Using the FriendlyARM OpenWRT custom build for the Neo2, the cpu_freq works. I just need to know what kernel modules got included in their OpenWRT build so we can add them as well
Cheers
Rob

Who is online

In total there are 38 users online :: 0 registered, 0 hidden and 38 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 38 guests