A Really Neat Trick With The RPi Pico

I imagine that almost everyone knows by now that the RPi Pico is dual-core and probably you also know that the FreeRTOS stack is available to enable multitasking. What I didn’t know until this morning is that there’s a super-simple, super-easy way of taking advantage of both cores without having to go down the RTOS rabbit hole (although FreeRTOS isn’t that difficult, it can, like many other things, be a wee bit daunting to the beginner).

This is a biggie! This apparently simple change just opened up the world of multitasking, multicore programming to absolutely everyone. This neat idea, centred on the Arduino IDE and with the added popularity of the Raspberry-Pi community, is going to be a huge boon to hobbyists everywhere.

So what is this multiprocessor trick? It couldn’t be much simpler. Using the Raspberry Pi Pico Arduino core (“Arduino-Pico”), use these two functions:-

setup1(){}

loop1(){}

That’s it! That’s essentially all you need to know.

By default, Arduino-Pico will use the normal setup() call to initialize core-0 of the processor, but if it finds that a setup1() function exists, it will initialize core-1 of the processor with the contents. This happens more or less simultaneously at start-up.

Likewise, while core-0 will run code contained in the default loop() function, core-1 will run the code contained within the loop1() function.

There are also a couple of other calls in there which will help you communicate between the two cores and which are also really simple to use. Rather than trying to describe them, I’ll just leave you with a link to a demo program (which will run a WiFi network scan on core-0, while simultaneously running a fader on the on-board LED using core-1).

Hopefully, this change will be picked up on other platforms (ESP32 anyone?) and become an integral part of the Arduino IDE; in the meantime, have fun running multicore on the Pico, quickly and easily!


The Arduino-Pico core is available from Earle F. Philhower’s GitHub repository.

Excellent documentation for the core is also available.

Advertisement

The Daily Steal:- 11th Gen Jasper-Lake Bargain

Today’s daily-steal is actually a double, in that the same deal has two different models for almost the same price. These systems are currently available on Amazon U.S. and, although they’re not the absolute cheapest Mini-PCs available, they certainly are very good value for money, taking into account processor, memory, M2.SSD storage and peripherals. Both systems come with the same Intel N5095 processor and the same, basic port configuration.

The Amazon page has a selection box to choose between the 128GB and 256GB models and, as the 256GB model is only U.S. $4 more than the 128GB model, the choice seems to be pretty obvious.

The 8GB/128GB model is currently selling for U.S. $135 and the 8GB/256GB model is U.S. $139.

These are Beelink Mini-S machines, which means that they do not come with the USB-C port of the U59 models, but they still have 4 x USB-3 (type-A) ports for external disks. The RJ45 is 1GbE and there are dual HDMI ports on the back panel.

For those of us outside of the U.S., these systems can still be shipped (by Amazon) to most regions for a moderate extra cost, but you should be aware that you may have to pay additional import duties, too. Please also note that the shipping and import duties will change, depending upon which of the two models you choose.

Gemini-Lake Mini-PC

Right now, we seem to be on the cusp of a dramatic drop in PC prices (given the end of lockdown buy-ups and looming “Black Friday” sales) and we’re certainly starting to see some interesting deals appear in the mini-PC market already.

Photo courtesy of GMKtec

Here’s one attractive, pre-Black-Friday deal already available from Amazon.com. It is currently available for $100 ($129.99 listed price with a $30 discount coupon available). As far as I can tell, the coupon code is good for non-US purchasers too (there’s nothing that I can see in the Term & Conditions related to geographical location), but remember that you will be charged for transport and import fees, even assuming that Amazon will ship to your country.

If you can’t get it from Amazon in your country, GMKtec are running a “free, worldwide shipping” offer on their own web shop too, although the deal isn’t quite as sweet.

As you can see, although it’s a Gemini-Lake based system, it does have multiple USB-3 sockets, as well as both VGA and HDMI video (not to mention the snazzy, Cisco-esque ventilation hole pattern). It is also advertised as coming with 6GB of main memory and 128GB of eMMC, which is pretty decent.

Now I have to say up-front that I don’t own this particular model, but I have been running its baby-brother for a couple of years now — an N4000, 2-core system, badged by a different maker, but almost identical in the external configuration of ports. It runs FreeBSD, providing standard LAN services (unbound, nsd, NTP and DHCP) and has 20TB of disk storage attached across the multiple USB-3 ports; mainly providing back-up services to other machines on the LAN via ZFS send/receive and Jim Salter’s excellent “syncoid”. As well as all of that, it also runs multiple VMs. To date, it has provided me with sterling, trouble-free, 24/7 service.

The point is though, that my 2-core machine only came with 4GB of memory and a 64GB eMMC and it still works perfectly adequately as a headless server, so I think the 4-core model above, with its 6GB/128GB configuration should be a pretty reasonable investment for similar workloads (in case it’s not obvious, I wouldn’t advise anyone to buy this system as a desktop workstation).


The small(ish) print:-

  • I have no relationship (not even as a customer) with GMKtec, nor (as already mentioned above) do I actually own any of their products.
  • This is not the newest or best machine on the market. It does come in at an extremely attractive price, though.
  • Unlike the RPi range, it is available (I know, I’m going to get shirt for that remark).
  • You may want to wait to see what the Black Friday prices on N5105-based Jasper Lake systems are like.

New Kid on the BLEck

For anyone who hasn’t already heard yet, yesterday saw the release of yet another contender for the ESP’s cheap, small and connected WiFi device crown. This one comes from the Raspberry Pi stable and is a revamp of the RP2040 “Pico” which, in this new Pico-W variant, now sports a shiny, new Infineon  CYW43439 WiFi module to provide 802.11n connectivity.

My tongue-firmly-in-cheek title typo refers to the fact that the module also includes the hardware for both Classic Bluetooth and Bluetooth Low Energy …but unfortunately neither are actually enabled in this initial version of the Pico-W.

The great news about this new board is that it is cheap ($6 US) and actually available (unless, like me, you happen to live in Japan, in which case you can settle in for another 8-month wait while the Japanese government decide whether they’re going to “hanko” the approval or not — fun fact:- the Pi Zero 2W was released on October 28th, 2021, but only became officially available in Japan a couple of weeks ago).

The Pico-W certainly looks interesting (a lot more so than the non-WiFi original) and might be a real contender, with Eben Upton hinting in his announcement post that the pipeline is in place to produce millions of these boards (he was referring to the Pico family, not specifically the Pico-W). With the supply lines in place to get these into customer’s hands at a reasonable price across a large part of the globe (Element14, RS, Digikey and Mouser), they might well become the new, go-to board for connected projects. An SDK is already available for C/C++ and a network capable Micro-Python image also already exists.

If you’re looking to get your hands on one (and I do mean “one”), I can vouch for the fact The PiHut in the UK still had stock a few minutes ago and will ship internationally without breaking the bank.

Ah …seems like I might have snagged their last one. Sorry!

Pre-Black-Friday Bargains, Japan Style

For anyone else in Japan, here’s a bargain you can pick up from Amazon Japan’s “Featured Deals” in Laptops this morning (24th Nov 2021). Take a look at the 16″ LG at the right (enlarged version below).

And just in case you’re not familiar with the Japanese Yen conversion rate; this morning $1 US is worth 115 Yen and one U.K. pound is worth 154 Yen. That’s a fabulous discount of a fraction of a penny.

Yup, someone at Amazon Japan has a sense of humour.

An ESP32 project worth looking at…

…especially if you’re a farmer.

You might have noticed that it has been fairly quiet around here recently. That’s mainly because real life has been getting in the way quite a lot, but also because what little spare time I have has been taken up by a new project. I’m not ready to spill the beans on what that project is quite yet, but you can get a couple of fairly strong hints on what direction I’m going (!) by taking a look at the beautifully executed work of Matthias Hammer (and his daughter) on their autonomous equipment project. Note that Matthias isn’t limiting his work just to autonomous control of the tractor, but is also extending the project to automate the other agricultural equipment that he uses.

Matthias is using ESP32s in his project as replacements for the Arduinos used in the base AgOpenGPS project. He has a few videos up on YouTube giving a guided-tour through the equipment, as well as showing the tractor at work. If you’re at all interested in GPS/RTK and autonomous vehicles, his (short) videos, GitHub repository and the AgOpenGPS web site are all worth a visit (even if you’re not a farmer).


You could have used a 555!

Yup, the most frequent comment on Hackaday, “You could have used a 555 for that”. Well, I did. In fact, I used a pair of 555s …but probably not the sort you’re thinking of.

A pair of 555s

A few years back (see date-code photo, below), I found these batteries in a local equivalent of the “Dollar Store”. They only came in pairs, which made them more than twice as expensive as the normal, no-name AA alkaline cells, but with that branding I had to get at least one pack.

I used them (probably in one of my PIC projects back then) and then forgot about them, until I was scrambling to find some not-quite-so-dead batteries to check an ESP01S project a couple of weeks back and found them at the back of a drawer.

I popped the DVM probes on them (unloaded, of course) and was very surprised to see a healthy 1.5v reading.

Well okay, lets fire this thing up and see what happens! What happened was that the ESP01S blue LED flashed, then …nothing. Turning one of them upside-down, the date code reminded me that it was very many moons ago that I last used them.

"555 - 2013-09"

They certainly didn’t owe me anything, but I wondered what the voltage had gone down to under load. Having had lots of experience with these el-cheapo batteries, I wasn’t at all surprised to see that the voltage across the cell swung well into negative territory when I held down the “On” switch. What still surprised me was that the voltage swung almost straight back to that “healthy” 1.5v reading once the load was removed. Usually these cells are hard-pressed to register a no-load voltage of 0.9 ~ 1.1v in their fully depleted states.

Maybe these we’re just catching their “second wind” …or maybe they do have a 555 hidden inside them after all!

-1.33v displayed on DVM when load applied
…wth load
1.54v reading on DVM from single cell
No load

The ESP01S board wouldn’t stay powered with these batteries in the pack, so I had to hold down the “On” switch long enough to snap the photo.


No ESP01S modules were harmed in the production of this blog post, but it probably didn’t do my poor little 555s much good.

FreeBSD Notes: 13-Release and bectl

We’ve had several release candidates (at least one more than expected) of FreeBSD-13, of which I’ve tested the later ones as VMs on a 12.2-p6 host and found them to be lightweight and sprightly. So, when the final release was announced last week, I didn’t have any particular qualms about updating said 12.2 system to release 13.0. Having said that, FreeBSD makes it particularly easy to add belt-and-braces insurance to your updates nowadays, using “bectl“.

If you haven’t come across bectl before, I would heartily recommend that you check it out and read the manual page before you start any future upgrades. The “be” part of the name stands for “Boot Environment” and this extremely useful tool helps us to manage our ZFS filesystems to allow virtually risk-free changes to our root filesystem without needing to get deeply into the nitty-gritty of snapshots, rollbacks and boot menus. Yes, it only works through the magic of ZFS, but it’s just another reason why you definitely should be using this filesystem everywhere (even on your laptop).

bectl” will enable us to quickly create a snapshot of our current root filesystem, add that snapshot to our “beastie” boot menu and, importantly, then allow us to create a completely new clone of the existing snapshot (which we can then upgrade or change in whatever way we want) and optionally make that updated filesystem available as the default boot for our machine. This means that we can install an upgrade (in my case, release 13.0) and boot it immediately, but still have the option of selecting our original root from the boot menu, if things don’t quite go to plan.

Before we start the actual upgrade, just a couple of words of warning…

  • As noted above, the system must be using root on ZFS.
  • It should be running the GENERIC kernel.
  • We should be starting from a recently updated version of the previous major release (ie:- 12.2-p6 if updating to 13.0).

How do we prepare our system in advance of the actual upgrade? It couldn’t be much easier. The “back-up” boot environment will be the root filesystem which we have now. We will create a new clone of this existing environment to work on during the 13.0 install (leaving the original untouched).

First, we check our current boot environment with:-

root#   bectl list -D

BE              Active Mountpoint Space Created
default         NR     /          10.2G 2020-02-16 18:02

The bectl list command shows the currently available boot environments and the “-D” argument shows the space used. The “Active” column shows an “N” for the boot environment which is in use right Now and an “R” for the boot environment which will be activated on the next Reboot. In our case, we only have one boot environment, so it is both active and selected to be used on the next reboot.

To create the cloned (work) boot environment, we do:-

root#   bectl create 13.0-RELEASE

root#   bectl activate 13.0-RELEASE

The “create” is obvious. The “activate” command tells the system that we want to use the new, “13.0-RELEASE” boot environment at the next reboot. When we use the “list” command again now, we should see something similar to this:-

root#   bectl list -D
BE              Active Mountpoint Space Created
13.0-RELEASE    R      -          369K  2021-04-22 08:32
default         N      /          10.2G 2020-02-16 18:02

…indicating that “default” is currently in use, but that “13.0-RELEASE” will be used on the next reboot. If everything looks okay (and there were no error messages from the bectl commands), we can go ahead and reboot our system. It should boot as normal and look exactly the same as before (we haven’t actually changed anything on the filesystem yet, so we’re still running 12.2-p6). However, if we were to do another bectl list -D we’d see that the “Active” column would now show “NR” for 13.0-RELEASE and just “-” for “default”.

Do not proceed with the upgrade steps below unless you see the “NR” active status for the “13.0-RELEASE” boot environment.

Having checked that we’re using the cloned root filesystem, we can now go ahead and use that other wonderfully useful utility, freebsd-update, to start the actual upgrade process:-

root#   freebsd-update -r 13.0-RELEASE

Note that “13.0-RELEASE” in this command is specifying which release we want freebsd-update to upgrade to, not where we want to install it. We simply follow the instructions which freebsd-update gives as it goes along (we will need to reboot a couple of times to complete the full upgrade process).

If everything goes as planned, after the final reboot we should have a working FreeBSD 13.0 system.

My upgrade process went smoothly; all system utilities came back up and the VMs ran with no problems. Everything looked fine …until the first, automated, weekly reboot rolled around. The machine didn’t come back up. The console was complaining that there was a fatal ZFS error with the main user-data pool (zstore00 – not the root filesystem). I had to cycle power on the system to have it reboot and, when it came back up it did indeed show a checksum error on that pool. I cleared the error and initiated a scrub and once everything was stable and had been running for a couple of days, did a manual reboot. It failed again, in the same way.

The actual error shown was;-

uhub2: detached
uhub1: detached
umass0: detached
uhub3:detached
ubt0:detached
Solaris: WARNING: Pool zstore00 has encountered an uncorrectable I/O failure and has been suspended.

At that point the actual shutdown process hung solid and, as before, I needed to power cycle the system to have it come back up. I also tried updating the /boot/loader.conf file (as suggested in Graham Perrin’s very useful guide) and rebooted a couple of times manually, but to no avail.

Note that I had not run zfs upgrade on the pools, since this would have made it very difficult to roll back.

So, at this point I needed to get the system back up and running and decided to do that roll-back to 12.2. Here’s how you can do that…

Power cycle the machine (if you’re stuck with a hung system, as above) and once the beastie menu appears, wait a second for the additional options to appear at the bottom (it takes the boot process a moment or two to collect the boot environment listings) and then select the “Select Boot [E]nvironment…” option. You’ll get another, short menu where you can use #2 to cycle through the boot environment names until you see “default” displayed. At this point you can simply hit Enter to have the system select and boot into this saved environment.

Your system will now boot into the original 12.2-p6 root filesystem and work as before. The only minor issue that you have is that booting from the beastie menu only sets the boot environment for this one-time boot, so you must use bectl activate default to have your 12.2-p6 environment set as the permanent boot environment (if you do a bectl list -D at this point, “default” should now have “NR” showing in the Active column).

Looking a little closer at the listing you’ve just done, you’ll also notice that because we’ve actually got a complete 13.0 install on the alternate “13.0-RELEASE”, it now shows a much greater space-used than before (in my case around 12GB).

Great price on an Atom Z8350-based system (plus a giggle)

As regular readers know, I occasionally take a dive into the world of mini-pcs (especially low cost models) in my quest to get the best bang for the buck/watt. On my travels through the depths of Aliexpress this morning, I came across very reasonably priced Z8350-based system. It’s not going to blow the doors off, but I have a soft spot for these boxes, simply because they do so much for what they are.

This one is a design which is new to me, sporting more USB ports than normal, as well as both VGA and HDMI video ports. You’ll need to be careful though, as the retailer seems to be a bit confused about what hardware they’re selling …in the product “overview” they state it has 2 x USB3 and 2 x USB2, but the images clearly show 1 x USB3 and 5 x USB2 ports. The header of their advert also rather vaguely claims “support 2.5 inch HDD”, but (despite the extra height of this case compared to other models) there are no obvious SATA headers on the motherboard pictures and in the overview they only mention support of “external” disks.

They’re also a bit on the boastful side about the service they provide (hence the “giggle” in the title of this post — see image, below).

The price for the 4GB/32GB model is a modest $84.45 (plus $3 shipping to my part of the world). Although these boxes are sold as “Windows 10” machines, I certainly wouldn’t advise anyone to try running Windows on the 32GB eMMC model, as the initial download of updates will overflow the available storage space.

As I’ve mentioned before though, these machines make excellent little low-cost, low-power-usage servers for anyone doing 24/7 self hosting (I’ve even got a similar box with more than 12TB of USB disks hanging off the back as a back-up server on my home network). This version also comes with 4GB of main memory, which is 2GB more than my original Z8350 based system (which has been running 24/7 since Dec 2016).

Please note that I don’t own this exact system, so I can’t verify its actual hardware configuration or performance. I haven’t ever used the supplier SZMZ before either, so I can’t vouch for their delivery times or packing. Another point to note is that although SZMZ has a very impressive 100% feedback rating, it is only based on two orders (at the time of writing). All the same, this looks like a nicely built mini-pc (with more ventilation holes than equivalent models, if nothing else).


‡  —  As to the strangely worded phrase in their advert, I’m working on the assumption that what they’re trying to convey is that different builds and versions of this model are available  …or maybe the copywriter just took this chance to broadcast their views on men in general.

Will it mirror?

Pic of (old) Laptop with SSD attached to lid

Here’s another silly one for you. What do you do if the latest release of your OS of choice ships with ZFS, but you don’t have space in your laptop for a second disk? …Answer:- Reach for the velcro.

This Sony Vaio has a Centrino Core-2 p8600 processor, so it’s not going to break any speed records, but it works well enough for day to day use. Courtesy of the Buffalo 500GB SSD taped to the lid, it now sports 1TB of disk space (500GB mirrored), which is probably well in excess of what the designers originally envisaged.

Centrino.2 sticker next to USB ports

This is one of those little “because I can” projects which I don’t necessarily recommend to anyone else, but at the same time, the lightness of an SSD compared to a normal hard-disk (even a 2.5″ one) means this is now an eminently practical solution if your old laptop happens to be running out of space (I do move the laptop around the house to work in different rooms at different times, but it generally doesn’t travel much further afield than a deck-chair out on the veranda).

So, will it mirror? Heck yes!

Should I mirror?

No, probably not. It’s much more sensible to use a periodic ZFS send/receive job to back up your work to an existing server, that way you don’t need to worry about the extra drain on your battery and you still have your work if your laptop is stolen or knocked off the deck of your yacht, mid-ocean (what, you mean that’s never happened to you?).

One other consideration when thinking about installing Ubuntu on ZFS — currently (as of 21.04) Ubuntu will not allow you to edit the size of the disk partitions; you must accept their optimized defaults. Unfortunately , those defaults include a /boot partition which is much too small (typically 2GB). It will work fine for a couple of months, but with every apt update, the system will automatically add a snapshot of the boot partition. When the upgrade includes a kernel update, this means that tens, or even hundreds of megabytes of storage can be used. Even when you set the system defaults to compress the kernels using “xz”, it doesn’t take too many updates before you start getting “not enough free space” messages from apt and it will refuse to continue with the update. This is not something a novice user can easily recover from (hint: deleting files on a ZFS partition doesn’t always return that free space to the system — it all depends on whether it is still being held by a snapshot).