Skip to content

Commit

Permalink
Converted to markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
x1y committed Nov 5, 2024
1 parent 98c3ae2 commit 34e5e90
Show file tree
Hide file tree
Showing 3 changed files with 290 additions and 623 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,44 @@ menu:
{{< /admonition >}}

{{< admonition type="note" >}}
This page is incomplete, you're welcome to improve it.
This page is incomplete, youre welcome to improve it.
{{< /admonition >}}

{{< admonition type="note" >}}
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].
All information regarding clock speeds, voltages and more are stored in the DTB (Device Tree Blob). You can learn more about it [here](https://elinux.org/Device_Tree_Reference).
{{< /admonition >}}

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).
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 Pinephones hardware).

== A64-based devices
## A64-based devices

{{< admonition type="important" >}}
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.
{{< /admonition >}}

=== Editing the PinePhone DTS
### 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:
Once youve 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
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
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.

{{< admonition type="important" >}}
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).
{{< /admonition >}}

=== GPU
### 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 the PinePhone overclocking instructions.
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 Megis) in a text editor following the PinePhone overclocking instructions.

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

Expand All @@ -71,44 +71,29 @@ The GPU appears to run stable overclocked to 540 Mhz, however more testing with
Remember to run a benchmark tool (such as glmark2-es2) to help check stability.
{{< /admonition >}}

=== CPU
### CPU

The stock speed of the A64 is 1.152 GHz. The A64 can be overclocked significantly, it is highly advisable not to do this unless you can also drop the voltage at the same time.

If the CPU is undervolted and overclocked at the same time, it is possible to reach similar thermals and power consumption to the stock configuration but with better performance.

[cols="1,1,1,1,1"]
|===
|+ Power consumption at different voltages and frequencies
|Configuration
|Frequency
|Voltage
|Power (Screen 50%)
Power consumption at different voltages and frequencies:

|Stock
| 1.152GHz | 1.30v | ~4.35w
| Configuration | Frequency | Voltage | Power (Screen 50%) |
| --- | --- | --- | --- |
| Stock | 1.152GHz | 1.30v | ~4.35w |
| Stock + Undervolt | 1.152GHz | 1.18v | ~3.65w |
| Overclock + Undervolt | 1.344Ghz | 1.28v | ~4.60w |

|Stock + Undervolt
| 1.152GHz | 1.18v | ~3.65w

|Overclock + Undervolt
| 1.344Ghz | 1.28v | ~4.60w
|===
The table above contains measurements created in postmarketOS (SWMO/SXMO - postmarketOS 21.12 SP1) with the screen on (set to 50% brightness) under a threaded load.

[cols="1,1,1"]
|===
|+ AXP803 PMIC voltage steps on DCDC2.
|Voltage range
|Step size

|0.50V-1.20V
| 10mV
AXP803 PMIC voltage steps on DCDC2:

|1.22V-1.30V
| 20mV
| Voltage range | Step size |
| --- | --- |
| 0.50V-1.20V | 10mV |
| 1.22V-1.30V | 20mV |

|===
The table above shows the valid voltages provided by the AXP803 PMIC on DCDC2 (used to power the cores). For example, setting the voltage to 0.60V is valid, but setting it to 1.23V is not. When overclocking, ensure that you only use valid voltages at each operation point (otherwise it will simply be dropped and ignored). You can use (after installing) cpupower to display all valid frequencies after boot.

{{< admonition type="important" >}}
Expand All @@ -119,7 +104,7 @@ The table above shows the valid voltages provided by the AXP803 PMIC on DCDC2 (u
The exact voltages and frequencies that you can achieve will depend on your device. Make sure to run stress tests (such as _stress-ng_) to ensure stability.
{{< /admonition >}}

=== DRAM
### DRAM

{{< admonition type="warning" >}}
It is not recommended to exceed 667 MHz clockspeed on the DRAM. 648MHz is likely the upper limit.
Expand All @@ -133,17 +118,17 @@ Make sure to set your DRAM to a multiple of 24.
The current frequency your DRAM is running at can be found using this command: `cat /proc/device-tree/memory/ram_freq`
{{< /admonition >}}

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 A64s 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 U-Boot 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 U-Boot (https://gitlab.com/pine64-org/u-boot/-/blob/crust/configs/pinephone_defconfig)

You can find simple instructions on doing so here: link:/documentation/General/U-Boot[U-Boot]
You can find simple instructions on doing so here: [U-Boot](/documentation/General/U-Boot)

=== VPU
### 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.

Expand All @@ -153,22 +138,22 @@ In order to compile boot.scr you can run `mkimage -C none -A arm64 -T script -d
You may not have a boot.cmd file in your boot directory and instead you may instead have a boot.txt
{{< /admonition >}}

=== Cedrus
### 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

{{< admonition type="important" >}}
User _33yn2_ is not particularly sure if this makes any difference, or if it might in fact have a negative impact. Probably not worth messing with.
{{< /admonition >}}

== RK3399-based devices
## 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 [arch/arm64/boot/dts/rockchip/rk3399-opp.dtsi](https://github.com/torvalds/linux/blob/master/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 [arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi](https://github.com/torvalds/linux/blob/master/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
### GPU

Any clock speeds can be added for the GPU in `gpu_opp_table`

Expand All @@ -180,7 +165,7 @@ 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

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.

Expand All @@ -194,25 +179,24 @@ Segfault has found that the RK3399 in his Pinebook Pro can reach 1.7GHz on the l

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
## 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`.

Thanks to https://github.com/ayufan-rock64[Ayufan]'s work (with their https://github.com/ayufan-rock64/linux-build/blob/master/recipes/overclocking.md[overclocking recipe]), we know we can add a <strong>1.392GHz</strong> operating point, and a <strong>1.512GHz</strong> operating point (you should ensure you have a large heatsink for this last one). You can do so by adding the following in the `opp_table0` object, after the `opp-1296000000` operating point:
Thanks to [Ayufan](https://github.com/ayufan-rock64)'s work (with their [overclocking recipe](https://github.com/ayufan-rock64/linux-build/blob/master/recipes/overclocking.md)), we know we can add a <strong>1.392GHz</strong> operating point, and a <strong>1.512GHz</strong> operating point (you should ensure you have a large heatsink for this last one). You can do so by adding the following in the `opp_table0` object, after the `opp-1296000000` operating point:

opp-1392000000 {
opp-hz = <0x00 0x52f83c00>;
opp-microvolt = <0x149970>;
clock-latency-ns = <0x9c40>;
};
opp-1392000000 {
opp-hz = <0x00 0x52f83c00>;
opp-microvolt = <0x149970>;
clock-latency-ns = <0x9c40>;
};

opp-1512000000 {
opp-hz = <0x00 0x5a1f4a00>;
opp-microvolt = <0x162010>;
clock-latency-ns = <0x9c40>;
};
opp-1512000000 {
opp-hz = <0x00 0x5a1f4a00>;
opp-microvolt = <0x162010>;
clock-latency-ns = <0x9c40>;
};

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

Loading

0 comments on commit 34e5e90

Please sign in to comment.