Overclocking

Hardware Introduction

The Raspberry Pi's VideoCore IV System-on-Chip has several components, each of which can be run at different clock speeds. They are:

  • ARM - the main general-purpose CPU
  • SDRAM - the 1GB or 512MB or 256MB of main memory
  • Core - the GPU processor core (confusingly named)
  • GPU - a quick way to collectively refer to the following three parts:
    • H264 - the hardware x264 decoder used when watching movies and TV shows
    • ISP - the Image Sensor Pipeline, does things like color profile correction and image scaling
    • V3D - the 3D block, does the work described by OpenGL commands

All of these plus the voltages have an "idle" setting which they run at normally, only increasing to their individual maximums when they are used and placed under enough load. Changing this maximum is what Raspberry Pi overclocking does.

The H264, ISP, and V3D all share the same clock generator (a PLL) so all run at the same speed.

Both of these default behaviours can be changed if desired.

As a component is overclocked it may become unreliable. Unreliability is most often seen as program crashes, hardware lockups, and graphical glitches.

One way to increase that reliability is to increase the voltage to the component. This has the tradeoff that more heat is generated by the component. A component may be damaged if too much voltage is supplied.

A cooler component will usually perform more reliably than a hotter component.

Lifespan and Warranty

Whilst there are overclock settings which are considered "supported" by the Raspberry Pi Foundation, not every Pi will be able to reach all supplied overclock settings, and overclocking always runs the risk of shortening the lifespan of your Pi.

There are some settings which flip a hardware switch inside the Pi and void the warranty, these are:

  • over_voltage greater than 6
  • force_turbo=1
  • temp_limit greater than 85

Best Settings

There are no "best settings" for overclocking, each individual Raspberry Pi has a different maximum capability. Just because some guy on the internet says he can reach some huge speed and play every game smoothly does not mean your Pi will be able to do the same. Likewise perhaps yours will run even faster.

Why is this?

There is no way for a silicon chip manufacturer to make a processor which runs "at" a certain speed. There will always be some variance in the reliability of the components. Manufacturers make silicon chips so that the majority of a production run can achieve the chip's advertised speed, then they test all of the chips at that speed and throw out the small number of failures. This means there are always some chips which can do more than their advertised speed, though it's not known exactly how much more any given individual chip can do. It might be a significant percentage or it might be none.

This is seen all throughout processor history. Intel originally tried to make the first Pentium a 66MHz CPU but they couldn't get the production reliable enough, however, the chips which didn't run at 66MHz did run just fine at 60MHz so they printed "60MHz" on those chips and sold them at a slightly lower cost than ones with "66MHz" printed on them. The Raspberry Pi 1 (700MHz) and the Raspberry Pi Zero (1GHz) use the exact same System-on-Chip, the only difference being in the ~4 years between those models, Broadcom managed to make the production process better so they could make faster chips more reliably.

That said, there are some sensible starting points for Pi overclocking which are discussed below.

Power Supply

A good reliable power source and power cable are strongly recommended for overclocking.

An overclocked Pi 3 could draw over 1.5A of current, so a 2A supply should be the minimum considered. Many power supplies drop their voltage as current draw increases towards their maximum rating, so a 2.5A or higher power supply is a better choice than 2A. Some good suggestions are:

Users have reported success with:

  • Canakit 2.5A power supply, common on Amazon
  • Kootek 2.5A power supply
  • Genuine Apple 12W 2.4A iPad charger, available in stores
  • Pro-Elec 5.25V 2.4A power supply

The Pi runs off 5V but there's nothing wrong with a power supply providing 5.1V or 5.25V. There's usually about 0.25V drop over a typical USB power cable so the extra voltage helps compensate.

A good power cable is just as important as a good power supply. The wire in the cable should be 22AWG or thicker. Wire gauge goes down as it gets thicker, so 20AWG is thicker than 22AWG which is thicker than 25AWG. A longer cable drops much more voltage than a shorter cable, so use USB cables under 1M/3ft in length. A mobile phone or tablet "fast charge" cable should be sufficient.

Ensure you have a good solid connection at the MicroUSB connector, a loose or poorly-fitting connector can pass less current than a well-seated connector.

If you are powering many USB devices or power-hungry USB devices like rechargable game controllers off the Pi's USB ports, consider powering them off an externally-powered USB hub instead: http://elinux.org/RPi_Powered_USB_Hubs

There is a maximum current you can draw through the Pi board itself, dictated by the polyfuse next to the power connector:

  • Pi 1: 750mA
  • Pi 2: 2A
  • Pi 3: 2.5A

So there's no point getting a massively over-rated power supply like 10A and continuing to run many devices off the USB ports. There is also a smaller polyfuse on the USB ports which makes doing this even more unfeasible.

The exception to this is the Pi Zero, which has no current protection anywhere.

Rainbow Square or Lightning Bolt

If you see either a little rainbow square or a lightning bolt icon in the top right corner of the screen, those are the "under voltage" warnings, indicating your power supply is sending under 4.65V.

If this appears, shut down your Pi down properly and:

  • Pull out your power cable and plug it back in, at both ends if using a USB-A to MicroUSB cable, to ensure a good firm connection
  • Test without any powered USB devices
  • Try a different power cable
  • Try a different power supply

Temperature and Cooling

The Pi idles around 35C with usual operating temperatures as high as 75C depending on environment.

At 80C you'll start to see the red/orange/yellow square or thermometer icon in the top right corner of the screen, this is the temperature warning.

At 85C the Pi will throttle the CPU speed down to reduce temperature and performance will suffer greatly.

Cooling can be mainly broken up into two parts: heatsinks and fans.

Heatsinks

The small (14mm x 14mm x 4mm) heatsinks that come with most Pi kits are next to useless on their own without a fan, they'll only drop 5C at most.

Depending on the case used to house the Pi, a larger heatsink up to 25mm x 25mm x 15mm can usually be fit in. These will perform a bit better, dropping up to 20C without a fan.

Heatsink material - copper vs aluminium - is a never-ending debate within the overclocking community. For a relatively small Raspberry Pi heatsink, it's unlikely to make a huge difference.

There are three main areas available to cool on the Pi 2 and Pi 3 - the main SoC, the Ethernet controller, and the voltage regulator - however only the SoC in the middle of the board really benefits from any cooling. The Ethernet chip and the voltage regulator operate within specification without a heatsink. The RAM is underneath on the bottom on the board so is more difficult to cool.

When applying a heatsink, clean the surface of the SoC chip with isopropyl alcohol (aka rubbing alcohol) and a lint-free cloth to clean off any impurities or fingerprint oil and to ensure good contact with the thermal conductor to the heatsink.

The usual method to hold heatsinks on is thermal transfer tape. This is an extremely thin (less than 0.5mm) sticky layer and is designed specifically for thermal conductivity. 3M are a common brand to see. You can buy rolls or squares of it if you need to.

Cheap heatsink kits have been seen with double-sided tape to hold the heatsinks on. This material will act more as an insulator and probably raise temperatures! Double-sided tape is easily spotted as it's over 2mm thick and can be compressed then slowly springs back and retains its shape like a sponge. If you have this, remove it and get proper thermal transfer tape.

Another method to hold heatsinks on is a thermal glue/epoxy like Arctic Silver Thermal Adhesive however be aware this is a permanent solution. Trying to take off a heatsink fastened with thermal adhesive is more likely to remove the chip from the board and cause permanent damage.

Fans

A fan is needed to make the Raspberry Pi cool very well. With the right heatsink and fan combination, flat-out running temperatures as low as 55C are possible.

Fans can be powered externally, via the USB ports, or via the 5V GPIO pins. Do not power a fan off the 3.3V GPIO pin, it cannot supply enough current.

Fans are available from electronics suppliers, as well as the usual eBay and Amazon and Chinese gadget manufacturers. Specifically getting a quiet fan is a really good idea, some 5V fans sound like small jet engines!

It is sometimes possible to use a 12V fan like from a PC. Popular overclocker brands like Noctua make PC fans which are designed to run off a low voltage so these should work well. Cheap 12V computer fans often don't have enough power to start spinning with only 5V, though they may continue spinning with 5V once you start the blades turning with your finger.

Some Pi cases have a place specifically to mount a fan, sometimes you can cut a hole in a case, sometimes you have to get creative to mount your fan.

Overclocking Methods

There are two ways to overclock, either the Pi Foundation's raspi-config tool, or by manually editing /boot/config.txt.

After making any changes, reboot to apply the new settings.

Supported Overclocking

The Pi Foundation's supported overclocking tool provides some options for the Pi 1 and Pi 2. It does not provide any options for the Pi 3 or Pi Zero.

This tool can be accessed from the RetroPie menu in EmulationStation, or by typing sudo raspi-config in the terminal, and selecting the Overclock option:

overclock

You'll see this warning that overclocking may shorten the lifespan of your Pi:

warning

Then select your preferred overclock setting:

presets

This menu shows the options for Pi 1, the Pi 2 has only None and Turbo.

Manual Overclocking

All Raspberry Pi models can be manually overclocked by editing /boot/config.txt and rebooting. Read the SSH page if you are not familiar with editing text files in Linux.

Parameters are set like:

parameter=value

For example, to set the ARM to 1000MHz:

arm_freq=1000

Useful Parameters

The following speed parameters can be set:

  • arm_freq - speed of the ARM core
  • core_freq - speed of GPU processor core, keep it the same as gpu_freq
  • gpu_freq - speed of all GPU components, keep it the same as core_freq
  • sdram_freq - speed of SDRAM
  • sdram_schmoo - a set of SDRAM timings

The following voltage parameters can be set:

  • over_voltage - voltage of ARM and GPU
  • over_voltage_sdram - voltage of all SDRAM parts (c, i, and p)

The voltage starts at 1.2V and adjusts up or down in 0.025V steps. 0 is equal to 1.2V, the minimum -16 is 0.8V, and the maximum 8 is 1.4V. Voltage starts to help when running core/GPU/SDRAM at or over 500MHz.

To set voltage greater than 6 you must set force_turbo=1 which voids the warranty.

Other Parameters

There is a complex mathematical relationship between the clocks for the GPU core and the individual GPU components. Setting these without understanding their relationship may result in running a component faster or slower than intended.

You are better to just set core_freq and gpu_freq to the same thing and don't worry about it. The individual components only get faster when they are used anyway.

By setting avoid_pwm_pll=1 (which negatively affects 3.5mm audio quality) you can overclock the individual GPU components with the parameters:

  • v3d_freq - speed of OpenGL 3D graphics processor
  • isp_freq - speed of Image Sensor Pipeline
  • h264_freq - speed of x264 video decoder (not used by emulators, used by Kodi)

These more complex RAM voltages are set together by over_voltage_sdram and there is often not a need to set them individually:

  • over_voltage_sdram_c - voltage of SDRAM controller
  • over_voltage_sdram_i - voltage of SDRAM I/O
  • over_voltage_sdram_p - voltage of SDRAM PHY (physical RAM chip)

There is also:

  • temp_limit - CPU throttling temperature in Celsius

You can set temp_limit lower than the default 85 if you'd like your Pi to slow down sooner than normal. You can also set it higher if you like, which voids the warranty and heavily risks killing your Pi due to over-temperature.

  • force_turbo - disable dynamic clocking

Setting force_turbo=1 results in all components running at their maximum speed at all times. This will void the warranty and make your Pi run quite hot, though it may also perform faster.

Default Settings

The default settings for each model Pi are:

        ARM   Core    GPU   RAM
Pi 1    700    250    250   400
Pi 2    900    250    250   400
Pi 3   1200    400    300   450
Zero   1000    400    300   450

Where Do I Start?

Where emulation benefits from overclocks, there are two types:

  • Emulation restricted by the CPU
    such as MAME which has no 3D acceleration at all (neither on the Pi or on any other computer)

  • Emulation restricted by the GPU
    such as N64 which is based around graphics plugins and is relying mostly on the OpenGL V3D core to do work for it

You can measure CPU usage with top or htop. If emulation runs poorly and CPU usage is at maximum, emulation is probably limited by the CPU. If emulation runs poorly and CPU usage is not at 100%, emulation is probably limited by the GPU.

CPU-restricted emulation will not benefit from GPU speed increases, though GPU-restricted emulation may benefit slightly from CPU speed increases.

All types of emulation will benefit from increased RAM speed.

Some rules of thumb to start Raspberry Pi overclocking:

If overclocking the CPU (arm_freq), start at the original speed and take it up in steps of 50MHz.

If overclocking the GPU (core_freq and gpu_freq), start at 500 (or 400 for Pi 1) and take both up in steps of 20MHz or 25MHz. Always set the two GPU frequencies to the same thing.

For voltage, you are probably best to start with over_voltage=2 then increase by 1 if the system becomes unstable.

For RAM, start with the original speed and again go up in small steps of 20MHz or 25MHz, increasing voltage in steps of 1 if things become unstable. The schmoo setting is some timings known to help increase stability of overclocked RAM:

sdram_schmoo=0x02000020
sdram_over_voltage=2

After many config file edits and reboots it's difficult to remember exactly which settings were best and which didn't have any effect and which broke things. It's best to:

  • change only one setting at a time
  • write down exactly what you changed
  • write down the results of that change

Test your overclock thoroughly before going up to the next speed. Some people like to leave automated tests running overnight, some people only test for 15 minutes or so. Besides automated tests, test the things you actually care about and are trying to improve. There's no use making a commandline benchmark faster if your games don't run any better.

If emulators start crashing (check logs for segmentation fault or general protection fault or similar) or the kernel panics or the system freezes or any other such unexpected result, you're probably past the limit of what your individual Pi can do. Back off the overclock to the previous stable setting. That's probably as good as it gets.

How Do I Test?

This is a difficult question to answer for RetroPie, as there are not many easy automated ways to fully exercise the GPU and 3D components.

If you wish to install Quake 3 and have a keyboard, running the ioQuake3 console commands \timedemo 1 and \demo four provide a good exercise of the GPU.

Playing an N64 game is also a good way to use the GPU. A game which runs poorly and totally maxes out the system, like Conker's Bad Fur Day, might be a better choice than a game which runs well.

Some cryptographical functions to exercise the CPU can be benchmarked by running: openssl speed

The LINPACK benchmark runs a multi-computer CPU-based workload on one computer: https://www.howtoforge.com/tutorial/hpl-high-performance-linpack-benchmark-raspberry-pi/

A test script which runs simple processes in the background then does sdcard I/O is available at: http://elinux.org/RPiconfig#Overclock_stability_test

A very thorough set of tests which exercise many components of the Pi is documented at: https://www.raspberrypi.org/forums/viewtopic.php?p=952371

Help! I Overclocked Too Far and Cannot Boot

Place the sdcard in your computer, both Windows and Mac will see the small FAT32 partition which contains config.txt which you can edit and change the bad overclock settings.

If you have a USB keyboard attached to your Pi, holding the Shift key while powering on tells the GPU core to avoid applying overclock settings until the next boot.

What Speeds Can I Expect?

Whilst every individual Pi is differerent, experience shows most are able to reach at least these frequencies. Some get higher, some get lower, but these are common:

  • Pi 1 - ARM 900 and core/GPU/RAM 400, any higher is pretty lucky
  • Pi 2 - ARM 1000 and core/GPU/RAM 500, RAM over 600 is not unheard of
  • Pi 3 - ARM 1300 and core/GPU/RAM 500, RAM over 600 is not unheard of
  • Pi Zero - ARM not widely tested, core/GPU/RAM 500

Settings Examples

As much as copying someone else's settings simply may not work, people still ask for them, so here are some usually-safe baselines to start from:

Raspberry Pi 1

arm_freq=900
gpu_freq=400
core_freq=400
sdram_freq=400
sdram_schmoo=0x02000020
over_voltage=2
sdram_over_voltage=2

Raspberry Pi 2

total_mem=1024
arm_freq=1000
gpu_freq=500
core_freq=500
sdram_freq=500
sdram_schmoo=0x02000020
over_voltage=2
sdram_over_voltage=2

Raspberry Pi 3

total_mem=1024
arm_freq=1300
gpu_freq=500
core_freq=500
sdram_freq=500
sdram_schmoo=0x02000020
over_voltage=2
sdram_over_voltage=2

Raspberry Pi Zero

arm_freq=1000
gpu_freq=500
core_freq=500
sdram_freq=500
sdram_schmoo=0x02000020
over_voltage=2
sdram_over_voltage=2

Measurement Tools

To display a Frames Per Second counter in RetroArch cores to see the effect on emulation speed, edit /opt/retropie/configs/all/retroarch.cfg and set:

fps_show = "true"

You can SSH into your Pi while playing a game and run these commands to measure the effect of normal operation.

The temperature of the SoC can be queried with the command:

vcgencmd measure_temp

The currently applied config.txt parameters which differ from default can be queried with:

vcgencmd get_config int | egrep "(arm|core|gpu|sdram)_freq|over_volt"

The current frequency of the components can be queried with (remember they only increase speed under load unless using force_turbo):

for src in arm core h264 isp v3d; do echo -e "$src:\t$(vcgencmd measure_clock $src)"; done

The current voltages of the components can be queried with:

for id in core sdram_c sdram_i sdram_p ; do echo -e "$id:\t$(vcgencmd measure_volts $id)"; done

CPU usage of currently-running processes can be viewed with

top

A nicer display of CPU usage can be installed with sudo apt update; sudo apt install htop and then:

htop

Storage Overclocking

While loading a small ROM of a few kilobytes or even a few megabytes happens almost instantly, improved storage speed has benefits such as faster booting and regular operation, as well as providing quicker loading time to emulators dealing with very large ROMs and disc images such as PlayStation, Dreamcast, and PSP.

The sdcard specification says that when operating in "High Capacity (SDHC) mode" an sdcard must run at 50MHz, but when running in the faster "Ultra High Speed (UHS) mode" an sdcard must be able to run at 100MHz.

Whilst the Pi runs its sdcard reader at the 50MHz speed and does not enter sdcards into UHS mode, a UHS-capable card can probably still run at 100MHz while in SDHC mode, so we run the sdcard reader faster and hope the card is happy with it.

UHS cards are identified by the capital I of the UHS-I logo, as well as U1 or U3 speed markings. These are usually high-end expensive sdcards like Samsung Pro/Evo or Sandisk Extreme.

It is recommended not to try this with a regular non-UHS SDHC card.

The sdcard reader speed can be increased in /boot/config.txt with the following line and a reboot:

dtparam=sd_overclock=100

Once booted, the sdcard reader frequency can be queried with:

sudo grep clock /sys/kernel/debug/mmc0/ios

Spotting a bad sdcard overclock can be very difficult, as the sdcard will probably write corrupted data and everything will appear to work fine, you won't notice the data is corrupt until you access it again later on.

If your sdcard doesn't boot when overclocked, place the sdcard in your computer, both Windows and Mac will see the small FAT32 partition which contains config.txt which you can edit to remove the setting.

There are actually several frequencies in between 50MHz and 100MHz which can also be used, the exact speeds vary depending on Pi model. When a speed is applied which is not one of the useable frequencies, the next lowest frequency is chosen.

For example, setting 100MHz on a Pi 3 results in 100MHz, but setting 99MHz actually results in the sdcard reader running at 83MHz, and setting 82MHz would bump down to the next frequency under that.

Further Reading

Overclocking

  • http://elinux.org/RPiconfig#Overclocking (some outdated info for Pi 1, not Pi 2/3/Zero)
  • Official Pi Foundation forums thread (long): https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=6201
  • http://linuxonflash.blogspot.com/2015/02/a-look-at-raspberry-pi-2-performance.html

Cooling

  • ExplainingComputers video series: 1, 2, 3, 4
  • https://github.com/superjamie/lazyweb/wiki/Raspberry-Pi-Cooling

Power

  • https://www.raspberrypi.org/help/faqs/#powerReqs
  • http://www.righto.com/2012/10/a-dozen-usb-chargers-in-lab-apple-is.html
  • https://github.com/superjamie/lazyweb/wiki/Raspberry-Pi-Power
  • http://www.calculator.net/voltage-drop-calculator.html
  • http://www.powerstream.com/Wire_Size.htm

SDcards

  • https://en.wikipedia.org/wiki/Secure_Digital#Ultra_High_Speed_.28UHS.29_bus
  • http://www.jeffgeerling.com/blog/2016/how-overclock-microsd-card-reader-on-raspberry-pi-3
  • https://www.reddit.com/r/raspberry_pi/comments/4aoc3r/how_to_overclock_the_microsd_card_reader_on_a/

Other

  • http://www.elinux.org/RPI_vcgencmd_usage
  • https://github.com/nezticle/RaspberryPi-BuildRoot/wiki/VideoCore-Tools
  • Extra 16M memory on Pi2/Pi3