Stephen Smith's Blog

Musings on Machine Learning…

Archive for October 2021

Windows 11 Appears on my Laptop

leave a comment »

Introduction

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.

Installation

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.

Summary

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

with one comment

Introduction

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.

Summary

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 »

Introduction

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. 

#define PIR_MOTION_SENSOR D0
#include"TFT_eSPI.h"
TFT_eSPI tft;
TFT_eSprite spr = TFT_eSprite(&tft);
void setup()
{
    tft.begin();
    tft.setRotation(3);
    spr.createSprite(TFT_HEIGHT, TFT_WIDTH);
    spr.setTextColor(TFT_WHITE);
    spr.setTextSize(2);
    pinMode(PIR_MOTION_SENSOR, INPUT);
}
void loop()
{
    spr.fillSprite(TFT_BLACK);
    if(digitalRead(PIR_MOTION_SENSOR))//if it detects the moving people?
    {
             spr.drawString("Movement detected", 30, 60);
    }
    else
    {
         spr.drawString("Watching", 30, 60);
    }
    spr.pushSprite(0,0);
    delay(200);
}

Summary

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 3 comments

Introduction

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 lcd1602.py and dht11.py 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.home()
    d.print(“Temp:  ” + str(temp)) #display temperature on line 1
    d.setCursor(0, 1)
    d.print(“Humid: ” + str(humid))
    sleep(0.5)

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?

Summary

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 »

Introduction

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.

Summary

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