First, I’m not responsible for anything if you want to try what I did. Everything is at your own risk.
Clockworkpi is advertised as “Allwinner R16-J Quad-core Cortex-A7 CPU @1.2GHz” although if you check your cpufreq-info info with the kernel that came with OS v.0.5 you will see that the maximum frequency is, in fact, 1.008GHz witch is ~20% less. So I thought that maybe something was wrong with it and tried to look more information.
The Allwinner R16 datasheet/User manual doesn’t specify what is the maximum clock frequency of the SOC, but if we go to the sunxi-linux wiki we see that the R16 is actually a rebranded version of the A33, and if you go to:
You will end up in the A33 page. There you see that the maximum frequency is not even 1.2GHz, but 1.5GHz
So if the R16 is basically the A33 we are actually underclocking the R16 and we could obtain ~50% more horse power???
Well I tried to look a bit more on it, and compare our board to others with the same SOC. The very closest board is the Banana Pi M2M. It uses the same R16 SOC, same PMIC, same Wifi module… If we look to the board dts file for Banana Pi M2M:
We see that it is practically the same that we use for clockworkpi, almost a copy and paste:
As you can see both boards use as its bases the A33 code in the very begining:
/dts-v1/;
#include "sun8i-a33.dtsi"
The big difference between them, and actually where we are interested is the following code:
&cpu0 {
cpu-supply = <®_dcdc3>;
};
&cpu0_opp_table {
opp-1104000000 {
opp-hz = /bits/ 64 <1104000000>;
opp-microvolt = <1320000>;
clock-latency-ns = <244144>; /* 8 32k periods */
};
opp-1200000000 {
opp-hz = /bits/ 64 <1200000000>;
opp-microvolt = <1320000>;
clock-latency-ns = <244144>; /* 8 32k periods */
};
};
Here we can see that for Banana pi M2M the SOC can go to 1.1GHz, and 1.2GHz. The other information, opp-microvolt, tells the PMIC to change the voltage to that value when changing the clock.
So, from where cames the 1.008GHz that we have at maximum?
This information is written in the file:
There we have all “basic” supported clock speeds: 120MHz, 240MHz, …, 1.008GHz.
So if banana pi M2M can go to 1.2GHz, also without any heatsink, why clockworkpi can’t?
There is another difference on our board dts file. The voltages for the cpu in our regulator are fixed:
®_dcdc3 {
regulator-always-on;
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1200000>;
regulator-name = "vdd-cpu";
};
whereas for bananapi they can vary from 0.9V to 1.4V
®_dcdc3 {
regulator-always-on;
regulator-min-microvolt = <900000>;
regulator-max-microvolt = <1400000>;
regulator-name = "vdd-cpu";
};
Well, this means that even if you underclock cpi to 240MHz it would still apply 1.2V to the CPU. I think would be better to apply less voltage if we underclock, since it could save some battery, on the other hand, if we are locked to 1.2V we can’t go to higher frequencies. At least, if we plan to use the same code used in Bpi board. So I changed the voltages for dcdc3, d5ldo, and dcdc2, which are different from our board to the Bpi board. Now the kernel can change voltages when we want to change clock speed.
Is safe changing the voltage applied to the cpu to 1.4V? Well, if we look to the R16 datasheet (https://linux-sunxi.org/images/b/b3/R16_Datasheet_V1.4_(1).pdf), on page 25, you will see the recommended voltages. They recommend the CPU voltage to be from 0.9V to 1.4V. These numbers are coincident of what we have for Bpi. So if we are in this range we are actually using the Allwinner recommended values. If we see the “Absolute maximum ratings” you will see that an “overclocking” would be between 1.4V and 1.5V.
Another consideration that we have to take if we want to do this experiment is the thermals of the cpu. I saw some posts from some years that clockworkpi was overheating, and even some people asked to underclock the board.
So, what temperature is safe? Especially if we don’t want to use heatsink? To answer that we can go to the same table on the R16 datasheet. There you will see that the maximum “recommended” case (silicon die) temperature is 90 degrees Celsius. So everything bellows it is perfectly fine.
To monitor the temperature I compiled the kernel with the information provided by @r043v. I enabled the following flags:
CONFIG_CAN=y
CONFIG_CAN_SUN4I=y
CONFIG_MFD_SUN4I_GPADC=y
CONFIG_SUN4I_GPADC=y
and with this new kernel (I’m working on kernel 5.5, you can get a patch for 5.5 on my github https://github.com/wolfallein/clokworkpi-kernel, the patch doesn’t apply yet the thermals readings that I mentioned) I was able to see the cpu temperature with:
cpi@clockworkpi:~/src/kernel/linux$ cat /sys/class/thermal/thermal_zone0/temp
47304
So, I went a bit further because I wanted to see if we can get 1.5GHz, so I added a 1.3GHz (1.32V), 1.4Ghz, 1.45GHz, and 1.5GHz all last 3 with 1.4V (the maximum recommended voltage).
With 1.5GHz I got the system freezing sometimes, with 1.45GHz it worked well, but when I tried to compile some massive code it started to send corrupted kernel messages, so I tried 1.4GHz with 1.4V and it is working very well.
With 1.4GHz, and 1.4V I recompiled the kernel as an experiment. All 4 processors were at 100% for about half-hour, I didn’t use any fan, and I use the same “motherboard container” without any holes on it. Didn’t get any crash, everything was fine. The maximum temperature was 76 degrees Celsius. I also was looking to the clock frequency, and I saw that the CPU was being thermal throttling to lower clocks. Sometimes, when the temps were ~76, the CPU was clocked down to 1.3GHz and 1.2GHz not less. This is very good news. It means that the kernel is taking care of the thermals and decreasing the clock when it sees that the cpu is getting hot.
I did some performance tests, and the increase in clck speed really makes a big difference. I can try to compile some results in another post.
Another thing that is good to have in our kernel is the ondemand profile. It would decrease the clock if the CPU is not being used, and with voltage modifications to the dts file it could save battery.
Since the clock is increased the battery will also take a hit, so the already small battery would last for less time, but maybe with this tweaks we can play some more games that were just almost playable The Ondemand CPU profile wold increase the clock just when we need it. I noticed that some emulators doesn’t make use of all cores, instead only uses one, and a higher clock is very welcome.
Maybe the clockworkpi developers could tell us what is very safe to do, and explain why we don’t get 1.2GHz out of the box. So, 1.2GHz seems to be a very very safe clock, they even advertise it.