Trying out UASP on my Raspberry Pi 4

Recently, I watched a Jeff Geerling video where he talks about UASP and how it is useful in improving Read / Write speeds of his USB connected SATA SSD. Curious, I wanted to try out how having an SSD as my boot drive would be for my Raspberry Pi 4B.

I bought a cheap ADATA SU650 120GB SSD as my boot drive and a PiBOX 2.5 Inch SATA to USB 3.0 connector from Amazon.

Preparing to flash

I downloaded the 64-bit Raspberry Pi OS from here and extracted the zip file to an empty folder. I then used the Raspberry Pi Imager to flash the 64-bit image to the SSD.

Since I use Arch Linux I installed the imager from AUR using Trizen.

1
trizen -S rpi-imager

When you launch the Imager you might get a screen like this.

/images/blog/uasp-pi/imager-1.png

Select Choose OS under Operating System and scroll down till you find Use Custom.

/images/blog/uasp-pi/imager-2.png

Select the .img file you extracted from the zip file you downloaded.

Now under SD Card select Choose SD Card and select the USB Connected SSD drive and click Write. Once done writing unplug the USB and keep it aside. We now need to update the EEPROM of the Raspberry Pi.

Updating the EEPROM

First, update the Raspberry Pi packages to the latest version using apt.

1
sudo apt update && sudo apt upgrade

Then using nano update the rpi-eeprom-update file.

1
sudo nano /etc/default/rpi-eeprom-update

Change the value of FIRMWARE_RELEASE_STATUS="critical" to FIRMWARE_RELEASE_STATUS="stable" and save the file.

At the time of writing this blog the latest version for the EEPROM file was 2020-09-03. Use the below command to update the EEPROM.

1
sudo rpi-eeprom-update -d -f /lib/firmware/raspberrypi/bootloader/stable/pieeprom-2020-09-03.bin

Once updated reboot the Raspberry Pi.

Now run sudo rpi-eeprom-update you should get an output like this.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
 ~  sudo rpi-eeprom-update
BCM2711 detected
Dedicated VL805 EEPROM detected
BOOTLOADER: up-to-date
CURRENT: Thu  3 Sep 12:11:43 UTC 2020 (1599135103)
LATEST: Thu  3 Sep 12:11:43 UTC 2020 (1599135103)
FW DIR: /lib/firmware/raspberrypi/bootloader/stable
VL805: up-to-date
CURRENT: 000138a1
LATEST: 000138a1

Run vcgencmd bootloader_version to check the Bootloader version and verify the update.

1
2
3
4
 ~ vcgencmd bootloader_version
Sep  3 2020 13:11:43
version c305221a6d7e532693cc7ff57fddfc8649def167 (release)
timestamp 1599135103

Connecting the USB SSD Drive

Connect the SSD drive to one of your 3.0 USB ports. Before switching to booting off SSD drive follow the below instructions to enable SSH. You may skip the steps if you prefer login using GUI.

Check for UASP Support

To check if your SATA to USB adapter supports UASP the reliable way is to plug in the SSD drive and using lsusb -t to check. In my case, my device supports UASP and when plugged in lsusb shows that it is using uas driver.

1
2
3
~ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=uas, 5000M

If your adapter does not support UASP you will get something like this.

1
2
3
~ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M

Note that the value for Driver is uas in the first case and usb-storage in the second case. If your output has uas this means that your adapter supports UASP.

Enabling SSH on boot

  1. As root run fdisk -l find out the Disk drive. In my case it was /dev/sdb.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Disk /dev/sdb: 111.8 GiB, 120034123776 bytes, 234441648 sectors
Disk model: 2115            
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xdc0628d4

Device     Boot  Start       End   Sectors   Size Id Type
/dev/sdb1         8192    532479    524288   256M  c W95 FAT32 (LBA)
/dev/sdb2       532480 234441647 233909168 111.5G 83 Linux
  1. Create a folder mkdir /mnt/boot.

  2. Mount the drive using mount /dev/sdb1 /mnt/boot.

  3. Create an empty ssh file touch /mnt/boot/ssh.

  4. Unmount the drive using unmount /mnt/boot.

Rebooting into the SSD

  1. Shutdown your Raspberry Pi and carefully unplug the SD card.

  2. Start up the Raspberry Pi and wait for a few minutes.

  3. Type ssh pi@<ip address of pi> to ssh into the Pi.

  4. Congratulations you are booting off the SSD drive.

I’m assuming you have a static IP mapped to your Raspberry Pi MAC address. If not you can use nmap to scan your network.

Benchmark Results

/images/blog/uasp-pi/benchmark.png

From the results, we can immediately notice how much faster UASP is compared to USB-Storage. It’s about 15 - 20% faster over USB-Storage. The benchmark tests were performed and averaged over 3 runs.

For benchmarking using hdparm:

1
sudo hdparm -tT /dev/sdb2

For benchmarking using dd:

1
dd if=/dev/zero of=benchfile bs=4k count=200000 && sync; rm benchfile

Summary

UASP is definitely faster than USB-Storage. If you are interested in buying a USB 3.0 to SATA adapter please consider buying a UASP compatible adapter.

A small note to consider during purchase is that it’s better to buy controllers made by ASMedia Technology Inc as they are reported to have a high chance of success supporting UASP.