Overclocking is also considered a reflection of the technical level of DIY players and a measure of the research and development capabilities of DIY manufacturers. So how should we overclock the Raspberry Pi? It depends on the specific device, the most popular models on the market currently are the Raspberry Pi 3 and Raspberry Pi 2. Since the Raspberry Pi 3 outperforms the Raspberry Pi 2 in various aspects, I will focus on the Raspberry Pi 3. However, since the basic technical characteristics of the two models are similar, the overclocking techniques for the Raspberry Pi 3 also apply to the Raspberry Pi 2, but the overclocking effect will be greatly diminished.
In short, overclocking is a method to enhance the hardware performance of the Raspberry Pi by adjusting multiple device parameters. To do this, additional hardware and special operational skills are required.
What can you do with a Raspberry Pi?
Just like any desktop or portable computer running a Linux system, you can do many things with the Raspberry Pi. Of course, there are a few differences. Ordinary computer motherboards rely on hard drives to store data, while the Raspberry Pi uses an SD card as its “hard drive”; you can also connect an external USB hard drive. With the Raspberry Pi, you can edit Office documents, browse the web, and play games—even those requiring powerful graphics acceleration, such as Quake.
What preparations are needed for overclocking?
First, good hardware, CPU, memory, and graphics card must be able to maintain reasonable temperature and power consumption even under 100% load.
Secondly, a powerful motherboard is needed, especially in terms of the motherboard’s power supply.
Finally, overclocking requires strong coolers and power supplies; coolers can keep the CPU and GPU operating at reasonable temperatures, enhancing overclocking potential and stability, while the power supply can provide sufficient energy to the hardware, easily handling increased power consumption.
Risks Related to Overclocking
Risk 1
Currently, there is no official support for overclocking the Raspberry Pi 3, so you may damage your device.
Risk 2
Overclocking may raise the hardware temperature close to 90°C, which can lead to program crashes, CPU damage, and memory chip damage. To prevent this, the chip must be well-cooled. It is highly recommended to use a fan to enhance cooling. So it’s important to say this three times: do not overclock without cooling.
Additional Hardware Required for Overclocking
If you want to overclock your Raspberry Pi, you need to configure three important hardware components:
1. Raspberry Pi, I used a Raspberry Pi 3 Model B V1.2 running Raspbian GNU / Linux 8 (Jessie).
2. Power supply, it is strongly recommended to use a reliable power supply; the overclocked Raspberry Pi 3 can work with 1.5A or even higher current. Therefore, a 2A power supply is used in this article.
3. Cooling equipment, to prevent the Raspberry Pi from overheating, I must find fans and heatsinks.
Before starting, you can use the following command to upgrade the installed packages to the latest version. After that, you need to check the system performance. You can easily do this with the “sysbench” tool, which can be installed using the command $ sudo apt-get install sysbench.
The following image shows all the overclocking equipment I need.
In detail, they are:
1. A Raspberry Pi 3;
2. A power supply with a voltage of 5 volts and a current of 2500 milliamps;
3. An internal fan;
4. Three heatsinks;
5. A base with memory cooling space and fan space.
The image below shows the schematic of the equipment after I assembled it:
Note that in this photo, the largest heatsink is under the fan, and the copper heatsink is at the bottom of this image.
Routine Check Before Overclocking
CPU Frequency Monitoring
To understand the current CPU operating frequency, I must read the proc files cpuinfo_min_freq, cpuinfo_max_freq, and cpuinfo_cur_freq from the directory /sys/devices/system/cpu/cpu0/cpufreq, where:
cpuinfo_min_freq indicates the minimum frequency in “idle” mode;
cpuinfo_max_freq indicates the maximum frequency;
cpuinfo_cur_freq indicates the current operating frequency of the Raspberry Pi;
CPU Temperature Monitoring
To know the current CPU temperature, I can run the command vcgencmd measure_temp. Additionally, to observe the temperature changes every second, I can run the following command.
$ while true ; do vcgencmd measure_temp ; sleep 1 ; done
After starting, if you want to terminate it, you need to use CTL + C to stop it.
Setting Default Speeds
The default CPU configuration of the Raspberry Pi board is in idle mode when there are no tasks, as follows:
· arm_freq = 600 mhz
· core_freq = 250 mhz
If a process is running, the frequency will rise to:
· arm_freq = 1200
· core_freq = 400 (this is the maximum default value for the Raspberry Pi 3).
To prevent idle mode from being disrupted, I must set the following lines in /boot/config.txt:
· force_turbo = 1, note! Changing this parameter will automatically void the warranty
· boot_delay = 1;
After that, restart the Raspberry Pi and check the current operating frequency again; it should now be set to 1200000KHz.
I recommend performing a performance test on the Raspberry Pi without overclocking first. During the first performance test, I ran the following command.
$ sysbench –test=memory –cpu-max-prime=2000 –num-threads=4 run
The output is as follows:
At this point, the testing of the Raspberry Pi 3 before overclocking has concluded.
Raspberry Pi 3 Overclocking Parameter Configuration
Overclocking configurations should be set in the /boot/config.txt file, and to overclock, I only need to set various system configuration parameters in this file. There are six methods to achieve overclocking:
1. Overclock the Raspberry Pi CPU, which means changing the “arm_freq” parameter: the frequency of ARM (in MHz);
2. Overclock the Raspberry Pi GPU, which means changing the “core_freq” parameter: the frequency of the GPU processor core (in MHz). Since it drives the L2 cache, it will affect the performance of ARM;
3. Overclock the Raspberry Pi memory, which means changing the “sdram_freq” parameter: the frequency of SDRAM, in MHz;
4. Additional extensions to the Raspberry Pi memory, which means using ZRAM to compress memory;
5. An additional overclocking parameter “Over_voltage”, which is the adjustment of ARM/GPU core voltage. It is only allowed to set values above 6 if the “force_turbo” or “current_limit_override” parameters are specified;
6. Setting an additional overclocking parameter “Force_turbo”, this parameter disables the dynamic cpufreq driver and requires the subsequent minimum settings, at which point the warranty is void.
Before changing any parameters, make sure to back up the /boot/config.txt file.
Since the performance of different models of the Raspberry Pi varies, the correct values can only be determined by trying various parameters. This means that the optimal values on each Raspberry Pi are different.
Problems Encountered During Overclocking and Prevention
Most overclocking problems will manifest immediately when they occur; once a problem arises, the device will immediately stop booting. If this happens, press the “shift” key during the next startup. This will temporarily disable all overclocking, allowing you to boot and then edit the respective settings.
By this method, you can learn how to adjust the values of CPU, GPU, and memory frequencies to achieve better performance, which also includes adjusting the “over_voltage” parameter to ensure stable operation of overclocked hardware. Another way is to overclock your Raspberry Pi 3 by adjusting the memory frequency. At this point, I will monitor it through ZRAM. So, I just need to execute the following:
1. The default values for the Raspberry Pi 3 are
arm_freq=1200
gpu_freq=400
core_freq=400
sdram_freq=450
over_voltage_sdram=0
2. Write the following configuration to the /boot/config.txt file, then restart the Raspberry Pi.
arm_freq=1300
gpu_freq=500
sdram_freq=500
over_voltage_sdram=0
3. If the Raspberry Pi starts and runs, further try the next configuration, which is to increase the value of arm_freq to 1500, save and restart.
4. If your Raspberry Pi fails to start or runs unstably, find the correct value for over_voltage_sdram until Pi runs normally.
5. If adjusting over_voltage_sdram does not help stabilize the operation of your Raspberry Pi or even prevent it from starting, you must reduce the arm_freq value until the Raspberry Pi runs again. Also, note that the system must be restarted after each change to the /boot/config.txt file.
How to Overclock with ZRAM
The ZRAM method is an additional option to enhance the performance of the Raspberry Pi device; this method requires you to expand the memory, and overclocking can be achieved by using ZRAM to compress internal storage.
ZRAM uses compression algorithms LZ4 and LZO, with LZO being the default; this algorithm creates a block device that can be used for swapping or as a general RAM disk.
How to load ZRAM? Since ZRAM is already integrated into the Linux kernel, I just need to use the command sudo modprobe zram to load the module. To check if the ZRAM module is running, execute the command sudo lsmod | grep zram.
If I want to optimize the settings for ZRAM on the Raspberry Pi, I can obtain the script zram.sh from GitHub. This script creates an additional compressed RAM swap disk for each CPU core, which can be activated without further configuration.
You can download the zram.sh script using the following command:
sudo wget –
O /usr/bin/zram.sh https://raw.githubusercontent.com/novaspirit/rpi_zram/master/zram.sh
The execution process is as follows.
Before activating ZRAM, you can check the memory information. The commands free -h and swap -s show that I have only activated 100MB of swap space on the Raspberry Pi.
Now I can run ZRAM with the command:
sudo zram.sh
This script will generate a swap space of about 232 MB for each CPU core; if I check again using the free -h command, the swap space will increase to 1GB.
By running swap -s again, I can see that four additional swap space partitions have been created and are running.
To set the Raspberry Pi to automatically run ZRAM on startup, I must edit the /etc/rc.local file and insert the line /usr/bin/zram.sh & before the exit. Then, you can check the end of the /etc/rc.local file.
After restarting the Raspberry Pi, the identification of the configured ZRAM memory will appear. However, you still want to use the free -h and swap -s commands to check again to ensure that ZRAM is started and running.
Performance Testing of Raspberry Pi 3 Under Overclocking
After completing the overclocking, I hope to test the performance of the Raspberry Pi again to see if the device is functioning properly. To do this, I will run the following command again.
$ sysbench –test=memory –cpu-max-prime=2000 –num-threads=4 run
The output is as follows:
All test values are better than those before overclocking; in the image above, the values marked in green are the running values before overclocking.