Stephen Smith's Blog

Musings on Machine Learning…

Archive for May 2024

Raspberry Pi Connect

leave a comment »

Introduction

Our writing group meets Friday mornings at a local coffee shop. I usually write these blog posts at these sessions. Often when writing about the Raspberry Pi or another SBC, I have to leave early because I need to go home to try some more things on the physical device. Raspberry Pi Connect is a service from the Raspberry Pi organization that lets you remotely connect to your Pi through their servers. I thought I’d be able to write this article in the coffee shop and use Raspberry Pi Connect to access my Pi 5 for anything additional I needed. Of course, I arrive at the coffee shop and find my laptop battery dead and I didn’t bring a charging cable. First world problems. Now I’m back home writing this article.

Before going home, I connected to my Pi via my cellphone to see it work when not on my local Wifi. Here it is in Chrome on my iPhone.

Installation and Setup

Installation on the Raspberry Pi is simple. Start a terminal window and type:

sudo apt update
sudo apt upgrade
sudo apt install rpi-connect
sudo reboot

After the Pi finishes rebooting, there will be a new icon in the system tray. Click this icon and choose “Sign in”. This will launch a web browser and allow you to either sign in if you have a Raspberry Pi ID or to create a new one. When you create the new one, you also add your Pi as a device and give it a name. You need to enter your email and then go to email to click verify in the email Raspberry sends you. When done the Pi is ready to be connected to.

Next, on your laptop, or the device you want to connect from, start a browser and go to https://connect.raspberrypi.com. Sign in using your new Raspberry Pi ID, and select your device. You can either see information on the device or connect to it directly.

The documentation is fairly good and worth skimming through.

Useage

Once connected you see your desktop and can interact using the keyboard and mouse. There is a limited facility to copy the clipboard between the Raspberry Pi and the accessing computer. It works fine for text, you just need to remember to copy the text from your document then hit the “Copy to remote” button. I tried to use this to copy files between the two computer’s file managers, but this didn’t work.

Other Notes

  • Raspberry Pi Connect tries to connect the two computers via WebRTC which is the same technology used by Zoom and other conferencing software. If this doesn’t work it relays the traffic through a server in the UK which can introduce a lot of latency. So far it’s always worked quite well for me, so probably meaning it is mostly able to use WebRTC.
  • Raspberry says this service is free and they intend to mostly keep it this way, but did hint at adding a fee if WebRTC doesn’t work and you need to be relayed through their servers.
  • This software works quite easily using the GUI, which I like. However, the documentation also covers how to do this all on the command line. Running a Raspberry Pi headless using terminal mode is quite easy and now running headless using a GUI is also easy.

Summary

Raspberry Pi Connect is a nice service to allow people to easily access their Raspberry Pi remotely. With more Pi’s being embedded in robots and other DIY projects, having an easy hassle free way to access the Pi headless is greatly appreciated. This service is currently beta, but it seems to work quite well and I’ll be using it going forward. The only thing missing is an integrated way to transfer files back and forth.

Written by smist08

May 31, 2024 at 11:48 am

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