Tag: hardware

  • Raspberry Pi vs used Thin Client

    I saw Jenny List’s post on Mastodon the other day:

    I need a small server to do a thing.

    I totted up the price of a Raspberry Pi 5 with all the accessories I would need, and came up at more cash than an equivalent x86 box.

    I’m sorry to say this, but there’s no reason for me to use a Pi there.

    along with Jonty Wareing’s reply:

    … Other than hats or pins I find there is rarely a good reason for a pi these days. You can get cheap x86 thin clients that beat the pants off them – the dell wyse ones are very cheap on ebay and excellent, the 5070 has an m2 slot and upgradable ram.

    I’ve had Raspberry Pis since they were launched. I used to work for an Official Reseller. I’ve been hired for my expertise with them. They’re so much part of the woodwork around here that I’ve never really considered them expensive. So how do they compare to an ex-corporate thin client box?

    Dell Wyse 5070

    ebay sold item page for "Dell Wyse 5070 Thin Client J5005 @1.5GHz 8GB RAM 128GB AC Adapter- NO OS/Stand" with picture of a small thin client computer box

    I found one on eBay from a local reseller, GREENSTAR💻⭐. For $68.44 including sales tax (that’s €42), I got a used thin client box including:

    • a great big power supply brick;
    • Intel j5005 quad core cpu, fanless;
    • 8 GB of DDR4 RAM (dated 2021);
    • 128 GB SATA M.2 SSD;
    • 3× DisplayPort video ports, 1920×1080 at 60 Hz;
    • 5× USB 3 ports, 1× USB C port and 2× USB 2 ports;
    • a real 9-pin serial port;
    • no wifi!

    This isn’t a detailed hardware review: for those, I suggest you read Gough Lui and David Parkinson. To get this machine up to a usable spec, I added:

    • a DisplayPort → HDMI cable (about $20);
    • a replacement BIOS backup battery ($1);
    • a cheap USB wifi adapter. I’m still finding old RTL8188CUS dongles about the house from the early Raspberry Pi days, some still in original packaging. These work, but aren’t great, but I can’t beat the price.

    All in — excluding monitor, keyboard and mouse — I’ll say I brought it in for $100 inclusive (about €61).

    Raspberry Pi 5

    To come up with an equivalent system (bought from an Official Reseller that I didn’t work for) I’d need:

    Description Price
    Raspberry Pi 5 8GB $114.95
    Raspberry Pi 45W USB-C Power Supply $21.99
    Case (with fan) $13.95
    MicroHDMI to HDMI Cable (2 m) $9.95
    128GB SD Card $24.95
    RTC Battery $7.00
    Subtotal $192.79
    Sales Tax $25.06
    Total $217.85

    (or €134)

    Not all of these items are available from the one reseller, particularly the 128 GB SD Card and RTC battery. I’ve included the RTC battery so you can do timed power-on tricks as with a regular PC. All the parts are from Raspberry Pi themselves. Curiously, you can pay more for non-official accessories with the CanaKit Raspberry Pi 5 Starter Kit at $224.95 + tax.

    Raspberry Pi 4

    An equivalent 8 GB Raspberry Pi 4 system breaks down like this:

    Description Price
    Raspberry Pi 4 8GB $104.95
    Raspberry Pi 15W USB-C Power Supply $10.95
    Case $6.95
    Case fan $6.75
    MicroHDMI to HDMI Cable (2 m) $9.95
    128GB SD Card $24.95
    DS3231 Real Time Clock Module for Raspberry Pi $9.95
    Subtotal $174.45
    Sales Tax $22.68
    Total $197.13

    (or €121.)

    This is surprisingly expensive, and unless you must have this particular SoC, likely better to go with a Raspberry Pi 5. Again, the RTC is optional, but timed power-on can be handy in a small computer. Most of the “RTC for Pi” boards use a cheaper DS3231M clock chip which can’t issue alarms for power control. You might have to shop around a bit to get this particular part.

    For roughly $2 more, you could go for the official Raspberry Pi 4 Desktop Kit (tiny 16 GB SD card, two HDMI cables, guidebook, no fan, no RTC — but includes the surprisingly lovely Raspberry Pi Keyboard and Hub and Mouse). For a whole lot more ($259.95), you could go with the CanaKit Raspberry Pi 4 EXTREME Kit.

    (As a former employee of a reseller, I suspect I’m permanently blocked from sharing why official resellers bundle third-party bits with their kits, always with a considerable price bump. Let’s just say that, during the Pandemic Chip Shortage, it was very galling to get a rare shipment of Raspberry Pi boards, go to extreme lengths to cancel multiple orders [oh the javascript injection hack attempts that I saw] and hurry to ship the boards out. The next day, we’d see what had to be the same hardware appearing on eBay at a 300% markup. And there was nothing we could do about it …)

    Testing

    I’m not interested in testing:

    1. Network throughput — Beyond having a working connection, I don’t have the skill or attention span to test networking stuff
    2. Video performance — I don’t really do video things. Raspberry Pis and thin clients are going to struggle with full screen 60 fps video anyway, and optimizing this is not my jam
    3. Power consumption — I don’t have the right kit for this. All I have is a 20 year old Kill-a-Watt clone which doesn’t have the necessary resolution.

    I’m going to have to rely on benchmarks. Benchmark results are notoriously easy to fiddle and give only a rough idea of how a system will perform in real life. I’m going to present the results of three systems (Raspberry Pi 4 and 5, Dell Wyse 5070: all running stock but up-to-date Raspberry Pi OS or Debian) in three tests, in decreasing order of arbitrariness.

    1: MP3 Encoding

    The time, in seconds, to encode Aphex Twin’s minimalist opus aisatsana [102] (5′ 21″) from a 55MB WAV file to a 6.8MB MP3 with:

    time lame -V 2 aphex_twin-aisatsana.wav
    System Time
    Raspberry Pi 4 14.2 s
    Dell Wyse 5070 8.6 s
    Raspberry Pi 5 5.7 s

    The thin client comes out between the two Raspberry Pis. It’s not a bad result at all: 8.6 s is still 37× real-time encoding.

    2: pichart

    pichart is a processor benchmark developed by Eric Olson for ranking numeric processing power of various computers against Raspberry Pi boards. It’s documented here: A Pi Pie Chart.

    It’s possible to tweak this benchmark endlessly with compiler options, but I stuck with whatever version of gcc the system came with. I also used exceptionally conservative compiler options of -O2. I reckon that if your compiler has got to version 12, it won’t be producing terrible code with simple options. Anyway:

    info graphic comparing multi core numeric performance of several small computers, including Raspberry Pi 4, Raspberry Pi 5 and Dell Wyse 5070.

The centre is dominated by a large pie chart, and there are individual results around the corners for Prime Sieve, Fourier Transform, Merge Sort and Lorenz.

With some variation in relative results, the Raspberry Pi 5 has the best performance, followed by the Wyse 5070 and then the Raspberry Pi 4

    (raw results, if you must: Wyse5070-vs-Pi.txt)

    All of these are OpenMP multi-core, multi-thread results. The Wyse 5070 holds a pretty solid second place to the Raspberry Pi 5.

    3: UnixBench 6.0.0

    byte-unixbench must be a very serious benchmark because it wraps a whole suite of results into one impenetrable number. We’re supposed to believe that This Number has some respectable heft. It certainly takes a long time to run (almost half an hour) and if your computer has fans, things can get loud.

    Since all three machines have four cores, it’ll save a lot of words to report only the multi-core System Benchmarks Index Score:

    For all its purported repeatability, this set of scores surprised me most. The Wyse 5070 doesn’t feel much slower than either Raspberry Pi board. Could the small SATA SSD be a bottleneck? I’d have to spend money to find out.


    (I also ran sbc-bench, but the results are even less enlightening. The only thing I could discern was that the Wyse 5070 was running some kind of custom thermal regime. Since it has no fan and only a modest heat-pipe cooler, this is no surprise. My results, have at ’em: sbc-bench)

    Conclusions

    I can get two Wyse 5070 systems for the cost of one Raspberry Pi 4 or 5. This is what makes the decision for me, and every other issue is window dressing. So much of “I made a thing with a Raspberry Pi!” is really “I made a thing with a small Linux computer!” these days, and the 5070 and other thin clients excel at this.

    Yes, the Raspberry Pi 5 is likely to be slightly faster that the Wyse 5070. And if you’re locked-in to their cameras, HATs or GPIO layout, you’re probably going to stick with Raspberry Pi. Likewise, if you’re kitting out a classroom, Raspberry Pis are all repeatable, from the same vendor, and have a proper warranty. Nobody in education got fired for buying Raspberry Pi — even if the micro:bit is the STEM board of choice round these parts.

    Even if the supply can be a bit variable, and you can’t be quite sure you’ll be able to get the same spec every time, the Wyse 5070 represents great value for money. I’ll definitely think twice about buying a Raspberry Pi next time.

    … about those GPIO pins

    If you’re not constrained to using Raspberry Pi’s 40-pin header or specific HAT hardware, you’ve still got options, including but not limited to:

    • an FT232H Breakout and PyFtdi. It may be possible (with some fiddling) to make the FT232H appear as a Linux gpio chip directly;
    • u2if (USB to interfaces) running on a Raspberry Pi Pico, talking to Python on the Linux end;
    • and of course, Firmata running on an Arduino is exactly where you left it in 2011. It still works, it hasn’t gone away, and is still at the heart of many custom interactive installations.

    Parting thought

    raspberry pi computer” is an anagram of “temporary price burps”. This, I feel, is important for you to know.

  • Weird thrift-store find: homebrew CD player

    I killed some time this lunchtime in a thrift store. I was half-looking for a case for a kit computer, but wasn’t expecting much to turn up. But I found this:

    There really are no identifying marks on this. No idea how it got to be in Canada.

  • [tɒk bɒks] — a tiny hardware speech synthesizer/TTS

    a small black component case with speaker holes, a switch and two sockets
    [tɒk bɒks]: case
    a circuit board with two smaller boards mounted on top. One is the EMIC-2 board, the other a USB to serial adapter
    [tɒk bɒks]: inside. The observant amongst you will notice that the speech board is 1/10″ further in than it should be for ideal alignment with the USB serial adapter.

    Back in the 1980s, the now-defunct Digital Equipment Corporation (“DEC”) sold a hardware speech synthesizer based on Dennis Klatt’s research at MIT.  These DECTalk boxes were compact and robust, and — despite not having the greatest speech quality — gave valuable speech, telephone and reading accessibility to many people. Stephen Hawking’s distinctive voice is from a pre-DEC version of the MIT hardware.

    DEC is long gone, and the licensing of DECTalk has wandered off into mostly software (ahem …). Much to the annoyance of those in earshot, I’ve always enjoyed dabbling in speech synthesis. DECTalk hardware remains expensive, partly because of demand from electronic music producers (its vocoder-like burr is on countless tracks), but also because there are still many people who rely on it for daily life. I couldn’t justify buying a real DECTalk, but I found this: the Parallax Emic 2 Text-to-Speech Module.  For about $80, this stamp-sized board brings a hardware DECTalk implementation to embedded projects.

    The Emic 2 is really marketed to microcontroller hobbyists: Make Your Arduino Speak! sorta thing. But I wanted to make a DECTalk-ish hardware box, with serial input, a speaker, and switchable headphone/line jack.  [tɒk bɒks] (a fair IPA approximation of how I pronounce “Talk Box”) is the result.

    Hardware

    • Parallax Emic 2 Text-to-Speech Module
    • OSEPP FTDI USB-Serial Breakout — there are many USB-Serial boards that would do this, but two points in this one’s favour are: i) it has header pins for breadboard use, and ii) I had a spare one.
    • Small 8Ω speaker element — the one I used is most likely a headphone element, bought from Active Surplus (RIP). This should be as small as you can get away with (and still hear) as the USB-Serial connection isn’t designed to supply audio power.
    • Header pins and sockets
    • Toggle switch
    • Small project box with perfboard
    • Jumper wires and solder

    Connections

    Emic 2             Serial
    ======             ======
     GND                GND
     5V                 Vcc
     SOUT               RXD
     SIN                TXD
    
    Emic 2             Speaker
    ======             =======
     SP-                -
     SP+  (via switch)  +

    Using it

    You’ll need some kind of serial terminal connection. In a pinch, you can use the serial monitor that is in the Arduino development environment. Either way, identify your serial port (/dev/ttyUSBN, COMN:, or /dev/tty-usbserialNNNN) and find a way to send 9600 baud, 8N1 characters to it. Hit Return, and you should be greeted by the Emic 2’s : prompt (or a ?, followed by :). Whether you get the prompt or not depends on whether local echo is set or not. Either way, try sending this line:

    SAll watched over by machines of loving grace.

    You should hear a voice say the title of Richard Brautigan’s lovely poem All Watched Over by Machines of Loving Grace (caution: video link contains nekkid hippies). You should get the : prompt back once the the speech has stopped. And that’s all there is to it: send an S, followed by up to 1023 bytes of (basically ASCII) text, followed by a newline, and it will be spoken. There’s more detail, of course, in the Emic 2 documentation and the Emic 2 Epson/Fonix DECTalk 501 User’s Guide for changing voices, etc. Yes, you can make it sing. No, you probably shouldn’t, though.

    Notes

    1. The Emic 2 has no serial flow control, so you have to wait until the module stops speaking (or you send it the stop command) before you can send more. The easiest way is to poll the serial port and see if there’s the : prompt waiting. Until you see the prompt, any text you send it may be lost.
    2. The Emic 2 is an embedded device: Unicode is a bit of a stretch. It’s supposed to accept ISO Latin-1 8-bit characters (handy for Spanish mode), though.
    3. Starting every speech line with S may make this board incompatible with assistive technology software such as the JAWS screen reader. I don’t think that this was the goal for Emic 2’s designers (Grand Idea Studio), however.
    4. The output from the audio jack has a fair bit of noise on it, and you need to set the volume quite low to avoid hiss and hum. Your experience may be different, as I may have accidentally made a ground loop. There is an  audible click at the start and end of the text, too.
    5. The Emic 2 uses DECTalk v5 commands and phonemes. Many DECTalk resources on the web (like these songs) use v4 or older, which are subtly incompatible. I haven’t found a reliable conversion protocol yet.
    6. The board also starts in Epson-style command mode, which uses slightly different commands from standard DECTalk.

    To end, here’s the Emic 2’s “Dennis” voice reading all of Brautigan’s All Watched Over By Machines of Loving Grace:


    (plain link: molg-dennis-140wpm-16khz.mp3)

    (even plainer link if you can’t decode MP2 files: molg-dennis-140wpm.mp3)

    (recorded and edited for length with Audacity. No hippies — nekkid, or otherwise — were harmed in the making of this recording.)

    Resources

    Parallax Inc have rearranged their website and deleted a lot of their archive documents. Here are PDF copies, retrieved from the Internet Archive:

  • “Well, that was unexpected …”: The Raspberry Pi’s Hardware Random Number Generator

    Hey! This is a bit old! Things may have changed and I haven’t necessarily fixed them.

    Most computers can’t create true random numbers. They use a formula which makes a very long stream of pseudo-random numbers, but real randomness comes from thermal noise in analogue components. The Raspberry Pi has such a circuit in its SoC, as it helps making the seed data for secure transactions. It was only recently that a driver for this circuit was supplied. To enable it (on Raspbian): I think the module is enabled by default now for the different versions of the SoC.

    1. Make sure your system is up to date with
      sudo apt-get update
      sudo apt -y upgrade
    2. Install the module:
      sudo modprobe bcm2708-rng
    3. To make sure it’s always loaded, add the following line to /etc/modules (editing as root):
      bcm2708-rng
    4. For some RNG-related stuff, install rng-tools:
      sudo apt-get install rng-tools

    The /dev/hwrng device should now be available, but can only be read by the root user.

    Nico pointed out that you also need to:

    1. Edit /etc/default/rng-tools, and remove the # at the start of the line
      HRNGDEVICE=/dev/hwrng
    2. Restart rng-tools with
      sudo service rng-tools restart

    What random looks like

    random20130606210642random20130606210630

    Random data look pretty dull. Here are random RGB values made with:

    sudo cat /dev/hwrng  | rawtoppm -rgb 256 256 | pnmtopng > random$(date +%Y%m%d%H%M%S).png

    (you’ll need to install the netpbm toolkit to do this.)

    What random sounds like

    Two short WAV samples of, well, noise:

    Yup, sounds like static. It was made with the rndsound.sh script. You’ll need to install sox to run it.

    This is not random

    If it sounds like static, and even if it sometimes looks like static, it may not actually be true random noise. An infamous case of a pseudo random number generator being not very random at all was RANDU, which at first glance appeared to produce nearly random results, but close study showed it to be very predictable.

    I wrote (what I think to be) a C implementation of RANDU: randu.c. While it produces appropriately random-sounding audio data (randu17.wav), if you output it as an image:

    randu17_rgbThose stripes are a giveaway; there should be no order in the output. (Then again, I have no idea if I’ve implemented RANDU correctly.) Testing random data is hard, then — you really need a barrage of tests, and even some of them might fail even for truly random output. Thankfully, when you installed rngtools, it included rngtest, a simple checker for random data:

    sudo cat /dev/hwrng | rngtest -c 1000
    rngtest 2-unofficial-mt.14
    Copyright (c) 2004 by Henrique de Moraes Holschuh
    This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    rngtest: starting FIPS tests…
    rngtest: bits received from input: 20000032
    rngtest: FIPS 140-2 successes: 1000
    rngtest: FIPS 140-2 failures: 0
    rngtest: FIPS 140-2(2001-10-10) Monobit: 0
    rngtest: FIPS 140-2(2001-10-10) Poker: 0
    rngtest: FIPS 140-2(2001-10-10) Runs: 0
    rngtest: FIPS 140-2(2001-10-10) Long run: 0
    rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
    rngtest: input channel speed: (min=67.969; avg=921.967; max=1953125.000)Kibits/s
    rngtest: FIPS tests speed: (min=842.881; avg=3208.336; max=6407.890)Kibits/s
    rngtest: Program run time: 27658884 microseconds

    We were lucky that none of the tests failed for that run; sometimes there are a few failures. RANDU, on the other hand fares very badly:

    ./randu 17  | rngtest -c 1000
    rngtest 2-unofficial-mt.14
    Copyright (c) 2004 by Henrique de Moraes Holschuh
    This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    rngtest: starting FIPS tests…
    rngtest: bits received from input: 20000032
    rngtest: FIPS 140-2 successes: 0
    rngtest: FIPS 140-2 failures: 1000
    rngtest: FIPS 140-2(2001-10-10) Monobit: 730
    rngtest: FIPS 140-2(2001-10-10) Poker: 1000
    rngtest: FIPS 140-2(2001-10-10) Runs: 289
    rngtest: FIPS 140-2(2001-10-10) Long run: 0
    rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
    rngtest: input channel speed: (min=45.630; avg=14255.221; max=19073.486)Mibits/s
    rngtest: FIPS tests speed: (min=23.694; avg=154.238; max=176.606)Mibits/s
    rngtest: Program run time: 141071 microseconds

    See? Lots of failures there. It’s hardly random at all. If you really want to get out testing randomness, there are the dieharder tests. They takes ages to run, though.

    (Note: newish Intel machines also have a real hardware RNG in the shape of Rdrand.)

    I trust you all got the obvious Strictly Ballroom reference in the title?