Difference between revisions of "Overclocking"

From PINE64
Jump to navigation Jump to search
(42 intermediate revisions by 3 users not shown)
Line 3: Line 3:
{{hint|All information regarding clock speeds, voltages and more are stored in the DTB (Device Tree Blob). You can learn more about it [https://elinux.org/Device_Tree_Reference here].}}
{{hint|All information regarding clock speeds, voltages and more are stored in the DTB (Device Tree Blob). You can learn more about it [https://elinux.org/Device_Tree_Reference here].}}


Overclocking is a way to get more performance out of the system by running it at higher clock speeds than the factory default, usually while putting out more heat and using more power (You can also downclock to possibly reduce power consumption and thermals at the cost of performance). It is highly recommended that you avoid overvolting the device, as that has a high risk of damaging the hardware, hence the warning at the beginning of this page. However, just some slight overclocks without the added voltage can not only improve performance, but carry little risk to your device. It should be noted however that overclocking can cause instability, so you will need to test and see what values work best with your device (There is a silicon lottery for the Pinephone's hardware).
Overclocking is a way to get more performance out of the system by running it at higher clock speeds than the factory default, usually while putting out more heat and using more power (You can also downclock to possibly reduce power consumption and thermals at the cost of performance). It is highly recommended that you avoid overvolting the device, as that has a high risk of damaging the hardware, hence the warning at the beginning of this page. However, just some slight overclocks without the added voltage can not only improve performance, but not carry as much risk (Still: Do at your own risk!). It should be noted however that overclocking can cause instability, so you will need to test and see what values work best with your device (There is a silicon lottery for the Pinephone's hardware).


= Preparation =
= A64-based devices =
==TODO==


Kernel Compilation instructions
{{note|These instructions are targeting the Pinephone to simplify the explanation, however they can be used to also overclock other devices such as the Pinetab if you modify the proper DTB files.}}


Recompile just kernel DTB instructions
== Editing the Pinephone DTS ==


In the future there will likely be a driver to adjust clockspeeds from userspace without the need to recompile.
In order to overclock the Pinephone you will have to first convert the DTB file in <code>/boot/dtbs/allwinner/</code> to a DTS file. You will see <code>sun50i-a64-pinephone-1.2.dtb</code>, and also two other files with different pinephone mainboard revisions (1.1 and 1.0). You will want to select the correct file for your pinephone (Only choose 1.1 if you have a braveheart, As all other consumer pinephones use the 1.2 DTS).


= A64-based boards =
Once you've found the file, you can run the following command to convert the DTB to DTS:
== GPU ==
<code>dtc -I dtb -O dts /boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dtb -o /boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dts</code>
Open <code>arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi</code> (You will have to find the source of the kernel used by your distribution) in a text editor.
 
Finally, modify the newly converted .dts file and change the clockspeeds you wish to modify. You can simply use a text editor to do so.
 
To convert back to DTB:
<code>dtc -I dts -O dtb /boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dts -o /boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dtb</code>
 
Afterwards you can simply reboot and check with <code>sudo cat /sys/kernel/debug/clk/clk_summary</code> to see if the changes have correctly applied.


Look for
{{note|In the future it is possible that someone may make a driver to adjust clockspeeds of the A64 from userspace (using a config file) without the need to recompile. However, currently the only way to overclock is to either compile your own kernel, or modify just the DTB (instructions above).}}


<nowiki>
== GPU ==
mali: gpu@1c40000 {
compatible = "allwinner,sun50i-a64-mali", "arm,mali-400";
reg = <0x01c40000 0x10000>;
interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>,
    <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
    <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>,
    <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>,
    <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
    <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
    <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "gp",
  "gpmmu",
  "pp0",
  "ppmmu0",
  "pp1",
  "ppmmu1",
  "pmu";
clocks = <&ccu CLK_BUS_GPU>, <&ccu CLK_GPU>;
clock-names = "bus", "core";
resets = <&ccu RST_BUS_GPU>;


assigned-clocks = <&ccu CLK_GPU>;
Open <code>/boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dts</code> (You will have to find the source of the kernel used by your distribution. There is the Pine64 kernel, and Megi's) in a text editor following these instructions: https://wiki.pine64.org/wiki/Overclocking#Edit_Pinephone_DTS
assigned-clock-rates = <432000000>;
};
</nowiki>


The <code>assigned-clock-rates</code> line is set to <code>432000000</code>, this means that the GPU is clocked at 432MHz. So if you want 500MHz, set the value to <code>500000000</code>.
Look for <code>mali: gpu@1c4000 {</code> and within that block search for <code>assigned-clock-rates = <432000000>;</code>


Save the dtsi file, and recompile the DTB.
The <code>assigned-clock-rates</code> line should be set to <code>432000000</code>, this means that the GPU is clocked at 432MHz by default. So if you want 500MHz, set the value to <code>500000000</code>.


The GPU appears to run stable overclocked to 560 Mhz, however more testing with a wider group of devices is needed.
Save the dts file, and recompile the DTB. In order to check if the overclock was successfully applied you can run: <code>sudo cat /sys/kernel/debug/clk/clk_summary</code>.


{{note|Remember to run a benchmark tool (such as glmark2-es2) to help check stability.}}
{{note|The file may be slightly different and you may need to enter the values as hexidecimals}}
{{hint|The GPU appears to run stable overclocked to 560 Mhz, however more testing with a wider group of devices is needed.}}
{{hint|Remember to run a benchmark tool (such as glmark2-es2) to help check stability.}}


== CPU ==
== CPU ==


Stock speed: 1.152GHz CPU
The stock speed of the A64 is 1.152 GHz. It is not recommended to the overclock the CPU because doing so greatly increases power and thermals and will overheat the device for little to no gain.


== DRAM ==
== DRAM ==
Line 66: Line 50:
When overclocking the GPU, it is a good idea to also overclock the DRAM, as the main bottleneck of the A64 SOC is the memory. The A64's maximum ram clockspeed falls just short of 667MHz. This may be unstable on your device however.  
When overclocking the GPU, it is a good idea to also overclock the DRAM, as the main bottleneck of the A64 SOC is the memory. The A64's maximum ram clockspeed falls just short of 667MHz. This may be unstable on your device however.  


Around 600 MHz (PC-1200) should work fine, however some people have reported instability at lower clockspeeds. Arch Linux Arm uses a default clockspeed of 624MHz, with uboot builds available to easily switch out for a lower DRAM clockspeed.
Around 600 MHz (PC-1200) should work fine, however some people have reported instability at lower clockspeeds. Arch Linux Arm uses a default clockspeed of 552MHz, with uboot builds available to easily switch out for a higher (624) or lower (492) DRAM clockspeed.


It is possible that by reverse engineering the DRAM driver from allwinner that auto tuning can be accomplished to get the best performance.
It is possible that by reverse engineering the DRAM driver from allwinner that auto tuning can be accomplished to get the best performance.
Line 72: Line 56:
Setting the DRAM clock is accomplished by modifying pinephone_defconfig in uboot (https://gitlab.com/pine64-org/u-boot/-/blob/crust/configs/pinephone_defconfig)
Setting the DRAM clock is accomplished by modifying pinephone_defconfig in uboot (https://gitlab.com/pine64-org/u-boot/-/blob/crust/configs/pinephone_defconfig)


You can find simple instructions on doing so here: [https://wiki.pine64.org/index.php?title=Uboot Here]
You can find simple instructions on doing so here: [[Uboot]]
 
== VPU ==
 
In order to allocate more VRAM for the GPU you can add <code>cma=256</code> to your kernel (or use kconfig with CONFIG_CMA_SIZE_MBYTES=256) cmdline in boot.scr which you will have to compile using mkimage. By default the kernel allocates only 64MB, and the maximum value is 256MB.
 
In order to compile boot.scr you can run <code>mkimage -C none -A arm64 -T script -d boot.cmd boot.scr</code>
 
{{note|You may not have a boot.cmd file in your boot directory and instead you may instead have a boot.txt}}
 
== Cedrus ==
 
Overclocking cedrus is achieved by modifying the kernel source code: https://elixir.bootlin.com/linux/latest/source/drivers/staging/media/sunxi/cedrus/cedrus.c#L507
 
{{note|I'm (33yn2) not particularly sure if this makes any difference, or if it might infact have a negative impact. Probably not worth messing with.}}


= Rockchip RK3399 based boards =
= RK3399-based devices =
The RK3399 clocks are found in [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi]
The RK3399 clocks are found in [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi]


More optimised voltages and clocks can be found in [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi]
More optimised voltages and clocks can be found in [https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi]
These include a slight overclock and undervolt, they are intended for the OP1 CPU found in many chromebooks but have worked fine in all recorded cases on regular RK3399s in other devices.
These include a slight overclock and undervolt, they are intended for the OP1 CPU found in many chromebooks but have worked fine in all recorded cases on regular RK3399 SOCs in other devices.
 
Specific to the Pinebook Pro DTS in tsys' kernels is an extra clock speed entry for the big cores in <code>arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts</code><br>
It overrides the <code>opp08</code> entry for the big core cluster with one that runs 2GHz at 1.3V.<br>
It is up to you how to deal with this, either by just skipping opp08 in the main dtsi to keep using that entry or by removing that entry from the Pinebook Pro dts and adding your own to the regular dtsi.


==GPU==
==GPU==
Any clock speeds can be added for the GPU in <code>gpu_opp_table</code>
Any clock speeds can be added for the GPU in <code>gpu_opp_table</code>


The highest safe voltage for the GPU is 1.2V as specified in the RK3399 schematic from Rockchip.
The highest recommended voltage for the GPU is 1.2V as specified in the RK3399 schematic from Rockchip.
 
Segfault has found that the RK3399 in his Pinebook Pro can reach 950MHz on the GPU while being stable.


TuxThePenguin has found that the RK3399 in his Pinebook Pro can reach 950MHz on the GPU while being stable.
The stock speed for the GPU is 800Mhz.


The stock speed for the GPU is 800Mhz
Note that the GPU in the RK3399 is already bottlenecked by the memory bandwidth available to it, so overclocking generally yields no improvements.


==CPU==
==CPU==
Line 98: Line 94:
These clock speeds can be added to <code>cluster0_opp</code> for the small cores and <code>cluster1_opp</code> for the big cores respectively.
These clock speeds can be added to <code>cluster0_opp</code> for the small cores and <code>cluster1_opp</code> for the big cores respectively.


There is a hard limit of 1.8GHz on the little cores and 2.2GHz on the big cores.
The maximum limit is 1.8GHz on the little cores and 2.2GHz on the big cores.
 
The highest recommended voltage for the little cores is 1.2V and for the big cores is 1.25V.
 
Segfault has found that the RK3399 in his Pinebook Pro can reach 1.7GHz on the little cores and 2.08GHz on the big ones.


The highest safe voltage for the little cores is 1.2V and for the big cores is 1.25V.
The stock speed for the little cores is 1.4GHz and on the big cores it is 1.8GHz, the OP1 speeds default to 1.5GHz and 2.0GHz instead.


TuxThePenguin has found that the little cores on his RK3399 can run at 1.6GHz, and 2.08GHz on the big cores.
= ROCK64 =


==DRAM==
DTB is in <code>/boot/dtbs/rockchip/rk3328-rock64.dtb</code>. CPU clock rates are inside <code>opp_table0</code> as hexadecimal numbers in the <code>opp-hz</code> field.
TODO


Check the achieved clock speed with <code>sudo cat /sys/kernel/debug/clk/clk_summary | grep armclk</code>. Does not seem to overclock at stock voltages at all, defaults to 408 MHz if it fails to set a clock rate. Stock voltage is 1.30V, just shy of the 1.35V maximum outlined in [https://www.rockchip.fr/RK3328%20datasheet%20V1.1.pdf the datasheet]. Overvolting to 1.325V just left the device in an unbootable state for CounterPillow, would not recommend.


= Rockchip RK3328 based boards =
GPU needs investigating, but current mainline device tree does not try to clock up the GPU at all.
TODO


[[Category:SOPine]] [[Category:Pine A64]] [[Category:Pine H64]] [[Category:A64-LTS]] [[Category:PineBook]] [[Category:PinePhone]] [[Category:PineTab]] [[Category:Rock64]] [[Category:PineBook Pro]] [[Category:ROCKPro64]] [[Category:Allwinner A64]] [[Category:Allwinner H6]] [[Category:Rockchip RK3399]] [[Category:Rockchip RK3328]]
[[Category:SOPine]] [[Category:Pine A64]] [[Category:Pine H64]] [[Category:A64-LTS]] [[Category:PineBook]] [[Category:PinePhone]] [[Category:PineTab]] [[Category:Rock64]] [[Category:PineBook Pro]] [[Category:ROCKPro64]] [[Category:Allwinner A64]] [[Category:Allwinner H6]] [[Category:Rockchip RK3399]]

Revision as of 15:59, 28 November 2021

Warning: There is the possibility of damaging your equipment by overclocking. Do so at your own risk!
This page is incomplete, you're welcome to improve it.
All information regarding clock speeds, voltages and more are stored in the DTB (Device Tree Blob). You can learn more about it here.

Overclocking is a way to get more performance out of the system by running it at higher clock speeds than the factory default, usually while putting out more heat and using more power (You can also downclock to possibly reduce power consumption and thermals at the cost of performance). It is highly recommended that you avoid overvolting the device, as that has a high risk of damaging the hardware, hence the warning at the beginning of this page. However, just some slight overclocks without the added voltage can not only improve performance, but not carry as much risk (Still: Do at your own risk!). It should be noted however that overclocking can cause instability, so you will need to test and see what values work best with your device (There is a silicon lottery for the Pinephone's hardware).

A64-based devices

These instructions are targeting the Pinephone to simplify the explanation, however they can be used to also overclock other devices such as the Pinetab if you modify the proper DTB files.

Editing the Pinephone DTS

In order to overclock the Pinephone you will have to first convert the DTB file in /boot/dtbs/allwinner/ to a DTS file. You will see sun50i-a64-pinephone-1.2.dtb, and also two other files with different pinephone mainboard revisions (1.1 and 1.0). You will want to select the correct file for your pinephone (Only choose 1.1 if you have a braveheart, As all other consumer pinephones use the 1.2 DTS).

Once you've found the file, you can run the following command to convert the DTB to DTS: dtc -I dtb -O dts /boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dtb -o /boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dts

Finally, modify the newly converted .dts file and change the clockspeeds you wish to modify. You can simply use a text editor to do so.

To convert back to DTB: dtc -I dts -O dtb /boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dts -o /boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dtb

Afterwards you can simply reboot and check with sudo cat /sys/kernel/debug/clk/clk_summary to see if the changes have correctly applied.

In the future it is possible that someone may make a driver to adjust clockspeeds of the A64 from userspace (using a config file) without the need to recompile. However, currently the only way to overclock is to either compile your own kernel, or modify just the DTB (instructions above).

GPU

Open /boot/dtbs/allwinner/sun50i-a64-pinephone-1.2.dts (You will have to find the source of the kernel used by your distribution. There is the Pine64 kernel, and Megi's) in a text editor following these instructions: https://wiki.pine64.org/wiki/Overclocking#Edit_Pinephone_DTS

Look for mali: gpu@1c4000 { and within that block search for assigned-clock-rates = <432000000>;

The assigned-clock-rates line should be set to 432000000, this means that the GPU is clocked at 432MHz by default. So if you want 500MHz, set the value to 500000000.

Save the dts file, and recompile the DTB. In order to check if the overclock was successfully applied you can run: sudo cat /sys/kernel/debug/clk/clk_summary.

The file may be slightly different and you may need to enter the values as hexidecimals
The GPU appears to run stable overclocked to 560 Mhz, however more testing with a wider group of devices is needed.
Remember to run a benchmark tool (such as glmark2-es2) to help check stability.

CPU

The stock speed of the A64 is 1.152 GHz. It is not recommended to the overclock the CPU because doing so greatly increases power and thermals and will overheat the device for little to no gain.

DRAM

Warning: It is not recommended to exceed 667 MHz clockspeed on the DRAM. 624MHz is likely the upper limit.
Make sure to set your DRAM to a multiple of 24.

When overclocking the GPU, it is a good idea to also overclock the DRAM, as the main bottleneck of the A64 SOC is the memory. The A64's maximum ram clockspeed falls just short of 667MHz. This may be unstable on your device however.

Around 600 MHz (PC-1200) should work fine, however some people have reported instability at lower clockspeeds. Arch Linux Arm uses a default clockspeed of 552MHz, with uboot builds available to easily switch out for a higher (624) or lower (492) DRAM clockspeed.

It is possible that by reverse engineering the DRAM driver from allwinner that auto tuning can be accomplished to get the best performance.

Setting the DRAM clock is accomplished by modifying pinephone_defconfig in uboot (https://gitlab.com/pine64-org/u-boot/-/blob/crust/configs/pinephone_defconfig)

You can find simple instructions on doing so here: Uboot

VPU

In order to allocate more VRAM for the GPU you can add cma=256 to your kernel (or use kconfig with CONFIG_CMA_SIZE_MBYTES=256) cmdline in boot.scr which you will have to compile using mkimage. By default the kernel allocates only 64MB, and the maximum value is 256MB.

In order to compile boot.scr you can run mkimage -C none -A arm64 -T script -d boot.cmd boot.scr

You may not have a boot.cmd file in your boot directory and instead you may instead have a boot.txt

Cedrus

Overclocking cedrus is achieved by modifying the kernel source code: https://elixir.bootlin.com/linux/latest/source/drivers/staging/media/sunxi/cedrus/cedrus.c#L507

I'm (33yn2) not particularly sure if this makes any difference, or if it might infact have a negative impact. Probably not worth messing with.

RK3399-based devices

The RK3399 clocks are found in arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi

More optimised voltages and clocks can be found in arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi These include a slight overclock and undervolt, they are intended for the OP1 CPU found in many chromebooks but have worked fine in all recorded cases on regular RK3399 SOCs in other devices.

GPU

Any clock speeds can be added for the GPU in gpu_opp_table

The highest recommended voltage for the GPU is 1.2V as specified in the RK3399 schematic from Rockchip.

Segfault has found that the RK3399 in his Pinebook Pro can reach 950MHz on the GPU while being stable.

The stock speed for the GPU is 800Mhz.

Note that the GPU in the RK3399 is already bottlenecked by the memory bandwidth available to it, so overclocking generally yields no improvements.

CPU

A set of available clock speeds that can be added to the CPU clusters can be found in drivers/clk/rockchip/clk-rk3399.c under rk3399_cpuclkl_rates for the little cores and rk3399_cpuclkb_rates for the big cores.

These clock speeds can be added to cluster0_opp for the small cores and cluster1_opp for the big cores respectively.

The maximum limit is 1.8GHz on the little cores and 2.2GHz on the big cores.

The highest recommended voltage for the little cores is 1.2V and for the big cores is 1.25V.

Segfault has found that the RK3399 in his Pinebook Pro can reach 1.7GHz on the little cores and 2.08GHz on the big ones.

The stock speed for the little cores is 1.4GHz and on the big cores it is 1.8GHz, the OP1 speeds default to 1.5GHz and 2.0GHz instead.

ROCK64

DTB is in /boot/dtbs/rockchip/rk3328-rock64.dtb. CPU clock rates are inside opp_table0 as hexadecimal numbers in the opp-hz field.

Check the achieved clock speed with sudo cat /sys/kernel/debug/clk/clk_summary | grep armclk. Does not seem to overclock at stock voltages at all, defaults to 408 MHz if it fails to set a clock rate. Stock voltage is 1.30V, just shy of the 1.35V maximum outlined in the datasheet. Overvolting to 1.325V just left the device in an unbootable state for CounterPillow, would not recommend.

GPU needs investigating, but current mainline device tree does not try to clock up the GPU at all.