Blog

All Blog Posts  |  Next Post  |  Previous Post

TMS WEB Core and More with Andrew:
Raspberry Pi Revisited

Thursday, September 29, 2022

Photo of Andrew Simard

In our recent post, Raspberry Pi was introduced as a deployment target for desktop-class applications using TMS WEB Core and its included Miletus framework, where the development was done on another platform - Delphi in our example. It was a little slow overall, but the Raspberry Pi itself can be upgraded in a couple of ways to improve its performance. In this post, we'll look at doing just that.

Motivation.

Why would someone want to do such a thing? Well, much of the focus on Raspberry Pi is related to the ultra-low-cost and all-inclusive nature of its design. But sometimes it helps to give it a bit more power, particularly when doing a lot of testing. While the ultimate product might still be a low-cost Raspberry Pi, new development and testing don't necessarily have to be constrained by the same environment.

Storage Upgrade.

Specifically, we're looking at trying to make improvements to disk performance and to WiFi performance. While I appreciate very much the low price point that Raspberry Pi is targeting, I'm also curious about how much better it can be with a few small tweaks. But first, we'll need some baseline data so we can determine whether anything has improved.

For disk performance, I'm using the microSD card that came preloaded with my Raspberry Pi OS order. The card in question turns out to be a SanDisk Ultra 32GB microSD card (SDSQUNB-032G-GN3MN) which, as near as I can tell, has a rated 48 MB/s max read speed and 10 MB/s max write speed. To get some actual numbers, the following script was used.


#/bin/bash
dd if=/dev/zero of=./speedTestFile bs=20M count=5 oflag=direct
dd if=./speedTestFile of=/dev/zero bs=20M count=5 oflag=dsync
rm ./speedTestFile

This consistently reported about 45 MB/s read speed and 20 MB/s write speed. Not the worst, but not the best. As the plan is to do lots of development, a little more room might also be beneficial, as it is already half-full just with the operating system. 

Let's try something a little more substantial - a USB3-connected Samsung SSD 980 500 MB NVMe M.2 SSD. It has a reported read/write speed of 3500/3000 MB/s, likely well beyond anything the Raspberry Pi can cope with, but should be fun either way. The SSD cost $70 CAD and the M.2 USB3 enclosure (ADATA AEC700GU32G2-CGY) cost $40 CAD. There are less expensive alternatives to each, but using anything here is likely to lead away from what anyone would consider a low-cost Raspberry Pi.

Moving the Raspberry Pi microSD contents over to the SSD so we can boot from it without the microSD card can be accomplished using the SD Card Copier utility that is included in the Accessories menu. The USB device was detected automatically when it was plugged in, and it didn't take very long to copy over to the SSD.


TMS Software Delphi  Components
Copy microSD partitions to SSD.

Once the copy was complete, shutting down the Raspberry Pi, removing the microSD card, and booting the Raspberry Pi, and we're in business. Didn't have to fiddle with bootloader settings or anything. Available free space went from 50% to 97%, as expected.

As for performance, our test script now reports about 240 MB/s read speed and about 200 MB/s write speed. Quite a step up! If minimizing boot times is your thing, you might have to look elsewhere as boot times are still in the 25-30s range, booting with either the microSD card or the SSD. But nothing has been done in that regard - the splash screen and all other defaults haven't been changed.

Wireless Upgrade.

As far as WiFi is concerned, there was no issue connecting to my WiFi router originally, and it does indeed work.  However, it isn't very speedy. Using speedtest.net, my regular desktop reports around 900 Mbps (wired connection), and an original and aging iPad Pro (9.7") reports around 400 Mbps. Raspberry Pi comes in at around 80 Mbps. 

To try and address this, let's give a BrosTrend AC1200 Wireless Dual-Band USB3 Adapter a try. Around $40 CAD. Unlike the SSD, this device wasn't automatically recognized, and installing new drivers in any Linux system is likely to be a headache. Less so in this case, because we already have a working internet connection. It comes with a mini-CD with the drivers on it, but that's a little bit antiquated. Can't even recall the last time I used a regular CD, much less one of these! In any event, the pamphlet that comes with it points to a website with the necessary command. This downloads the drivers, all the Linux dependencies for headers, and the rest of what is needed to rebuild the kernel (?!).


sh -c 'wget deb.trendtechcn.com/install -O /tmp/install && sh /tmp/install'

Once complete, the onboard WiFi can be disabled as follows.

echo "dtoverlay=disable-wifi" | sudo tee -a /boot/config.txt 

It did take quite a while to run (longer than copying the microSD card, who knows how long it would have taken if we hadn't done that first!) but when complete, our new network adapter was available. Speeds are now around 170 Mbps. So certainly an improvement. Whether that is enough to justify the extra expense depends on how much your work relies on network performance. Interestingly, perhaps, a wired connection to the Raspberry Pi only gets around 210 Mbps. 

Curiously, I had recorded before/after videos showing the https://www.actorious.com page loading - lots of network activity, a fair amount of data, etc. But the videos ended up looking nearly identical, after both updates. Seems that the issue there is more to do with Raspberry Pi's lower-powered CPU than anything else. 

Does it Make Cents?

And finally, just a note about the cost. The cost of the Raspberry Pi board itself (about $60 CAD) was just slightly more than the new WiFi adapter (about $40 CAD), and around half the cost of the new SSD ($70) and its M.2 - USB3 adapter ($40 CAD) combined. This is not likely something you'd spend when deploying a Raspberry Pi in a kiosk environment or anywhere else really, as once your app is up and running, these won't make much difference anyway, most of the time.

There are also large capacity and speedy microSD cards that can be found for far less money and with ultimately the same level of performance. It might be that the onboard WiFi adapter could be further tweaked to get a little better performance. Something that might be worthwhile, if deploying a number of these at the same time. 

In general, though, it seems the Raspberry Pi is just lacking in raw horsepower to get beyond these numbers. Not a criticism in any way whatsoever - hard to complain about a $60 computer when it does include all of this stuff anyway, just not the top-end version of everything, which is expected.


Player Project - Visualizer.

So now that we're all set up, let's try something fun. In the first Web Audio API post, we developed an app that had a visualizer. And it turns out that the latest Raspberry Pi 4B (or 400) supports dual HDMI displays. So wouldn't it be fun to connect a second display just for the visualizer? 

Kind of a proof of concept at the moment, but a 7" 1280x400 display (including capacitance touch) can be found for around $100 CAD. It has an HDMI connector, a power connector, and a touch USB connector, standoffs for mounting, various cable adapters (right angle adapters for example) if you want to be more creative in how it is mounted, and surprisingly no documentation of any kind. There are a couple of buttons on the back, for on/off and changing the touch orientation. By default, it is set to display in a vertical orientation, but the Raspberry Pi's Preferences/Screen Configuration app can be used to change the orientation. 

After connecting a new WiFi adapter and the external SSD, this was a bit too much for the Raspberry Pi power system. So the display had to be connected to an external power supply (just via a USB dongle, no special wiring).  The Raspberry Pi is plenty capable enough to display an even higher resolution visualizer. Here's a quick video of what it looks like.



Full-Screen Visualizer 
Video.

In a future post, we'll have a look at what else we can do with this display. Should be possible to have the Raspberry Pi boot and display this app - maybe with a few more tweaks for more of a jukebox-like interface. Nothing else is required! Something similar could be done for implementing a "smart photo frame" or for displaying any other kind of diagnostic information, or data from Raspberry Pi's sensors. So much yet to explore.


Follow Andrew on 𝕏 at @WebCoreAndMore or join our
𝕏
Web Core and More Community.



Andrew Simard




This blog post has received 3 comments.


1. Saturday, October 8, 2022 at 7:56:53 AM

Very cool, Andrew! I don''t know why, but that visualizer reminded me of the old color organs from the 60''s and 70''s. Instead of bars, have a bunch of blogs randomly scattered around the display that get larger and brigher for their frequency band. :)

I found this video on YouTube of a guy who found an old color organ and hooked it up. When he opened it up to look inside, it''s incredibly simple.

https://youtu.be/9Unr1Ki5eVo

A RPi could be used to create a whole new generation of these things!

Schwartz David


2. Saturday, October 8, 2022 at 7:58:18 AM

I meant to say, "have a bunch of blobs randomly scattered around the display..."

Schwartz David


3. Saturday, October 8, 2022 at 10:40:09 PM

Yes, a Raspberry Pi 4 has all the connectivity found in a modern computer (Ethernet, WiFi, Bluetooth, USB2, USB3) and is extendible in all kinds of ways out of the box that a typical PC is not. All at an extremely low price point, and powered by a USB port. Mind-boggling to think about what can be done with it. And using TMS WEB Core to develop for it means it is almost no extra effort at all.

Andrew Simard




Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post