How to overclock the microSD card reader on a Raspberry Pi 3

Late last year, I published a blog post with comprehensive benchmarks of various microSD cards used with the internal Raspberry Pi 2 reader, based on the comprehensive (and always-up-to-date Raspberry Pi microSD card benchmark page I maintain for the Pi Dramble project). After publishing the blog post, a few different readers pointed me to some overclocking tweaks that could help boost the speeds further for UHS microSD cards, allowing large file I/O speed to double, and random I/O to get a solid boost as well.

I finally got my hands on a Raspberry Pi 3 and wanted to see how it compares to the Pi 2 (review + benchmarks incoming!), but one of the first things I wanted to test was overclocking the microSD clock for better disk I/O. On average, with all the cards I've tested so far, overclocking the microSD reader resulted in 25-50% better performance for real-world disk operations (benchmarks further down in this post). And with a reliable power supply, you shouldn't need to worry about reliability or corruption (in my limited stress testing, I only had one corruption, and that was when I was using my cheaper iClever power supply).

Overclock the microSD reader with sdhost

First, a caveat: I generally treat my Pis as cattle, not pets, so I do crazy things to them on an hourly basis, and typically rewrite the microSD cards dozens of times trying new configurations, building new servers, etc. If you have anything important on your Pi, overclocking the reader can cause data corruption, especially for non-UHS-certified cards. Make a backup! You've been warned!

Add a dtoverlay directive to overclock the microSD reader to 100 MHz (it defaults to 50):

sudo bash -c 'printf "dtoverlay=sdhost,overclock_50=100\n" >> /boot/config.txt'

Reboot the Raspberry Pi (sudo reboot), and you should experience much better disk I/O!

Note: The above instructions work on the Raspberry Pi 2 and other models as well (assuming you use a valid integer divisor of the core clock—on the Pi 2 you could try 84, 72, or 63 by default).

Benchmarking microSD cards

There are a couple benchmark scripts you can run to test the speed and verify the updated microSD clock:

# Installs and run hdparm, dd, and iozone benchmarks.
$ curl https://raw.githubusercontent.com/geerlingguy/raspberry-pi-dramble/master/setup/benchmarks/microsd-benchmarks.sh | sudo bash

# Run hdparm and some large file read/write benchmarks.
$ curl http://www.nmacleod.com/public/sdbench.sh | sudo bash

Here are a couple quick benchmarks comparing the same cards at normal clock and overclocked:

Raspberry Pi 3 microSD card performance - overclock with sdhost

Random disk I/O performance has the highest impact on most day-to-day Pi usage (especially if you use it as a desktop computer!), so I tend to focus my benchmarking on it; large file operations (e.g. large file reads and writes) basically doubles with the 2x clock speed increase, so if you do things like copy giant files across the network or stream large video files, then the performance boost may be even more noticable. 4K random writes don't benefit as much, mostly because microSD cards typically max out at much lower speeds than would saturate the Pi's bus.

Potential issues

If you notice the clock is not set at 100 MHz after changing these settings (both of the above benchmark scripts output the current clock setting before running the benchmarks), and you've confirmed the steps above were run correctly, there are two things that could be causing problems:

  • If your power supply can't supply at least 2.4A at a consistent 5V, then the Pi might not even boot, or might automatically under clock the SD reader.
  • If you run dmesg after bootup, see if there are any messages relating to mmc0 and "reducing overclock"; the card might not be able to sustain a full 100 MHz overclock.

Sometimes a simple hard power off and power on will resolve these issues; other times it just means either your card, your Pi, or your power supply won't sustain the overclock setting reliably. You can try other, lower overclock settings, as long as the number is an integer divisor of the core clock (default is 400 MHz on the Pi 3), e.g. 50, 80, or 100.

Also, if you experience WiFi issues, or if your Raspbian version doesn't include the sdhost overlay inside /boot/overlays, you can download sdtweak-overlay.dtb manually: sudo wget -O /boot/overlays/sdtweak-overlay.dtb https://dl.dropboxusercontent.com/u/1221084/share/Raspberry-Pi/sdtweak-overlay.dtb; it's better to update/upgrade, though, so the sdhost overlay is present. You will also need to change 'sdtweak' to 'sdhost' in the overlay line in config.txt if you do this.

More info

Comments

I'm reposting a snippet from a comment from this post's Reddit thread, from user QuirkyQuarQ:

tl;dr: All UHS-I cards should be capable of up to 100 MHz, but YMMV. How high depends largely on the card, not the Pi.

By default, the Pi provides 50 MHz as the SD clock.This is technically the maximum for non-UHS cards ("SD mode") according to the SD specification, and since SD cards perform I/O in 4-bits (0.5 bytes)-per-clock-cycle, should result in a theoretical max transfer rate of 25 MBytes/sec (about 21-22 in the real world after overhead, etc.) Non-UHS cards (i.e. no "I" or "U1" logo on the card) are not required to go higher than 50 MHz.

UHS-I microSD cards, on the other hand, must support up to 100 MHz in UHS mode. Although the Broadcom SoC is capable of UHS mode, the Pi does not support it because it requires 1.8v signaling while the Pi's is fixed at 3.3v.

I'm going to see if I can push some of my UHS-3-certified cards to even higher clocks as QuirkyQuarQ suggests later in his post, and update this post with results...

For more information on UHS/Class certifications for SD cards, see this page: https://www.sdcard.org/consumers/speed/

After a few more tests with higher clock rates (133, 150, 200), nothing ended up working (these settings resulted in different amounts of errors or gibberish during boot).

All 3 of my 64gb evos (non+) are able to handle 107mhz. As expected, 4k performance isn't noticeably affected, but sequential read goes up proportionately.

There is an easier, better way to overclock the UHS-1/HC-1sdcard on the Pi3, and benchmark it using 'sdbench'.

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install piclone geany usb-modeswitch pi-bluetooth
sudo apt-get install python-pigpio python3-pigpio mesa-utils
sudo reboot

open:
sudo nano /boot/config.txt

add:
dtparam=sd_overclock=100

open, select/copy all:
http://www.nmacleod.com/public/sdbench.sh

open, paste into:
sudo nano sdbench.sh

save

then make it executable:
sudo chmod +x sdbench.sh

run benchmark:
sudo ./sdbench.sh

Does this void the Raspberry Pi 3's warranty bit? Just want to make sure before proceeding.

Not that I know of. The only real risk is potential data corruption (usually only on cheaper cards).

UPDATED METHOD:

sudo bash -c 'printf "dtparam=sd_overclock=100\n" >> /boot/config.txt’

You can edit file containing these settings with:

sudo nano /boot/config.txt