Go here to sign up for The Embedded Muse.
The Embedded Muse Logo The Embedded Muse
Issue Number 405, September 7, 2020
Copyright 2020 The Ganssle Group

Editor: Jack Ganssle, jack@ganssle.com

   Jack Ganssle, Editor of The Embedded Muse

You may redistribute this newsletter for non-commercial purposes. For commercial use contact info@ganssle.com. To subscribe or unsubscribe go here or drop Jack an email.

Editor's Notes

SEGGER Embedded Studio cross platform IDE

The Embedded Muse now goes to over 40,000 subscribers.

Quotes and Thoughts

Let's disagree without being disagreeable – Laurene Powell Jobs

Tools and Tips

HCC flash webinar

Please submit clever ideas or thoughts about tools, techniques and resources you love or hate. Here are the tool reviews submitted in the past.

Gerald DeSantis wrote:

To the extent possible, I use a SPICE simulation program to check out my designs before ordering PCBs.  In the past, I've used programs such as TINA TI and LT SPICE; but was never fully comfortable with either.

When doing a recent Internet search, I found a program called Micro-Cap 12 SPICE that previously sold for $4500 and is now available at no cost as the company is no longer in business.  Since the program is in its 12th revision, it is very stable and I've been most impressed with its capabilities.  Also, from my personal perspective, it's by far and away, the best SPICE simulation programs I've used.

If anyone has interest, please check out the links below.



Freebies and Discounts

September's giveaway is courtesy of Binho, and is one of their Nova Multi-Protocol USB Host Adapters with accessories (reviewed later in this issue).

Enter via this link.

The Rust Programming Language

James Munns is a big advocate of Rust, and he contributed the following article:

The Rust Programming Language has been steadily growing in usage and popularity in the five years since its 1.0 release in 2015 (and in the 14 years since its inception in 2006). Although it is a systems language, with comparative performance and control to languages like C, C++, and Ada, it has also taken inspiration from more modern languages, including best-in-class tooling, package and configuration management, testing infrastructure, and other conveniences provided out of the box. As a language, Rust aims to empower **everyone** to build reliable and efficient software: from resource-light embedded systems, to high performance server software.

Rust as a language has a number of features, including a strong type system, and a concept of "data ownership", that allow it to guarantee thread and memory safety at compile time, preventing issues such as use-after-frees, data races, and buffer overruns. These safety checks exist primarily at compile time, meaning they can be used effectively for any target system. These foundational concepts make a huge difference between static analysis that can catch bugs some or most of the time, and compile time errors for potential bugs.

The standard library also provides a number of built-in features, such as iterators, pattern matching, tagged enums, and more, which can also be used to write code that is more descriptive of what the developer is doing, rather than how the computer should do it. These features allow for aggressive optimizations at compile time, making them suitable for resource limited systems. The Rust standard library is split into two main parts, "std" and "core", the latter of which can still be used on systems without an Operating System or Allocator. This means that a wide variety of libraries can be used interchangeably on embedded and non-embedded systems, without customization required.

Rust also has a vibrant and widely used package repository, crates.io, with (at the time of writing) nearly 46,000 crates (or packages) available, and over 3.7B crate downloads. This allows for a huge amount of reusable code, and quick iteration and development cycles. This package manager also tracks tools that can be used to help with development, including static analysis tools for code size or speed, tools for embedded logging and testing, and tools for automatic generation of bindings between C, C++, and Rust code bases. Rust has built-in support for FFI interoperability with other languages, making it straightforward to combine languages like Rust and C within a single project.

Over the past five years or so, Rust has gained wide adoption in a number of industries, and is being used in production by companies including Dropbox, Cloudflare, Threema, Microsoft Azure, and more. The Rust project has an RFC based open governance process, allowing for adaptations and changes over time based on needs. This open process has also allowed the project to grow out of its original home at Mozilla, moving into its own foundation later this year. Despite all of these continuous changes, and having a stable compiler release every 6 weeks, Rust has a strong backwards compatibility guarantee: code you write today will always compile on future versions of Rust.

Since 2018, Rust has also had a specific focus on embedded systems, with bare-metal targets becoming a first class stable target for Rust development. Currently, Rust supports bare-metal Arm Cortex-A, Cortex-R, and Cortex-M devices, RISC-V CPUs, the MSP430 architecture, and more recently, Atmel's AVR architecture. Rust also supports a wide variety of embedded Linux targets as well. The Rust compiler supports cross compilation natively, which means that you don't need separate tooling for your desktop and embedded development efforts.

Rust is continuing to progress (particularly for embedded systems), adding support for new tools for embedded development, adding support for new platforms like the Xtensa architecture (which powers ESP32 and ESP8266 processors), and preparing Rust for use in Safety Critical markets, based on interest from the Automotive industry.

Although languages like C, C++, and Ada are not going to be going away any time soon due to the huge investments, niche and legacy targets, and largely working code bases already in wide usage, Rust is working to be an excellent choice for new or critical projects or software components, where performance, development speed, and correctness are paramount. If you're looking to get started with Rust, check out the Rust Bookshelf, where there are a number of free books and courses for getting started, the Embedded Rust Bookshelf, a similar set of free and open source resources for embedded systems, or reach out to us at Ferrous Systems for guided training or advice.

James Munns is an embedded systems engineer, and Managing Director at Ferrous Systems GmbH in Berlin, Germany. James has experience in a variety of domains, including safety critical avionics, robotics, and gas detection, as well as connected IoT devices.

Ferrous Systems GmbH is the largest software consultancy worldwide focused on the Rust Programming Language. Ferrous Systems provides services in advising, development, and training, and has experience developing embedded systems and systems level software in Rust.

Debugging Embedded and Real-Time Systems

Arnold Berger has a new book out and his publisher graciously sent me a copy. Debugging Embedded and Real-Time Systems is a worthy addition to the literature.

Arnie teaches embedded systems at the University of Washington, and I was stunned to read in this volume that the Circuits 1 students get a breadboard and they actually construct and test circuits. When I went to college circuit theory was entirely theory. A later lab class was a joke of playing with multimeters. So while the pundits complain of education going to hell in a handbasket, my hat is off to the U of W for a class rich in practicum.

This book is really aimed at students, and I think it should be a part of the pedagogy of every CS and EE department. Arnie pushes the idea of using a disciplined approach to debugging. Over the decades I've seen (and have participated in) too many shotgunning sessions. Sometimes these work though more often much time is wasted. And sometimes a "fix" is masking tape over the wrong issue, creating more havoc later.

The book is about debugging embedded systems; not hardware, not software, but both the hardware and the software, which is means it's written assuming the reader is familiar with both. Though it does zero in on each in isolation at times, it's a broadly-focused work that should appeal to all embedded practitioners, especially those at the intersection of the two disciplines.

When it does come to software Arnie's first advice is to write bug-free code. For that he presents a strategy. He admits we'll never be perfect, but the unfortunate truth is that many of us write firmware figuring on long sessions with the debugger instead of employing every means possible to avoid errors.

The same is true for hardware, and he presents a number of ideas for designing the hardware correctly. Some of this will be obvious to old-timers; for newbies, not so much so. An example: Use pullups on the bus to implement a NOP so you can run tests without memory loaded. I prefer a software interrupt instruction, when possible, as that will create write cycles as well. A scope or logic analyzer will show all of the resulting bus activity (if any!).

Chapter five is a good overview of the tools we use. I was surprised that the oscilloscope didn't get its own section, though many references are made to that tool in other places.

One tidbit I've been advocating for years: Keep a debugging log. Have you ever chased a bug for days and find yourself repeating a test, simply because you forgot you ran it? I have. A log documents the process in a disciplined way.

Some concepts will be new to even many experienced hands. Ever hear of SIMICS? It's a fascinating tool I've been following for some years, and I'm told Intel (which owns it) uses it to evaluate most of their products.

Arnie highly praises going to the Embedded Systems Conference. Alas, that show is a shadow of its former self. Once that advice was spot-on. Today I recommend Embedded World (in Germany) as that gathering is huge and dynamic.

Arnie presents lots of anecdotes from his career which makes for fun reading.

Debugging Embedded and Real-Time Systems is a quick and easy read that condenses a lot of useful information into 285 pages. Every student of our profession should read it and embrace the concepts. Experienced readers will pick up useful nuggets as well. If there's one nit to pick it's the $80 price tag, a price that's becoming all too common for tech books. I sheepishly admit my own books are also way too expensive. The Embedded Systems Dictionary, which I co-wrote with Mike Barr, is currently $143 on Amazon. Perhaps that explains its pathetic sales!

The Binho Nova Multi-Protocol USB Host Adapter

Binho sent me one of their Nova Multi-Protocol USB Host Adapters. I wasn't quite sure what such a device is or does, so went to the company's web page, which didn't shed enough light for a dullard like me to understand. A lot of web sites today are very pretty yet they don't clearly state what the company is selling. We used to talk about having an elevator speech: a 15 second explanation of what you do. Too many web sites neglect that.

However, this page gives an excellent description of the Nova. It is basically an interface between a PC's USB port and common interfaces found in embedded systems. In particular, the device can interface to devices that communicate via I2C, SPI, UART, 1-WIRE, and SWI. On one side of the device is a USB connector; on the other is a flat ribbon cable with power and ground signals, plus five pins for connecting to these interfaces.

Pinouts are:

Pinout of the Binho device

Why would you want to do this? Early in development it may be easier to develop prototype code for a device driver on a PC rather than in the less-friendly cross-development environment. The Nova can also enable automatic testing of devices in an embedded system. And it can be a nice way to download code to flash memory in production.

Steve Jobs taught us that beauty can be combined with functionality, and a few makers of test equipment (notably Saleae's logic analyzers) have profited from that lesson. Binho, too, provides a unit in a slim, elegant metal package, which in turn is shipped in a quite attractive hard case.

A GUI interface named "Mission Control" is available for Windows, Linux and Macs. It's self explanatory. For example, to control an SPI device:

Binho Mission Control SPI

An alternative mode lets you use these 5 pins as GPIO connections or A/D inputs. One can be a DAC. Four can be PWMs with controllable frequency and duty cycle.

Binho Mission Control IO page

The Mission Control GUI is a clean and easy way to interface to the device, but the real power comes from Python libraries that let you write code to send and receive data at speed via the Nova to your hardware. I did not try this, but the web site contains numerous examples, all too long to list here.

You can also drive the Nova from a command terminal like Tera Term.

Binho's web site has very clear step-by-step instructions for installing and using the device. I do wish they were available as a single PDF as I like to keep user manuals on my disk, and prefer random access access rather than stepping through web pages.

At $149 the Nova is a very affordable way to tie a PC to an embedded system using any of these serial interfaces. The GUI is simple and powerful. If you're willing to write some Python code, there's really no limit to the control you could exercise over a device.

Failure of the Week

Another heart rate fail to complement the one in the last Muse. According to the CDC the max heart rate is 220-(age in years) which means this poor person is negative four billion years old. I guess that means he or she will be born about the time the sun turns into a cinder. I suspect at that time we'll be programming 8051s in C0xFFFFFFFF.


Let me know if you’re hiring embedded engineers. No recruiters please, and I reserve the right to edit ads to fit the format and intent of this newsletter. Please keep it to 100 words. There is no charge for a job ad.

Joke For The Week

These jokes are archived here.

From Phil Matthews:

Everybody trusts a hardware engineer, except themselves.
Nobody trusts a software engineer, except themselves.

About The Embedded Muse

The Embedded Muse is Jack Ganssle's newsletter. Send complaints, comments, and contributions to me at jack@ganssle.com.

The Embedded Muse is supported by The Ganssle Group, whose mission is to help embedded folks get better products to market faster. We offer seminars at your site offering hard-hitting ideas - and action - you can take now to improve firmware quality and decrease development time. Contact us at info@ganssle.com for more information.