Overclocking the Raspberry Pi 4

The latest firmware for the Raspberry Pi 4 Model B allows you to individually overclock it’s CPU, GPU, SDRAM etc. This posting shows you how to do that.

Before you rush to this, a word of warning: Overclocking can void your warranty and irreparably damage your RPi. To use sustainable overclocking, you must apply active cooling to your RPi - a heatsink alone is not good enough! DON’T FOLLOW THESE INSTRUCTIONS unless you understand and agree to apply them at your own risk!

Technically speaking, overclocking the RPi is simple: All you have to do is edit the file /boot/config.txt to set certain variables for frequencies and voltages in the [all] section and reboot the device. For the full list of variables, please check this reference page.

For example, to set the frequency of the ARM CPU, you can set the variable arm_freq, which defines the frequency in MHz. The default value for the RPi 4 is 1500:

[all]
arm_freq=1500

Setting a higher frequency for a component generally requires a higher voltage to drive the component. For example, to set the voltage for the ARM CPU, you can set the variable over_voltage, which defines the voltage in steps of 25mV. The default value for the RPi 4 is 0:

[all]
over_voltage=0

For me, I’ve applied the PoE HAT to the RPi 4s in my Kubernetes cluster:

The PoE HAT has a built-in fan which allows me to overclock the ARM CPU like this:

[all]
arm_freq=1750
over_voltage=2

Setting a higher frequency causes the firmware to frequently throttle the CPU clock in order to protect it from overheating - throttling starts at 80’C. Setting a lower voltage causes the CPU to crash because there is not enough power to drive it. Setting a higher voltage causes the CPU to become hotter and thus, getting throttled more often. Of course, your mileage may vary based on your cooling solution and ambient temperature (mine is A/C controlled at 23’C).

Don’t forget to reboot the device:

$ sudo reboot

You can check the results using the vcgencmd command. Here’s what it shows for me on one of the cluster nodes:

$ vcgencmd measure_temp; vcgencmd measure_clock arm; vcgencmd get_throttled
temp=78.0'C
frequency(48)=1750412160
throttled=0x20000

Everything below 80’C is OK. If it’s significantly lower while the device is running a CPU intensive workload for a while already, then it means that you can increase the frequency, which in turn may require you to set a higher voltage, too.

The throttled property indicates if the CPU is currently throttled or was throttled at some point in the past: If the least significant digit is not zero, then the CPU is currently throttled for some reason. If the most significant digit is not zero, then the CPU was throttled for some reason in the past. In this example, the value 0x20000 indicates that the CPU has been set to a lower frequency at some point in the past. Ideally, the value should be 0x0, of course.

Since I’m running a cluster, I’m using Ansible to get this information from all my nodes. Here’s a sample reading:

$ ansible all --module-name=shell --args='vcgencmd measure_temp; vcgencmd measure_clock arm; vcgencmd get_throttled' --one-line | sort
node-0 | CHANGED | rc=0 | (stdout) temp=79.0'C\nfrequency(48)=1750412160\nthrottled=0x20000
node-1 | CHANGED | rc=0 | (stdout) temp=50.0'C\nfrequency(48)=1750412160\nthrottled=0x0
node-2 | CHANGED | rc=0 | (stdout) temp=79.0'C\nfrequency(48)=1750412160\nthrottled=0x20000
node-3 | CHANGED | rc=0 | (stdout) temp=76.0'C\nfrequency(48)=1750412160\nthrottled=0x20000
node-4 | CHANGED | rc=0 | (stdout) temp=77.0'C\nfrequency(48)=1750464896\nthrottled=0x20000
node-5 | CHANGED | rc=0 | (stdout) temp=73.0'C\nfrequency(48)=1750412160\nthrottled=0x0
node-6 | CHANGED | rc=0 | (stdout) temp=74.0'C\nfrequency(48)=1750412160\nthrottled=0x0

In case you wonder why node-1 is relatively cool at 50’C while all the others are sweating close to 80’C: This is because node-1 is the single master node in my Kubernetes cluster. It doesn’t run a real workload like the other nodes do - more on that in a separate posting.

Enjoy!