Stephen Smith's Blog

Musings on Machine Learning…

Technology Predictions for 2022

leave a comment »


Last year, I made my technology predictions for 2021. In this article, we’ll see how those predictions did and make some new predictions for 2022. This last year has seen a lot of challenges with the continuing pandemic and problems with the global supply chain. We’ve had a year of chip shortages affecting everything in high tech, which has caused prices in many categories to sky rocket.

The CPU Wars Rage On

Last year, we predicted the continuation of the heated CPU war between AMD and ARM as they adopted new chip technologies and increased their power and improved their power consumption. During 2021, Intel tried to make a comeback with new CPUs, but Intel’s main problem remains power consumption. The Intel chips have great performance if you can provide them enough power and have the technology to keep them cool. Until Intel finds a way to produce chips with comparable power consumption and heat production as existing chips from both AMD and ARM, it will keep playing catch up and see its market share decline. Even in data centers where Intel is king, they are having problems as power is a major cost to the data center and data center operators are moving to more efficient chips to save money.

ARM had a great year, capped off with Apple’s release of new MacBook Pro’s with its M1Pro and M1Max chips. Even with the distraction of nVidia’s attempted acquisition of ARM, we are still seeing big steps forward including their new v9 architecture, and new chips coming out from all their partners. At the low end, ARM saw the Raspberry Pi foundation release the RP2040, which isn’t the first ARM microcontroller, but is the first to see some real success.

A lot of people are rooting for RISC-V, the more open contender in the CPU battles, but besides some success in the microcontroller market, these chips remain quite expensive with performance lagging quite far behind inexpensive ARM chips.

New Generations of Graphics Cards

2022 will see nVidia and AMD releasing new generations of their graphics cards. Plus Intel is entering the discrete graphics card market this coming year. All the stories in 2021 were about lack of supply. It has been pretty much impossible to buy a good graphics card, especially if you are looking to build a custom system. Hopefully, with China banning Cryptocurrency mining and hopefully other countries following, we should see the supply of graphics cards restored to some normalcy.

Crypto-mining has been a big problem for gamers, causing shortages of graphics cards and RAM. Hopefully, either crypto is on the decline or the graphics card companies can ramp up production to serve everyone. Gamers are pretty mad at nVidia right now as it seems nVidia has been favoring shipping cards to the miners, probably because of the volume.

Ransomware & Hacking

We predicted a continuing upswing in hacker activity. Ransomware attacks were way up. Since quite a few companies elected to pay the ransom, these are perceived as profitable and hackers everywhere are jumping into the game. Last year was bad and next year will be worse. We are just finishing the year with a serious log4j vulnerability that is affecting huge sections of the web and corporate applications everywhere.

Self-Driving Cars

I predicted a bigger uptake in self-driving cars than actually happened. They are being used as taxis in some cities as well as on university and corporate campuses. There are self-driving cars out there as lots of people are getting tickets for sleeping while their cars drive them around. Self-driving cars are only one category of new products leveraging advances in AI technology. Other technologies such as translation, image recognition and auto-suggestions are improving day by day.

Raspberry Pi 5

The Raspberry Pi 4 was released in 2019, so I’m predicting we are due for a Raspberry Pi 5. Last year, we got the Raspberry Pi Pico microcontroller, so I think it’s the full Pi’s turn for a new version. My big feature request is an M.2 connector so a regular SSD harddrive can be connected. The current bottleneck and weakness in the Pi is the microSD card it uses as a disk drive. I find the 8gig Raspberry Pi 4 has plenty of memory, so not sure we need a 16gig version, but why not? Otherwise, adding a better way to expose PCI lanes to allow custom integrations of high performance peripherals, perhaps even graphics cards. It would also be nice if they switch the built-in GPU from that Broadcom thingy to a proper ARM Mali GPU. Now that ARM designs their RP2040 SoC, it will be interesting to see if they stick with a Broadcom SoC, or switch to one that they design themselves?


In spite of the supply chain and pandemic problems, last year was a good year for tech. As the supply chain problems get resolved and Covid lessens, we should see progress accelerate. I’m looking forward to seeing all sorts of new products with faster, more efficient CPUs and GPUs and better, smarter software incorporating AI technology behind the scenes.

Written by smist08

December 17, 2021 at 10:53 am

Assembly Language is Number 8

with 2 comments


Tiobe regularly produces a list of the most popular programming languages and their recently published list has Assembly Language at number 8, moving up from number 16 last year. The top eight languages are:

  1. Python
  2. C
  3. Java
  4. C++
  5. C#
  6. Visual Basic
  7. JavaScript
  8. Assembly Language

The top spots are all well established and well used, C shows remarkable resilience and Java remains popular, in spite of Oracle. In the early days of the PC, all major applications and games were written in Assembly Language, but with the availability of high quality C compilers, this waned and application development switched to C and then other high level languages. Let’s look at why Assembly Language is having a bit of a renaissance.

Assembly Language is Accessible

In the early days, you needed to buy a macro assembler from the chip manufacturer or some other vendor, such as Microsoft’s MASM. Now, all the chip vendors add their Assembly Language support directly into the open source GNU Assembler and/or the LLVM Assembler. Both of these are excellent macro assemblers, run on any hardware, support cross compiling and best of all are completely free.

In my first job out of university, I did some Assembly Language programming on an Intel 80186 board and to debug it, I needed to use an in-circuit emulator (I2ICE) which was a big expensive piece of hardware that replaced the CPU with a debugging probe. Now, all the CPUs and boards have excellent debug probes and you can debug them using open source tools like GNU’s gdb.

Another big help are all the great books on Assembly Language that are available such as: “Raspberry Pi Assembly Language Programming”, “Programming with 64-Bit ARM Assembly Language” and “RP2040 Assembly Language Programming”.

Microcontrollers are Everywhere

The Arduino microcontroller has created a giant community of DIY electronics hobbyists. There is a huge proliferation of inexpensive microcontrollers. In the Arduino world, you program these in Arduino C, but often to get the performance you need, you need to drop down to Assembly Language. Similarly, the memory on these boards is limited, and Assembly Language is the only way to get use of every single bit available to you. With the newer microcontrollers like Raspberry’s RP2040 which are based on ARM 32-bit M-series CPUs, these are much more powerful and have more memory. However, with the extra power, people are attempting more ambitious projects, often involving machine learning applications or other compute intensive applications. Again, they hit the wall with C or MicroPython programming and have to delve into Assembly Language to solve their problems.

When people program these microcontrollers, they are connecting to all sorts of imaginative hardware devices, and they have to create their own libraries to interface to these and often the best way to do this is via Assembly Language.

Competition in the Phone App Market

The App markets for both iOS and Android have matured where as new versions come out, there are fewer changes. The competition between various Apps in a given category is intense and one key way for vendors to differentiate themselves from their competition is via improved performance. Beyond re-writing code to use more efficient algorithms, programmers are turning to hand-crafting the core routines of their Apps into Assembly Language.

Machine Learning

Machine Learning (ML) or AI is extremely compute intensive. There has been a proliferation of coprocessor boards for performing ML computations. All these coprocessors need to be programmed in their own native Assembly Language. Similarly, although you can program nVidia GPUs in CUDA C, to get the absolute most out of a board, you need to delve into the board’s native Assembly Language. Most of the ML libraries are built over top of older Linear Algebra mathematical libraries written in Fortran. As people take on harder and harder problems and need to get useful work done out of every CPU cycle, many routines are being re-written in Assembly Language.


Modern applications are usually written with a number of modules, each module written in the best programming language for the module’s function. Perhaps C for a back end process, JavaScript for a web page and then Assembly Language for important performance critical routines. I don’t think anyone is taking on large applications in 100% Assembly Language, but enough Assembly Language is making its way into applications to move it up the Tiobe index.

Assembly Language is a great way to learn about how computers work and you might want to take a look at one of my books on the subject.

Written by smist08

November 13, 2021 at 4:47 pm

Posted in assembly language

Tagged with ,

RP2040 Assembly Language Programming

with 6 comments


My third book on ARM Assembly Language programming has recently started shipping from Apress/Springer, just in time for Christmas. This one is “RP2040 Assembly Language Programming” and goes into detail on how to program Raspberry’s RP2040 SoC. This chip is used in the Raspberry Pi Pico along with boards from several other manufacturers such as Seeed Studios, AdaFruit, Arduino and Pimoroni.

Flavours of ARM Assembly Language

ARM has ambitions to provide CPUs from the cheapest microcontrollers costing less than a dollar all the way up to supercomputers costing millions of dollars. Along the road to this, there are now three distinct flavours of ARM Assembly Language:

  1. A Series 32-bit
  2. M Series 32-bit
  3. 64-bit

Let’s look at each of these in turn.

A Series 32-bit

For A Series, each instruction is 32-bits in length and as the processors have evolved they added features to support virtual memory, advanced security and other features to support advanced operating systems like Linux, iOS and Android. This is the Assembly Language used in 32-bit phones, tablets and the Raspberry Pi OS. This is covered in my book “Raspberry Pi Assembly Language Programming”.

M Series 32-bit

The full A series instruction set didn’t work well in microcontroller environments. Using 32-bits for each instruction was considered wasteful as well as supporting all the features for advanced operating systems made the CPUs too expensive. To solve the memory problem, ARM introduced a mode to A series 32-bit where each instruction was 16-bits, this saved memory, but the processors were still too expensive. When ARM introduced their M series, or microcontroller processors, they made this 16-bit instruction format the native format and removed most of the advanced operating system features. The RP2040 SoC used in the Raspberry Pi Pico is one of these M Series CPUs using dual core ARM Cortex M0+ CPUs. This is the subject of my current book “RP2040 Assembly Language Programming”.


Like Intel and AMD, ARM made the transition from 32-bit to 64-bit processors. As part of this they cleaned up the instruction set, added registers and created a third variant of ARM Assembly Language. iOS and Android are now fully 64-bit and you can run 64-bit versions of Linux on newer Raspberry Pis. The ARM 64-bit instruction set is the topic of my book: “Programming with 64-Bit ARM Assembly Language”.

ARM 64-bit CPUs can run the 32-bit instruction set, and then the M series instruction set is a subset of the A series 32-bit instruction set. Each one is a full featured rich instruction set and deserves a book of its own. If you want to learn all three, I recommend buying all three of my books.

More Than ARM CPUs

The RP2040 is a System on a Chip (SoC), it includes the two M-series ARM CPU cores; but, it also includes many built in hardware interfaces, memory and other components. RP2040 boards don’t need much beyond the RP2040 chip besides a method to interface other components.

“RP2040 Assembly Language Programming” includes coverage of how to use the various hardware registers to control the built-in hardware controllers, as well as the innovative Programmable I/O (PIO) hardware coprocessors. These PIO coprocessors have their own Assembly Language and are capable of some very sophisticated communications protocols, even VGA.

Where to Buy

“RP2040 Assembly Language Programming” is available from most booksellers including:

Currently if you search for “RP2040” in books on any of these sites, my book comes up first.


The Raspberry Pi Pico and the RP2040 chip aren’t the first ARM M-series based microcontrollers, but with their release, suddenly the popularity and acceptance of ARM processors in the microcontroller space has exploded. The instruction set for ARM’s M-series processors is simple, clean and a great example of a RISC instruction set. Whether you are into more advanced microcontroller applications or learning Assembly Language for the first time, this is a great place to start.

Written by smist08

November 5, 2021 at 10:42 am

Windows 11 Appears on my Laptop

leave a comment »


Microsoft Windows 11 released on October 5, 2021 approximately six years after the release of Windows 10. At the time of Windows 10’s release, Microsoft said Windows 10 would be the last release of Windows with all improvements rolling into incremental Windows Updates released twice a year. I guess the marketing honchos at Microsoft got tired of this strategy, decided to put fresh lipstick on the pig, and roll out Windows 11. Windows 11 didn’t roll out to everyone at once, and the update only became available to my laptop the other day (Oct. 27, 2021). I let it download and install and this blog post are some of my early impressions and what this new release brings.


Most people don’t install new versions of Windows, rather they get the latest version when they purchase a new computer. This is because usually a new version costs money and installing a new operating system can be problematic and difficult. If you are running Windows 10, then upgrading to Windows 11 isn’t any more difficult or time consuming than installing one of their half yearly updates and like the updates is free. The installation didn’t take any longer than an update and didn’t ask any additional questions, besides the usual agreeing to the EULA. Basically it just felt like any other Windows 10 update, and didn’t even feel like a particularly big one.

There is some controversy that Windows 11 requires newer hardware than Windows 10, but in my opinion Windows 10 probably didn’t run particularly well on this old hardware anyway and I would recommend switching any hardware that doesn’t support Windows 11 to running Linux. Linux runs great on older hardware and lets you get a lot more life out of your computing equipment rather than filling up the landfills. The main point that is annoying people is a requirement for the TPM (Trusted Platform Module) which isn’t particularly popular and tends to be the limiting factor. There are workarounds to this, but again, I would switch to Linux if this is an issue.

The Same but Different

My question about Windows 11 was: what is different? The signon screen is the same with the same nice picture and text. When I logged in, my desktop background was the same and all the icons on the desktop were preserved. From a distance, to me it looks pretty much like Windows 10. The first thing I noticed was that the icons on the taskbar are centered rather than on the left. There were some new things on the taskbar to poke at and as usual, Microsoft added back their programs that I had previously removed like the Edge browser. The other differences are more subtle and led to a bit of head scratching as I performed my usual work.

The Start menu has been split into three: the start menu, search and widgets. Widgets contain the same useless things that used to clutter the start menu, it’s nice they are separated out to be ignored, it would be nicer if there was an option to delete them entirely. Search is the useful option that I use to find and launch programs that aren’t pinned to the taskbar or on my desktop. The Start Menu has the same functionality as Windows 10 without search, but has more promotion built in, it has programs that you don’t have installed, like Adobe Lightroom, that if clicked start installing. I think Search is the good way to start programs, and I’ll likely ignore Start and Widgets entirely.

The Start Menu

One change that was a bit of a head scratcher is that the right click menus are different. For instance cut, copy, paste, etc. are icons, with no text, along the top of the menu and then other items seem rearranged. I’ll get used to this, but it did slow me down and reduce my productivity for a day or two.

Note the small icons at the top of the menu for copy/paste type operations.

The fonts and color scheme are a bit different than Windows 10, but I suspect this could have been achieved by simple customization. Anyway, I actually like the color scheme and font a bit better than Windows 10, so I’ll count that as an improvement.

There is a new desktop manager, so you can have multiple desktops and switch between them. This is a clone of a MacOS feature that I have never used and I suspect I’ll never use the Windows 11 feature either. This might be more useful for people that work, who can keep a work versus personal desktop or kids that have a personal versus parent-facing desktop.

Other Changes

Supposedly, Windows 11 handles the transition between laptop and external monitor better. I haven’t tried this, but it can’t be any worse than Windows 10.

The touchscreen support is advertised as better, but my laptop doesn’t have this, so I don’t know.

There are more gaming features ported from the XBox. I found the previous support pretty good, but I think this is good for gaming overall that Microsoft is committed to Windows gaming and not just selling XBox consoles. After all, the truly great gaming rigs are all PC based with top of the line graphics cards that typically cost several times the cost of an XBox.


Windows 11 really feels like the second half of 2021 Windows 10 update. I know this is a separate different update, and why Microsoft created both of these, I have no idea. I imagine it’s to do with corporate licensing and support agreements. That aside, this seems like a good update to Windows 10, there are changes in workflow, but for the most part things are familiar. I don’t think things have been moved around so much for the sake of making things different and hence hard to find. I like that the installation is just a simple Windows Update and the color scheme is ok. It would be nice if Microsoft didn’t spend so much time trying to force Edge and Teams down our throats, but that’s going to be a problem with large corporations and not having these sorts of things remains one of the things I like best about Linux. My laptop seems to run about the same as Windows 10, I haven’t seen any performance degradation that some people have reported and so far writing this article in a coffee shop, battery usage seems about the same.

If you are offered this update, I would recommend taking it. If for no other reason, than this is where the main security patches and bug fixes will be going first. Windows 10 will be supported for many more years, but I like to stay with the newest if my hardware supports it and I don’t see any huge red flags like happened with Windows Vista or Windows 8.

Written by smist08

October 29, 2021 at 11:27 am

Posted in Business

Tagged with , ,

The Newest Ubuntu Linux 21.10 Impish Indri

leave a comment »


When you run the Linux operating system, you aren’t running a single project. The core of Linux is the Linux Kernel which is the core of the operating system that handles memory management, multi-tasking, controlling hardware devices and providing useful services for application programs. A Linux distribution takes the Linux kernel and bundles with it other open source projects including applications, development tools, utilities and a graphical user interface. The Linux distribution provides an installer along with an update mechanism to keep everything up to date. Most distributions provide everything already compiled, so you don’t need to build the whole operating system from the open source code.

Ubuntu Linux is a popular Linux distribution that releases a new version every six months. If you’ve run Linux, you know that everything is updated fairly regularly, so what are these six month releases about? The continuous updates tend to be minor point releases with security and bug fixes. The six month releases include newer full version releases. This is where a newer version of the Linux kernel is included along with newer versions of all the applications and desktop GUI interface.

Ubuntu Linux is derived from the Debian Linux distribution. All these distributions are open source, so anyone can take a distribution, modify it and release it as a new distribution. Debian Linux is where the apt package management system originates, which is used for building, installing and updating software. Many distributions are based on this and then several distributions like Linux Mint, Elementary OS, Pop!_OS and Zorin OS are based on Ubuntu Linux.

Each Ubuntu version is named after an animal, in this case the Indri Lemur from Madagascar. We last reviewed the Groovy Gorilla release and the previous release was Hirsute Hippo. Notice how the alphabetic letter increases by one with each release.

New Linux Kernel

Linus Torvalds releases a new Linux Kernel every two to three months. These six month releases provide an opportunity to go to a newer kernel release. The Linux kernel 5.14 just released at the beginning of October which was a bit too new for this release, so the included Linux kernel is 5.13. This is still quite a new kernel and a couple versions higher than the 5.11 in the 21.04 release.

The main thing this gives you is new hardware support. Hardware vendors are always checking in new updates to better support their newest wares. Often older kernels will work with newer hardware, but won’t take advantage of any of the newer features until the support is added to the kernel. Other work in the kernel includes performance improvements and security improvements. Sadly, as security problems have been discovered in newer CPU chips, the fixes have been hurting performance, since some of the more advanced features can’t be used. This has been offsetting other work to improve code performance including using higher compiler optimization levels.

Gnome 4.0

Gnome is the window manager most people using Ubuntu use. You can switch to other Window managers like KDE or Xfce. The improvements to Gnome are subtle but they make the Linux experience a bit better with each release. There is nothing extraordinary about this update, everything works as before. However some of the features make better use of the screen real estate and tasks get a little more intuitive and easy.

Installation and Updates

Linux has a reputation for being hard to install. This is partly because no one ever installs Windows or MacOS, they come with the computer and most people never see the installation experience. There are a few computer manufacturers that ship Linux pre-installed such as Dell and System76; however, most Linux users start by installing Linux over something else.

The various Linux vendors have been working hard to make the installation process as painless as possible. Ubuntu has alway led in this regard and with this release is a newer installer that allows you to get up and running with fewer questions. Most settings are auto-detected and I found the installation painless.

Linux is very good at supporting hardware and chances are you can install this newest release on hardware long out of support from Windows or MacOS. Chances are if you install Ubuntu over Windows on an older computer, it will end up running far faster than you expect.

Lots of Extras

Linux distributions come with a lot of applications for free, including LibreOffice which has been updated to the newest 7.2 release. Of course you can install new versions of applications yourself, but most people don’t and just follow what the distribution gives them. A lot of times the main changes people notice are in the applications.

Not a Long Term Release

This release of Ubuntu isn’t a long term release, meaning it will only be supported for 9 months, after which you are expected to upgrade. You don’t need to upgrade and can use this version forever, you just can’t get direct support from Ubuntu and they won’t keep releasing bug fixes and security patches.

Ubuntu releases a long term release every two years. The next release in April, 2022 will be a long term release which will be supported for at least five years. Many people only run the long term releases as these are perceived as more stable and there is no pressure to upgrade. Personally, I like the half year releases and upgrade to them whether they are long term or not. I like running the newest releases and have found these Ubuntu releases to be quite stable.


Ubuntu is a great release and its release is noteworthy as many other distributions are based on it. I’ve always liked Ubuntu and find it does the jobs I need doing. I’m a software developer, so easily running development tools and libraries like for machine learning is important to me and I find these are usually supported in Ubuntu first, often before Windows, Mac OS and other Linux distributions.

If you are running mission critical server applications, then sticking to the latest long term release is the correct thing to do, but for personnel use, I recommend staying up to date with the latest half yearly release.

Written by smist08

October 23, 2021 at 1:58 pm

Posted in linux

Tagged with , ,

Playing with the Wio Terminal’s Grove Connectors

leave a comment »


When I first reviewed Seeed Studio’s Wio Terminal, I didn’t have any Grove devices to make use of its two Grove connector ports. Since then I received a Seeed Studio Raspberry Pi Pico Grove Starter Kit and that provided me with 13 Grove devices to play with.

The Wio Terminal exposes a standard Raspberry Pi 40 pin header on its back, but some of these leads are wired to two Grove ports on the bottom of the terminal. This gives you one I2C grove port and another port that can be used as either a digital or analy port. There is no UART grove port, but you can use one of them for PWM which isn’t standard but can be configured. If you are using both the 40-pin connector and the Grove ports, then you need to be careful to avoid conflicts, as these are all wired up to the same pins in the SoC.

In this article, I’ll connect the mini PIR (Passive Infra-Red) motion sensor to the digital port. We use the Wio Terminal’s built in display to indicate whether movement is detected or not. The Wio Terminal is nice, in that you don’t need to use another port to connect a display.

Connecting it Up

 The PIR sensor plugs into the right Grove port, which is the one that supports general digital or analog devices. Below is a picture of this in action.

The sensor is quite sensitive, in this case it’s showing the motion of my cell phone taking the picture. At first I didn’t think it was working, since it kept indicating movement, until I realized it was sitting on the table and picking up the vibrations as I typed. To work well, the PIR sensor needs to be secure, so it doesn’t vibrate or move, otherwise it will report on movement of the sensor rather than objects in the room. This sensor works best for objects about two meters away. If you want something for your yard you might consider the Seeed’s non-mini PIR motion sensor. This sensor is good if you want a motion sensitive halloween display to scare the neighborhood kids, motion activated XMas displays or notification if someone comes right up to your door.

The Code

For this project, I’m using Arduino, since I find that environment is the best one for the Wio Terminal. Accessing the PIR motion sensor is easy, it sets the digital pin high if motion is detected and low if nothing is happening. This doesn’t require any special libraries or classes, being such a simple device. Notice the definition of D0, which is used to specify the primary digital pin in the Grove connector, or you could use the pin number which is 13 in this case. This is documented on the Wio Terminal wiki.

For the Wio’s display we use the TFT library like we did in our first impressions article, except we are displaying text rather than graphics. When I first coded this, the flashing was terrible, but after a bit of research on Seeed’s wiki, I discovered I needed to use a sprite to avoid the flashing. With the sprite you do all the drawing to the sprite and then update the display in one quick pushSprite statement. The TFT library for the Wio Terminal is quite powerful, but lacks a good technical reference, so you have to look at the code, or at least the TFT_eSPI.h header file which is quite long, or watch through some tutorial videos. The tutorials have a lot of good information, but are quite long, making them a bit time consuming to refer back to. 

TFT_eSPI tft;
TFT_eSprite spr = TFT_eSprite(&tft);
void setup()
    spr.createSprite(TFT_HEIGHT, TFT_WIDTH);
void loop()
    if(digitalRead(PIR_MOTION_SENSOR))//if it detects the moving people?
             spr.drawString("Movement detected", 30, 60);
         spr.drawString("Watching", 30, 60);


The Wio Terminal is a great way to play in the Arduino world without requiring any soldering or breadboarding. The terminal has lots of useful built-in functionality, and allows you to easily connect up sensors and devices in a plug and play manner. This is great for the classroom where you might not want to supervise a large group of kids playing with soldering irons. The mini PIR sensor was fun to play with and getting the Arduino code working was easy. I find I get projects up and running much quicker with the Wio Terminal, since there is a lot built in, and I don’t get wiring problems, since the Grove connectors have been reliable.

Written by smist08

October 15, 2021 at 11:14 am

Playing with the Seeed Studio Grove Starter Kit for the Raspberry Pi Pico

with 2 comments


Seeed Studios sent me one of their Grove Starter Kits for the Raspberry Pi Pico to review. The goal of this kit is to make working with microcontrollers accessible for educational purposes. No soldering is required, everything snaps together and away you go. This starter kit comes with a carrier board for the Raspberry Pi Pico (sold separately), a number of connector cables and a selection of devices you can connect up.

What is Grove?

Grove is a standardized connector to allow you to connect devices to a microcontroller using a standard cable using four wires. This is similar to how you can connect devices to your laptop via USB cables. Modern microcontrollers like the various Arduino boards and the Raspberry Pi Pico have pins for multiple communications protocols as well as some general purpose digital and analog connections. The Grove connectors standardize how to wire up a number of these including:

  1. UART for standard serial communications
  2. I2C for synchronous serial communications
  3. Digital includes a wire for power, ground and primary and secondary digital signals
  4. Analog includes a wire for power, ground and primary and secondary analog signals

Seeed manufactures carrier boards for several common microcontroller boards. In this case the Raspberry Pi Pico.

The Raspberry Pi Pico fits into the inside pins in the two rows of pin receptors. You can use the outside rows to bypass the Grove connectors and wire the Pico to a breadboard as normal. The Grove ports provide three analog ports, three digital ports, two UARTs and two I2C. There are also breakouts for SPI and debug. Note that the Raspberry Pi Pico I have doesn’t have headers for the debug ports, so doesn’t make use of the debug receptors on this carrier. If you want to avoid soldering altogether, you need to purchase a Pico with pre-soldered headers such as this one.

The carrier board doesn’t have any active components, the PCB routes the pins on the Pico to the correct parts of each Grove connector. 

If you are familiar with the Raspberry Pi Pico, you might know that most of the pins have multiple functions so you can make maximum use of the various pins. The Grove configuration is hardwired for one configuration and if you want to do something different then you need to connect to a breadboard or do some soldering. However, the Grove ecosystem provides lots of devices to connect up here and if you are living in the Grove world then this isn’t a problem.

Sample Program

Seeed’s web page to introduce the Starter Kit has lots of sample projects and I thought as a quick test, I’d wire up the temperature and humidity sensor along with the two line LCD display, I ran into an immediate problem that the sample project on the website was for a different LCD display than included in the kit. However modifying the code for the correct LCD display was fairly easy, mostly looking at one of the other sample projects. I suspect the components might be swapped in and out as supply and demand changes and the web site has trouble keeping up to date.

The direct support for Grove is via MicroPython, with Seeed promising to support Arduino C support sometime soon. You could program this with the RP2040 SDK, since there is direct support for all these devices, but the emphasis here is on educational settings and MicroPython. You need to have the Raspberry Pi Pico connected to a host computer via a micro-USB cable, I used my Windows 10 laptop for this. You write your program in the Thonny Python IDE, which has good support for the Pico, including installing the MicroPython runtime. The Pico version of MicroPython has good low level device support for the RP2040, which means it already knows how to talk to I2C, UARTs, digital and analog devices. Seeed provides MicroPython classes that provide a higher level interface to the various Grove devices included in the starter kit. Below is the source code for reading the temperature and humidity and displaying it on the LCD. The and files are the high level Python classes that Seeed provides for the LCD and digital humidity/temperature sensor.

from lcd1602 import LCD1602
from dht11 import *
from machine import Pin, I2C
from time import sleep

i2c = I2C(1,scl=Pin(7), sda=Pin(6), freq=400000)
d = LCD1602(i2c, 2, 16)
dht2 = DHT(18) #temperature and humidity sensor connect to D18 port

while True:  
    temp,humid = dht2.readTempHumid() #temp:  humid:
    d.print(“Temp:  ” + str(temp)) #display temperature on line 1
    d.setCursor(0, 1)
    d.print(“Humid: ” + str(humid))

To get this project going, you connect the devices, using the Grove connector cables, enter this small Python program and away you go. Who knew building a microprocessor project and programming it could be so easy?


Building and programming microprocessor projects can be intimidating, involving soldering small fiddly wires and then writing programs in C and Assembly Language. Seeed simplifies this process by replacing soldering with simple standard connectors and then combines this with simplifying MicroPython high level classes to make the programming simpler. For learning and prototyping DIY projects this is great. This opens the educational potential to younger children, where you might be scared to give them a soldering iron. Further, you are less likely to get parts broken or lost. The Raspberry Pi Pico with its powerful RP2040 CPU runs MicroPython effortlessly and there is plenty of memory for quite large projects.

Written by smist08

October 12, 2021 at 10:08 am

ARM’s True RISC Processors

leave a comment »


I recently completed my book, “RP2040 Assembly Language Programming” and was thinking about the differences in the three main instruction sets available on ARM Processors:

  1. The “thumb” instructions used in ARM’s 32-bit microcontrollers are covered in “RP2040 Assembly Language Programming”.
  2. The full 32-bit A-series instruction set as used by the Raspberry Pi OS is covered in my book “Raspberry Pi Assembly Language Programming”.
  3. The 64-bit instruction set used on all smartphones and tablets covered in my book “Programming with 64-Bit ARM Assembly Language”.

ARM is advertised as Reduced Instruction Set Computer (RISC) as opposed to Intel x86 chips which are Complex Instruction Set Computers (CISC). However, as ARM instroduces v9 of their full chip architecture, the instruction set has gotten pretty complex. Writing the RP2040 book and writing the included source code was nice in that the microcontroller version of the instruction set really is reduced and much simpler than the other two full versions. In this article, we’ll look at a bit of history of the various ARM instruction sets and why ARM is still considered a RISC processor.

A Bit of History

Originally, ARM was developed as a replacement to the 6502 processor used in the BBC Microcomputer, developed by Acorn. The early versions were specialty chips and it wasn’t until ARM was selected by Apple to use ARM in their Newton PDAs that ARM was spun off as a separate company starting with their 32-bit RISC CPUs. They reached the next level of success as Apple continued to use them in their iPods and then they hit it big when they were used in the iPhone and after that pretty much every smartphone and tablet that reached any level of success.

The original 32-bit instruction set used 32-bits to contain each machine instruction, which worked great as long as you had sufficient memory. In the microcontroller world there were complaints that for devices with only 4k of memory, these instructions were too big. To answer this, ARM added “thumb” instructions which were 16-bits in length, using half the memory of hte full instructions. The processor was still 32-bits, since the registers were 32-bits in size and all integer arithmetic was 32-bit. The “thumb” instruction set is a subset of the full 32-bit instruction set and the processor can switch between regular and thumb mode on select branch instructions. This allowed the microcontroller people to use the “thumb” subset to develop compact applications for their use. Even on computers with larger memory, “thumb” instructions can be useful since loading 16-bit instructions means you can load two instructions for each memory read and save contention on the memory bus and allowing twice as many instructions to fit in the instruction cache, improving performance.

The first “thumb” instruction set wasn’t complete which meant programs had to revert to full instructions to complete a number of functions. To address this ARM developed “thumb-2” to allow complete functionality without switching back. The various “thumb” instruction sets are all 32-bit, the 64-bit version of the ARM instruction set has no “thumb” subset.

Enter Microcontrollers

ARM has alway had the ambition to provide CPU chips covering the whole market from inexpensive small microcontrollers all the way up to the most powerful datacenter server chips. The full 32-bit ARM processors were a bit too expensive and complicated for the microcontroller market. To address this market, ARM developed the M-series CPUs where they chose to make the full instruction set of these devices, the “thumb” instruction set. This made these CPUs far simpler and required fewer transistors to create. This laid the way for powerful ARM 32-bit CPUs for the microcontroller market costing under $1 each.

For instance, the ARM Cortex-M0+ used in the Raspberry Pi Pico has 85 instructions. This sounds like a lot, but it counts things like adding a register to a register different from adding an immediate operand to a register. This is far fewer instructions than in an ARM full A-series processor, which is far fewer than the instructions in an x86 processor.

Some of the features that are dropped from the M-series processors are:

  • Virtual memory
  • Hardware memory protection
  • Virtualization
  • Conditional instructions
  • Not all instructions can address all the registers
  • Immediate operands are much smaller and shifting isn’t supported
  • The addressing modes are far simpler
  • Instructions either set or don’t set the conditional flags, there is no extra bit to control this

Most microcontrollers run a single program that has access to all the memory, so these aren’t an issue. However, the lack of hardware hasn’t stopped people adding software support and implementing Linux and other OS’s running on these microcontrollers.

Are ARM Processors Still RISC?

A full ARM A-Series processor like those found in the Raspberry Pi, Apple’s iPhone 7 iPad along with dozens of Android and ChromeOS devices, all run the full 64-bit instruction set, as well as the full 32-bit instruction set including the “thumb” instruction. They support virtual memory, virtualization, FPUs, vector processors, advanced security and everything else you would expect in a modern processor. That is a lot for something that is billed as “reduced”. Basically an ARM CPU has the same transistor budget as an x86 processor, so they use every transistor to do something useful. So why are ARM processors still considered RISC? The parts of RISC that all ARM processors retain is:

  • The instructions are a fixed length.
  • They are a load/store architecture (no instructions like add memory to register). An instruction either loads/stores from memory or performs an arithmetic operation on the registers.
  • Most instructions execute in a single clock cycle.
  • They have a large set of registers, though Intel processors now also have a large set of registers.

Even with all this functionality, ARM processors use far less power than x86 processors, this is mainly due to the simplifications that fixed length instructions and a load/store architecture provide. Intel processor now execute a RISC processor at their core, but then have to add another layer to translate each x86 instruction into their internal RISC instructions, that all uses transistors and power when executing,

So yes, even though the number of instructions in an ARM CPU has multiplied greatly over the nine generations of the chips, the core ideas are still RISC.


The line of M-series ARM CPUs are far simpler to program than the full A-Series. There is no virtual memory support, so you can access hardware addresses directly, reading and writing anywhere without worries about security or memory protection. The instruction set is simpler and nothing is wasted. Having written three books on ARM Assembly Language Programming, I think learning Assembly Language for a microcontroller is a great way to start. You have full control of the hardware and don’t have to worry about interacting with an operating system. I think you get a much better feel for how the hardware works as well as a real feel for programming for RISC based processors. If you are interested in this, I hope you check out my forthcoming book: “RP2040 Assembly Language Programming”.

Written by smist08

October 2, 2021 at 10:31 am

Introducing the Seeed Studio Wio RP2040

with one comment


When the Raspberry Pi Foundation designed their new microcontroller, the Raspberry Pi Pico, the heart of the board is the RP2040 System on a Chip (SoC). This chip contains dual ARM Cortex-M0+ CPU cores, 296kb RAM, a number of coprocessors and a number of specialty I/O processors. Raspberry made the decision to sell this chip separately and it has since appeared on the boards from various other hardware vendors. Previously, we discussed the Adafruit Feather RP2040 and in this article is about Seeed Studio’s Wio RP2040 which is another of these boards. The Raspberry Pi Pico contains support for several wired communications protocols, but no support for wireless communications, or ethernet, making it difficult to connect directly to the Internet. Seeed Studio paired the RP2040 chip with a ESP based wireless chip, adding both WiFi and Bluetooth in a board smaller than the Pico.

Update (2021/12/23): Seeed Studio has released another RP2040 based board, the XIAO RP2040. It runs at up to 133MHz, is built with rich interfaces in a tiny thumb size, and fully supports Arduino, MicroPython, and CircuitPython. The onboard interfaces are enough for developing multiple applications with pins compatible with Seeeduino XIAO and supports Seeeduino XIAO’s Expansion board.

Module vs Development Board

There are two versions of of the Wio RP2040 board:

  • The Wio RP2040 Module containing the RP2040
  • The Wio RP2040 Mini Dev Board which adds a bootsel button, led, usb connector, and the pins to add it to a breadboard.

If you are experimenting, I would recommend getting the development board. If you get the CPU module then at a minimum you need to solder the wires for a USB wire to the board so you can connect it to a host computer to download programs from.

I received the module version, so I learned a bit about the four wires contained in a USB cable. Fortunately, there is a standard for the wire colors, so figuring out the wiring was easy. Soldering the USB cable to the module was fiddly but doable. You also need to solder two wires for the bootsel button, you can either connect these to a button, or just touch them together to activate bootsel. If you want to debug with gdb, then you also need to connect three wires to the two SWD pins and a ground pin, to allow gdb to control the board.

Below is my module with the USB cable soldered in and two leads for the bootsel button. I should add three more wires for debugging, but this isn’t necessary if you are only using MicroPython.

Software Development

The core of this board is the RP2040 processor, so you can develop with this board using Raspberry’s RP2040 SDK. You can also use any of the environments that support the Raspberry Pi Pico like MicroPython or the Arduino system. The only restriction is that WiFi support is only officially supported with MicroPython which we talk about next.

Developing with WiFi

As of this writing, using the WiFI/Bluetooth functionality is only supported from MicroPython. Seeed supplies a custom version of MicroPython which has this module compiled in. This version leverages the work in MicroPython done for the Raspberry Pi Pico and as a consequence works with the Thonny Python IDE. This is an interesting contrast with Seeed’s Wio Terminal which doesn’t have IDE support and you need to rely on REPL for development.

The problem with this approach is that I couldn’t find the source code for this build of MicroPython, which means if I wanted to add more libraries, I don’t have a way to do this, including my own custom C and Assembly Language code. Again, contrast this to the Wio Terminal, which includes all the source code as well as a build system for adding modules and custom code. Hopefully, the source code for this MicroPython build makes it onto Seeed’s Github repository in the near future.

There is speculation on the forums that the WiFi is an ESP8266 board connected via the SPI interface and then controlled using AT commands. These are basically an extension of the old Hayes modem command set, extended to a more modern world. It wouldn’t take much documentation on Seeed’s part to provide some details, such as the SPI port used and SPI configuration parameters. With this detail it would be easy to add WiFi and/or Bluetooth support to programs written in the standard RP2040 SDK. Or better still contribute their WiFi support to the Raspberry Pi Pico Extras GitHub repository.


The Seeed Wio RP2040 is a compact module to build your projects around. The big current limitation is the lack of software support for the ESP radio module; hopefully, this will be rectified in the near future. Seeed designed this module to be included into custom PCB boards such as their dev board and offer a service to manufacture these. If this is your first Wio RP2040, then you should get the mini dev board as this is far easier to connect up and get working, then use the smaller module in your final project.

Written by smist08

September 12, 2021 at 9:32 am

ArduPy on the Wio Terminal

with one comment


Last week, we introduced Seeed Studio’s Wio Terminal and wrote a small program in C using the Arduino IDE. This week, we’ll replicate the same program in Python using ArduPy, Seeed’s version of MicroPython for the Wio Terminal and Seeeduino XIAO. In this article we’ll look at what’s involved in working with ArduPy along with some of its features and limitations.

The Koch Snowflake in ArduPy on the Wio Terminal

What is ArduPy?

ArduPy is an open source adaptation of MicroPython that uses the Arduino API to talk to the underlying device. The goal is to make adding MicroPython support easier for hardware manufacturers, so that if you develop Arduino support for your device, then you get MicroPython support for free. There are a large number of great microcontrollers out there and for board and system manufacturers, and the most time consuming part of getting a new board to market is developing the SDK. Further, great boards run the risk of failing in the market if the software support isn’t there. Similarly, a programmer buying a new board, really likes to be able to use familiar software and not to have to learn a whole new SDK and development system from scratch.

When you develop an Arduino program, you include the libraries used and the program then runs on the device. In the case of ArduPy, the Python runtime is the running Arduino program, but what libraries does it contain? Seeed developed a utility, aip, to rebuild the ArduPy runtime and include additional libraries. This lets you save memory by not including a bunch of libraries you aren’t using, but still have the ability to find and include the libraries you need.

The downside of ArduPy is that currently there isn’t Python IDE integration. As a partial workaround there is REPL support (Read Evaluate Print Loop), which lets you see the output of print statements and execute statements in isolation.

You need to flash the ArduPy runtime to the device, after that the device will boot with a shared drive that you can save a file that is run everytime the device boots, or which is run every time it is saved.

Our Koch Snowflake Program Again

We described the Koch Snowflake last time and implemented it in C. The following is a Python program, where I took the C program and edited the syntax into shape for Python. I left in a print statement so we can see the output in REPL. The screenshot above shows the program running.

from machine import LCD
import math

lcd = LCD()                            # Initialize LCD and turn the backlight
lcd.fillScreen(lcd.color.BLACK)        # Fill the LCD screen with color black
lcd.setTextSize(2)                     # Setting font size to 2
lcd.setTextColor(lcd.color.GREEN)      # Setting test color to Green

turtleX = 0.0
turtleY = 0.0
turtleHeading = 0.0

DEG2RAD = 0.0174532925

level = 3
size = 200
turtleX = 320/8
turtleY = 240/4

def KochSnowflakeSide(level, size):
  print(“KochSnowFlakeSide ” + str(level) + ” ” + str(size))
  if level == 0:
      forward( size )
      KochSnowflakeSide( level-1, size / 3 )
      turn( 60 )
      KochSnowflakeSide( level-1, size / 3)
      turn( -120 )
      KochSnowflakeSide( level-1, size / 3)
      KochSnowflakeSide( level-1, size / 3)

def forward(amount):
  global turtleX, turtleY

  newX = turtleX + math.cos(turtleHeading * DEG2RAD) * amount
  newY = turtleY + math.sin(turtleHeading * DEG2RAD) * amount
  lcd.drawLine(int(turtleX), int(turtleY), int(newX), int(newY), lcd.color.WHITE)
  turtleX = newX
  turtleY = newY

def turn(degrees):
  global turtleHeading
  turtleHeading += degrees

turn( 60 )
KochSnowflakeSide( level , size)
turn( -120 )
KochSnowflakeSide( level, size)
turn( -120 )
KochSnowflakeSide( level, size)
turn( 180 )

Developing and Debugging

Seeed’s instructions are good on how to set up a Wio Terminal for ArduPy, but die out a bit on how to actually develop programs for it. Fortunately, they have a good set of video tutorials that are necessary to watch. I didn’t see the tutorials until after I got my program working, and they would have saved me a fair bit of time.

I started by developing my program in a text editor and then saving it as on the Wio. The program did nothing. I copied the program to Thonny, a Python IDE, which reported the most blatant syntax errors that I fixed. I started debugging by outputting strings to the Wio screen, which showed me how far the program ran before hitting an error. Repeating this, I got the program working. Then I found the video tutorials.

The key is to use REPL, which is accessed via a serial port simulated on the USB connection to your host computer. The tutorial recommended using putty, which I did from my Raspberry Pi. With this you can see the output from print statements and you can execute Python commands. Below is a screenshot of running the program with the included print statement.

I tried copy and pasting the entire Python program into putty/REPL, but copy/paste doesn’t work well in putty and it messes up all the indentation, which is crucial for any Python program. When I write my next ArduPy program, I’m going to find a better terminal program than putty, crucially, one where cut/paste works properly.

Using putty/REPL isn’t as good as debugging in a proper Python IDE, but I found I was able to get my work done, and after all we are programming a microcontroller here, not a full featured laptop.


ArduPy is an interesting take on MicroPython. The library support for the Wio Terminal is good and it does seem to work. Being able to use an IDE would be nice, but you can get by with REPL. Most people find learning Python easier than learning C, and I think this is a good fit for anyone approaching microcontrollers without any prior programming experience.

Written by smist08

September 3, 2021 at 10:45 am