Stephen Smith's Blog

Musings on Machine Learning…

Raspberry Pi 5 with SSD

with 2 comments


Introduction

The Raspberry Pi 5 is quite a speedy little computer, but the main bottleneck is using microSD cards for storage rather than SSD type memory drives found in most other computers. You could connect an SSD drive to the Pi via an USB port, but then this only runs at USB speed rather than full SSD speed and isn’t much better than a microSD card. The Raspberry Pi 5 added a PCI express connector with the promise that this would allow a fast way to connect SSD drives as well as other devices requiring faster data transfer rates. At the time of shipping there wasn’t a way to utilize this connector, which was too bad. There are now lots of different interface boards to allow the Raspberry Pi 5 fast interconnect with all sorts of devices.

Slow Rollout

The Raspberry Organization promised to ship a hat for SSD cards, eventually but without any timeline. A hat for the Raspberry PI is a board that sits on the GPIO pins and provides a mechanism to pass these through, so multiple hats can be stacked. In the meantime, several companies such as Pimoroni shipped their own products. Next, the Raspberry Organization released a spec for the PCIE port, which greatly helped companies create their own boards.

I thought I would wait for the official Raspberry SSD hat, but was seeing quite a few good reviews of the third party ones. So I ordered the Waveshare SSD hat and a Samsung PM991 M.2 2242 256 Gig SSD to go with it. Note you need to use the shorter 2230 or 2242 M.2 drive sizes, the longer ones don’t fit.

Of course a couple of days after I ordered the Waveshare, Raspberry announced their product.

The reason I chose the Waveshare product was that it was available on Amazon with free prime shipping. These hats only cost $12CAD, and paying $20 for shipping is outrageous. I would be willing to pay $5 for regular post, but having to pay $20 for FedEx without an inexpensive option is a non-starter.

Assembly/Installation

Assembly was relatively easy, only a matter of connecting the ribbon cable and number of screws/posts. I already have a USB caddy for M.2 SSD drives, which I connected to my laptop. I then ran the Raspberry Pi Imager to write the Raspberry PI OS to the device. Before you can use the SSD, you need to change the Raspberry Pi boot order to boot from the SSD. To do this:

  1. Run the RPI EEPROM configurator: sudo rpi-eeprom-config –edit
  2. Change the boot order to: BOOT_ORDER=0xf416
  3. Add the line: PCIE_PROBE=1
  4. Type: Ctrl-O to save the file
  5. Type: Ctrl-X to exit the editor

After you do this, you can take out the microSD card and reboot from the SSD. This all turned out to be quite straightforward and I was up and running.

Update 2024/05/25: Thanks to Cameron to pointing out Jeff Geeling’s link showing how to enable PCIE gen 3 by editing /boot/firmware/config.txt to add the following two lines:

dtparam=pciex1
dtparam=pciex1_gen=3

The first enables pcie even if not the boot device and the second enables gen 3 speeds of 8Gig/Sec over gen 2’s 5 Gig/Sec. I added the benchmark results below.

Running from the SSD feels much faster than the microSD. Programs start quickly, the Pi boots quickly. It feels like a much more powerful device. In fact, it feels like I have quite a powerful little desktop computer.

I do worry that the active cooling module (fan) is sandwiched between the main Pi board and the hat. So far it seems to be working fine, but I worry that the air flow situation isn’t ideal.

Also, make sure you have a good enough power supply for your Raspberry Pi, as the SSD will draw more power than a microSD card. I’m running the official Raspberry Pi 27 Watt one and it seems fine, so far no low voltage warnings.

Benchmarks

I ran the Pi Benchmarks script to see how this configuration worked. I chose this benchmark since it mostly tests storage performance. In this case I don’t care about the CPU or GPU. The results for the SSD are:

    Category                  Test                      Result    
HDParm                    Disk Read                 418.78 MB/sec            
HDParm                    Cached Disk Read          410.84 MB/sec            
DD                        Disk Write                279 MB/s                
FIO                       4k random read            106113 IOPS (424455 KB/s)
FIO                       4k random write           89043 IOPS (356173 KB/s)
IOZone                    4k read                   182659 KB/s              
IOZone                    4k write                  143168 KB/s              
IOZone                    4k random read            57281 KB/s              
IOZone                    4k random write           156228 KB/s              
                          Score: 37178

Update 2024/05/25: Here are the results with PCIE Gen 3 enabled. Good performance boost:

    Category                  Test                      Result    
HDParm                    Disk Read                 798.48 MB/sec            
HDParm                    Cached Disk Read          709.25 MB/sec            
DD                        Disk Write                417 MB/s                
FIO                       4k random read            141241 IOPS (564965 KB/s)
FIO                       4k random write           92669 IOPS (370678 KB/s)
IOZone                    4k read                   225749 KB/s              
IOZone                    4k write                  174120 KB/s              
IOZone                    4k random read            61798 KB/s              
IOZone                    4k random write           196116 KB/s              
                          Score: 45268            

The results for my microSD card, a relatively new Samsung 128 Gig, are:

   Category                  Test                      Result    
HDParm                    Disk Read                 86.42 MB/sec            
HDParm                    Cached Disk Read          84.62 MB/sec            
DD                        Disk Write                46.4 MB/s                
FIO                       4k random read            4352 IOPS (17411 KB/s)  
FIO                       4k random write           832 IOPS (3329 KB/s)    
IOZone                    4k read                   21174 KB/s              
IOZone                    4k write                  3218 KB/s                
IOZone                    4k random read            16612 KB/s              
IOZone                    4k random write           3249 KB/s                
                          Score: 1965                     

This makes the SSD drive using gen 2 is 19 times faster than my microSD card and then gen 3 is 23 times faster. Pretty good.

Summary

The Waveshare hat is $12 and the Samsung SSD is $40. So for approximately $50 you can make your Raspberry Pi into a far more powerful computer. Further SSD drives are typically more reliable than microSD cards, so your data is safer. With this addition, I feel that the Raspberry Pi 5 really is a competitive desktop computer that you can be productive doing work on.

Written by smist08

May 24, 2024 at 11:50 am

2 Responses

Subscribe to comments with RSS.

  1. Hi Stephen,

    I haven’t got a Pi 5 yet, however the ability to boot from an SSD looks like a big deal.

    You might like to have a look at the following youtube video https://www.youtube.com/watch?v=EXWu4SUsaY8&t=19s at 10:20, where Jeff has changed a parameter in the config.txt file i.e. “dtparam=pciex1_gen=3” This can speed up the read/writes.

    I enjoy reading your blog,

    Cameron

    GoG

    May 24, 2024 at 8:13 pm

    • Thanks, that gives an additional boost. I added it to the article.

      smist08

      May 25, 2024 at 9:31 am


Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.