Overclocking the Raspberry Pi 4 for Fun and Games

 This is the belated first part of a series of posts on getting a Raspberry Pi working with RetroPie for some sweet retro gaming. The Raspberry Pi is a fun, way too small computer that is great for all sorts of stuff, but especially for playing old video games with. It should be noted that I bought mine near the end of 2020, when they were actually available in stores. I also bought an Argon One Pi 4 case for it, and so it stays (relatively) cool when I overclock it. Unfortunately, I lost the piece of paper where I had the overclock values written down, and so I started over from scratch. The following process is how I figured out the overclocking values I'll use, and you can too if you follow along. This is aimed at the Pi 4 or 400, but some of it should be applicable to the Pi 3 and below with some tweaking to the numbers used. Be sure to have a paper and pencil handy for writing the speeds you've achieved down.

The first thing you'll need (aside from the Pi and a case, obviously) is an SD Card. You'll need at least a 32 GB card for this process, but a larger one is great if you want to run something like RetroPie later. Grab the Raspberry Pi Imager from here, install it, run it, and then choose PINN under Misc utility images. You'll want to use PINN, because at some point during the process, your Pi will refuse to boot, and so the recovery menu that PINN has is really nice. Also, if you have a newer Pi firmware and a wired internet connection, you can install an OS directly from the Pi, rather than using the Imager (don't worry, once you've installed Raspberry PI OS, it'll update the firmware for you.) Write it to an SD Card, put it in your Pi and boot it.

Once you've booted PINN, you can select a WiFi network if you need one. Be sure to select a 2.4 GHz network, as 5 GHz doesn't seem to work for me after installing an OS. After that, select Raspberry Pi OS (64-bit) as the OS to install. It is possible to use 32-bit, but the stress tests won't be fully functional. Once you've gotten it installed, right click on the taskbar, and click Add / Remove Panel Items. Click Add, and then add the CPU Temperature Monitor. Next, set up any fan control software you might have, and then reboot. Next download the installer script archive with your Pi's web browser, and then extract it to your home directory by pasting the following command into a terminal in your Downloads directory.

tar -xjvf pitest.tar.bz2 -C ~

Be sure to look at the included instructions - they're minimal, but they include the necessary commands to run for benchmarking and stability testing. After everything's in your home directory, type this in a command prompt in your home directory to install the prerequisites:

./install.sh

Once that stuff has installed, do a web search for Phoronix Test Suite, and download the Ubuntu/Debian Package for it. When the Keep/Discard thing pops up, click keep, then open it, and install it, typing your password in when asked. You'll need to set a root password before installing it, so type sudo passwd root, set your root password, and then type the install command from the instructions (phoronix-test-suite install pitest). Type the root password you just set when asked. Now go do something else, because it'll be downloading and installing stuff for an hour or two.

You might want to run all the benchmarks with the default settings before you try overclocking. The sysbench and stress-ng benchmarks only take a couple of minutes to run, and will show you if your overclock is unstable very quickly. sbc-bench is a longer one (even longer the first time you run it, as it installs some software before running it), but if you can get through those, you're probably OK. Stressberry is pretty cool, as it'll output a graph of the temperature the Pi got to at various points. Finally, there's the PTS PiTest suite I came up with. It can take 20 hours, but if it finishes, your Pi is rock solid stable.

Overclocking on the Pi is controlled by the config.txt file in the boot directory. You can edit it in Pi OS, or you can edit it in the PINN recovery menu, or you can edit it from a PC, as it's on a FAT32 partition. Some of the newer Pi 4s have upgradde hardware from the one I have, and so are set up to run at 1800 MHz instead of 1500 MHz by default. You can check what speed it's running at by using the measurepi.sh script included with the installer script. The newer versions of Pi OS have the arm_boost=1 flag set by default. That is the command that sets the higher default speed. It also sets the Pi to use adaptive voltage - no more having to tweak the over_voltage setting. You can tweak it, but over_voltage seemed to not work as well as just letting it set the voltage on its own.

I would suggest starting by setting the desired CPU frequency under arm_freq first. If you're using an original Pi 4, try setting it to arm_freq=1800. If you're using a Pi 400 or newer 4, try setting it higher. The highest that an original Pi 4 can theoretically go is 2147 MHz, but it probably won't boot when it's that fast. If it fails to boot, or it resets, or it freezes up, that's a sign to drop the frequency. For example, I was able to successfully run all the benchmarks at 2000 MHz, but the silicon lottery might favor you more. Run the sysbench, stress-ng, sbc-bench, stressberry, and PTS PiTest benchmarks in a row. If it doesn't freeze up or crash during any of those, you've got a rock solid CPU overclock.

Overclocking the GPU is a little different. The official instructions say to modify the v3d_freq setting, but that makes the performance worse, rather than better. So, I overclocked via the gpu_freq setting. I benchmarked with the the glmark2 and glxgears tests, increasing it from 500 MHz by 125 MHz at a time until it wouldn't boot, which for me was at 1000 GHz GPU speed. I then dropped it by 25 MHz at a time until I was able to finish all three benchmarks - for me, that was at 925 MHz. Then I ran the Raspi_stability_test, which stresses both the CPU and GPU. I then increased the CPU overclock by 100 MHz, and re-ran glmark2 and Raspi_stability_test until both would run successfully. If not, I dropped the GPU overclock by 25 Mhz, and would try again. That should provide you with minimally stable CPU-GPU frequency combinations.

You can also try running stressberry to see if it'll work at a particular speed. It's more sensitive to the GPU setting than the other GPU testers, and so you'll probably have to drop the GPU speed more. If you really want to know what a rock solid CPU-GPU combination is, just try running the sysbench and stress-ng combo in the instructions file. If it resets there, then it's not really stable. Don't bother trying to run the PiTest suite if you're overclocking the GPU - it will crash on you, no ifs, ands, or buts.

Comments

Popular posts from this blog

CoCo 3 NitrOS-9 Emulator VHD Install Disks

Mac Emulator Videos