How to overclock the Raspberry Pi device? Don’t matter if you are looking for the way to overclock the Raspberry Pi 3 or overclock the Raspberry Pi 2 – the algorithm stays the same. The only thing should be taken into consideration is that the Raspberry Pi 3 has significantly improved processor performance compared to previous models. Through various techniques such as overclocking and overvoltage, we can get even more power out of the Raspberry Pi 3. While Raspberry Pi 2 device will always be a little bit behind on performance due to basic technical peculiarities. |
Overclocking, basically, is the way to boost Raspberry Pi hardware performance by tuning up several device parameters. For that, additional hardware and special skills are required. Also, you’ll need to implement several tests to make sure of changes to take effect as well as keep your device from damage.
As you have already understood, the overclocking of your Raspberry Pi 3 exercises some risks. What are they and how to avoid them, read in this article below
Overclocking Risks and Warnings
WARNING 1
For now, there is no official support for overclocking the Raspberry Pi 3, so you could damage your Pi. We are not responsible for any damage you may do to your Pi. If you follow up any instruction in this document, you do it at your own risk!
WARNING 2
Overclocking may heat up the hardware up to nearly 90 °C. That in turn, can cause programs to crashes or, in the worst case, damage the CPU or memory chip. To prevent this, the most important chips have to be heatsinked. A fan increases the effectiveness of cooling and is therefore highly recommended.
Do not follow up any instruction in this article without cooling!
Additional Hardware for Overclocking
If you want to overclock your Raspberry Pi, you need to equip yourself with three essential hardware accessories:
- Raspberry Pi. In this documentation, we use a Raspberry Pi 3 Model B V1.2 with Raspbian GNU/Linux 8 (Jessie) running.
- Power Supply. A good reliable power supply is strongly recommended. An overclocked Pi 3 could draw 1.5A and more. So, a 2A supply should be the minimum.
- Cooling equipment. To prevent the Raspberry Pi device from overheating we have to provide the most important chips with a heatsink as well as with an additional fan.
Important: upgrade your installed packages to their latest versions with the command:
|
At the very beginning and at the very end of the process, you’ll need to check the system performance. You can easily do that with the “sysbench” tool that can be nstalled with a command:
$ sudo apt-get install sysbench |
Wel, the equipment we need for overclocking is represented in the picture below to illustrate the whole set.
In this picture you can see the following set:
- Raspberry Pi 3
- Power supply 5 Volt with 2500 mA
- A fan for build in the chassis
- Three heat sinks
- A chassis with gaps for memory heat skins and fan
And here is this set assembled and prepared for overclocking:
Note, that the large heatsink is under the fan, the copper heat sink is on the bottom in this set in this picture.
Checkup Before Overclocking
Before we start to overclock our Raspberry Pi, we have to prepare and check some conditions.
Monitor the CPU frequency
To learn the current frequency the CPU is setup and running, we have to read out the proc files cpuinfo_min_freq, cpuinfo_max_freq and cpuinfo_cur_freq from the /sys/devices/system/cpu/cpu0/cpufreq/ directory, where:
- cpuinfo_min_freq – is the minimum frequency for the “idle” mode
- cpuinfo_max_freq – is the maximum frequency
- cpuinfo_cur_freq – is the current running frequency of Raspberry Pi
Monitor the CPU temperature
To know the current CPU temperature, we can run the vcgencmd measure_temp command. To watch the temperature every second, we can run it in a “while” loop like this:
$ while true ; do vcgencmd measure_temp ; sleep 1 ; done |
This loop is running until we terminate it with CTL+C.
Setup the default speed
The default CPU configuration for the Raspberry Pi board, which goes in idle mode with no task is the following:
- arm_freq=600MHz
- core_freq=250MHz
If processes are running, the frequency goes up to:
- arm_freq=1200
- core_freq=400 (which is the maximum default values for the Raspberry PI 3).
To prevent the idle mode from damaging, we have to set these lines in your /boot/config.txt:
- force_turbo=1 (Beware! Changing this parameter auto-voids the warranty)
- boot_delay=1
After that, reboot your Raspberry Pi and check the current running frequency again. It should now be set to 1200000 KHz.
Performance test without overclocking
For the first performance test, we run the following command.
$ sysbench --test=memory --cpu-max-prime=2000 --num-threads=4 run |
This gives us the following results as an output:
Keep that in mind for the test at the end with the overclocked Raspberry Pi 3.
How to Overclock you Raspberry Pi 3
Raspberry Pi Overclocking Options
The configuration for the overclocking is set up in the /boot/config.txt file. And to do the overclocking, you simply need to set various system configuration parameters in this file. There are several ways you can do the overclocking.
- Overclocking the RPi CPU. It means changing the “arm_freq” parameter – Frequency of ARM, measured in MHz.
- Overclocking the RPi GPU. Changing the “core_freq” parameter – Frequency of GPU processor core, measured in MHz. It has an impact on ARM performance since it drives L2 cache
- Overclocking the RPi Memory. Changing the “sdram_freq” parameter – Frequency of SDRAM, measured in MHz.
- Additional extension for the RPi Memory. Using ZRAM by compressing the memory. (Additional way to p.3, see below).
- Additional overclocking parameter “Over_voltage”. It is ARM/GPU core voltage adjust. Values above 6 are only allowed when the “force_turbo” or “current_limit_override” parameters are specified (which is set in the warranty bit).
- An additional overclocking parameter “Force_turbo”. This parameter disables dynamic cpufreq driver and requires the minimum settings below. Voids Warranty!
Before you start to change any parameter, be sure you have made a backup of the /boot/config.txt file.
Different Raspberry Pi models have different manufacturing tolerances. So, the correct values can only be determined by trying out the widest variety of parameters. Optimal values can only be found by testing them on every Raspberry Pi board individually.
Overclocking problems
Most overclocking issues show up immediately with a failure to boot. If this occurs, hold down the “shift” key during the next boot. This will temporarily disable all overclocking, allowing you to boot and then edit your settings.
Overclocking Algorithm
This algorithm shows how to adjust the values of CPU, GPU and memory frequencies and thus achieve the better performance. This also comprehends adjusting the “over_voltage” parameter to let the overclocked hardware work stably. And as an additional way to overclock your Raspberry Pi 3 with memory frequency adjusting, we are going to look through the way with ZRAM. So, simply do the following:
1. These are the default values for the Raspberry Pi 3
arm_freq=1200 gpu_freq=400 core_freq=400 sdram_freq=450/pre> over_voltage_sdram=0 |
2. With that in mind, write to /boot/config.txt file the following configurations (then reboot the Pi):
arm_freq=1300 gpu_freq=500 sdram_freq=500/pre> over_voltage_sdram=0 |
3. If the Pi comes up and running we can go one step further and try out the next configuration: step up the arm_freqvalue until 1500. Save it and reboot again
4. If your Pi does not boot or running unstable, count up the values for the over_voltage_sdram until the Pi is running fine.
5. If adjusting the over_voltage_sdram doesn't help to stabilize the work of your Pi (or even boot), you have to reduce the arm_freq value down until the Pi is running again. Also, note that you have to reboot the system after each change of the /boot/config.txt file.
Overclocking with ZRAM
This is an additional option to increase the performance of your Raspberry Pi device. This way involves expansion the internal memory. It can be done by using ZRAM, which compresses the internal memory.
ZRAM uses the compression algorithms LZ4 and LZO, where LZO is the default one. It creates a block device which can be used for swap or as a general-purpose RAM disk.
How to load ZRAM? Because ZRAM is integrated into the Linux Kernel, we just have to load the module with the command sudo modprobe zram. To check if ZRAM module is running, fulfill the command sudo lsmod | grep zram as shown below.
If we want to setup ZRAM optimized for RPi, we can get the script zram.sh from GitHub - https://raw.githubusercontent.com/novaspirit/rpi_zram. This script creates an additional compressed RAM swap disk for each CPU core and activates it. No further configuration action is necessary.
You can download the script with this command:
sudo wget -O /usr/bin/zram.sh https://raw.githubusercontent.com/novaspirit/rpi_zram/master/\zram.sh |
Then, make it executable with as shown below.
Now, let’s see the memory information before we activate ZRAM. The free -h and swap -s commands show that we have just 100MB swap-space activated in our Raspberry Pi.
Now we can run ZRAM with the command:
sudo zram.sh |
This script will generate a swap space for each CPU core with a size of about 232 MB. Together we got an additional swap space from about 1 GB.
If we check again with the free -h command, it shows us that the swap space is increased to 1GB RAM.
By running swap -s again we can see that we have four additional swap space partitions created and running.
To setup the Raspberry Pi for automatic running ZRAM at boot time, we have to edit the /etc/rc.local file and insert the line /usr/bin/zram.sh & at the end but before the exit 0 line of the file.
Then, you can check the end of the /etc/rc.local file.
After rebooting the Raspberry Pi, it comes up with the configured ZRAM memory. Check it again with the free -h and swap -s commands to make sure that ZRAM is up and running.
Performance test with overclocking
Now, after we have finished the overclocking of our Raspberry Pi, we want to see the results of the performance test again. For that, we should run the following command again.
sysbench --test=memory --cpu-max-prime=2000 --num-threads=4 run |
The results are the following:
As we can see, all the values are better than before without overclocking. The green values are the ones from the first run.
How to Remove the overclocking
If you want to remove the overclocking from your Raspberry Pi, you just need to remove the changes from the /boot/config.txt file. If you have made a backup file, just copy it back to the /boot directory and overwrite the config.txt file.
Also, you must remove the line /usr/bin/zram.sh & from the /etc/rc.local file.
Reboot your Raspberry Pi after that and all overclocking configurations will be disabled.
Final notes
Well, now you have successfully overclocked your Raspberry Pi device and you are ready to start doing different projects on this marvelous and accelerated ARM device.
Also, a lot of people actually wonder how can they use their overclocked Raspberry Pi 3. If your Raspberry Pi is working stably after the overclocking, you will probably notice much better performance, speed and possibilities. For, instance, you can try to run x86 applications with higher technical requirements and expect better speed and quality of work. To run x86 apps on Raspberry Pi (and other ARM devices) you'll need additional software - Exagear Desktop in combination with Wine.
You can find a lot of example