Space

August 2019: Apollo 11, Design for the Blind, Architecture

Welcome to the August 2019 edition of the Embedded Artistry Newsletter! This is a monthly newsletter of curated and original content to help you build superior embedded systems. This newsletter supplements the website and covers topics not mentioned there.

This month we'll cover:

  • Apollo 11: 50th anniversary
  • Electronics design for the blind
  • Ravioli, a tool for calculating the Koopman Spaghetti Factor
  • Embedded systems architecture resources
  • Embedded news from around the web
  • Embedded job postings
  • Updates to the Embedded Artistry Website

50th Anniversary of Apollo 11

July marked the 50th anniversary of the Apollo 11 mission, which has garnered much media attention and the launch of the spectacular Apollo 11 in Real Time project. While it's interesting to revisit the Apollo 11 program, we're going to focus on a different angle: the Apollo Guidance Computer (AGC).

Space programs serve as excellent examples for embedded system designs with extreme requirements.

It's common to see quotes about the AGC like this one from Michio Kaku:

“Today, your cell phone has more computer power than all of NASA back in 1969, when it placed two astronauts on the moon.”

But statements like these are misleading. In an age of room-sized computers, the 70-pound Apollo Guidance Computer was an engineering marvel. The computer was responsible for computing the navigational course to the moon and adjusting that course based on in-flight astronaut input. The AGC needed to communicate with 150 different devices onboard the spacecraft - an immense task even for today's systems. The computer enabled Apollo 11 to get to the moon, reach the surface, and return to earth autonomously. And after a quarter of a million miles - the AGC hit its target within 500-600 feet of the goal. Such a feat of engineering is worth studying, which is why we feature the Apollo 11 AGC in our Source Code Classics article. For a book on the subject, check out Apollo Guidance Computer: Architecture and Operations.

Also, while we're all thinking about the Apollo programs, we want to share this wonderful anecdote from Margaret Hamilton:

Often in the evening or on weekends I would bring my young daughter, Lauren, into work with me. One day, she was with me when I was doing a simulation of a mission to the moon. She liked to imitate me – playing astronaut. She started hitting keys and all of a sudden, the simulation started. Then she pressed other keys and the simulation crashed. She had selected a program which was supposed to be run prior to launch – when she was already “on the way” to the moon. The computer had so little space, it had wiped the navigation data taking her to the moon. I thought: my God – this could inadvertently happen in a real mission. I suggested a program change to prevent a prelaunch program being selected during flight. But the higher-ups at MIT and NASA said the astronauts were too well trained to make such a mistake. Midcourse on the very next mission – Apollo 8 – one of the astronauts on board accidentally did exactly what Lauren had done. The Lauren bug! It created much havoc and required the mission to be reconfigured. After that, they let me put the program change in, all right.

For more on the Apollo 11 50th anniversary and the Apollo AGC:

Electronics Design for the Blind

IEEE Spectrum recently published an article titled "You Don’t Need Sight to Read These Electronic Schematics". Our interest was immediately piqued. The article briefly detailed developments in enabling electronic design for the blind. Electronics work seems like an area where sight is critical. It is exciting this assumption has been proven false.

The article describes Lauren Race's thesis project, Designing Tactile Schematics, which researched standards and best practices for designing tactile schematics. Race initially tried to print schematics on Swell Touch Paper, which causes areas printed in black ink to swell up and create raised surfaces when passed through a fuser machine. She learned through usability testing that making existing schematics tactile did not make them readable. She then worked with user groups to modify symbols and create schematics that were readable to both sighted and blind people. You can find the culmination of her work in her Visual Style Guide, as well as a sample set of 50 schematics following the tactile style guide rules.

The article also mentions the Blind Arduino Project, which aims to overcome the barriers faced by blind people who want to participate in hardware prototyping. The Project offers occasional hands-on workshops teaching coding, soldering, and other skills to blind makers. They also document their learnings on the Blind Arduino blog and host a regular Bay Area Blind Arduino Monthly Meetup.

For more on enabling electronics design for the blind:

Ravioli: A Tool for Calculating the Koopman Spaghetti Factor

Matt Chernosky, who runs Electron Vector, has created a software quality tool dubbed Ravioli. This tool calculates the Koopman Spaghetti Factor, a software complexity metric created by Phil Koopman.

The Spaghetti Factor (SF) metric is calculated in the following manner:

SF = SCC + (Globals*5) + (SLOC/20)

Where:

  • SCC = strict cyclomatic complexity (for more information, see the Phil's article).
  • Globals = number of read/write global variables, excluding const variables and file-scope statics
  • SLOC = source lines of code, which focuses on actionable programming statements and excludes comments

Phil Koopman provides a helpful and actionable scoring guide. Here are Phil's thoughts on complexity scores:

  • 5-10 - This is the sweet spot for most code except simple helper functions
  • 15 - Don't go above this for most modules
  • 20 - Look closely; review to see if refactoring makes sense
  • 30 - Refactor the design
  • 50 - Untestable; throw the module away and fix the design
  • 75 - Unmaintainable; throw the module away; throw the design away; start over
  • 100 - Nightmare; probably you need to throw the whole subsystem away and re-architect it

Our complexity analysis tool of choice is Lizard, but we will be adding Ravioli to our CI suite for another perspective. Ravioli is currently targeted for C source files, but we think it can also be adapted for C++.

For more on Ravioli and the Spaghetti Factor:

Embedded Systems Architecture Resources

Last month we received multiple requests for resources to help learn about embedded systems security. This month we had many engaging conversations about architecting embedded systems, which surprised us because "architecture" and "design" are typically words that send programming teams running for the hills.

These conversations prompted us to share our collection of embedded systems architecture resources. Software architecture is a broad field, so we've focused our recommendations on a the following areas:

We also frequently write about systems thinking and software architecture on Embedded Artistry, and we will be publishing more articles on these topics as we develop our architectural skills.

Around the Web

We've grouped our August reading recommendations by these categories:

  • General
  • Embedded
  • Security
  • Hardware

General

The authors of Elements of Programming have released a free PDF copy of the book in honor of the 10 year anniversary. This is a programming classic, so definitely take this opportunity to read it.

All About Circuits published a great article discussing the Principles of Cache Design, a topic low-level programmers should be familiar with.

Memfault published an article describing how to get the most out of the linker map file.

Memfault also published an excellent tutorial on automating debugging tasks with GDB's Python API.

Hillel Wayne published an approach for identifying missing requirements using modeling.

Jonathan Boccara, author of the Fluent C++ blog, published a wonderful post addressing a common problem we see: duplicate global data. Check out his article, What Every C++ Developer Should Know to (Correctly) Define Global Constants.

Embedded

Jay Carlson authored an excellent post describing how he teaches embedded systems to EE undergraduate students. Jay's notes are valuable for anyone who teaches embedded systems topics to others.

Elecia White shared a GitHub repository, Machine Learning on Embedded Devices, which serves as a wonderful collection of resources for those interested in the intersection of ML and embedded systems.

Security

Researchers seem to have found a way around Bluetooth LE's MAC address randomization feature, which is used to prevent identifying and tracking devices.

Memfault published Fix Bugs and Secure Firmware with the MPU, a guide for securing ARM MCUs with the Memory Protection Unit.

All About Circuits looked at microcontrollers with security-focused hardware components in Secure Microcontrollers Address IoT Security

All About Circuits highlighted Hardware Security Vulnerabilities that Engineers Should Know. The article concludes with advice for securing embedded systems.

Hardware

EDN published a review of TI's new tutorial book titled Radiation Handbook for Electronics. The book is pitched as "a compendium of radiation effects topics for space, industrial and terrestrial applications." Checkout this book if you're interested in designing electronics for high-radiation environments.

All About Circuits published an introductory article on Understanding Schematics, a critical skill for all embedded engineers.

Job Postings

At IRNAS, innovation lab for hardware and IoT products, based in Maribor, Slovenia, we are expanding our crew with an Embedded Software Engineer, who will collaborate on interdisciplinary development of telecommunication solutions, IoT systems, 3D bio-printing and more. Find out more about the open job position and apply by visiting this link.

Hiring Embedded Engineers?

Is your company hiring embedded systems hardware/software engineers? Send us a short job ad with a link to the full job description. We will be happy to include it in our newsletter.

Website Updates

We expanded the Glossary with additional terms and links.

We updated Technology Radar statuses for items that were under evaluation.

We added additional Apollo 11 links to Programmers: Let's Study Source Code Classics.

New Articles

We published the following articles in July:

These were our most popular articles in July:

  1. Creating a Circular Buffer in C/C++
  2. std::string vs C-strings
  3. Demystifying Microcontroller GPIO Settings
  4. For Beginners
  5. Installing LLVM/Clang on OSX
  6. Migrating from C to C++: NULL vs nullptr
  7. C++ Casting, or: "Oh No, They Broke Malloc!"
  8. An Overview of C++ STL Containers
  9. What can software organizations learn from the Boeing 737 MAX saga?
  10. Jenkins: Running Steps as sudo

Thanks for Reading!

Have any feedback, questions, suggestions, interesting articles, or resources to recommend to other developers? Simply reply to this email!

While you're waiting for our next edition, check out the website or follow us on Twitter.

Happy hacking!

-Phillip & Rozi

July 2019: Security, Security, Security!

Welcome to the July 2019 edition of the Embedded Artistry Newsletter! This is a monthly newsletter of curated and original content to help you build superior embedded systems. This newsletter supplements the website and covers topics not mentioned there.

This month we'll cover:

  • Phillip's interview on Embedded.fm
  • Atomic clocks in space
  • Stuxnet: ten years later
  • Embedded systems security resources
  • Embedded news from around the web
  • Updates to the Embedded Artistry Website

Embedded.fm Interview

Last month, Embedded.fm interviewed Phillip. Elecia, Chris, and Phillip discussed consulting, writing, learning, code reviews, rules of thumb, Boeing 737 MAX, and implementing C++ threading types with an RTOS.

Check out Embedded.fm episode 290!

Atomic Clocks in Space

We love learning about technological developments with space exploration, since they involve wonderful examples of highly reliable embedded systems.

In June, NASA’s Jet Propulsion Laboratory (JPL) announced that they were creating a deep-space atomic clock. This clock is a toaster-sized device that aims to facilitate navigational efforts for future space missions. The first clock was launched into Earth’s orbit at the end of June for a one-year trial.

You can learn more about the Deep Space Atomic Clock with these JPL links:

A Look at Stuxnet, Ten Years Later

June marked the 10th anniversary of the first Stuxnet infection, which targeted Siemens PLCs and was responsible for damaging Iran's nuclear program. Stuxnet caused centrifuges at the nuclear plant to spin out of control while operator screens reported nominal values, leading to systems failures, asset damage, safety concerns, and a national security fiasco.

It's interesting to look back on Stuxnet with the context of today's continual onslaught of security vulnerability announcements and IoT botnet attacks. What have we learned in the ten years since Stuxnet demonstrated the capability of vulnerabilities to wreak havoc on physical systems? The overall state of device security hasn't noticeably improved, and reports of hacked devices reaching into the physical world abound.

Security can no longer be an afterthought. Even if your product isn’t connected to a nuclear reactor, vulnerabilities are exploited with disastrous results. For more on Stuxnet:

For more on Stuxnet:

Embedded Systems Security Resources

A reader reached out to us on LinkedIn and requested recommendations for books and resources discussing embedded systems security. As we just mentioned, security is an area that we all need to focus on when we design and build our embedded systems. If you have recommended books or links that discuss embedded systems security, let us know! We will be collecting recommendations and publishing a post dedicated to security resources. Here’s what we’ve collected thus far.

Phil Koopman has a collection of lectures discussing embedded systems security:

The following books relate to embedded systems security:

Here are articles with general introductions to embedded systems security concepts:

These articles focus on common pitfalls with embedded device security:

Around the Web

We've grouped our July reading recommendations by these categories:

  • General
  • Software
  • Security
  • Hardware

General

Elecia at Embedded.fm wrote a great post about Giving Feedback prompted by our conversation on the podcast.

Bunnie comments on the trade war with China and its potential impact on Open Source Could Be a Casualty of the Trade War.

All About Circuits published a helpful introduction to the Advanced Microcontroller Bus Architecture (AMBA), which is the de facto standard for SoC design.

Software

If you're interested in the intersection of machine learning and embedded systems, a reader on LinkedIn shared this link for running TensorFlow Lite on a microcontroller.

The Memfault team published an excellent article on digging into firmware code size. If you're trying to reduce your binary's size, this article is a must read.

The Memfault team also published an excellent article on writing linker scripts for firmware.

Colin Walls wrote about mixing C and C++ in an embedded application. If you're interested in trying out C++ on an existing embedded product, try one of Colin's two approaches.

Burkhard Stubert added another article to his Speaking CAN series, this time analyzing write buffer overflows.

Watchdog timers are a staple element of embedded systems. Alexandru Lazar shared some Watchdog Timer Anti-patterns that we should keep in mind when building our systems.

Thread Group announced version 1.2 of the Thread wireless protocol. Stacey Higginbotham provided a summary of the changes

For a great example of applying std::variant to create a state machine, check out this C++ article: Space Game: A std::variant-Based State Machine by Example.

Security

Appropriately for the 10-year anniversary of Stuxnet, we saw an inordinate amount of articles related to security.

EE Times highlighted that the IoT security gap is widening: we're adding more devices and sending more data, but IoT devices are still a prime hacking target.

Designing Hardware for Data Privacy highlights the need to develop a thread model for our devices and to implement the appropriate countermeasures.

Enhancing Privacy and Security in the Smart Meter Lifecycle provides a look at a variety of techniques that can be used to improve IoT device security.

How Many Layers of Security Do You Have? argues that designers should consider two guiding principles: defense in depth and principle of least privilege.

Will the Real Root of Trust Stand Up? discusses the concept of a "root of trust".

Hardware

Strange Parts recorded a fantastic factory tour of the PCBWay factory in Shenzen: Inside a PCB Soldering Factory - in China. If you are curious about how circuit boards are manufactured, check out this video.

Dangerous Prototypes shared a helpful app note discussing magnetometer placement in mobile devices.

Dangerous Prototypes also shared a helpful app note discussing a method for using two accelerometers to make rotational measurements, which is useful if you already have two accelerometers and don't want to update your product to add a gyroscope.

Hiring Embedded Engineers?

Is your company hiring embedded systems hardware/software engineers? Send us a short job ad with a link to the full job description. We will be happy to include it in our newsletter.

Website Updates

Stickers are now available in the Embedded Artistry store. You can help support the website by purchasing a sticker.

We've renamed the "Embedded C++" and "Migrating from C to C++" categories to work around a Squarespace link generation issue.

We added additional acronyms to the Glossary.

We added new book recommendations and links to For Beginners, Hardware References and Software References.

We updated the following articles:

New Articles

We published the following articles in June:

These were our most popular articles in June:

  1. Creating a Circular Buffer in C/C++
  2. For Beginners
  3. std::string vs C-strings
  4. Demystifying Microcontroller GPIO Settings
  5. Installing LLVM/Clang on OSX
  6. C++ Casting, or: "Oh No, They Broke Malloc!"
  7. Improving Your Callback Game
  8. Jenkins: Configuring a Linux Slave Node
  9. An Overview of C++ STL Containers
  10. Migrating from C to C++: NULL vs nullptr

Thanks for Reading!

Have any feedback, questions, suggestions, interesting articles, or resources to recommend to other developers? Simply reply to this email!

While you're waiting for our next edition, check out the website or follow us on Twitter.

Happy hacking!

-Phillip & Rozi