Download as pdf or txt
Download as pdf or txt
You are on page 1of 68

March 2021 | www.elektormagazine.

com

lektor innovate > launch > trade


Elekto
r Helps

EMBEDDED
Electr
o
challe nics in
ng
times ing

&TOOLS embedded world DIGITAL Special

TOO QUICK
TO CODE
and Too Slow
to Test?
37

SECURE BOOT
SOLUTION FOR
RASPBERRY PI
Retrofit Security at a
Reasonable Price
20

INTERVIEW
embedded world
Director Benedikt
Weyerer on the
Digital Events
12 60 27 10

AVR-IoT and PIC-IoT The Rise of Contactless Low-Power Flagship for


Development Boards Manipulation Artificial Intelligence
Securely Communicate For Very Delicate SMARC Modules With
with the Cloud Using AWS Components NXP i.MX 8M Plus Processor
Join the
Elektor C mmunity
Take out a G O LD
membership
membership!

The Elektor web archive from 1974! An online Elektor LABs account, with
6x Elektor magazine (Print) access to more than 1000 Gerber files
9x Digital (PDF) including and a direct line of communication with
Elektor Industry (EN) magazine our experts!
A 10% discount in our web shop and Bring a project to publication or even sell
exclusive offers it in our shop
Elektor’s annual DVD-ROM

Also available Access to Elektor’s web archive


10% discount in our web shop
The Digital G R E E N membership
6x Elektor magazine (PDF)
Exclusive offers
membership! Access to more than 1000 Gerber files

www.elektor.com/member
Foreword

By Jens Nickel
Editor-in-Chief

Digital Opportunities
 
Even in this foreword, I cannot avoid mentioning the troublesome have to be mutually exclusive. A digital trade show in addition
virus. The COVID-19 crisis still has a tight grip on the electronics to a “real” exhibition can help you get the information you need
sector. And it primarily affects those who are on the front line faster and improve your own network with the right contacts.
throughout the industry: product managers, marketing specia-  
lists, buyers. Anyone who offers platforms for the exchange of During his visit to embedded world DIGITAL, my colleague
information — for example, trade fair organizers and the trade Mathias Claußen discovered many interesting products, gathe-
magazines — also face an uphill battle. Visible signs were the red information and used the opportunity to video chat with
closed doors of the Nuremberg trade fair, where embedded world other engineers. His (by no means complete) overview of new
would normally have taken place. However, like Messe München controllers, software tools and more can be found on page 6. The
at electronica, Nürnberg Messe also took the opportunity to move MAX78000 presented there — a SoC with an integrated Cortex-M4
the important event to the Internet. The whole thing is not just arm, a RISC-V core, and an AI accelerator — won the trade fair’s
born of necessity. Such virtual events are also test balloons for “embedded award.” My colleagues in the Elektor Lab have already
the trade fairs. The experiences gained can help to develop new worked with the MAX78000. In fact, the MAX78000 AI Design
business opportunities. (Read the interview with Benedikt Weyerer Contest is now underway. Head over to www.elektormagazine.
on page 10.) In the foreseeable future, nothing will be able to com/ai-contest-max78000 to learn more about it.
replace an event where people meet in person. But the two don’t 210204-01

SIMULATION OF THERMAL DISSIPATION


ON PCB FOR POWER MODULES

REDEXPERT. Würth Elektronik‘s online platform for simple


component selection and performance simulation.
www.we-online.com/redexpert

 The world’s most accurate  Ability to compare inductance/


AC loss model current and temperature rise/
 Filter settings for over 20 DC current using interactive
electrical and mechanical measurement curves
parameters  Online platform based on
 Inductor simulation and measured values
selection for DC/DC converters  Order free samples directly
 Available in seven languages  Direct access to product
 No login required datasheets

WE are here for you!


Join our free webinars on
© eiSos

www.we-online.com/webinars

lektor Embedded & Tools 3


CONTENTS Elektor Industry Edition 1/2021 Focus: Embedded & Tools

Focus

EMBEDDED
&TOOLS
embedded world DIGITAL Special

Regulars 27 Low-Power Flagship for Artificial Intelligence


SMARC Modules With NXP i.MX 8M Plus Processor
5 Colophon
30 The Red Cube and Its Fellows
44 Infographics REDCUBE Terminals for High Current Connections
Facts and figures
32 Tracking Down Microcontroller Buffer Overflows with
56 Wall of Fame 0xDEADBEEF
Elektor’s partners in the electronics industry
37 Too Quick to Code and Too Slow to Test?

46 How to Make Design for Manufacturing Easy

Articles 48 More Effective Analysis of Environmental Sensor Data


Through Automated Cloud-Based Analysis
6 embedded world 2021 DIGITAL
A Short Overview of the Digital Fair 50 Embedded System Development with RISC-V
Processors
10 New World, New Ways A Brief Introduction and Market Overview
embedded world 2021 Went Digital
58 Solutions for Touchscreen Applications with High
12 A Look at Microchip Technology’s AVR-IoT and EMC Requirements
PIC-IoT Development Boards
Securely Communicate with the Cloud Using AWS 60 The Rise of Contactless Manipulation

20 Secure Boot Solution for Raspberry Pi 62 What Is tinyML?


Retrofit Security at a Reasonable Price An Interview with Matthew Stewart

4 March 2021 www.elektormagazine.com


COLOPHON

Elektor Industry for free at select trade shows

Interview
Edition 1/2021 including productronica
Embedded & Tools (Munich), electronica (Munich),
© 2021 and Embedded World

Matthew Stewart
www.elektormagazine.com (Nuremberg).

about tinyML Elektor Industry, English edition,


will be published three times in
Reader Notices
Elektor Industry contains
2021. contributed/sponsored content.
The Publishers acknowledge
Head Office all trademarks that may exist in
Elektor Verlag GmbH connection with products,
Kackertstr. 10 services, materials and
52072 Aachen company names that appear
Phone +49 241 95509-190 in this publication. The views
Fax +49 241 95509-013 expressed in Elektor Industry
are not necessarily those of the
Editor in Chief Publisher or the Editor.
Jens Nickel

62
redaktion@elektor.de Copyright Notice
The content of this magazine
Editorial Team is for educational use only. All
C. J. Abate, Stuart Cording, drawings, photographs, printed
Robert van der Zwan circuit board layouts, and
article texts published in this
Advertising & Sponsoring magazine (other than third-party

The Red Cube


Raoul Morreau advertisements) are copyright
Phone: +31 (0)6 4403 9907 Elektor International Media b.v
and Its Fellows raoul.morreau@elektor.com and may not be reproduced
or transmitted in any form
Layout or by any means, including
Harmen Heida, Giel Dols and photocopying, scanning and
Jack Jamar recording, in whole or in part
without prior written permission
Publisher from the Publisher. Such
Don Akkermans written permission must also
be obtained before any part of

30
Printer this publication is stored in a
Pijper Media, Stettinweg 15, retrieval system of any nature.
9723 HD Groningen Patent protection may exist
in respect of circuits, devices,
Mission components etc. described in

Next Edition
Elektor Industry offers this magazine. The Publisher
electronics engineers, does not accept responsibility
innovators, and start-up for failing to identify such
companies essential information patent(s) or other protection.
Edition 2/2021 of Elektor Industry magazine will cover and insights into the latest The Publisher disclaims any
sensors as well as equipment and methods for test and products, research and responsibility for the safe and
measurement, with contributions from companies, industry intelligence from the industry. proper function of reader-
specialists, Elektor editors, and free-lance authors. assembled projects based upon
Distribution and Supply or from schematics, descriptions
The issue will be available to Elektor GOLD Members in print, Elektor Industry appears or information published in or in
and Elektor GREEN and GOLD Members as a PDF download synchronously in English and relation with Elektor Industry.
at www.elektormagazine.com. German and is supplied free to
Elektor Magazine Gold members © Elektor International Media b.v.

Publication date: 20 May 2021. in print, and to Elektor Green 2021

Subject to change. members as a PDF download. www.elektormagazine.com


The magazine is also distributed Printed in the Netherlands

lektor Juli/August 2020 5


regular title

A Short Overview of the Digital Fair

By Mathias Claußen (Elektor Lab)

In 2020, embedded world was one of the


last fairs to be opened for international AMD Ryzen V2000 for Embedded Edge Devices
Congatec announced their Ryzen
exhibitors and visitors, before the COVID-19 V2000-based COM modules. The
crisis began to rule the globe. This year, the AMD Ryzen V2000 processors are
popular fair was held completely digitally. designed for embedded systems
and offer a good combination of raw
Participants could enter the event via computing performance together with
an online platform, find the exhibitor of AMDs Radeon graphics in one chip.
interest, and chat with experts per message With the reduced power consumption,
the congatec modules are nicely suited for systems running 24/7.
and video. Catalogues, brochures and  
product flyers were downloadable. Of course,
it did not offer the same experience as a real Arm Cortex-M33 on the Rise
The Cortex-M33 is an Armv8-M mainline core and can be seen as
fair, but embedded enthusiasts (like Mathias an upgraded Cortex-M4. The STMicroelectronics STM32U5 is a
Claußen from the Elektor Lab) could discover low-power, Cortex-M33-based MCU with DSP instructions and
a lot of new and interesting products. Here is FPU. It comes in LQFP48, QFN48, LQFP64, WLCSP90, LQFP100,
UFBGA132, LQFP144 and UFBGA169 packages.
a brief selection of these!
 The Renesas Electronics RA4M2 set of microcontrollers is the
newest generation of Renesas 32-Bit MCUs featureing a Cortex-M33
and a rich set of peripherals like USB 2.0 Full-Speed, SDHI, QSPI
and advanced analog capabilities.
 

  The nRF5340 SoC from Nordic Semicon-


ductor features not only a RF radio capable
of Bluetooth LE, Bluetooth mesh, NFC,
Thread and ZigBee but also incorporates two
MCU Reaching 1 GHz Cortex-M33 cores in one package. With its
With the NXP Semiconductors i.MX RT1170, MCUs are hitting the peripheral set, it can be a nice MCU for IoT
1-GHz clock range. Not only integrating a dual-core Arm Cortex-M applications and other devices. Its smaller cousin, the nRF51822,
chip (Cortex-M7 + Cortex-M4) with a rich set of interfaces, it is also powers already the BBC micro:bit.
featuring a 2D GPU, with OpenVG 1.1 interface. May we get one  
integrated into a Teensy 5.0 [1]?
 

6 Elektor Industry 1/2021 www.elektormagazine.com


chapter by eliminating a battery completely in achieving a mainte-
nance-free system. The RE Family is suitable for many IoT applica-
The u-blox NORA-B1 module is based on tions such as hybrid watches, smart homes/buildings, healthcare,
Nordic Semiconductor’s latest nRF5340 smart agriculture, structure monitoring, and trackers.
chipset, the first to host a powerful Arm  
Cortex-M33 dual core MCU. The NORA-B1 series is designed to
meet the needs of performance-oriented applications. The brand- Industrial Applications and Interfaces in Mind
new Bluetooth 5.2 low energy NORA-B1 modules comes with the
Arm TrustZone® and CryptoCell-312 for enhanced security, making it
ideal for industrial machine control, asset tracking, remote controls
and gateways, connected power tools requiring continuous motor
control, and advanced medical wearables.
 

AI for Power-Constrained Devices


Winning the “embedded award” of the embedded world show with
the MAX78000, Maxim Integrated incorporates neural network
accelerators into a chip, designed for mobile applications running
of batteries. This design is a nice piece of hardware that Elektor
engineer Clemens Valens covers in the article “AI at the Edge:
Get Started with the Maxim Integrated MAX78000FTHR” [2]. The
MAX78000 is available on affordable evaluation boards.
 

The Texas Instruments AM6442 is built for industrial applications,


such as motor drives and Programmable Logic Controllers (PLCs),
which require a unique combination of real-time processing and
communications with applications processing. AM6442 combines
two instances of Sitara’s gigabit TSN-enabled PRU-ICSSG (program-
mable real-time unit with Gigabit industrial communication subsys-
tem) with up to two Arm Cortex-A53 cores for web services, up
to four Cortex-R5F MCUs for real-time computing, and a Cortex-
M4F MCU.
 
The DS28E40 from Maxim is a 1-Wire authenticator, providing
cryptographic functions and authentication to 1-wire capable Wired and Wireless Long Range
devices. This can be used to avoid use of untrusted hardware in
your systems.
 

Energy Harvesting

The STMicroelectronics STM32WL range of MCUs is integrat-


ing LoRa, SigFox and legacy sub 1-GHz with a single or two core
Cortex-M solution into a single die for lowest power consumption.
 
Texas Instruments 10BASE-T1L single-pair
Renesas added the RE family to their set of microcontrollers. An Ethernet PHY makes long-distance 10-Mbps
ultra-low-power chip running at low voltages down to 1.62 V at Ethernet networking a reality by enabling cable
64 MHz, the RE01 MCU can significantly extend battery life and reach up to 2 km. The DP83TD510E helps
deliver higher performance with a smaller battery size. Its on-chip designers implement a single communications
energy harvesting controller can bring development to a new network, from controller to edge node, that can transmit full-duplex

lektor Embedded & Tools 7


Getting the Round Edges

data over a single pair of twisted wires. By eliminating the need for
additional protocols, gateways and cables for higher-bandwidth
communications, designers can simplify network management
while improving system control and interoperability in long-dis-
tance applications.
 
Semtech’s LoRa Edge LR1110 Asset Management
Platform is an ultra-low-power platform that integrates
a long-range LoRa transceiver, multi-constellation
scanner and passive Wi-Fi AP MAC address scanner RockTouch show their first full round TFT with touch for outdoor
targeting asset management applications. The LR1110 and automotive application. Build for outdoor and harsh environ-
solution utilizes Semtech’s LoRa Cloud geolocation capabilities, ment, with 3-mm Cover Glass it can operate from -30° to +85°C.
to significantly reduce power consumption by determining asset With a resolution of 1540×1540 pixel at 9.5 inch, this offers new
location in a Cloud-based solver. design possibilities for upcoming hardware designs.
   

Lower-Power Position Tracking Software and Development Tools


The u-blox MAX-M10S module is built on the
ultra-low power u-blox M10 GNSS platform
which provides exceptional sensitivity and
acquisition times for all L1 GNSS systems. The
extremely low-power consumption of less than
25 mW in continuous tracking mode allows great power autonomy
for all battery-operated devices, such as asset trackers, without
compromising on GNSS performance.
 
The Bosch smart sensor BHI260AP
provides an ideal all-in-one solution for
always-on sensor applications such as
fitness tracking, pedestrian positioning,
machine learning analytics and orientation
estimation. The BHI260AP includes a wide
variety of software functionalities, a 32-bit customer programmable Green Hills has extended its products to be used with the RISC-V
microcontroller, and a 6-axis IMU, all in one package. architecture. This means their products and compilers are support-
  ing 32- and 64-bit version of the RISC-V ISA. A popular feature of
RISC-V is the support of custom vendor dependent instructions. The
When Hardware Gets Flexible tools Green Hills provide take this into account and offer an easy-to-
learn user interface for adding new instructions into the compiler.
 
IAR Systems, developer of the IAR Embedded Workbench, added
RISC-V support to their product. IAR Embedded Workbench for
RISC-V supports RV32 and RV32E 32-bit RISC-V cores and exten-
sions, including RISC-V P extension for Packed-SIMD instructions.
The support for custom extensions helps when working with design-
ing custom cores with exact definitions for an application or a
product.

GOWIN is a newer FPGA vendor that offers some interesting


devices. Having more choice for FPGAs is great and having ones
with hardwired Cortex-M cores is as well.
 

8 Elektor Industry 1/2021 www.elektormagazine.com


Also shown on the fair: The I-jet and I-jet trace for Arm and RISC-V,
debugging and trace probes for these kind of processors, enabling
powerful features in IAR Embedded Workbench.

  Apache 2.0 open-source license, it is free to use in commercial and


noncommercial solutions. The Zephyr OS is based on a small-foot-
print kernel designed for use on resource-constrained systems: from
simple embedded environmental sensors and LED wearables to
sophisticated smart watches and IoT wireless gateways. The Zephyr
kernel supports multiple architectures, including ARM Cortex-M,
Cortex-R, Cortex-A, Intel x86, ARC, MIPS Nios II, Tensilica Xtensa,
and RISC-V (32 and 64 bit), and many supported boards.
 

SEGGER presented its Embedded Studio. It is a powerful, cross-plat-


form IDE for embedded C programming, coming along with, for
instance, a C/C++ compiler, integrated debugger, and direct J-Link
integration. All these components are designed from the ground
up for embedded systems to generate extremely small code in Azure RTOS from Microsoft is an embedded development suite
order to get the most out of microcontrollers. Specially designed including a small but powerful operating system that provides
as an all-in-one solution, Embedded Studio provides everything reliable, ultra-fast performance for resource-constrained devices.
needed for professional embedded development providing contin- It’s easy-to-use and market-proven, having been deployed on more
uous workflows: from managing, building, testing, up to deploy- than 6.2 billion devices worldwide. Azure RTOS supports the most
ing embedded applications. Its Visual Studio-like style offers the popular 32-bit microcontrollers and embedded development tools,
embedded world of engineering the same intuitive usage that PC so you can make the most of your team’s existing skills.
developers are familiar with. For non-commercial use and use with  
licensed partner devices, Embedded Studio is free to use. Wonder why it is called Azure RTOS ThreadX? You might remem-
  ber a company called Express Logic that once offered an RTOS
named ThreadX; well, this is one and the same. Express Logic
More Choice on the RTOS Market was bought by Microsoft end 2019 and the RTOS incorporated to
become Azure RTOS ThreadX. The code is open and can be found
on GitHub [3]. For evaluating the RTOS can be used for free, and
if you have one of the licensed hardware MCUs no royalties are
needed for commercial use (a list can be found in [4]).

210193-01

The Zephyr Project is a scalable real-time operating system (RTOS)


supporting multiple hardware architectures. Licensed under the

WEB LINKS
[1] Discussion on Teensy using a i.MX RT1170: https://forum.pjrc.com/threads/57842-Future-Teensy-features-amp-pinout
[2] C. Valens, “AI at the Edge: Get Started with the Maxim Integrated MAX78000FTHR,” 3/5/2021, ElektorMagazine.com :
www.elektormagazine.com/articles/ai-edge-get-started-maxim-max78000fthr
[3] Microsoft Azure RTOS on GitHub: https://github.com/azure-rtos/threadx/
[4] Microsoft Azure RTOS licensed devices: https://github.com/azure-rtos/threadx/blob/master/LICENSED-HARDWARE.txt

lektor Embedded & Tools 9


With Benedikt Weyerer
(Director Exhibitions embedded world, NürnbergMesse)

New World, New Ways:


embedded world 2021 Went
Digital
Questions by Shenja Panik (Elektor)

embedded world, a well-known and popular fair for


embedded professionals, is traditionally scheduled for the
beginning of March. This year, the event went completely
digital. Elektor asked Benedikt Weyerer, head of embedded
world, about the event’s background, results and future.

 
Elektor: Please tell us a bit about embedded world this year. Elektor: How was the transition from live to digital received?
   
Weyerer: embedded world 2021 DIGITAL provided the embedded Weyerer: The feedback we’ve received in numerous talks with
community with its own platform to connect. This year the event was customers is that the market needs embedded world — especially
completely virtual and took the place of embedded world in Nurem- in times of a pandemic. The virtual format offered new opportunities
berg. Matchmaking and networking in the community was a priority from which exhibitors and participants benefit. For example, we offered
on the digital platform, and beginning March 1, we offered five days special time slots in the agenda for participants located in the USA
for this instead of the usual three. and China to accommodate the different time zones. This most likely
  would not have been possible at the in-person event.
Together with the embedded world Conference DIGITAL and the  
electronic displays Conference DIGITAL, the virtual exhibition presented Elektor: The charisma of the staff at an exhibition stand — and, of
the entire range of topics related to the development of embedded course, the presentation of the stand — can massively determine how
systems — from components, modules and complete systems to operat- many walk-in customers approach the company. What could made
ing systems, hardware, software and services. Around 300 exhibi- up for this in 2021?
tors, including leading industry giants as well as innovative start-ups,  
presented themselves on the digital platform where the virtual exhibi- Weyerer: With four exhibitor packages, we offered tailored solutions
tion and top-class conferences complemented each other perfectly. that met the different requirements of participating companies. The
  key to a successful participation, however, is active involvement before,
In addition to company and product presentations, participants could during, and after the event — even if the event is held virtually. Our
attend expert talks in the Exhibitor’s Forum. The highlights of the trade participation options, such as presentations in the Exhibitor’s Forum,
fair included expert panels on the topics of “Embedded Artificial Intelli- the matchmaking function, as well as various lead generation options,
gence,” “Safety and Security,” “Embedded Vision,” “Connectivity in IoT,” offered the best conditions for this.
and diversity as a success factor for innovations. The accompanying  
conferences provided a first-class lecture program, top keynotes and
renowned speakers.

10 Elektor Industry 1/2021 www.elektormagazine.com


Around 300 exhibitors, including leading industry giants as well as innovative start-ups,
presented themselves on the digital platform where the virtual exhibition and top-class
conferences complemented each other perfectly.

 
Elektor: Now embedded world 2021 has come to an end. How did Weyerer: We received a great deal of positive feedback for embed-
it go? How do you feel? ded world 2021 DIGITAL; however, we were also frequently told that if
  conditions permit, the industry needs a place for personal exchange.
Weyerer: 301 exhibitors and more than 13,400 trade visitors used the How a face-to-face event will be received will, of course, very much
platform to exchange information about trends, products and solutions. depend on the conditions prevailing at the time. We are optimistic that
embedded world DIGITAL has thus underlined the importance of the these will allow for an on-site event in a year’s time.
event for the embedded community — especially in these special times.  
I am very pleased that embedded world DIGITAL was so well received Elektor: The embedded awards were presented for the 17th time.
in the industry. For us, this is both a confirmation and an incentive. Who were the big winners this year?
   
Elektor: Are there any lessons learned that you were able to draw Weyerer: This year, there were two winners who convinced the jury
from embedded world 2021? of experts with their outstanding innovative performance: The embed-
  ded award went to Maxim Integrated with its MAX78000 product,
Weyerer: For starters, the fact that the industry was so willing to while the embedded Start-up award went to Kudan for their Kudan
use the previously unknown digital format for knowledge transfer. Visual SLAM software.
Of course, we did everything we could; however, no one could have  
predicted this with any certainty because there simply was no prior Elektor: Before embedded world 2021 we asked you what you
experience. We are therefore all the more pleased that the program thought about the future of in-person trade fairs. What is your impres-
and formats offered were so well received. We also realized, however, sion after the digital event?
that a virtual event cannot function the same way as an on-site event.  
Exhibitors’ sales and marketing teams face different challenges when Weyerer: embedded world 2021 DIGITAL has shown us that it is
it comes to online communication and individual participants must also possible to transfer knowledge and connect embedded experts
use a different approach to planning their “trade fair visit.” Participants from all over the world using a digital format. Preparing such an event,
are required to actively use the communication tools to get the most however, requires that everyone involved adapts their way of thinking.
out of a trade fair visit. In my opinion, the most difficult thing is to implement characteris-
  tic elements that a trade fair experience offers. Personal encounters,
Elektor: Were you able to mobilize visitors from non-EU countries constructive interaction in technical discussions at trade fair booths
because of the fact that it was 100% online only? or the inspiration that visitors experience during a spontaneous stop
  at an exhibitor’s booth can only be offered by live events. So, let’s look
Weyerer: Overall, we were pleased to see a large number of inter- forward to embedded world 2022 in Nuremberg!
national participants. The share was higher than at the already very 210215-01
international event in Nuremberg. embedded world DIGITAL welcomed
participants registered from more than 100 countries, including a large
proportion from the USA and Asia.
 
Elektor: More than 96% of trade fair visitors were satisfied with the
embedded world trade fair in 2019 and around 97% of trade visitors WEB LINK
said they would also like to visit the trade fair next year. What is the
status after this very uncertain year? [1] embedded world Website: www.embedded-world.de/en

lektor Embedded & Tools 11


background

A Look at Microchip Technology‘s


AVR-IoT and PIC-IoT
Development Boards
Securely Communicate with the Cloud Using AWS
By Mathias Claußen (Elektor)

Microchip Technology’s AVR-IoT WA and PIC IoT WA


development boards for Wi-Fi connection to Amazon Web
Services (AWS) IoT Core provide secure access to cloud
services and IoT applications. Low power, an onboard
debugger, and an integrated lithum battery charger offer a
ready-to-go solution for reduced development time.

As you already should know, Microchip


Technology acquired Atmel in 2016 and
now offers the PIC® series of microcontrol-
lers (MCUs) and the Atmel lineup including
the AVR® MCU series. Microchip continues
to offer and expand the AVR series to add
new features and functions for its custom-
ers. This means that products and evalu-
ation boards will now get the best of all
products that are offered by Microchip.
Therefore, we would like to introduce you
to the Microchip AVR-IoT and PIC IoT WA
Development Boards for Wi-Fi connection
to Amazon Web Services (AWS) IoT Core.
 
Taking your fist steps into the world of cloud
storage and computing for your data can be
tricky. Operating on limited power while Figure 1: Both boxes side by side.
establishing a secure data transmission to
a cloud service like AWS can be challenging
for developers. Microchip offers two devel- software details, let’s first look at what is in included to save space and save planetary
opment boards that will give you access to the box and what we can expect. resources. As mentioned in the begin-
the AWS IoT Core and provide a way to ning, we have two boards, the PIC IoT
establish a secure communication over What’s inside? WA Development Board (Microchip part:
Wi-Fi while keeping the amount of energy We have two boxes indicating what should EV54Y39A), which has as a main MCU a
used low and shorten your development be inside (Figure 1). As most will have a PIC24FJ128GA705, and the AVR IoT WA
time. Before diving into the hardware and micro-USB cable at hand, those are not Development Board (Microchip part:

12 Elektor Industry 1/2021 www.elektormagazine.com


EV15R70A), which features an ATmega4808
MCU from the AVR family. This basically
means you can choose the red or the blue
pill when it comes to the preferred MCU
of choice.
 
As you can see in Figure 2, the boards
look similar. The front section (Figure 3)
provides a micro-USB port to connect the
system to the debugger or to provide power
to the board. Beside the USB connector
you can see the debugger, and above it is a
lithium battery charging circuit. With the
appropriate battery, this means we can use
the board as wireless standalone device.

Hardware for the evaluation Figure 2: Both IoT WA Development Boards unboxed.
boards
The power section features an MCP73871
Li-Ion/LiPo charging IC with power path
capabilities supported by an MIC33050
buck converter with integrated inductor.
This set of ICs itself is a nice combination, as
it provides charging capabilities of a lithium
cell with 4.2 V cell voltage (be careful to use
suitable cells) and a DC/DC converter that
can deliver up to 600 mA current.
 
Also, note that the charging IC’s power
path works as an ideal diode, preventing
current flow from the battery back to the
USB port. But this is just the power supply.
There is more on the board that deserves
a closer look. Moving a bit to the left, we
can see two ICs and a light sensor. One is
an MCP9808 temperature sensor and the
other is an ATECC608A cryptographic Figure 3: Debugger and power section. Figure 4: The ATWINC1510.
co-processor. The latter can be used here
for securing communications between this
device and the AWS IoT Core services. The AVR one. The ATmega can be clocked up you to add additional sensors and devices
ATECC608A cryptographic co-processor to 20 MHz and offering 20 MIPS with an to the board from the range or mikroBus
is not limited to the AWS IoT Core but can enhanced set of peripherals and options compatible devices, like 3D motion detec-
be used to secure communications to with to save power. tion.For the pins and functions on the board
various cloud based services.   it is enough to just flip it. The available
  Finally (Figure 4) further left we can find connections are marked with their name
In the center you will find the microcon- the ATWIN1510 Wi-Fi module, enabling and pin as shown by Figure 6. For those that
troller of choice, depending on the variant. network communication. It supports are interested in more details for the boards,
The PIC24FJ128GA705 offers in this variant IEEE 802.11 b/g/n network access as single like schematics, Microchip will provide nice
128 KB of ECC Flash and 16 KB of RAM. band 2.4 GHz network controller that can crafted starting guides for both boards, not
Running at 32 MHz, this chip can achieve be accessed through SPI. The ATWINC1510 only telling you what is on those boards but
16 MIPS and is offering a nice set of periph- is more than just a Wi-FI network card; you also give you schematics and a quick-start
erals while also providing low power mode can consider it to be a network coprocessor guide on how to connect with them to AWS.
to minimize energy consumption. For that can lift the heavy task of traffic encryp-
the ATmega4808, being one of the newer tion and TCP/IP packet handling from your Preloaded software
members of the AVR family of chips, this MCU inside the ATWIN1510. For both boards, they will come with prein-
one provides 48 KB of Flash and 6 KB of   stalled sample applications allowing a direct
RAM. For the peripherals present, this The connector at both sides (Figure 5) are out-of-the-box test for the AWS IoT Core
one is more an XMEGA chip than a classic mikroBus Click board connectors that allow utilizing a Microchip account. At this point

lektor Embedded & Tools 13


Something not yet in the manual

There can be the possibility that the


board that ship to you is preloaded
with an older firmware and the
data on the ATECC608A may be
outdated. This will result in the board
connecting to your WiFi network
just fine, but be unable to connect to
the AWS IoT Core, meaning you will
not be able to process the tutorials
or other steps any further. To get
the board up to the latest firmware,
including the ATECC608A and the
onboard debugger, you can use the
IoT Provisioning Tool from [1]. This
one runs on all three major operating
systems as command line application.
Unpack the downloaded file, use a
command line (Windows user can
Figure 5: AVR IoT WA Development Board showing the mikroBus connector.
use cmd.exe for it). For Windows,
the command will be iotprovision-
bin.exe -c aws -m sandbox. After this
is done your board and all required
certificates are in place. As sidenote,
if you prefer the Google services have
a look at Microchip’s video tutorial on
how to switch cloud provider [2].

and establish a Wi-Fi connection to your


network. If the connection to your network
is established the device will try to connect
to the AWS service and start publishing
data. With the opened CLICK-ME.HTM this
will look like Figure 8.

Figure 6: The backside of the IoT WA Development Board showing pin labels. What’s next?
The little button below our sensor values
will guide us through the next steps —
the first of which is setting up MPLABX
a word of warning, which is also to be found not be updated by the MCU firmware, it may (Figure 9). After the Microchip-Atmel
in the quick-start guide. Data sent to this contain outdated firmware or certificate merger, the MPLABX development environ-
account will be available to all that have information. If you have trouble connect- ment, formally dedicated to PIC develop-
the credentials, meaning in this case that ing your board to the AWS IoT core have a ment, added AVR and SAM device support.
it can be considered public. Integrating look at the textbox “Something not yet in  While you do not have the look and feel of
this device into your existing networks is the manual,” as this will update all compo- an Atmel Studio (a Visual Studio-based
a straightforward task. Connect the board nents on the board to the latest version. For environment), you will love the fact that you
of your choice to your computer and a new the update, drag the downloaded .hex file to are no longer bound to Windows. Users of
mass storage drive called CURIOSITY will the drive. After you drag and drop the file Mac OS and Linux will also be able to start
appear. In the root directory it contains a on the CURIOSITY drive, the new firmware AVR-based projects on their AMD64-ca-
CLICK-ME.HTM file that can be opened in a will be flashed and the MCU will reboot. pable machines. Those of us running only
browser and guide you through the config-   on a 32-bit-capable CPU or using a 32 bit
uration steps. First, we need to upgrade the Getting the device into your Wi-Fi network operating system will be out of luck with the
firmware to the latest version; otherwise, we is also just a matter of a few clicks.The latest version of MPLABX. MPLABX is based
will get into trouble configuring the Wi-Fi CLICK-ME.HTM in the root of our CURIOS- on Netbeans, a development environment
network. As you can see in Figure 7, you ITY drive allows you to enter your Wi-Fi started as an IDE for Java and over time
will be guided first to download the latest credentials and will generate a WIFI.CFG file extended to other languages and was later
firmware for your board. This update for you. This generated WIFI.CFG you can adapted by Microchip to become MPLABX.
will bring the MCU to the latest released drag and drop onto the CURIOSITY drive to At the time I write this article, version 5.45
firmware. As the onboard security chip will store the Wi-Fi credentials inside the MCU is the current release and will be used on a

14 Elektor Industry 1/2021 www.elektormagazine.com


Windows machine for this review. For the
different architectures, we need to install
the compiler and support files. The easy
way doing this is during installation, and
if there is enough space on the drive, just
choose all supported architectures to get
the support files. For the compiler we will
be informed at the end of the setup that
we need to fetch them from the Microchip
site. For those who want to use the AVR-GCC
compiler (the one included usually with
Atmel Studio 7 ), you need to download
this one manually from the Microchip site,
extract the .zip file and add manually the
compiler to MPLABX. Adding the compiler
to MPLABX is shown in Figure 9. Choose
the path where you extracted the compiler
files. Be aware that you need to specify the
‘bin’ folder; otherwise, the AVR8 toolchain
is not recognized. The sample projects will
compile per default with the XC compiler
series, meaning this step is not required but
can be convenient if you are used to the way
the AVR-GCC works.  

AVR-IoT WA Development Board


We also need to download the latest
Figure 7: CLICK-ME.htm configuration page for the boards.
AVR-Iot WA Application found at [3]. After
downloading the code this can be opened
with MPLABX and it will bring the project
as seen in Figure 10. You may notice
that with the connected board you also
get all resources and links to documen-
tation presented. The code is required to
get the next steps for the tutorial passed
and allows you to learn how you could
adapt the code for your own needs or
use the developed ideas and configura-
tion to speed up your development. The
opened and expanded project can be seen
in Figure 11. The last step of the tutorial
for the AVR-IoT WA Board at the time of
writing is a bit behind the structure of the
actual code and requires some seconds to
figure out the corresponding parts of code.
To make starting a bit easier in Figure 12
the required code changes are shown to
let the green LED work as an actuator.
After the changes are included in the
source code, it can be uploaded to the
AVR-IoT WA Board and the LED state can
be controlled with the nice slider as shown
in Figure 13. Besides this little glitch in the
last step of the tutorial, the board works
like a charm. If you have completed the
tutorial, the Microchip IoT Developer
Figure 8: First data arriving after Wi-Fi is connected. Guides for AWS [4] offer further informa-
tion and tutorials for using these boards

lektor Embedded & Tools 15


following listing shows.

#include „mcc_generated_files/
application_manager.h“
 
int main(void)
{
    application_init();
    
    while (1)
    {
        runScheduler(); 
    }
    return 0;
}
 
The initialisation of all components is
handled inside application_init() . This
function can be found inside the applica-
tion_manager.c where most of the high
level functions can be found. The code uses
the runScheduler() function to serve all
tasks that need to be done and coordinate
Figure 9: AVR GNU Toolchain setup.
them in a timely manner. From runSched-
uler() we have a function called timeout_
callNextCallback() that actually will
execute tasks that are due and is shown in
the following listing.
 
inline void
timeout_callNextCallback(void)
{
    if (executeQueueHead == NULL)
        return;
    bool tempIE = (IEC0bits.T1IE
== 1?1:0);
    IEC0bits.T1IE = 0;
    timerStruct_t *callBackTimer =
executeQueueHead;
    // Done, remove from list
    executeQueueHead =
executeQueueHead->next;
    // Mark the timer as not in use
Figure 10: MPLABX project and documentation overview.
    callBackTimer->next = NULL;
    if(tempIE)
    {
with the Amazon Web Services. als, and also a bit more RAM (see Figure 14).
        IEC0bits.T1IE = 1;
 
    }
PIC-IoT WA Development Board Also notice that the PIC offers more break-
    uint32_t reschedule
Like with the AVR, the PIC-IoT WA Applica- points in hardware for debugging your
tion must be downloaded and can be found software and data watchpoints compared = callBackTimer->
at [5]. The code can be opened in MPLABX to the AVR with a less efficient instructions callbackPtr(callBackTimer->
and has the same structure as the one for per clock than found on the AVR. If you payload);
the AVR. The tutorial works the same as want to explore a bit more of the provided     // Do we have to reschedule
with the AVR one, except that the PIC offers code, you someone will likely wonder about it? If yes then add delta
a lot more Flash, some advanced peripher- the main.c as the code is really short as the to absolute for reschedule

16 Elektor Industry 1/2021 www.elektormagazine.com


    if(reschedule)
    {
        timeout_
create(callBackTimer, reschedule);
    }
}
 
The code will probe if anything is ready
to be executed, and if not, it will return
immediately. In the following the code will
first disable for a short time a timer inter-
rupt, why we will discuss later, and grab the
element that is ready to be execute and call Figure 11: Expanded and built project for the AVR-based board.
the function. The call uint32_t resched-
ule = callBackTimer->callbackPtr(-
callBackTimer->payload); is executing
the function and the function itself returns
the timespan when it will be needed to be
called again. If this timespan is greater than
zero, it will be put back in a list of waiting
tasks with the given timespan. The timer
and timer interrupt mentioned is the
other part that keeps the system execut-
ing tasks. At a defined interval the function
timeout_isr is called from within the timer
interrupt.
 
void timeout_isr(void)
    {
        timerStruct_t *next =
listHead->next;
        absoluteTimeofLastTimeout
= listHead->absoluteTime;
        lastTimerLoad = 0;
 
    if (listHead != &dummy) {
    enqueueCallback(listHead);
}
 
    listHead = next;
 
    startTimerAtHead();
}
 
Simplified the code checks a list of tasks. Figure 12: Tutorial Step 3 – where the code needs to be modified.
Inside this list can be tasks that needs to
executed or dummy tasks that will do
nothing. If a task needs to be executed, it will
be put in a list of tasks that are due. The next
task from the list of tasks that are waiting to
be executed will be grabbed and the timer
will adjust its interval accordingly. The list
Related Products
with the due tasks will be handled by the > Microchip AVR-IoT WA Development Board
timeout_callNextCallback function we www.elektor.com/microchip-avr-iot-wa-development-board
have looked at. The isr is actually prepar-
> Microchip PIC-IoT WA Development Board
ing and scheduling tasks that need to run www.elektor.com/microchip-pic-iot-wa-development-board
next, driven by a timer. Combined with the

lektor Embedded & Tools 17


Figure 14: Resource consumption on a
PIC-based board.

timeout_callNextCallback function this


generates a cycle where tasks are managed
end executed in a timely manner. If no tasks
need to be executed any longer the MCU
could be put to sleep and wait for the next
time it is woken up by the timer or another
event. This nice concept is not only suited
Figure 13: Actuator button to toggle the LED on the board. for this case of operation but it might also
be interesting for other projects to run tasks
with reduced power consumption.

One step further


For the AVR-IoT WA Board at [6], you find
a guide to start the sample project from
scratch moving through MPLABX. This gets
you more familiar with the development
environment and the code generation itself.
A word of warning, even if this is supported
and working, some parts and plugins will
undergo enhancements to even increase
user experience and stability. Figure 15,
Figure 16 and Figure 17 show a few steps
on your way through the wizards. After the
steps from the user guide are done, you will
have a project that can also be compiled
with the AVR-GCC if you need to include
code written for that specific compiler.
 
You also see in Figure 17 the components
included with the AWS IoT Core Sample
project, like the CryptoAuthLibrary,
Figure 15: MPLABX Project start. WINC15XX or Message Queue Teleme-
try Transport (MQTT). This leads to the
security aspect of both evaluation boards.
The AWS IoT Core uses MQTT for data
exchange. If no additional measurements
are taken, data is exchanged in plain text,
so data can be modified on the way from

18 Elektor Industry 1/2021 www.elektormagazine.com


the device or back, something not wanted.
Therefor MQTT can use Transport Layer
Security (TLS) to encrypt communica-
tion. On both boards, the ATECC608A is
installed and used as cryptographic co-pro-
cessor offloading work from the MCU and
acting as secure element to your devices.
For network security, the WINC1510 offers
TLS encrypted communication and can
be assisted by the ATECC608A to ensure
that the data passed between the evalua-
tion board and the remote side cannot be
changed. With MQTT used by the AWS IoT
Core, this also means we are not limited to
the AWS IoT Core. We just need an MQTT
broker that will accept our connections and
processes data.

Easy entry
With the given price point and software
support both boards offer, there is
Figure 16: Select your target.
nothing to worry about. Combined with
the well-equipped documentation and
debugging facilities, the boards offer an
easy entry into connected devices that run
on restricted power. The included lithium
battery circuit offers flexibility beyond
just the workbench, and the mikroBus
connector gives you instant access to a lot
of additional hardware for your projects.
You can stay with your preferred MCU archi-
tecture with these boards, or you can use
the chance to get used to the other side
and experience what these will offer you.
In combination with the onboard debug-
ger, provided on both boards and a cross
platform solution for all three major operat-
ing systems, this is a more than complete
solution.

200567-01

Figure 17: Microchip Code Configurator.

WEB LINKS

[1]  Microchip IoT provision tool:www.microchip.com/design-centers/internet-of-­things/iot-dev-kits/iot-provision-tool


[2]  Video to change from Amazon to Google cloud and back: www.youtube.com/watch?v=nwP8obSRaaE&feature=emb_logo
[3]  AVR-IoT WA board GitHub repository: https://github.com/microchip-pic-avr-solutions/­avr-iot-aws-sensor-node-mplab
[4]  Microchip IoT Developer Guides for AWS:
https://github.com/microchip-­pic-avr-solutions/microchip-iot-developer-­guides-for-aws
[5] PIC-IoT WA board GitHub repository: https://github.com/microchip-pic-avr-solutions/­pic-iot-aws-sensor-node
[6]  AVR-IoT board User Guide:
http://ww1.microchip.com/downloads/en/DeviceDoc/AVR-IoT-WA-Development-Board-User-­Guide-DS50002998B.pdf

lektor Embedded & Tools 19


Secure Boot Solution
for Raspberry Pi
By The Elektor Team
Retrofit Security at a Reasonable Price
The beauty of an SD card is that it gives you simple access to data. You can copy
or alter a card’s content on laptops, PCs, or even microcontrollers. However,
this creates a security and maintenance risk for industrial machines and
other applications when used in combination with a Raspberry Pi. Swiss
semiconductor company Swissbit has developed a secure boot solution for
Raspberry Pi that protects your data at the SD card level using integrated
encryption and authentication hardware.

The ubiquity and simplicity of the The Raspberry Pi itself does not provide Swissbit AG
Raspberry Pi have made it very popular any support for a trusted secure boot. Thus, The company headquarters of Swissbit AG
and not just with hobbyists. Over the the average user can remove your SD card, [1] are in Switzerland and, until 2001, it was
years, and thanks to the introduction of make a copy of it, and investigate the files, part of Siemens AG. Specializing in memory
the Raspberry Pi Compute module, it has firmware, and any user data collected. To and storage products, and with production
also found its way into industrial applica- tackle this, Swissbit developed a solution facilities in Berlin, Germany, they can create
tions. However, equipment based on this that encrypts the data inside the SD card and manufacture unique storage solutions
approach has suffered from a significant and integrates the authentication infra- using their in-house design capabilities.
Achilles’ heel: the primary mass-storage structure required to offer a secure-boot Their Secure Boot Solution for Raspberry Pi
solution — namely, SD cards — lack any solution. is one such product that has resulted from
form of data protection. this unique set of capabilities.
 

20 Elektor Industry 1/2021 www.elektormagazine.com


Being an SD card, it can simply replace your write and read to a NAND flash wears the
existing storage medium while seamlessly bits of the memory out, leading it to fail
adding secure boot and data protection to over time. The memory controller also
your hardware. manages this.
 
Inside an SD Card The memory controller acts like a micro-
To understand why this solution is unique controller (see the example in Figure 1)
and why having ownership of memory with a CPU, specialized hardware for
production facilities comes in handy, we handling flash, and the host interface. It
need to start by examining an SD card’s lies between your device (the host) and the
composition. The two crucial compo- raw NAND memory hiding the real read and
nents are the NAND flash memory and write operations, dealing with bad bits, and
the memory controller. The memory handling wear leveling to extend the life-
controller handles the write, erase, and span of the SD card. The less each data bit
read sequences sent by the host using is written, the lower the probability that it
standardized commands. NAND flash itself, will fail.
with its increasing density, is not flawless.
Somewhere in the memory, there will be PS-45u DP “Raspberry Edition”
some bits that don’t behave as intended. Since Swissbit designs and manufactures
Such faults need to be detected and, if their SD cards, their memory controller
possible, corrected. Additionally, every can be optimized or extended as needed.

Raspberry Pi and the Missing


Security
When working with a Raspberry Pi, you
will notice that it uses an implicit chain of
trust, which means that, regardless of the
boot media used, the Raspberry Pi will try
to execute code from it. This opens it up to
attacks that can compromise the device’s
operating system. Since any user of your
device or an attacker has full access to
the boot device’s data, you may not even
recognize that a system has been copied
or modified with malware or data-min-
ing tools. In a worst-case scenario, third-
parties could use the device to attack the
networks to which the Raspberry Pi is
attached.
 
The addition of a more secure boot solution
to a Raspberry Pi is a sensible option to
counter this. However, as the hardware
itself cannot be changed, a smart solution
is required that can be retrofitted to existing
deployments. This is where the PS-45u DP
“Raspberry Edition” from Swissbit shows its
strengths and at a reasonable price point. Figure 1: Example implementation of an SD card controller. (Source: Hyperstone).

lektor Embedded & Tools 21


Figure 2: PS-45u DP ‘Raspberry Edition.’ Figure 3: PU-50n USB stick. (Source: Swissbit).
(Source: Swissbit).

Table 1: PS-45u specs. Table 2: Comparison of authentication methods.


Security Function PIN Policy USB Policy NET Policy
> Size 8 GB - 32 GB
> Hardware security features Know-How Protection √ √ √
> Page based flash management License Protection √ √ √
> Speed Class 10 Remote Attestation √ √ √
> MLC technology Data Protection √ √ √
> Software tool for authentication
Theft Protection √   √
> Industrial temp. range -25°C to
85°C and 0°C to 70°C Tamper Protection     √
Lock Device     √
Secure Unattended Boot   √ √

While consumer SD cards simply present


the NAND memory to the host, this new
solution has added additional security
elements. The PS-45u  DP ‘Raspberry
Edition’ [2], as shown in Figure 2, is an
SD card with security-enhancements that
work independently of the host CPU. More
detail on the card’s technical specifica-
tion can be found in Table 1. The host,
in this case the Raspberry Pi, simply sees
an SD card and, if unlocked, can access
the data on it. Currently, this “Raspberry
Edition” of the PS-45u  DP functions
with the Raspberry Pi 2 and Raspberry
Pi 3B+ models with the authentication
implemented in a Swissbit-customized
pre-boot phase to unlock access to the Figure 4: Requiered items per policy.
SD card data. The card is also hardened
to ensure data integrity on loss of power.
Those used to operating Raspberry Pi with
SD cards will know that some brands get is an attempt at recovery when the system the added robustness, these cards also offer
corrupted even during a clean shutdown is next booted. onboard encryption and authentication.
due to glitches on the power rails and data   For the authentication, there are three
lines. However, something that no SD card The PS-45u  DP “Raspberry Edition” is methods currently supported that are listed
can prevent is an interrupted OS write to available in 8 GB [3] and 32 GB [4] versions in Table 2. This means that only with the
the SD card: the best that can be expected directly from Mouser Electronics. Besides correct access token — a PIN, USB Token,

22 Elektor Industry 1/2021 www.elektormagazine.com


Table 3: PU-50n specs.
Compliance USB 3.1
USB 3.1
Data transfer
SuperSpeed
Temperature -25°C to 85°C
Compatible to U-50n
FLASH Technology MLC
Density DP Data
8 GB - 64 GB
Protection

Figure 5: SD card configuration utility.

or authentication server — will the data be


unlocked and accessible.
 
The PIN Policy means that a pre-defined
pin must be entered at the command
line at bootup. The USB Policy works in
conjunction with the PU-50n USB stick [5]
(Figure 3) as an authentication token that
is also available at [6]. Its technical specifi-
cation is provided in Table 3. This is similar
to a license dongle that is provided with
certain higher-priced PCB design tools.
The final option is the NET Policy. This
requires the implementation of an authen-
tication server running somewhere on your
network that will authenticate or refuse
use of the SD card.
 
To evaluate a system with PIN security you
need a Raspberry Pi (Model 3B+ recom-
mended) and a PS-45u DP “Raspberry Edition.” Figure 6: Request for PIN.
For evaluation of the NET policy in addition
to the requirements for the PIN policy, you
need a second Raspberry Pi and one regular
microSD card (recommended: S-50u).
For evaluation of the USB policy in addition the first part of the software that checks if Even if you can lock and unlock your card
to the requirements of the PIN policy, you a valid token is installed. While this first in Windows with the special characters
will need one USB PU-50n DP “Raspberry stage firmware can be read by anyone, it on your keyboard, it should be noted that
Edition”.  Figure 4 gives a short overview stops an attacker from gaining access to the Raspberry Pi forces the use of a UK
for the required items to evaluate one of the remainder of the SD card. This protects (qwerty) keyboard layout during boot. This
the three policies. your software installation from unautho- may cause irritation when using non-UK
  rized accesses using one of three potential keyboards and alphanumeric PINs. For
authentication methods as follows. example, when a PIN “qwertz” has been
Retrofitting Enhanced Security set in the Windows tool and the Raspberry
to Existing Applications PIN Policy Pi is booting with a German keyboard
Since the Raspberry Pi requires access to Using the SD card with the PIN Policy is connected, you will have to enter “qwerty”
some core firmware files when booting, the the simplest approach for added security (since “y” and “z” are switched in German
PS-45u DP “Raspberry Edition” has been measures. The SD card needs to be config- keyboard layout compared to UK layout) to
designed with a unique security feature ured according to [8]. Currently, Windows is successfully authenticate.
that allows seamless integration with exist- required to set the SD card up (see Figure 5).  
ing projects. If the SD card is secured, the The tools included allow a PIN for the card Besides the challenges provided by the
first partition is in a read-only state. This to be set but the use of the standard ASCII keyboard layout, this approach also means
allows the Pi to load the basic firmware and character set is highly recommended. that the PIN must be entered every time

lektor Embedded & Tools 23


upon booting to unlock the SD card and
continue with the remaining boot process
(Figure 6 shows the PIN prompt). Brute
force attacks, attempting to enter a correct
PIN by testing many combinations until
the correct one is found, are a general risk
with such an authentication approach. This
is something the SD Card can prevent in
hardware. When configuring the card you
can define the allowed number of incor-
rectly-entered PINs before the card will
refuse further unlock attempts. Once the
limit has been reached, a Supervisor PIN
(which you have hopefully set and noted),
can be used to unlock and change the
SD card’s PIN. Otherwise, the card can no
longer be unlocked.

USB Policy
Figure 7: Secure boot using a USB token. The USB Policy enables an unattended
secure boot. This works by adding a Swiss-
bit PU-50n DP USB stick as a security token
(Figure 3). The system is set up according
to [8], where the SD card and the PU-50n DP
USB stick are prepared with the same
PIN. The PU-50n DP has the same secure
firmware installed as the PS-45u DP. After
the Raspberry Pi has been booted with the
PS-45u DP SD card, a challenge-response
authentication takes place and, if the PIN
inside the PU-50n DP matches that inside
the PS-45u DP, the boot process continues.
A Raspberry Pi with this setup is shown in
Figure 7. In Figure 8, a successful boot with
an attached PU-50n DP USB stick is shown.

NET Policy
While PIN Policy and USB Policy allow
for easy security retrofitting for stand-
Figure 8: USB authentification using the PU-50n. alone devices without network access,
NET Policy is available for wired network
devices. This requires the implementa-
tion of a license server inside the network
that a Raspberry Pi with a PS-45u DP can
use to unlock the SD card. A readymade
Raspberry Pi image is provided for the
license server and can be written to a
standard 16 GB SD card. The license server
runs on Raspberry OS and features a web
interface for device configuration. The
setup process is described in [9].
 
After boot up, the desktop starts and a
connection can be made via a browser
to https://localhost/NetPolicyServer/. This
brings up the configuration webpage
(Figure 9). To add a device to the license
Figure 9: Net Policy Server user interface. server, the UID of the SD card you are

24 Elektor Industry 1/2021 www.elektormagazine.com


activating, along with the corresponding
password, is required. This information
can be obtained from the Windows utility
used for the SD card’s preparation. Follow-
ing the guide in [8] for the SD card prepara-
tion an IP address (Figure 10) needs to be
entered. Currently the system it limited to
IPv4 networks. If you do not want to enter
an IP address for your server, there is unoffi-
cial support for an DNS name instead, but
this is not covered in the manual and should
be used at your own risk.
 
After the client has been configured, any
boot attempt will contact the Net Policy
Server. The Raspberry Pi and server will use
a challenge-response scheme to unlock the
SD card and, if the server doesn’t provide
the correct response or is not available, the
boot process stops and the SD card remains
locked. This centralized implementation
allows the management of devices from
the server, enabling them to be disabled
in case they are no longer authorized to Figure 10: Setup for Net Policy Server IP address.
boot. Figure 11 shows the boot process
with incorrect credentials set on the server
side and a failed boot. Figure 12 shows the
response for a successful boot.

Retrofit Existing Hardware


The advantage with retrofitting exist-
ing hardware is the simplicity of the
process when replacing an SD card with
the PS-45u DP ‘Raspberry Edition’. The
examples and files provided assume that
you are running a version of Linux on your
device. This means an existing installation
can be cloned once the files to enable the
chosen PS-45u DP security features have
been added according to the manual.
 
You could argue that the Pi should be able
to do the same thing using software-based
disk encryption but, sadly, on this platform
all cryptographic operations must be
performed in software. This results in a high
processor load on the Raspberry Pi 2 and
3 during disk accesses, leading to perfor-
mance bottle necks during the execution
of standard applications. Because the
PS-45u DP ‘Raspberry Edition’ implements
the disc encryption within the integrated
controller of the SD card, it offloads the
encryption effort and has the additional Figure 11: Failed boot due to incorrect PIN.
benefit of not exposing the cryptographic
keys. As a result, once the PS-45u DP
is unlocked, the installed applications
function as though they were on a normal
SD card without any performance penal-

lektor Embedded & Tools 25


until the required components are ready
and tested. The same is also true for the
NetPolicyServer, which can be considered
a working tech demo rather than a fully-
fledged and polished product. It would be
nice to have some documentation on how
to construct your own Net Policy Server
along with background information on
the protocols used rather than having to
dig through the code. Also, those of us not
using Windows would like to configure the
PS-45u DP without the need for a virtual
machine or dual-boot setup.
 
Despite these small wishes for a next-gener-
ation product release, this secure SD card’s
overall approach provides a simple way to
protect data from unwanted access. The
centralized network server for authen-
tication is a further bonus, making it a
great choice when retrofitting existing
devices to add security. Not only does the
PS-45u DP protect your data from being
stolen, but it also restricts physical access
to the Raspberry Pi’s file system that would
  otherwise allow attackers to compromise
Figure 12: Booting with correct PIN. the platform.
 
210008-01

ties. Depending on your application and based on Raspberry, Swissbit recommends


chosen implementation policy, a security to use the ruggedized Raspberry Compute
retrofit can be undertaken in a reasonable Module CM3+.
amount of time.
  Wishes and final thoughts
According to Swissbit, the “Raspberry The PS-45u  DP ‘Raspberry Edition’
Edition” was designed as a hands-on learn- currently supports the Raspberry Pi 2
ing & evaluation kit to illustrate how secure and 3 models as these are the most-used
boot functionality can be “upgraded” to SoC versions (both for the standard and
embedded platforms that lack native the compute modules). Those looking for
support for it. For productive applications support for the Raspberry Pi 4 need to wait

WEB LINKS
[1] Swissbit: https://www.swissbit.com/en/
[2]  PS-45u DP “Raspberry Edition”: www.swissbit.com/en/products/security-technology/security-products/secure-boot/
[3] PS-45u DP “Raspberry Edition” 8 GB at Mouser.com: https://bit.ly/359jFpO
[4] PS-45u DP “Raspberry Edition” 32 GB at Mouser.com: https://bit.ly/3hNyAeq
[5] PU-50n USB-Stick at Mouser.com: https://bit.ly/3nht3xu
[6]  PU-50n USB-Stick: www.swissbit.com/en/products/security-technology/security-products/pu-50n/
[7] Swissbit S-50u at Mouser.com: https://bit.ly/2L4xbnx
[8]  Swissbit SecureBoot SDK RPi User Manual:
www.swissbit.com/files/public/data/security/raspberry-edition/Swissbit_SecureBoot_SDK_RPi_User_Manual_v2.0.pdf
[9]  Swissbit NetPolicyServer User Manual:
www.swissbit.com/files/public/data/security/raspberry-edition/Swissbit_NetPolicyServer_User_Manual_v2.6.pdf

26 Elektor Industry 1/2021 www.elektormagazine.com


feature

Low-Power Flagship for


Artificial Intelligence
SMARC Modules With NXP i.MX 8M Plus Processor

By Martin Danzer (Director of Product Management, congatec)

Congatec is expanding its SMARC platform


with a new module with an NXP i.MX 8M
Plus processor especially for embedded
AI applications. Thanks to the extensive
ecosystem with application-ready
3.5-inch carrier board, Basler cameras, and
AI software stack, fast proof of concept is
possible.

That hasn’t always been so easy. Previously, it was usually much more Figure 1: Congatec carrier board for SMARC modules.
difficult to use the latest processor technology from the Arm environ-
ment as a finished system than to implement the x86 environment.
This is because, as a result of the historically large range of individu-
ally tailored custom designs used in large quantities, the ecosystem
of system platforms is not that extensive. However, with the modular
approach based on the SMARC computer-on-modules specification,
it is now also possible to obtain standard form factors from the x86 box
PC range with ARM processors. For example, the embedded comput-
ing specialist congatec offers a 3.5-inch board that can be equipped
with modules from its SMARC 2.1 platform as required (Figure 1).
With each launch of a new SMARC module, the portfolio of possible
configurations is automatically expanded with a slight time lag. The
latest flagship processor is the new NXP i.MX 8M Plus processor
(Figure 2), which congatec will officially launch on SMARC at the
virtual Embedded World 2021 and for which the official support of
the 3.5-inch carrier is expected to be fully completed in the summer. Figure 2: Congatec SMARC module with NXP i.MX 8M Plus processor.

Attractive Features
Technical highlights of the new SMARC module with i.MX 8M Plus here is gesture-based control systems, e.g., enabling touchless login
processor are the four powerful Arm Cortex-A53 processor cores with into medical applications on intensive care computers for adjusting
the additional neural processing unit (NPU), which adds up to 2.3 TOPS the administration of infusions. In addition, the multimedia functions
of AI computational power. Thanks to the integrated image signal cover 3D/2D graphics acceleration as well as video decoding and
processor (ISP), they have been developed specifically for AI inference encoding including H.265 so that camera streams can be sent directly
and machine learning applications and can process the data of the two to the network. High resolutions are becoming increasingly import-
integrated MIPI CSI interfaces very efficiently. A key application field ant both in inspection and in monitoring systems for enabling better

lektor Embedded & Tools 27


Figure 3: Block diagram of the NXP i.MX 8M Plus processor module.

evaluation of details. The NPU can help with the pre-processing so interface and extended multimedia functions for increasingly immer-
that the raw data does not overload the network. High-quality DSP for sive experiences, in low-power and mobile device areas too. Support
audio and voice functions is also interesting. Through the combination of up to three independent displays also makes the new processor
with the arithmetic logic units, user-specific speech recognition with module predestined for multidomain applications. The NXP i.MX 8M
around 40,000 different words is possible, for example. And that, unlike Plus processor platform is thus a perfect replacement for all exist-
commercial solutions such as Alexa, Google, or Siri, purely locally and ing i.MX6 applications that are getting on in years. It also scales the
completely without any cloud connection, which can be very useful SMARC-based AMD and Intel portfolio from congatec towards more
for contactless voice commands. energy-efficient, compact, and mobile solution platforms. Added to
  that are mobile handheld devices and in-vehicle applications. Thanks
In addition, real-time control is possible via the Cortex-M7. And via to the camera and AI integration, the modules are also suitable for a
Gigabit Ethernet with time-sensitive networking (TSN). For the first multitude of different vision applications, for which congatec and its
time, high data security and reliability are ensured by the in-line ECC partner Basler offer extended services.
function of the processor, which can implement error correction code
based on LPDDR4 memory for up to 6 GB of capacity. The Cortex-M7 Industry 4.0 Applications With Real-Time
can also be used as a fail-safe unit, which is crucial for customer Networking
applications to be designed with fault tolerance in accordance with The new SMARC modules with processors from the i.MX8 M Plus
IEC 61508/IEC61511. If you look at this all-round service package and platform offer numerous attractive features for real-time control of
implement further application-specific functions via PCIe Gen 3 as safety-critical applications and networked Industry 4.0 systems
well as 2x USB 3.0 and 2x SDIO, you have a highly reliable and robust such as robots or autonomous logistics vehicles. These begin with
Linux, Android, or FreeRTOS platform, which, depending on the variant, the integrated watchdog, which can be used for failure detection in
can even be used in the industrial temperature range of -40°C to redundant machine control systems. Distributed edge systems with
85°C.  Incidentally, the BSP primarily supported by congatec is based real-time synchronization can also be established via the real-time
on the Yocto framework. The low energy consumption of 2..6 W and clock and the TSN-capable Gigabit Ethernet port. For example, in
the onboard eMMC with storage capacity of 128 GB and ability to be networked manufacturing cells or the process industry. The NXP Trust-
operated in robust pSLC mode to extend the service life of the robust Zone offers a secure execution environment for enhanced protection
memory even more are other attractive highlights (Figure 3). against cyberattacks, the risk of which increases through networking.
This is based on an encryption module (CAAM) for hardware-accel-
Diverse Application Areas erated ECC and RSA encryption, the Resource Domain Controller
The new SMARC modules with i.MX 8M Plus platform are thus focused (RDC) for the isolated execution of critical software, and the secure
on reliable industrial applications in combination with embedded vision, High Assurance Boot mode, which prevents execution of unautho-
machine learning, and AI as well as advanced multimedia applications. rized software during the boot procedure.
They thereby target Industry 4.0/IIoT, visual inspection and monitoring
systems, and smart infrastructures and smart cities. Other applications Embedded Vision Systems a Focus Market
can be found in agriculture and construction as well as in building The availability of the SMARC modules with i.MX 8M Plus is thus
automation and measurement technology. The target markets are thus another milestone in the company’s solution platforms for embedded
extremely diverse. One of the largest application fields is in the wide vision systems. Congatec already created a proof of concept for retail
range of HMIs because virtually every device today has a graphical user deep learning applications with Basler and NXP Semiconductors in

28 Elektor Industry 1/2021 www.elektormagazine.com


What About Qseven?

Congatec offers Qseven modules, in addition to


SMARC. The availability of the NXP i.MX 8M Plus pro-
cessor on this form factor is planned for the second half
of 2021. The two form factors do not differ significantly.
However, roughly speaking, SMARC is aimed more at
multimedia applications and Qseven is used more in
deeply embedded applications.

Figure 4: Congatec will now also equip its application-ready embedded Table 1: All SMARC modules of Congatec.
vision kit with the new SMARC 2.1 conga-SMX8-Plus module with i.MX 8M
Plus processors.
SMARC Module ARM x86
conga-SMX8M-Plus i.MX 8M Plus Quad –
i.MX 8M Plus Quad
2019. Integrated AI software, with which automated cash systems can with NPU
be realized in retail, runs on this platform. With the growing popular-
ity of contactless technologies as a result of the pandemic, this kit is
now more relevant than ever and the NXP i.MX 8M Plus processor
with the new NPU and the powerful image signal processor for even conga-SMX8 NXP i.MX8 Quad Max –
more powerful AI-based image evaluation in real time offers an even NXP i.MX8 QuadPlus
more attractive feature set for such applications (Figure 4). The ISP
can process video streams of 375 megapixels per second (MP/s). This
corresponds to 180 Full HD images per second with, for example, image
contrast optimization or lens distortion correction. With the integrated
neural processor and the support for OpenGL ES 3.1, Vulcan VX exten- conga-SMX8X NXP i.MX8 QuadX- –
sions, OpenCL 1.2 FP, and OpenVG 1.1, vision applications receive a Plus
uniquely high processing performance. NXP i.MX8 DualXPlus

With COM & Carrier to Customer-Specific Design


SMARC modules – like all computer-on-modules – are also attractive
for developers without the 3.5-inch board because application-ready conga-SMX8-Mini NXP i.MX 8M Mini –
carrier boards are often already available and the SMARC modules can Quad (industrial)
be used right on these customer systems. This practically eliminates NXP i.MX 8M Mini
the hardware development, which also significantly accelerates the Dual(industrial)
software development and ultimately leads to a faster time to market. NXP i.MX 8M Mini
In the further course of the product life cycle, performance variants Solo(industrial)
can also be created through simple replacement of the module, and conga-SA7 – Intel® Atom® x6425E
for extremely long-term availability, it is possible to switch to the next Intel® Atom® x6413E
generation at a minimal NRE cost when a processor is discontinued. Intel® Atom® x6211E
Ultimately, this means that the ROI can be significantly extended. Intel® Atom® x6212RE
For this reason, COMs have also assumed a leading position in the Intel® Atom® x6425RE
market for embedded computer boards and systems. Another attrac- Intel® Atom® x6414RE
Intel® Pentium® J6425
tive feature of SMARC is the fact that this standard supports Arm
Intel® Celeron® J6413
and x86. As a result, potential migration paths are extended even
further. SMARC modules from congatec can currently be scaled via conga-SA5 – Intel® Atom™ x7-E3950
24 module variants (Table 1). However, if the system performance Intel® Atom™ x5-E3940
is sufficient, it will still be able to be reordered in professional appli- Intel® Atom™ x5-E3930
cations for a long time to come. Congatec specifies an extended Intel® Celeron® N3350
Intel® Celeron® J3455
availability of 15 years for the new SMARC module with NXP i.MX
Intel® Pentium® N4200
8M Plus processor.
210062-01

lektor Embedded & Tools 29


feature

The Red Cube


and Its Fellows
REDCUBE Terminals
for High Current Connections
Contributed by Würth Elektronik

With the REDCUBE terminals, Würth Elektronik offers a


product group with high current contact solutions in various
designs. The terminals owe their name to an innovative
variant with a quick-locking system, which actually brings
the manufacturer’s company colour onto printed circuit
Figure 1: The rectangular SMD terminals are boards in the form of a red cube. On closer inspection, even
designed for rated currents up to a maximum of
50 A and require only a small solder area in the the less colourful models in the product series compete with
M3 package.
their red counterparts in terms of functionality.

When it comes to connecting power And what needs to be considered on the time and cost factor every time the current
connectors to the PCB, many users have cable side for currents above 10 A? Higher intensities increase? No!
two options in mind: classic, automated currents result in increased heat genera-  
SMT assembly and manual THT assembly. tion, which has to be handled with a larger Anybody who needs to apply up to 85 A
There are good reasons why surface mount cable cross-section. As a result, the mechan- (at 20°C) to the PCB can stick to classic
technology and through-hole technol- ical load on the PCB connection increases. SMT assembly with the REDCUBE SMD
ogy are so well known and popular. For The SMT connection cannot withstand this. product family in order to connect single
connections in the low voltage and mA That is why many are switching to through- wires to the PCB. In addition, those who
range, SMT assembly is and remains the hole assembly. do not want to do without the mechani-
most effective and cost-efficient method cal load capacity of THT components for
(Figure 1). In the fully automated assembly The Square Thing Must Go Into small and medium currents do not have
process, the components are placed by pick the Round Thing to deviate from the reflow process. Power
and place onto the printed circuit board, THT connectors are leaded components, connectors with THR (through hole reflow)
which is already covered with solder paste. with small connection pins that are later connections can be assembled together
In the subsequent reflow process, the solder inserted by hand through a through-hole with SMT components in the same reflow
is liquefied — hence the name reflow — in the PCB and connected to the board process. In reflow soldering, the compo-
to bond the components to the PCB. The using wave soldering. The THT assem- nents are exposed to higher temperatures
special feature of this process is that both bly takes place after the SMT production. than in wave soldering, however. For this
sides of the PCB can be processed in the This means that both sides of the board are reason, both connectors and pin contacts
same process. usually already assembled and the risk of must be adapted to THR assembly in terms
  damaging components that have already of design and material. The design modifi-
While SMT assembly was the domain of low been soldered on during wave soldering is cations can be found on the underside of
currents, it has now also established itself in often high. Therefore, manual soldering the housing: Spacer pins create space for
the midfield. Wire-to-board connectors with or selective soldering must often be used. the solder paste and promote airflow under
currents of around 5 A are already standard. These additional production steps cause the housing so that the soldering tempera-
SMT connections are also gaining ground corresponding additional costs in produc- ture can be evenly distributed in the PCB.
for terminal blocks up to 10 A. tion. But do you really have to deal with this The contact pins must also feature the
 

30 Elektor Industry 1/2021 www.elektormagazine.com


Figure 2: Instead of the common bracket Figure 3: Press-Fit terminals combine a very high Figure 4: The REDCUBE Plug series offers four
elements on the market, the REDCUBE THR current carrying capacity with high mechanical different plug-in connections from 50 to 120 A
terminals have a special and massive pin design, stability, while still allowing seamless and thus for simple and fast wire-to-board high-current
which provides a perfect soldering result and a cost-effective integration into the pick-and-place connection.
high mechanical stability. process.

correct length for the THR technology, so No Soldering! Press-In! processed. In order to make the advantages
that neither the stability of the contact pin So how can connections be made on a of connection by press-fit technology avail-
in the through-hole is impaired nor solder printed circuit board that are required to able to a wide range of applications, Würth
paste is pressed through the through-hole carry an even higher current and whose Elektronik offers the REDCUBE Press-Fit
and causes solder beads. All these adjust- connection must be mechanically much Terminals made of brass with a tin-plated
ments and the additional cost of tape and more stable and reliable over a long period surface in different variants: Internal thread
reel packaging result inevitably in a higher of time, for example in wind turbines, than (two-row, circumferential or full-surface),
price for the THR elements. But therefore a soldered connection can ever achieve? external thread full-surface, 90° two-row
switch to the conventional THT assembly? This is where press-fit technology comes in. or full-surface as well as two-part as basic
Particularly when THT components are only   and support element.
used in isolated cases, the THR process is Pressing the pins into the PCB, a high  
noticeably more cost-effective in terms of friction between pin and plated through- For anyone looking for a quick and easy way
its overall cost. In addition, significant space hole generates a homogeneous cold-weld- to implement a wire-to-board high-cur-
savings on the board can be achieved with ing between materials (Figure 3). This rent connection, Würth Elektronik offers
this process. results in a gastight, strong mechanical the REDCUBE Plug, the latest addition to
  connection with contact resistance less the series (Figure 4). This connector also
Whether it is a forklift, elevator or simply than 200 μΩ. No other technology transfers comes with all the advantages of press-fit
a battery charging connection, high vibra- power up to 500 A at this low heat develop- technology and completely without washers
tion resistance is a key requirement for ment. In principle, the vias are produced in and nuts/screws. The small red cube made
power connectors in applications where the same way as the holes for accommodat- of glass-fiber-reinforced plastic is capable
they are subject to regular movement or ing THT components. Consequently, there is of accommodating four different plug-in
many mating cycles. REDCUBE THR power no need for any changeover in PCB produc- connections ranging from 50 to 120 A. The
connectors are particularly suitable for such tion. The main difference to THT assembly, screwless connection is made by manually
applications because their contact pins are on the other hand, is that soldering does not actuating the housing from above and
rigid rather than flexible, unlike those of guarantee the solder introduced into the inserting the corresponding plug. By means
other power connectors (Figure 2). Note holes will also rise up the entire sleeve. Not of spring force, the plug is automatically
that the pin geometry also plays an import- only will this affect the mechanical stabil- locked in the housing. The connection
ant role in the THR process, as it must be ity but also the long-term reliability if the can also be released again in this way. The
taken into account when calculating the sleeve is not filled to 75%. This also results REDCUBE Plug is pressed in according to
solder paste volume. There is a simple in much higher contact resistances. Press- the same principle as the REDCUBE Press-
formula for determining the required solder fit terminals are different: If a solid press- Fit. On the cable side, the cable connec-
paste volume: fit pin on a 2.4 mm thick PCB is bonded to tor and cable, with cross-sections of 4,
  the sleeve at each corner with more than 6, 10 or 16 mm2, are connected together
(volume of through hole - pin volume 3° after the press-fit process, the press-fit using a hexagonal crimp. This releasable,
in via) x 2. zone has a lower electrical resistance than multi-pluggable wire-to-board and board-
  the brass pin itself and therefore does not to-board connection is particularly suitable
The factor 2 is necessary because only 50% represent an electrical or thermal bottle- for installation in small spaces or in hard-to-
of the solder paste is metallic and additives neck. Normally, the tether angle is many reach places, as no tools are required. For
such as flux vanish in the process. Optimal times higher, providing a high safety buffer use in chargers, REDCUBE Plugs can be
is a filling level of 100% — according to to the electrical connection. Another advan- supplied in other colors making them easier
IPC-A-610D a more than 75% filled solder tage over soldering is that printed circuit to distinguish.
joint is acceptable. boards with a thickness of up to 3.2 mm
and high copper occupancy can be easily 210067-01

lektor Embedded & Tools 31


feature

Tracking Down
Microcontroller
Buffer Overflows with
By Stuart Cording (Elektor) 0xDEADBEEF
Software development on microcontrollers can be a real challenge at times. Sometimes the
code just doesn’t function as planned, but you can’t really figure out why. In such cases, it is
time to approach the challenge like Columbo, Jessica Fletcher, or (insert your super sleuth
here), do some investigative research, and find out who the culprit is! And for that, you may
need to lay a trap using dead beef (0xDEADBEEF).

Code sometimes stops working as expected for seemingly no rhyme Laying a trap with dead beef
or reason. Perhaps some data changes unexpectedly, the program just One way of checking whether arrays are being written beyond their
seems to “stop,” or the microcontroller resets unexpectedly. The first bounds is to fill them with a known pattern before they are used.
thing to do is to admit that there is most likely a programming problem. Because hexadecimal includes the letters A to F, simple words can
Microcontrollers only do what we tell them to do, so we must have, be formed that provide easy to recognize patterns. One of these is
inadvertently, put it in a position to do the unexpected. Such issues 0xDEADBEEF.
may also arise because we do not fully understand how the compiler  
and linker functions. One way to do this is through the IDE and debugger being used to
  develop the code for your microcontroller (Figure 1). The first step is
to determine the start and end address of the array. Then, using a view
Make the error reoccur of the memory (RAM), it is usually possible to write such a pattern
The first step in your investigation, if the error is sporadic, should be to from the start address to the end address.  
determine how to make the error reoccur. Only by invoking the error  
repeatedly are you able to undertake further tests to see whether you The best approach to this debugging method is to download the code
can make it “go away.” However, you need to make sure the cause is to the microcontroller and allow the code to run until main() has been
clear so that you can be sure that whatever you changed actually reached (set a breakpoint at main() or use a “run to cursor” feature).
resolved the error and didn’t just shift the problem elsewhere! Determine the start/end address of your array, write the pattern, and
  then allow the code to execute for a while. Pause code execution and
It is tempting to add extra “test code” and variables to help in this then check the memory location you filled with your 0xDEADBEEF
process. If such a change makes the error “disappear,” it could be that pattern. If none of the pattern can be found, this may be because data
a memory problem is the cause of the issue. These can be the result has been written beyond the end of the array at some point. All that
of buffer overflows or an overflow of the stack. is left is to determine when and why.
   
Buffers are typically implemented as arrays on microcontrollers in C Note: Your development environment (IDE) may not allow the full
and will be defined with a fixed length. Less used on microcontrol- 0xDEADBEEF pattern to be written. In the examples included here using
lers, but also possible, is an array that is allocated at run-time using MPLAB X, only 16-bit patterns can be written into the memory of the
“alloc” (such as malloc or calloc). These are known as dynamically PIC24F (as it is a 16-bit microcontroller). Here we chose to just use
allocated arrays. Either way, the C language makes it very easy for 0xBEEF, which is also easily recognizable. Alternatively, you may be
programmers to write code that accesses memory beyond the defined able to write your pattern into an ASCII file, save it to your hard drive,
bounds of an array. The result: writing to an array could accidentally and then load it into memory.
overwrite neighboring variables.  
 

32 Elektor Industry 1/2021 www.elektormagazine.com


Figure 1: The development environment (here MPLAB X IDE) can be used to fill a section of RAM with a pattern.  

Did my memory change? If your 0xDEADBEEF pattern is completely gone, it will be difficult to
Another helpful feature of most debuggers in such investigations is know how far the erroneous code has written beyond the bounds of
that they highlight memory locations that have changed in a specific the array. In such cases, try defining additional arrays as a “buffer”
color, such as red, when the microcontroller is halted. If you halt code before and after the array being examined (Figure 3). This is a little
execution with the memory region you are examining in view, any tricky in C/C++ as, without some extra code, you cannot define the
bytes that have changed in value in the meantime will be shown in this address to which variables are allocated. However, generally speaking,
different color (Figure 2). This can be especially helpful if any third- variables defined after one another in code appear after one another
party functions or libraries were called that may have overrun a buffer. in memory too. This means that if you declare some “extra buffer”
 

Figure 2: Since the MCU was last halted the memory location circled in orange has changed, as its contents are highlighted in red. Black values denote no
change. If you weren’t expecting these values to change, you may be on your way to finding your software bug.

lektor Embedded & Tools 33


Figure 3: Two extra arrays defined to help debugging are, luckily, located at addresses before and after the array we are investigating. The linker can also be
forced to use specific addresses if this is not the case.

arrays, one before and one after the array you are investigating, you’ll             y++;
probably find they are allocated directly before and after that array             if (y >= 4) {
in memory. Simply fill all arrays with 0xDEADBEEF, execute the code,                 y = 0;
then check to see if the pattern in all array is intact.               }
          }
    }
Debugging real-time code }
Many real-time applications, such as those controlling motors, or  
implementing interfaces like USB or Ethernet, cannot be stopped and The code can be allowed to execute in its entirety until it either stops
debugged line by line as this would stop them working completely. This due to the error, or the microcontroller is halted by the developer.
means that we cannot stop the code to write the 0xDEADBEEF pattern When this occurs, the memory can be analysed using the IDE. Even
into memory using the IDE. Instead we need to do this in software. if the error caused the microcontroller to reset this does not clear the
This is simple to implement using a short array that is pre-filled with memory (unless some start-up code clears it all to zero) as long as it
0xDEADBEEF and a bit of code that copies it into the array(s) your are remains powered on. This means the debugger can still access the
investigating (Figure 4). RAM in the state it was in before the reset and you can search for
  any buffer overruns that have overwritten your 0xDEADBEEF patterns.   
/* Example code that writes 0xDEADBEEF pattern into an  
array on a Microchip PIC24F microcontroller */
  Filling the stack with 0xDEADBEEF before main()
#define ARRAY1_SIZE 16 Another possible issue is that the stack is being written beyond its limits.
uint8_t deadbeef[] = {0xDE, 0xAD, 0xBE, 0xEF}; Many microcontrollers have hardware detection for stack overruns.
uint8_t array1[ARRAY1_SIZE]; However, such a feature may not be available, or you may have defined
  the use of RAM differently. The stack can, of course, be filled using the
int16_t main() { IDE as already mentioned. However, you may need to fill this space
    uint8_t x = 0; with your 0xDEADBEEF pattern before your code executes (i.e., before
    uint8_t y = 0; main() is reached).
   
    while(1) Microcontrollers have quite a bit to do before main(), more than we
    { have time to cover here, but they include some hooks allowing user
        y = 0; code to be executed before the CPU jumps to main(). This capability
        for (x = 0; x < ARRAY1_SIZE; x++) { can be used to fill the stack with 0xDEADBEEF.
            array1[x] = deadbeef[y];  

34 Elektor Industry 1/2021 www.elektormagazine.com


Figure 4: The example code has written the 0xDEADBEEF pattern into the array being analyzed (marked in orange).

Join the MAX78000 AI Design Contest at


www.elektormagazine.com/ai-contest-max78000

lektor Embedded & Tools 35


Listing 1: user_init function for a PIC24 microcontroller.
/******************************************************************************/
/* Initialize DEADBEEF checking for stack                                     */
/******************************************************************************/
void __attribute__((user_init)) deadbeefPrep(void) {
    uint8_t *stackPointer = (uint8_t*)0;
    uint16_t y = 0;
    
    // Find out where stack is pointing now from SP (WREG15)
    stackPointer = (uint8_t*) WREG15;
    
    // Increment to next memory position after current stack pointer location
    // (we have a byte pointer into word-addressable memory)
    stackPointer += 2;
    
    // Loop through stack area until we reach stack limit address (in SPLIM register)
    for (y = 0; stackPointer < (uint8_t*) SPLIM; ++stackPointer) {
        // Write part of ’DE AD BE EF’ pattern into stack
        *stackPointer = deadbeef[y];
        
        // Cycle through four bytes of DE AD BE EF array
        ++y;
        if (y >= 4) {
            y = 0;
        }
    }
}

The method for doing this varies from microcontroller to microcontrol- The optimal approach to discovering buffer and
ler, but can typically be broken down into the following steps: stack overflows
  Probably the most important thing to remember is that, if the code
> Determine the start of the stack. on a microcontroller doesn’t work as expected, it is probably because
> Determine the end of the stack. of a programming error. Try to determine what causes the problem
> Fill this region with 0xDEADBEEF. so that it can easily replicated. From this point it will then be easier
  to determine which code changes you have made are resolving the
The example in Listing 1, written in C, is for a Microchip PIC24F 16-bit issue and what the ultimate cause may be. If buffer or stack overflows
microcontroller, implementing the user_init function (search the are suspected, try to 0xDEADBEEF them using one of the approaches
compiler documentation [2] for more details) that will be called once discussed here.  
the device is initialized but prior to main().
  200722-01
Knowing that the stack pointer is stored in a specific register, in this
case WREG15, the address to which it is pointing is stored in a pointer
variable. In this architecture, this is pointing to the current return address
for the function currently being executed, so we need to avoid overwrit-
ing it. Therefore, we increment the pointer by two bytes (this is a 16-bit
device) so we can start writing the 0xDEADBEEF pattern from the next
word-addressable location in memory. The remainder of the code writes
the pattern, stopping when the end of the stack is reached. This limit
WEB LINKS
is determined by using the content of the stack limit register SPLIM
(another a register unique to this processor architecture). [1] Elektor articles about microcontrollers:
  www.elektormagazine.com/tags/microcontroller
This approach can be adapted for most other microcontrollers quite [2] Microchip Technology, “MPLAB C Compiler for
easily, but will probably require some in-depth reading of the documen- PIC24 MCUs and dsPIC DSCs User’s Guide,” 2008:
tation for the microcontroller and the compiler tool chain. https://bit.ly/3btCHec

36 Elektor Industry 1/2021 www.elektormagazine.com


background

Quick to Code
Too
and Too Slow to Test?
By Stuart Cording (Elektor)

When it comes to embedded software, testing matters.


We all know this. So, why do we rush to code and wait a
long time before we start testing?

 
Embedded software developers seem very “If carpenters made buildings the way firmware could not be updated without
keen to get on with the business of coding, programmers make programs, the first an expensive jaunt into the field where
eschewing discussions of software architec- woodpecker to come along would destroy the equipment was installed. Despite this
ture, abstraction, and modeling and simula- all of civilization.” inherent lack of room for error, the estab-
tion. Since embedded software, tradition-   lished approach to code development
ally, has had no way of updating released This slightly modified version of Weinberg’s by some embedded software developers
code, there has never really been any room Law [1] really struck a chord. Why weren’t remained unchanged.
for error. So why, with a plethora of model- embedded software developers drawing
ing and simulation tools available, do we upon computer science research and build-
still rush to code and wait so long before ing their code with an appropriate archi- Is there ROOM for a new(er)
starting testing? tecture or using modeling and simulation? development approach?
  While the code executing on microcontrol-
lers past could often be implemented using
The dangers of woodpeckers Too quick to code? a simple state machine, the challenges
It was one of those moments that, quite One answer is that it could be a result of being tackled today are genuinely multi-di-
literally, generated an “aha moment” the generation of the engineers concerned. mensional. Today it is not unusual for a
in my head. Researching background Having grown-up with resource-limited, microcontroller to commutate an electrical
material for the development of a train- 8-bit microcontrollers and mastered how motor using field-oriented control (FOC) as
ing course, I wondered why embedded to squeeze every ounce of performance out well as hosting a number of other tasks. Just
software developers seemed so reluctant of them in assembler, abstraction and the determining the rotor angle and, from this,
to use concepts and methodologies that thought of tool-generated code implied the next commutation point in real-time
were becoming commonplace in other code bloat and an inevitable loss of control. is a significant undertaking, even if the
branches of software development. I had Even the move to C had been a challenge required software is already available.
regularly encountered engineers who for some, despite its closeness to the under-  
had not introduced coding standards, lying hardware. When this is built into a house-
despite multiple people working on the   hold washing machine, IEC 60730 [2]
development of software for a microcon- Another aspect is how C is typically taught, (Automatic electrical controls — Part 1:
troller-based project. None of them had focusing on the “grammar” rather than how General requirements) also needs to
defined any development design rules that best to use it. However, just like a spoken be considered. Most microcontroller
would allow for portable, reusable code. language, competence in grammar does vendors will offer a “Class B” library [3]
And object-oriented design, modeling, and not make the student an eloquent orator. that executes a variety of tests, cover-
simulation weren’t on the radar. It was at   ing CPU registers, program counter and
this point that this, seemingly pertinent, Until the emergence of Internet of Things memory integrity, as well as testing the
quote appeared: (IoT) applications, a microcontroller’s clock. This code needs to be executed

lektor Embedded & Tools 37


of messages via ports, and any resultant
response returns through the ports.
 
Inheritance provides the object-oriented
aspect of ROOM, treating actors as classes
that can be instantiated multiple times.
Each instantiation also inherits the state
machine that, naturally, can be extended
if required. Finally, a further concept is
that of layering. For example, this allows
communication between applications or
Figure 1: An example “Ping-Pong” project in eTrice, showing the “ping” and “pong” actors (left) along
access to services such as timers through
with their behaviors (right). service access points (SAP).
 
This software development approach is
supported by eTrice [7], a package that can
be added to the Eclipse IDE. Models can be
created graphically or textually that gener-
ate code in C, C++, or Java. Simulation of the
model generates message sequence charts
(MSC) for visualization in the external
tool Trace2UML, part of Astade [8], a UML
tool. A tutorial project shows how a simple
ping-pong application can be implemented
(Figure 1), with the delay in the response
provided by a timer SAP. The structure and
behavior can be examined graphically or
in the ROOM DSL. Executing the model
Figure 2: The Message Sequence Chart that results from simulating the “Ping-Pong” model. provides the results on a command line.
Finally, the result of the simulation can be
examined as an MSC (Figure 2).

“in parallel” to real-time motor control. the application code, is known as a phase
Additionally, there are likely to be commu- discontinuity [5]. Ideally, any modeling Why so slow to test?
nication interfaces in use that must also approach should resolve this which is After rushing to start coding, many embed-
respond in a timely manner, along with the case with the Real-Time Object-Ori- ded development teams seem to be very
a human-machine interface. While an ented Modeling (ROOM) domain specific reluctant to begin testing until a good
embedded software developer can be sure language (DSL) [6]. Designed specifically for portion of application development is
all these features operate in isolation, what the needs of those developing event-driven, complete. The reasons for this are diverse
will happen when they are all integrated? real-time systems, it supports modeling and complex. They start with the misguided
  and simulation while also being capable view that testing is expensive and has to be
One option is to use the Unified Modeling of generating code that can be used on the done by a testing team or department. Lack
Language (UML) and simulate a model of the target hardware. of clear, testable requirements for individ-
application. But here, there is often signif-   ual software modules is also an issue. And,
icant push-back from embedded software It describes software systems along the perhaps, the availability of powerful debug-
developers. One of the primary concerns is three-dimensions of structure, behavior, gers for our chosen development IDE gives
that it is a waste of time. After all, if you’re and inheritance. Structures can be repre- us the feeling that we checked everything
going to go to the trouble of building a model sented by diagrams containing actors that as we wrote the code.
of the application, you may as well be coding communicate with each other via ports.  
it. Also, UML has been given a bad name Messages passing between them are The results of coding mistakes are humor-
due to misuse as people have attempted to handled by runtime libraries that provide ously discussed in Lisa Simone’s book, If I
apply it to every part of a system [4]. This the services required to support this. The Only Changed the Software, Why is the Phone
abstracted way of working also requires a behavior of actors are described using on Fire? [9]. In one example, an error in a
different development methodology, and hierarchical finite-state machines that can temperature control algorithm is the result
trying to convince a team of developers to also be generated as diagrams. Entry and of an inappropriately chosen data type. While
adopt new methods is challenging. exit code can be defined for the states in Simone excellently describes the debugging
  the target language of the code generator process to find such issues, they should have
This concern regarding coding everything being used (C compiler for a microcontrol- been detected through unit testing.
twice, once as a model and then again as ler). State transitions occur upon receipt  

38 Elektor Industry 1/2021 www.elektormagazine.com


Unit testing is a white-box style test,
meaning the test is written with a knowl-
edge of the source code, typically by the
person who developed it. On a micro-
controller, this requires writing an appli-
cation that can execute the code, evalu-
ate the responses, and then output the
results, most likely over a serial interface
to a console. This means that a hardware
platform would be required on which to
execute the tests. An Arduino, and many
of its clones, that include a UART to USB
converter make this much easier by allow-
ing test results to be output to a console.
But it is still a significant amount of work
to maintain a testing application for each
software module developed.
  Figure 3: Testing individual software functions on the microcontroller hardware in testIDEA (Source:
The software testIDEA from iSYSTEM iSYSTEM AG).
provides an excellent and straightfor-
ward way of lowering the testing effort
[10]. As a debug tool manufacturer, their especially challenging since much of the tested, help is at hand in the form of
development environment already has relationship between the source and binary MBTsuite [12] from sepp.med GmbH. This
access to the source code and the micro- code is lost. By running the same suite of model-based testing framework is ideally
controller’s internal workings via the testIDEA tests it is possible to determine if suited to integration and system testing as,
debugging interface. All it requires is a the basic code still functions as expected at this stage of the development process,
compiled application (ELF format) that before moving to testing at the integration it is difficult to determine all possible test
can be programmed into the microcon- or system level. permutations.
troller’s flash memory.    
  The process starts by examining the
Tests are defined in testIDEA that execute How many tests are enough? sys­tem’s requirements and entering them
individual functions using defined For those new to testing, it can be into a tool such as Enterprise Architect [13].
test values for the function parameters challenging to determine the optimal From here, a model of the system can be
(Figure 3). With full access to the RAM, strategy to apply. Testing quickly becomes constructed, with the model being linked
all data types and pointers can be inserted much like the rabbit hole of Alice in back to related requirements to show
with ease. Success or failure of the test Wonderland in that the more you look how they are tested. Complex aspects
depends on the return value provided by at what to test, the more there seems of the design can be broken down into
the function called. Additionally, tracing to test. Again, due to the multi-dimen- sub-models, keeping the top-level clean
can also be enabled during testing, provid- sional aspects and dependencies, it and the model well abstracted (Figure 4
ing code coverage in addition to the results becomes unclear how much testing is and Figure 5).
of the testing. C++ is also supported but enough. Anyone who has worked on  
requires the additional step of calling the a safety-critical project will also know With the model complete, it is imported
constructor before any of the methods that the applicable standards, such as into MBTsuite. The tool allows a test plan to
can be tested. Tests can also be exported ISO 26262 for automotive and ISO 14971 be generated according to a variety of strat-
into Python, allowing test execution to be and IEC 60601 for medical, are open egies. Full Path Coverage would attempt
automated. to interpretation. As an example, ISO to develop a testing plan covering the
  26262 states branch coverage as “highly entirety of the model, while Shortest Path
One impressive capability is that all the recommended” for structural coverage attempts to find the shortest paths through
internal and private variables can be metrics, while statement coverage and the model, as the name suggests (Figure 6).
injected with values or evaluated as part MC/DC (modified condition/decision The Random strategy can help discover
of the testing procedure. When you’re coverage) is only “recommended” [11]. issues that may not be found using the
the debugger, you can do anything. This Only by working with experts in testing more formal approaches. It is also ideal for
is helpful when testing code compiled can you determine what this means in performing a smoke test to ensure both the
using optimization. As is well known, due the context of your application and how hardware-under-test and the test harness
to the removal of unused code and shuffling best to implement it. are working correctly.
of code fragments, software built using    
optimizations often results in code that To ensure that all possible branches of As can be seen in the Electric Park Brake
doesn’t function precisely as the non-op- code are covered and that, as far as possi- (EPB) model (Figure 4), it is possible to move
timized code did. Debugging such code is ble, all permutations of code have been cyclically through many sections of the

lektor Embedded & Tools 39


 
At its simplest, MBTsuite generates the
tests as a Word or Excel document that
lists test steps and verification points where
an expected outcome of each is given.
Manual testing can then provide a pass/
fail result using a tick-box for each step.
However, if an automated approach to
testing is desired, the test can be exported
in an appropriate format, such as Python,
in combination with a suitable template.
 

Rapidly testing on hardware


Ideally, hardware-in-the-loop (HIL) testing
is required to put an application through its
paces. This is especially helpful for appli-
cations operating at dangerous voltages
and currents or when moving mechani-
cal parts are in play. However, such a test
harness can be very expensive. Many teams
may also only have one harness available to
Figure 4: The model of an Electric Park Brake in Enterprise Architect. test multiple variants of the products they
develop. As a result, the HIL can become
a severe bottle-neck and testing there-
fore occurs very late in the development
process. Under the current restrictions
imposed by the Coronavirus, HIL testing
may simply be unavailable.
 
To circumvent this challenge, PROTOS
Software GmbH has developed its miniHIL
platform. It consists of a hardware board
around the size of an A4 piece of paper. On
the right-hand side is space for an STM32
Nucleo development board, while on the
left-hand side sits a powerful STM32H743.
In the middle are a collection of pins that
serve as a connection matrix between the
two sides. The STM32H743 serves to simulate
the plant that the STM32 Nucleo controls
and provide any signals the plant gener-
ates. This makes it ideal for testing motor
control application code without having to
run the code on a real washing machine or
electric drill.
 
The environment is supported by eTrice and
the CaGe [14] (Case Generator) language
to develop the tests. Not only does this
allow the developer to rapidly check that
Figure 5: The sub-model of “Release Brake” in Enterprise Architect with link to the requirements. code changes function as expected, but
the entire platform can be combined with
a continuous integration (CI) platform such
as Jenkins [15]. Automated tests can thus
model, potentially resulting in an endless runs and maximum path length. Sections be executed regularly on the hardware,
loop. To limit such recursive loops, each of the model can also be named, allowing perhaps overnight, delivering the results
testing strategy can be limited in scope tests for a particular feature or capability on a dashboard that can be reviewed first-
with parameters such as number of loop to be generated. thing the next day (Figure 7).

40 Elektor Industry 1/2021 www.elektormagazine.com


Figure 6: The Electric Park Brake model in MBTsuite generating tests according to a Full Path Coverage strategy.

Finding those sporadic failures


Today’s automotive applications are exceptionally complex,
with the amount of code in a vehicle purported to be similar
to that used to code Windows NT [16]. With the distributed
nature of code development, involving many suppliers and
even the automotive customer themselves in some cases, it
is not functionality but timing that is increasingly the cause
of sporadic, hard-to-find failures. This is compounded by the
use of multicore processors and even virtual machines.
 
Despite the wealth of testing undertaken, strange things still
happen once the hardware is ready to ship or, worse, once
it is already in the field. One example comes from the field
of automotive, where two electronic control units (ECU)
connected via a CAN bus displayed intermittent failures.
ECU A connected to ECU B showed failures, but not when
connected to ECU C. ECU B and ECU C worked fine together.
The issue was linked to slight differences in quartz frequency
in each ECU. Over time, the microcontroller’s timing diverged
enough to result in a CAN message occasionally being lost. Complete Electronic Solutions
 
Tools such as chronSIM and chronVIEW from Inchron AG [17]
- Specialist for all HMI technologies
and the TA Tool Suite from Vector Informatik GmbH [18] give - Compelete solutions from idea to delivery
timing the same status as functionality. They allow models - Approved according to medical standard ISO 13485
- Worldwide presence with competence centres
to be built of the target system before any code is written, - Service over the entire product life cycle
enabling system architects to determine the optimal architec-
ture for the code on a variety of target hardware. The impact of
info.de@schurter.com | +49 7642 6820
assigning code to differing cores can also be assessed, essential schurter.com
when heterogeneous multicore processors operating at differ-

lektor Embedded & Tools 41


01_2021_SCHURTER_89x124_elektor_industry.indd 1 20.01.2021 15:56:10
Figure 7: MiniHIL setup integrated with a PC running a Jenkins Continuous Integration server (Source: PROTOS Software GmbH).

Figure 8: The Inchron Tool-Suite places timing, rather than functionality, in focus through modeling, simulation, and analysis. Here an event chain is analyzed
(Source: INCHRON AG).

42 Elektor Industry 1/2021 www.elektormagazine.com


ing frequencies are used. Finally, the evalu- range of development toolchains provided change. Their abstracted nature pushes
ation of chains of events (Figure 8), the by microcontroller suppliers that focus on traditional embedded developers into a
timing from the sensor through the system coding and debugging on target. Being realm of the unknown, far away from the
to the actuator, can be undertaken. This is mainly without cost, they diminish the hardware they know and love. They require
even more critical in today’s era of auton- value of alternative toolchains whose changes to development processes, which
omous driving capability, where sensor existence depends on paid licensing leads to a lot of push-back. Until they are
fusion combines inputs from multiple models. actually in place, their benefits, although
sensors delivering data at differing rates.   clear and sensible on paper, remain intan-
  Tools that support modeling and simula- gible. However, many of the tools discussed
By focusing on both timing and functional- tion of embedded systems provide a way of here have been around for more than a
ity, and defining the allowed execution time taking a step back and abstracting before decade, indicating that they have estab-
of sections of code, the time-related issue getting into the hard work of coding. Due lished their place and role. It remains for
seen in the CAN-connected ECUs mentioned to the inherent repetitive testing and individual developers to investigate each
can be avoided by design. Models can also analysis that results from this approach, option’s appropriateness in the context
be simulated to understand the impact of architectural issues can be determined of their processes and the products they
clock frequency variations, core assign- before application development reaches develop since savings in development time
ment, code execution time, or changes in a stage where it becomes too expensive and costs, and improvements in quality are
clock frequency. To ensure that the timing to change course. Bench-top HIL with there to be had.
requirements are fulfilled, these tools can simulation solutions allow even small (200677-01)
also analyze the trace data captured from the code changes to be assessed in compact
microcontroller operating on real hardware, time cycles, rather than waiting for a big
checking that the execution time of code test of fully integrated code. Finally, the
sections under differing test conditions still most complex real-time applications, such Questions or Comments?
meets the requirements. as those being developed for automotive, If you have any technical questions about
  where modeling and testing are already this article, feel free to contact the author
in widespread use, need to look beyond by email at stuart.cording@elektor.com.
Time to take modeling more functional requirements and include
seriously? timing requirements.
Embedded software development has  
remained very traditional. The “rush-to- Perhaps the biggest challenge to adopt-
code“ mindset is exacerbated by the wide ing these model-based tools is the fear of

WEB LINKS
[1] Weinberg’s Law: http://bit.ly/2WBOeiU
[2] IEC 60730-1:2013: http://bit.ly/37Bq8Lw
[3] Hitex Class B Library: https://bit.ly/2KorSz5
[4] A. E. Bell, “Death by UML Fever,” ACM QUEUE, April 2004: https://bit.ly/3auSCsv
[5] B. Selic, G. Gullekson, P. Ward, Real-Time Object-Oriented Modeling, Wiley, 1994: http://bit.ly/3mJdJtC
[6] Real-Time Object-Oriented Modeling - Wikipedia: http://bit.ly/34xxLkq
[7] eTrice: http://bit.ly/3mGWk4p
[8] Astade: http://bit.ly/34vLxnG
[9] L. Simone, If I Only Changed the Software, Why is the Phone on Fire?, Newnes, 2007: http://bit.ly/3my2nIx
[10] testIDEA - iSYSTEM: http://bit.ly/3rh2BHS
[11] Feabhas Ltd, “A Quick Guide to ISO 26262,” 2016: https://bit.ly/3nHMeSk
[12] MBTsuite: https://mbtsuite.com/
[13] Enterprise Architect: https://sparxsystems.com/
[14] CaGe User Manual: http://bit.ly/3h8ht6M
[15] Jenkins: https://www.jenkins.io/
[16] Infographic: How Many Millions of Lines of Code Does It Take?: http://bit.ly/37BS4iH
[17] INCHRON Test-Suite: https://www.inchron.com/
[18] Vector TA Tool Suite: http://bit.ly/3mBMocF

lektor Embedded & Tools 43


Elektor infographics
By Robert van der Zwan

Embedded and AI: A Tango for Two


At first glance, artificial intelligence
(AI) and embedded computing seem
irreconcilable. “Embedded” is something
engrained in something else, untouchable
and inflexible. AI is all about adaptability,
with phrases like “machine learning”
and “deep learning.” Can the two come
together? They can. This is because
AI will increasingly be embedded in
embedded systems. What’s more: the
growth of embedded computing will
largely depend on AI or rather its subset
ML, machine learning. Just take a look at
the similar growth in absolute terms of
embedded computing and AI, sorry ML.

(Sources: Allied Market Research, Global Market


Insights, Market Resarch Future, Research and
Markets) * CAGR = Compound Annual Growth Rate

Embedded applications
A1

Embedded and AI Staying a Pair


Others (Aerospace,
When looking at the applications where Defence etc.) Healthcare
embedded designs meet AI (or more
specifically ML), it is obvious that
Manufacturing
about half of all AI applications will be
Banking,
implemented in embedded software, Financial Services
not regular software. Judging from a pie Agriculture
chart coming from Grand View Research, Embedded
sectors like healthcare, automotive/ Law
transportation, agriculture, manufacturing Automotive and
Transportation
and “others” (aerospace and defence,
etc.) will adopt ML in their dedicated Retail
software. Other sectors, like banking or
Advertising
retail, can rely rather heavily on AI coming and Media
from external software.

(Source: Grand View Research)

44 Elektor Industry 1/2021 www.elektormagazine.com


Low or High Education? It is a Mixed Bag

%
Accountancy and consultancy firm PwC did substantial research
on the way automation and AI affects the global labour force. It is
of existing jobs at potential risk of automation
difficult to say whether tasks carried out by embedded systems
Wave 1 Low education will take away jobs or will, on the whole, create them. One thing is
(to early 2020s) Medium education certain, however. The level of education matters, certainly when
High education embedded computing and AI meet each other. The first wave in the
Wave 2
(to late 2020s) early 2020s still leaves opportunities for any kind of job. From 2030
onwards, embedded AI really takes hold, especially in the sectors
Wave 3 of transportation and manufacturing.
(to mid-2030s)

0 10% 20% 30% 40% 50% (Source: PwC, based on OECD/PIAAC data)

Factors that Impact the Global Embedded Computing Market


What makes the embedded computing
market with or without AI such a solidly Use in consumer electronics
growing market? Well, the negative
factors are in a minority and on their way Initial Investments Usage in
out. The positive factors are in a majority Artificial Intelligence
and on the rise. The two negative ones:
initial investments (are less necessary)
and hardware limitations (successful
Hardware limitation Emerging economies
work in progress). The five positive ones:
design (becoming smarter by the day),
the ever growing popularity of consumer
electronics, the maturity of AI, the still Design & configuration Evolution in Internet of Things
emerging economies and… the growth of 2015 2022
a phenomenon called IoT.

(Source: Allied Market Research)

Factors that Impact the Global Machine Learning Chip Market


Which are the factors that determine the Emergence of quantum computing
success, or lack thereof, of the machine
learning chip market? Allied Market Popularity of IoT Growth in number of
Research puts them in a spider web, only across the globe machine learning applications
to come to the conclusion that embed-
ding ML in chips will become ever more
popular. This is not only because the
Increase in efforts to make Trending Artificial Intelligence (AI)
IoT drives AI like no other. Or because more human-like robots
human-like robots will be in high demand.
It is also because the dearth of skilled
Increase in demand for smart Dearth of skilled workforce
workers is retreating slowly, as is the AI homes & smart cities
phobia among the public. Chances grow,
Al Phobia
but scepticism will not.
2017 2025
(Source: Allied Market Research)

lektor Embedded & Tools 45


feature

How to Make
Design for Manufacturing

Contributed by Eurocircuits
Easy
Design for Manufacturing (DFM) offers decisive advantages: it reduces costs in prototype
and series production, increases the quality and reliability of assemblies and conserves
valuable resources. Eurocircuits’s freely available Visualizer makes DFM possible: fast,
easy, and right first time.

Figure 1: The Eurocircuits Visualizer can be used to validate design parameters or to find more cost-effective options.

 
When designing a PCB, the first thing that nents and considered as early as possible The layout of a PCB and which components
comes to mind is, of course, the electrical in the design process. As most of the series are used helps to determine the production
functionality. However, the PCB must be production costs are determined during the cost and reliability of the hardware. There-
manufactured and populated with compo- prototype phase. fore, it is important to have a cost optimised

46 Elektor Industry 1/2021 www.elektormagazine.com


prototype as it can easily be transferred to ing experience in their online engineering different PCB types. PCB designers also
series production and thus fast entry of the platform Visualizer (Figure 1). The Visual- use the Visualizer to validate the data for
product to the market. izer is a powerful tool for design review assembling the PCB. For this purpose, the
  and verification. Available 24/7, free of BOM and CPL can be uploaded, and the
Designers would greatly benefit by taking charge in 6 languages. Visualizer is also data validated. The central element is
into consideration the realities of PCB a user-friendly online ordering and price Eurocircuits’s database with over 250,000
manufacturing and assembly. A PCB is calculator. The platform was completely electronic components.
very complex and technically demanding revised and further enhanced in 2020.  
to manufacture as it is made of different   The PCB and assembly are virtually
materials and process steps with unavoid- Interactive DFM tools for PCB production manufactured in before ordering. This
able manufacturing tolerances. An experi- and assembly are integrated in the Visual- helps designers validate their design is
enced PCB manufacturer knows how to izer to check the design data is complete, right the first time for manufacture — a
manage these influencing factors and show critical points in the design and give validated parts list and component place-
optimise their process. Nevertheless, indus- concrete suggestions to correct design ment for assembly together with a 3D
trial tolerances are reality and unavoidable. errors. The goal is always to suggest visualisation of the assembly. Validating
solutions where its alternative component the data/design shortens development
An Industrial-Quality Design parts or design changes to achieve a design times and makes it possible to optimally
Right the First Time that is suitable for manufacture (Figure 2). move prototypes into series production at
When designing fault-free and reliable   any manufacturer.
PCBs, having knowledge of the manufac- The Visualizer works with over 700 rules  
turing processes and their tolerances helps. to validate the parameter selected and 210166-01
Eurocircuits has packaged its manufactur- has over 900 predefined build-ups for

Figure 2: Eurocircuits Online tools support the optimal design flow with the aim of getting it right first time (Right First Time for Manufacture).

WEB LINK
[1] Eurocircuits Website : www.eurocircuits.com

lektor Embedded & Tools 47


feature

More Effective Analysis of


Environmental Sensor Data

By Mark Patrick (Mouser Electronics)

Through Automated Cloud-Based Analysis


For the Internet of Things (IoT), tens of billions of nodes are To maximize efficiency and keep response
expected to go into operation over the next few years. times as short as possible, it will be neces-
sary to put an automated decision-making
One of the major uses of this technology will be the process in place – and this will call for the
monitoring of different key environmental parameters. employment of advanced algorithms. Just
Finding an efficient way to carry out in-depth analysis on storing a set of rules on a database then
cross-referencing them against the data
the vast quantities of data continuously being acquired received isn’t effective when you take into
and initiating an appropriate reaction is not that simple. account the sheer number of IoT nodes that
To maximize efficiency and keep response times as short as are likely to be involved. Such an arrange-
ment could quickly become snowed under.
possible, it will be necessary to put an automated A more sophisticated, yet streamlined,
decision-making process in place. approach is therefore needed.

The Rete Algorithm


The Internet of Things (IoT) is now start- maintenance, or has reached the end of Some have concluded that the Rete
ing to see significant implementation, its working life and should be replaced algorithm is the key to this. Already
with tens of billions of nodes expected to altogether. applied to a vast array of business cases,
go into operation over the next few years.   this was first developed back in the late
As widespread roll-out begins in earnest, Finding an efficient way to carry out 1970s. The core objective of the Rete
one of the major uses of this technology will in-depth analysis on the vast quanti- algorithm is to provide a pattern matching
be the monitoring of different key environ- ties of data continuously being acquired mechanism through which the vast quanti-
mental parameters – such as temperature, through the sensor devices incorporated ties of pattern data (such as those that IoT
air humidity, carbon monoxide levels, etc. into an expansive network of IoT nodes, networks are now starting to generate) can
Via this captured data, it will be possible then initiating an appropriate reaction is be rapidly compared against a database
to make decisions and identify appro- not that simple. Though it may not present containing many different objects. The
priate actions to take. For example, let’s a challenge when there is just data coming need for data iteration is avoided, with
consider a chemical processing plant. If the in from a small number of nodes, coping the status of a particular pattern being
gas content output from a chimney was to with the weight of numbers that an indus- kept in a memory reserve throughout the
exceed a predetermined threshold, then trial control or environmental monitor- process. The upshot of this is that there is
it might be necessary to reduce the level ing system will have is something entirely no need to revert to rules that have been
of processing activity at that time. Alter- different. This is equally applicable to a applied previously — thereby accelerat-
natively, it may be a sign of a longer-term broad spectrum of potential contexts, such ing the whole procedure and making it
trend that will need addressing — perhaps as smart homes/buildings, factory automa- much more time efficient than alterna-
the processing equipment involved requires tion, agriculture, smart cities, etc. tive methodologies.
   

48 Elektor Industry 1/2021 www.elektormagazine.com


About the Author

As Mouser Electronics’ Technical


Marketing Manager for EMEA, Mark
Patrick is responsible for the creation
and circulation of technical content
within the region — content that is
key to Mouser’s strategy to support,
inform and inspire its engineering
audience. Prior to leading the Technical
Marketing team, Patrick was part of
the EMEA Supplier Marketing team
and played a vital role in establishing
and developing relationships with
key manufacturing partners. In
addition to a variety of technical and
marketing positions, Patrick’s previous
roles include eight years at Texas
Instruments in Applications Support
and Technical Sales.
Figure 1: UrsaLeo IoT hardware — comprising a Thunderboard 2 module and a Raspberry Pi 3B+.

Operating in conjunction with Silicon Labs’ triggering when a mobile node moves compiled data can be transferred back to
Thunderboard 2 sensor module and the outside/into a given area. This could be the cloud via either its wireless (Wi-Fi) or
Raspberry Pi 3B+ (which is pre-loaded with used to keep forklift trucks within prede- wireline (Ethernet) connectivity options.
Yocto Linux), UrsaLeo’s cloud-based analy- termined confines on the factory floor, or Depending on the application scenario, the
sis software follows this tactic. It enables in fleet management and livestock track- hardware may be powered by USB or using
captured data to be actioned by applying ing applications. Furthermore, if a captured a Li-Ion coin cell battery.
a tree-based rule structure for pattern data value is unusual (e.g., it remains the  
matching, rather than having to refer time same constantly or is permanently at zero), The tree-based methodology employed
and again to a lookup table. This ensures then it may suggest that the sensor is not means that this system is fully scalable,
that better-informed decisions are made operating correctly, and this can then be with the ability to attend to any prospec-
without adding unwanted latency to the flagged so that an engineer can be sent out tive number of connected IoT nodes within
system. Customized dashboards displaying into the field to undertake any necessary a network, rather than being limited to a
the compiled datasets can be accessed and repairs. certain quantity. As a consequence, it will
triggers set up to alert operatives if certain be possible for hundreds of thousands of
events occur for which human intervention A Wealth of Different Sensors events/alerts to be dealt with every second.
will be required. The Thunderboard 2 module can acquire Even with a medium-sized server, the
  environmental data from the wealth of system can process 500,000 messages per
By using the intuitive visually-based editor different sensors that have been incorpo- second, and this could be pushed up to 1-2
tool, a set of rules can be established that rated — covering ambient light, air quality, million with a high capacity server.
fully align with the particular application barometric pressure, relative humidity, and  
requirements. A trigger can be set every temperature, as well as having scope for Through the combination of highly
time a message is received, or conversely adding in gas detection functions. A 6-axis optimized cloud-enabled hardware and
if a message has not been received within inertial sensor (for space orientation) and a superior algorithms, the way that IoT data
a specified period. Alternatively, a trigger Hall effect sensor (for geographical orien- is handled can be made considerably more
can be initiated at regular intervals (after tation) are also encompassed. The accom- time efficient than it is today. This will
an hour, a day or a week has elapsed), panying Raspberry Pi board serves as an facilitate the ramp-up of IoT deployments
for long-term monitoring purposes. A IoT gateway (interfacing directly with the to a point where there are hundreds of
geo-fencing rule can also be defined — Google Cloud platform). Through it, all the thousands of connected nodes involved —
allowing the true benefits of this technology
to be realized across all manner of different
Even with a medium-sized server, the system can process
industry sectors.
500,000 messages per second. 21036-01

lektor Embedded & Tools 49


feature

Embedded System
Development with
RISC-V Processors
A Brief Introduction and Market Overview

By Allan He (Embedded System Association, China) on processor instructions; in fact, it is not even a complete instruction
set. RISC-V originated from the University of California, Berkeley. In the
This article introduces the origin and summer of 2010, Professor Krste Asanovic launched a three-month
development of the RISC-V ISA. It briefly research project with his students Andrew Waterman and Yunsup
Lee. The goal was to develop an open ISA in order to work around the
describes the technical characteristics and technical complexity and IP complications of x86 and ARM.
selection guidelines of various RISC-V CPU  
cores and SoC design platforms. We will also The RISC-V Foundation was established as a non-profit organization in
2015. The foundation’s board consists of representatives from Bluespec,
have a look into the features of the RISC-V Google, Microsemi, NVIDIA, NXP, UC Berkeley, and Western Digital, and
instruction extensions and the open-source chaired by Professor Krste Asanovic. The foundation establishes standards
and commercial software development and contributes to the building of the ecosystem of RISC-V cores; the
standards are public and open for download. There are more than 300
tools. The article finally looks forward to the paid members of the foundation, including Qualcomm, NXP, Alibaba and
trend of RISC-V in education and industry Huawei. Members are authorized to use RISC-V trademarks. RISC-V is
development. licensed under the open-source BSD license, any company, institution, and
individual can design a CPU with RISC-V architecture manuals. Last year,
the RISC-V Foundation was renamed to RISC-V International Association,
In the past two decades, ARM has achieved milestones in mobility and and moved its headquarters from the USA to Switzerland; the association
embedded system areas. Today, we are observing ARM establishing completed its registration in Switzerland in March 2020 [1].
its market leadership in IoT, while witnessing the demise of commer-  
cial processor architectures like MIPS. After ARM entered the PC and After a decade of development, RISC-V has logged significant achieve-
server markets that were previously dominated by x86, it has placed a ments in CPU IP core, platform, SoC, and application. To name a few
fair amount of pressure on Intel. Right at this moment, the rise of RISC-V example applications of RISC-V cores: Western Digital’s SSD and
has attracted the attention of the industry. IT giants have been searching HDD controllers that sport SweRV cores, Shenzhen Bluetrum’s TWS
for an alternative to ARM; the openness of RISC-V ISA means they have Bluetooth headset, China Canaan Creative’s K210 AIoT  SoC chips,
found a viable option. In the academia, RISC-V is now replacing MIPS and Bluetooth/generic 32bit/high-speed MCUs from Nanjing Qinheng
and x86 as the architecture of choice in textbooks at a break-neck pace. Microelectronics.
With governments and enterprises adopting RISC-V as the standard,
we are seeing a blowout of new CPU and SoC designs, a growing RISC-V’s Instruction Set
ecosystem, and an ever more engaging development community. The instruction set of RISC-V uses a modular design to organize instruc-
tions, with one English letter representing a module. The most basic
What Is RISC-V? and required instruction set in RISC-V is the integer set, signified by
An Instruction Set Architecture (ISA) refers to the instructions and the letter “I”. Even with just one set, one can implement a complete
their bytes encoding supported by a CPU; it is the bridge between software compiler. Other instruction sets are electable modules, a few
computer software and hardware. CPU families, like x86, PowerPC, notable examples are M/A/F/D/C. If a RISC-V cure is RV32IMAC, it
and ARM, have their own individual ISAs; RISC-V is currently the only means it implements I/M/A/C instruction sets. The 32I and 64I sets
open-source ISA. RISC-V is an open-source ISA, which means it is not in RISC-V are already frozen, so are MAFDQC extensions; 32E, 128I,
an actual CPU chip, but a collection of specifications and standards JBJTPV, and ZAM atomic access extensions are still under develop-

50 Elektor Industry 1/2021 www.elektormagazine.com


ment. Instruction set extension is a unique technical feature of RISC-V;
by working with member institutions and the industry, RISC-V is able
to maintain stable growth [2].
About the Author
 
RISC-V Processor Core, SoC Platform, and ChipRISC-V Allan He is an Embedded Systems Specialist. He served as
Processor Core deputy director of the editorial board of Microcontrollers and
Before we dive into embedded system development with RISC-V
Embedded Systems Journal. He is the founder of an embedded
processors, let’s first converge on a few concepts: RISC-V processor
software company. He frequently speaks in conferences
core (referred to as the core), SoC platform, and SoC chip. Since the
and teaches about embedded operating systems and IoT at
inception of RISC-V architecture, there have been dozens of RISC-V
universities and corporations.
cores and SoC chips; some of them are open-source, some are inter-
nal projects, while others are enterprise-grade cores and platforms.
Western Digital’s SweRV (RV32IMC) is a 32-bit sequential execu-
tion instruction architecture; it has a two-way superscalar design, a
nine-stage pipeline, and is manufactured with a 28-nm process. With education board. Additionally, there are Nuclei’s RV-Start and Sipeed
a top runtime frequency of 1.8 GHz, SweRV processor logs a perfor- Longan Nano development board [4], as well as IAR’s latest RISC-V
mance benchmark of 4.9 CoreMark/MHz, which is slightly higher than GD32 EVAL evaluation kit [5], as Figure 1 below shows.
ARM Cortex A15. SweRV is an open-source project and has already  
been deployed on SSD/HDD controllers produced by Western Digital. China Canaan Creative’s K210 is an AIoT SoC sporting a RISC-V CPU;
  the processor consists of two RV64GC cores with MAFD instruction
There are quite a few examples of open-source RISC-V cores. Rocket extensions. K210 includes a KPU general-purpose convolution neural
Core from UC Berkeley is a classic RV64 design, while BOOM Core network processor to detect human faces and objects in real-time.
from the same university aims for higher performance. ETH Zurich’s The Fast Fourier Transform (FFT) Accelerator on K210 is implemented
Zero-riscy is a typical RV32 design, while their R15CY Core is intended on hardware [6].
for ultra-low-power/small silicon and can be configured as RV32E.  
RISC-V Core PicoRV32, developed by Clifford Wolf, focuses on smaller NXP RV32M1 integrates 4 cores: RISC-V RI5CY, RISC-V Zero-riscy,
footprint and optimization of CPU frequency. ARM Cortex M4, and ARM Cortex M0+ (Figure 2). From a profes-
  sional’s perspective, RV32M1 is more like an engineering prototype
Although open-source cores are suitable for research and teaching, there for developers to evaluate. NXP established the Open ISA commu-
are more works to do if they want to design a commercial SoC. Yunsup Lee, nity (https://open-isa.org/) and has been contributing to toolchain
a co-developer of RISC-V, started SiFive. In 2017, the company announced maintenance and construction of the software ecosystem.
its first RISC-V core and SoC family, together with software and develop-
ment boards. These chips include 28-nm process 64-bit multi-core CPU
U500 that supports Linux, and 180-nm process low-cost IoT processor
core E300. Many more manufacturers are in the business of developing
RISC-V processor cores, including Codasip, Syntacore, T-Head, Andes,
as well as startup companies, such as Nuclei System Technology.

RISC-V SoC Platform


ETH Zurich’s PULPino, open-source project LowRISC, and UC Berke-
ley’s Rocket Chip open-source SoC generator (based on Chisel) are
some of the most well-known RISC-V processor SoC platforms. In
China, Zhenbo Hu, founder of Nuclei, is the initiator of the now popular
Hummingbird E200 open-source softcore SoC platform [3].

RISC-V CPU/MCU Chip


In recent years, RISC-V processor SoC chips have been leaping
forward. One example of well-known SoC chips is the GD32VF103
MCU chip made by GigaDevice; it is based on Nuclei’s Bumblebee
core (RV32IMAC). The GD32VF103 series has a clock speed of 108
MHz, 16..128 KB of on-chip flash , 6..32 KB of SRAM, 4x 16-bit gener-
al-purpose timers 2x 16-bit basic timers, and 2 multi-channel DMA
controllers. GD32VF103 MCU offers a newly designed Enhanced Core
Local Interrupt Controller (ECLIC); it supports as many as 68 peripheral
interrupts and 16 levels of interrupt priority, making the MCU capable
of high-performance real-time computing.
 
There are several GD32VF103 MCU development boards: GD32VF103V- Figure 1: IAR RISC-V GD32V Evaluation Kit (Photo: iar.com).
EVAL full-featured evaluation board and GD32VF103-START entry-level

lektor Embedded & Tools 51


Figure 2: NXP RISC-V Vega Development Board (Photo: open-isa.org). Figure 3: Arty FPGA Development Board Capable of Running RISC-V
Softcore (Photo: digilentinc.com).

NXP played an important role in the early market cultivation of RISC-V > Embedded system and IoT developers will benefit from choos-
by sending out development boards [7] and holding competitions/ ing RISC-V SoC chips. For instance, GD32VF103 series MCU has
hackathons in China. numerous development boards available and supports multiple
  toolchains; AIoT applications can go with K210, which is accom-
Microchip PolarFire SoC is a low-cost, multi-core SoC FPGA; it consists panied by a mature SDK and support of both FreeRTOS and bare
of four 64-bit RV64GC RISC-V application cores, and one RV64IMAC metal. Recently, Linux 5.8 added support of K210 RISC-V to the
core for real-time and monitoring tasks. PolarFire SoC is capable to mainline release. K210 has been successfully adopted in machine
run Linux and is particularly suitable as a development platform for vision/hearing applications like face recognition and intelligent
industrial control and IoT applications. energy meter-reading.
> Universities and research institutions can elect open-source
Choosing Between RISC-V Core, SoC Platform, RISC-V core on FPGA to teach and research in areas like
and Chip computer architecture, OS, compiler, and embedded system.
To the increasing number of practitioners that have started to partic- As an example, Arty FPGA development board that implements
ipate in RISC-V research, development, and education, I have the SiFive open-source Freedom E310 MCU (as shown in Figure 3) is
below recommendations: a mature platform with good software toolchain support [8].
 
> Chip designers can opt to use RISC-V cores and SoC platforms RISC-V’s Advantages in Embedded Systems
to construct their own chips. For example, one can use PULPino Apparently, embedded system, IoT, and AIoT are RISC-V’s most
platform to develop SoC, and adopt RI5CY and Zero-riscy cores; active application markets. RISC-V brings quite a few advantages
a number of companies and universities in China are using them to the embedded system ; they can be summarized in three major
in business/research projects. points.

Figure 4: Reference Application of MultiZone Security IoT Stack (Photo: riscv.org).

52 Elektor Industry 1/2021 www.elektormagazine.com


 
> Open-source and free. Open-source ger riscv-gdb, and open-source debugging
is the new way to be economical and software OpenOCD, which runs on PC and
successful business-wise; it is also the controls JTAG hardware like J-link. OpenOCD
best way for students and engineers to is built in with GDB server and support of
learn. Open-source ISA means develop- GDB commands.
ers can create their own chip architec-  
ture design targeting specific application GNU Open-Source Toolchains
scenarios. A free price tag lowers the bar Common open-source IDEs include SiFive
to enter the chip design arena, allowing Freedom Studio, AndesSight, and Nuclei
grassroots developers to participate. Studio IDE; they are Eclipse-based and are
> Simple and flexible. There are 50 funda- optimized for the vendors’ own CPU cores. A
mental RISC-V instructions in 4 basic developer can download JDK, Eclipse IDE for
instruction sets. The modular design C/C++ developers, GNU MCU Eclipse build
allows a designer to create RISC-V CPU tools, and riscv32-unknown-elf-gcc toolchain
with a simplified instruction set, which by to build his own RISC-V development environ-
extension leads to lower code density and ment. QEUM processor emulator already
smaller energy footprint. The flexibility of supports the RV32/RV64 instruction set,
RISC-V also means it can support a wide which is good news to the growing RISC-V
range of processors, from 8051 to the family; developers can choose software and
ARM A series. OS to run on the emulator, including FreeR-
> Highly efficient and secure. RISC-V can TOS, Zephyr, and Linux [11].
be easily extended with its reserved  
encoding space and user instructions; Commercial embedded software compa-
instruction extensions can accelerate nies have already started to support RISC-V
computation and provide IoT security RV32 and some processor core/chips (e.g.
enhancements. A general approach in IoT GD32VF103 and SiFive E310), Swedish
security is to identify the area of Trusted company IAR’s Embedded Workbench for
Execution Environment (TEE) out from RISC-V and German company SEGGER’s
untrusted environment; hardware TEE Embedded Studio RISC-V are among the
is part of RISC-V’s ISA standard specifi- most popular products available in the market.
cation and can be implemented on any  
RISC-V chip; the specifications include IAR Embedded Workbench
Physical Memory Protection (PMP). IAR’s Embedded Workbench is a develop-
​ ment tool that enjoys fame similar to Keil MDK
Hex-Five has a demonstration of RV32 Core in embedded system and MCU markets. It
with IoT hardware-enforced security domain offers excellent optimization on code size and
separation [9] (see Figure 4). Source code is efficiency; developers can entrust it for compil-
available on GitHub [10]. From the design, we ing, analyzing, and debugging application code.
can see the X300 Bitstream SoC with Rocket The latest version of IAR Embedded Workbench
RV32IMAC core and Digilent Arty A7 develop- for RISC-V is 1.30 with the features as:
ment board with Ethernet support. Software-  
wise MultiZone defines 4 zones of TEE: > Further optimization of the compiler and
  the runtime library,
> Zone 1: FreeRTOS, runs CLI, PWM LED, > Support DSP instructions in the P
and robotic arm tasks. extension and the draft of Packed SIMD
> Zone 2: TCP/IP with PicoTCP, channel specification,
encrypted with TLS. > Support debug based on the Nexus
> Zone 3: WolfSSL TLS 1.3, trusted root, IEEE-ISTO 5001™ protocol and SiFive
encryption keys/passwords, protected Insight solution and
files. > Added support for more than a dozen
> Zone 4: UART, TEE console. MCUs (e.g. GigaDevice GD32V).
 
RISC-V Embedded Software SEGGER Embedded Studio
Ecosystem SEGGER is known for its hardware JLINK
RISC-V ’s software ecosystem is largely debugger in the embedded field. SEGGER’s
open-source with some commercial software. Embedded Studio (Figure 5) started to
Several GNU open-source toolchains support support RISC-V in 2017. In addition to JLINK,
RISC-V, like C compiler riscv-gcc, binary Embedded Studio is compatible with other
tools/linker/assembler riscv-binutils, debug- debugging interfaces like OpenOCD and

lektor Embedded & Tools 53


Embedded Studio has a friendly licensing
scheme. It is free to university students/
lecturers and non-commercial usage; you
can start using it right after agreeing to the
license agreement.

Embedded Operating Systems


A RISC-V processor must accompany
an embedded OS to work in embedded
systems and IoT applications. There are
already sample RISC-V ports in FreeRTOS,
Zephyr OS, ThreadX and µC/OS. FreeRTOS
version 10.3 already has ports on NXP Vega
and SiFive Freedom HiFive1-revB boards;
compiler-wise GCC and IAR are supported.
Figure 5: SEGGER Embedded Studio. SEGGER embOS has a demo with emWin
on GD32VF103-EVAL board. SiFive released
Amazon FreeRTOS port on Github; currently,
  SiFive Learn Inventor education board and
GD-Link. Embedded Studio has compre- Embedded Studio is an integrated develop- Andes Corvette-F1 N25 platforms can take
hensive support for the single-core RV32 ment tool. According to SEGGER, it utilizes advantage of it. In China, RT-Thread has a
instruction set, including RV32I, RV32IMA, Clang/LLVM and GCC C/C++ compilers demo on HiFive1-revB, Huawei LiteOS has
RV32IMAC, RV32IMAF, RV32IMAFC, RV32G, and also supports external toolchains. For demoed on GD32VF103-EVAL board, Tencen-
and RV32GC; support for RV64 and multi-core instance, a Nuclei Embedded Studio project tOS Tiny has a demo PM2.5 monitoring appli-
are reportedly being tested. It also supports by default uses the GCC toolchain optimized cation on GD32VF103 board.
Nuclei Technology’s RISC-V processor core, by Nuclei. More information about Embedded  
Real-Time Transfer (RTT) between host and Studio you can read Rolf Segger‘s blog The As RISC-V ISA intends to enter the high-end
debugger, as well as SEGGER SystemView SEGGER Compiler [12]. computing market, it is critical for RISC-V
software analytic tool.   to gain support by Linux and be admitted

LINKS AND LITERATURE


[1] History of RISC-V: https://riscv.org/about/history/
D. Patterson and A. Waterman, The RISC-V Reader: An Open Architecture Atlas, Strawberry Canyon LLC, 2018.
[2] 
Hu, Zhenbo. RISC-V Architecture and Introduction to Embeddded System Development.
[3] 
China Posts & Telecom Press, 2019. p34-39.
RISC-V MCU Chinese Community: https://www.riscv-mcu.com/
[4] 
Evaluation kit for RISC-V: https://www.iar.com/iar-embedded-workbench/tools-for-risc-v/evaluation-kit-for-risc-v/
[5] 
Kendryte K210: https://canaan-creative.com/developer
[6] 
V32M1-VEGA Development Board User Guide, fetched from :
[7] 
https://github.com/open-isa-org/open-isa.org/releases/download/1.0.0/Documentation.zip
Arty FPGA Evaluation Kit Hands-On + Verification of RISC-V Instruction on SiFve Chip (blog in Chinese):
[8] 
www.cnblogs.com/zjutlitao/p/9745365.html
The first TEE for RISC-V: https://hex-five.com/multizone-security-sdk/
[9] 
[10] Sourcecode at GitHub: https://github.com/hex-five/multizone-iot-sdk
[11] RISC-V Foundation, „RISC-V - Getting Started Guide“ May 2019, p5/14
[12] The Segger Compiler: https://blog.segger.com/the-segger-compiler/
[13] Linux on RISC-V: https://kernelnewbies.org/Linux_5.8#RISCV
[14] RISC-V Computer Architecture Course (includes teaching materials and hands-on exercises for students):
https://bit.ly/3tXvr1h
[15] rCore OS (Site in Chinese): https://rcore.gitbook.io
[16] Embedded System and IoT Development Online Seminar (3): http://hexiaoqing.net/courses/
[17] S. Greengard, “Will RISC-V Revolutionize Computing?” Communication of the ACM, Vol. 63 No. 5, May 2020.

54 Elektor Industry 1/2021 www.elektormagazine.com


into the Linux tree. There have been some tools. Lab code projects and related materials
developments thanks to engineers of Andes, of the courses have been made available for
You CAN get it...
Western Digital, and SiFive. For instance, there the community [16].
Hardware & software for
are demos where Fedora and Debian run on   CAN bus applications…
SiFive HiFive Unleashed. RISC-V is a new RISC-V faces many challenges in embed-
processor architecture that open-source Linux ded system applications. First, embedded
developers clearly take interest in. However, system development requires standardized
as there weren’t many low-cost RISC-V devel- general purpose development platforms; there
opment boards, developers have found it diffi- are very few of them in the market. Second,
cult to work on RISC-V. Recently, Linux 5.8 commercial-grade open-source software is
added official support of K210 [13], which important; support of Linux has been newly
means K210 is no longer only supported by added, but Android may not run on RISC-V
no-MMU Linux. The importance of this news in the immediate future. Third, RISC-V has
is that developers can easily obtain a K210 an active ecosystem, but there hasn’t been
(RV64GC) board to work on it. enough accumulation of achievements in the PCAN-Router Pro FD
community.
Freely programmable 6-channel
Education and Development   router for CAN and CAN FD with
In September 2020, Imagination Technolo- Without a doubt, RISC-V is extremely suitable I/O and data logger. Delivery
gies announced its undergraduate RISC-V- for education research and curriculum in incl. development package with
examples.
based Computer Architecture course titled electronics and information technology. A
“RVfpga: Understanding Computer Archi- brand new open-source hardware model
tecture” [14]. The course was developed signifies the start of an environment that
by Imagination and Harvey Mudd College promotes innovation and cooperation. I
Associate Professor Sarah Harris, who is a will close with words from Michael Taylor,
co-author of the well-known Digital Design & an Associate Professor in the School of
Computer Architecture textbook. According to Computer Science and Engineering at the
Sarah Harris: “RISC-V improves on previous University of Washington in Seattle: “There
processor generations in every conceivable are no serious technical or practical issues
way, from power consumption to performance with RISC-V. It will eventually supplant x86
and even increased security. As another huge and ARM as the primary instruction set for
PCAN-PCI Express FD
step forward in computer architecture it is microprocessors. It will fundamentally change
CAN FD interface for PCI Express
important for students to understand RISC-V the computing world” [17].
slots with data transfer rates
at a fundamental level.” 200659-01 up to 12 Mbit/s. Delivery incl.
  monitor software, APIs, and
Associate Professor Yu Chen of Tsinghua drivers for Windows and Linux.
University leads a team that has been working
on implementing an OS in RUST on RISC-V.
The objectives of their rCore OS, a port of
uCore in RUST, are to improve OS develop-
ment experience and quality using a modern
programming language, as well as to explore
future OS design and implementation [15]. I
have participated in the 2nd and 3rd embedded
system and IoT development online courses
co-developed by BMR, IAR, SiFive, GigaDe-
vice, and Nuclei. These courses aim to help
developers, university lecturers, and students PCAN-Explorer 6
to learn about the latest in RISC-V, embed- Professional Windows software
ded system development, and development for observation, control, and
simulation of CAN FD and CAN
2.0 busses.

related product
> A. He and L. He, Embedded Operating System: Otto-Roehm-Str. 69
64293 Darmstadt
History and Future in the Internet of Things, Elektor 2020. Germany
Phone:+49 6151 8173-20
www.elektor.com/embedded-operating-system Fax: +49 6151 8173-29
info@peak-system.com

lektor Embedded & Tools 55


Wall of Fame
March 2021
Elektor International Media is proud tech innovation. The companies listed on
to present its 2021 Wall of Fame! We this month‘s Wall of Fame offer electrical
partner with top electronics companies engineers, makers, and students a wide
– from global parts suppliers to device range of indispensable tools and solutions
manufacturers – to promote exciting for developing next-generation electronics
products and services that power high- projects and products.

56 Elektor Industry 1/2021 www.elektormagazine.com


Your logo could
be here.
Please call
+49 (0)241 955 09 178

lektor Embedded & Tools 57


feature

Solutions for
Touchscreen Applications
with High EMC Requirements

Contributed by SCHURTER

Touch panel products for the European market must comply ics. By choosing the right components and
filter elements, these emissions are effec-
with European directives and be CE certified. An essential tively combated at source.
requirement is that these products meet the requirements
for electromagnetic compatibility (EMC). Emission Source Controller
The touch screen controller chip used
But which are these? by SCHURTER is a potential source of
emissions if not properly wired. By design-
ing an optimised, customised PCB layout
Other electrical devices in the immediate that all specific requirements are recorded in cooperation with the customer and the
vicinity of a touch panel must not affect the at an early stage and included in the design. chip manufacturer, the emission is kept
operation of this device. The touch panel as low as possible. Consideration is given
must therefore have high immunity to Clever Design to correct routing, filtering of signal lines,
interference. Conversely, the panel must Emitted interference (emission) and demarcation of supply lines and place-
not interfere with other products, so its own immunity are not only determined by the ment of ground planes in the PCB. A multi-
emissions must be low. The EMC require- electronic circuits and their components, layer design provides additional shielding
ment classes vary depending on the appli- but also by the mechanical construction, the against high-frequency interference signals.
cation area of the application. For example, positioning of the electronic assemblies, the As the capacitive touch screen is located
medical devices require a higher interfer- choice of materials and the cable routing. on the outside of the end product, it can
ence immunity for safety reasons. Since SCHURTER takes these influences act as a transmitting antenna for higher
into account in the early design phase, EMC frequencies. For these frequencies and
EMC Specialist problems are avoided (Figure 1). Subse- their harmonics it is sometimes neces-
EMC specialist SCHURTER has decades of quent, costly modifications after comple- sary to integrate an internal shielding of
experience in the field of EMC. This can be tion of the product are therefore avoided. the electronics in the form of metal foil or
seen in the fact that the EMC properties of a complete metal housing.
both the touch screens and the end product Low Emissions
are already taken into account at the design Many electronic devices nowadays work High Interference Immunity
stage. To achieve a well thought-out design with highly integrated, high clocked A PCAP touchscreen must never trigger an
in the field of EMC, SCHURTER engineers circuits, which are often the cause of action if it is not touched (a so-called ghost
are often involved in the project right from emitted interference signals. Furthermore, touch). A touch screen can be disturbed by
the start. Preferably a joint development these signals often have a very high edge high-frequency energy from outside. This
team is put together. This has the advantage steepness, which leads to further harmon- can be conducted or radiated disturbing

58 Elektor Industry 1/2021 www.elektormagazine.com


energy. Additional precautions are taken
to achieve the required high immunity to
interference. These can consist of hardware
solutions such as signal and power line
filtering, the shielding of printed circuit
boards and the wiring. On the other hand,
the touch screen controller chip also has a
number of built-in software functions. These
include a noise suppression algorithm and
the frequency hopping method. Taking all
aspects into account, SCHURTER carefully
selects the best possible solution.

Conducted Interference
Immunity
The developers at SCHURTER have profes-
sional test equipment at their disposal
to determine the conducted immunity
(Figure 2). Already with the first proto-
Figure 1: Conducted immunity EMC test setup for touchscreens.
types, the immunity is verified at the level
of pre-compliance tests in official test
laboratories. If interference is detected
during such a test, the engineer will adjust
the correct parameters in the controller
firmware while in progress and fine-tune
the optimal functionality.

Assembly of the Controller


For optimum EMC properties of the end
product, both in terms of emission and
immunity, it is essential that the touch
screen controller is correctly mounted.
Especially the ground connections, the
wiring and the electrical connection with
other components of the device are essential
in this respect. Ground connections, whether
separate or not, are also important as they
help determine the final performance of a
touchscreen. For customers, SCHURTER
provides detailed assembly instructions for
the correct installation of the touch panel
Figure 2: Performing a conducted immunity EMC test.
with the corresponding controller.
 
Touchscreen Sensor and screen printing process, they are available SCHURTER designs and manufactures the
Capacitive Touch Points in any desired size and shape. SCHURTER touchscreen sensors in-house. This allows
An important component in the design manufactures the sensor design itself, SCHURTER to incorporate the specific EMC
is the sensor. The sensor can be made of matching the respective application. In requirements into the design. SCHURTER’s
polyester or ITO glass. Touch points can also addition to environmental interference, a own facilities offer great design freedom,
be integrated directly on a printed circuit touch sensor can also pick up interference so that every diagonal and every shape is
board. An optimal conductor pattern of signals from the LC display below. This can available.
the sensor is essential for good function- be solved via the electronics of the control- 210042-01
ality. Conductive ITO glass allows transpar- ler or via an additional transparent shield-
ent switching areas for easy backlighting. ing foil between display and sensor.
The sensor itself is laminated or bonded
behind the selected cover lens material. A
connection lug made of polyester or Kapton
WEB LINK
is required for each sensor. As the sensors
are manufactured using an etching or [1]  SCHURTER Input Systems: www.schurter.com/en/Products/Input-Systems

lektor Embedded & Tools 59


feature

Touchless Automation

The Rise of
Contactless
Manipulation
Manipulating objects without touching them has ogy, manufacturing still copes with multiple
always been one of the most widely used magic tricks. challenges. The operations of picking the
components from adhesive tape, manipu-
Unfortunately, these tricks cannot be used in industrial lating them or bonding them to a substrate
environments to produce actual products. The ability of are still creating surface imperfections that
manipulating components without touching them would sometimes require cleaning, sometimes affect-
ing the component functionality for good. Here,
be especially useful for very delicate or fragile components contactless manipulation comes in to play.
like microstructures, thin dies or photonics. The latter is
especially important because almost every component that Contactless handling is a reality
Touchless Automation has been focusing on
deals with the interaction between light and matter needs to providing contactless manipulation solutions
have an almost perfect surface. since its birth. The company is located in
Bienne, a small town in Switzerland famous
for being the center of the Watch Valley. Start-
Manufacturing these components is cumber- photonics components. ing from the need of watchmakers to have
some and many producers report double-digit Photonics has been rising and gaining impor- perfect surfaces for their high-end parts,
defect rates. At the same time, the implemen- tance but, unlike standard semiconductors, the company perfected this manipulation
tation of such components in multiple fields the heart of its R&D and production still lies and launched a line of industrial machines
has been steadily growing in recent years. within western countries. A document issued dedicated to Photonics components.
In 2010, only top level smartphones had two earlier this year by the European Commis- The last product, Levio, has been presented
cameras and the sensors were just check- sion (“A New Industrial Strategy for Europe”, at SPIE Photonics West in San Francisco in
ing if your phone was close to your ear. Now, 10.03.2020) clearly puts Photonics as one of 2019 and it’s already at work on customer
the top smartphones can have more than six the Key Enabling Technologies for the future applications. This machine is able to pick
cameras and a whole set of sensors that can and promises further investments in the field. up from adhesive tape, visually inspect the
do a wide range of tasks such as facial recog- These efforts are particularly effective also components and sort them according to
nition or 3D imaging. But it’s not just commer- thanks to multiple initiatives at European level the results of the inspection. As of today, the
cial electronics that have implemented these such as the European Photonics Industry largest amount of customer requests have
changes. Telecommunications is every day Consortium, EOS and many more local ones, come from laser diodes, micro lenses and
more optical oriented and the upcoming wave such as SwissPhotonics or Photonics France. optical filter producers. But the technology has
of autonomous driving cars will heavily rely on Despite the wide spread of the technol- already proven useful in a multitude of other

60 Elektor Industry 1/2021 www.elektormagazine.com


fields. The company successfully completed can be manipulated, provided that such shapes den and could accelerate the implementation
projects for MedTech components such as are known while the system is designed. of materials that are too brittle or soft to be
pacemaker parts or standard semiconduc- However, Touchless Automation’s main held. Many industry experts have deemed this
tor components. strengths are not just in the manipulation technology to be revolutionary and potentially
This flexibility in the final application attracted of components. With years of experience in the new paradigm of future manufacturing.
the interest of large entities such as the machine making and commissioning, the With customers already in three different
European Commission, which financed part company focuses on developing systems that, continents, Touchless Automation has been
of the development and the European Space starting from the Levio platform, can be easily expanding quickly and aims to become an
Agency, which welcomed the company in its adapted to many different processes. To align industry leader in the coming years. The list
ESA BIC Switzerland program. further with the needs of the application, the of applications has been expanding greatly,
inspection system can be modified accord- but the company is always looking for new
The technology ing to the defect to be caught. For instance, challenges.
The innovation of the company lies in its laser diode facets usually require detection of
technology. The manipulation is the result of a submicron defects, while for optical compo- 200210-01
combination of two opposite forces. A vacuum nents such defects can be orders of magni-
suction pulls the component up and allows tudes larger and still be tolerated. This flexi-
it to be lifted. At the same time, the very tip bility allows for cost effectiveness and proper
of the gripper vibrates at high frequency. This allocation of resources, without wasting
vibration generates a thin air cushion between money on a system that is more powerful
the component and the tip itself, which forbids than is needed.
them from coming into contact.
This manipulation technology allows for a very A brighter future
stable grip but, at the same time, never physi- The coming of contactless manipulation will
cally touches the piece. In this way, all of the enhance state of the art processes, increasing
component surfaces remain unscathed and component quality, decreasing defect rates
the final component is processed without any and the need for cleaning steps, also provid-
defect. ing also industrial waste reduction. However,
Relying entirely on air and fluidic phenomena, this is only the first and most direct effect. The
it is possible to manipulate components of any possibility of handling components in such a
material and with a wide range of shapes. Even delicate way will unlock design possibilities for
components with convex or concave surfaces microcomponents that are currently forbid-

lektor Embedded & Tools 61


With Matthew Stewart

What Is
tinyML?
Questions by C. J. Abate (Elektor)

A subcategory of artificial intellience, learning was piqued by taking the introductory data science course
at Harvard during the first year of my PhD work, which was when I
machine learning (ML) has applications realized the huge potential of machine learning both generally and
in a wide range of fields, including atmo- also specifically for atmospheric research.
spheric science and computer vision. As  
Abate: What led you to Harvard University?
Harvard PhD candidate Matthew Stewart  
explains, tinyML is an emerging disci- Stewart: Well, the obvious response is that Harvard is one of the
pline for developing “fast, low-resource, top research institutions in the world and studying here is the goal of
many passionate and hard-working students. I was also drawn by the
and power-efficient implementations of research interests of my supervisor, who studies the tropical Amazonian
machine learning algorithms that can be rainforest using drones. I became interested in pivoting to environmental
operationalized on resource-constrained science through the course of my mechanical engineering degree as it
became more clear to me that most of the defining engineering problems
microcontrollers.” of the modern age will be environmental problems, namely climate
change, energy security, and sustainability. This work on drones in the
Amazon rainforest seemed ideal based on my interests and engineer-
C. J. Abate: Let’s start with your background. When did you first ing background and was the main stimulus for coming to Harvard.
become interested in machine learning [1]? Did you come at the field  
due to a background in programming or hardware design? Abate: As an environmental scientist, how do you keep yourself
  educated about embedded systems and programming? It must be
Matthew Stewart: For my undergraduate degree, I studied difficult to stay on top of all the new developments in the AI field, as
mechanical engineering, so this gave me some experience in program- well as innovations in sensor technology, embedded systems, and
ming and mechatronics. However, I was not introduced to machine so on. What’s your approach to staying informed about these various
learning until starting at Harvard University. My interest in machine subjects?
 

62 Elektor Industry 1/2021 www.elektormagazine.com


Stewart: This is a very real issue for many graduate students and For example, in some applications it may be imperative to have both
academics due to the relentless and rapid progress in these fields. fast inference and high accuracy. To improve inference speed, we could
Personally, there are several resources I use to keep relatively up-to- use 8-bit arithmetic instead of floating-point arithmetic, but this will
date. Firstly, Twitter can be a good resource for discovering new have an impact on the accuracy of our algorithm, and will also influ-
research posted by other academics in the field. I am also part of ence the memory and compute resources required for the algorithm.
several Slack channels wherein colleagues periodically share news This example helps to highlight why I view tinyML as a proto-engi-
and research articles about related topics. I also periodically review neering discipline, since we are starting to think more about functional
new papers published in relevant journals to look for anything particu- requirements that must be satisfied but are often in direct competition
larly eye-catching and worth reading in more detail. Fortunately, most and must be balanced.
published work is of little relevance to my own research, and broader  
trends are often the subject of seminar talks given by various depart- Abate: Can you provide a few examples of practical use cases?
ments and interest groups within the university.  
  Stewart: Actually, there are already some quite widespread examples
Abate: Although I touched on tinyML during an interview Daniel of tinyML in smartphones. An important example is keyword spotting,
Situnayake [2] a few months ago, it remains a new subject for many which involves the detection of words such as “Hey Siri” and “Hey
of the engineers in Elektor’s global community. How do you define Google.” If smartphones used the CPU to continuously monitor the
tinyML? Is it basically an approach for running machine learning appli- microphone and detect these words, your phone battery would only
cations on edge microcontrollers? last a few hours. Instead, a lightweight digital signal processor contin-
  uously monitors for these words and, in the event that someone says

“tinyML is not a specific technology or set of principles, exactly, it is more of a


proto-engineering discipline involving synergy of the fields of computer architecture,
performance engineering, and machine learning.”

Stewart: Yes, that is essentially the goal. tinyML is not a specific the keyword, wakes up the CPU, verifies that it was said by a known
technology or set of principles, exactly, it is more of a proto-engineer- speaker, and then waits for additional voice input.
ing discipline involving synergy of the fields of computer architecture,  
performance engineering, and machine learning. The overarching Another example exists in smartphones that helps to detect when a
goal is to develop fast, low-resource, and power-efficient implemen- user picks up their phone. Data from the onboard inertial measure-
tations of machine learning algorithms that can be operationalized on ment unit and gyroscope are continuously monitored, and when a
resource-constrained microcontrollers. This can also involve the devel- user picks up their phone the set of signals informs the device of this
opment of bespoke hardware for specific tasks, the development of new and subsequently wakes up the CPU.
algorithms specifically designed for resource-constrained applications,  
or new tools to port algorithms or optimize their performance across Another useful example is person detection, where a microcontroller
a wide range of hardware architectures. A useful guideline has been connected to a camera can detect the presence of an individual. This
proposed referring to tinyML as the application of machine learning can be adapted to, for example, detect whether a user is wearing a
to microcontrollers with less than 1 MB of random access memory mask, which is particularly useful during the current pandemic. Anomaly
and power consumption less than 1 mW, but this is by no means a detection will likely become an important use-case in industry, where
rigorous or exhaustive definition. signals from heavy machines can be continuously monitored to detect
  abnormalities for predictive maintenance purposes.
Abate: And just to be clear: we aren’t talking about devices like  
the NVIDIA Jetson and Raspberry Pi. The focus is on much more Abate: In 2019 you published a fascinating article, “The Machine
resource-constrained devices (i.e., less than 1 mW and kilobytes rather Learning Crisis in Scientific Research,” [3] which addressed the issue
than megabytes), right?  of whether machine learning is contributing to a “reproducibility crisis”
  in science. For instance, if a scientist uses a “poorly understood” ML
Stewart: Correct. Devices like the Raspberry Pi and NVIDIA Jetson algorithm in an experiment, it might mean that other scientists cannot
are not the focus of tinyML, nor are technologies related to applica- reproduce the original research results. Even non-scientists can see
tions such as self-driving cars, which often have access to consider- the problem there. I assume the debate — machine learning vs tradi-
able computational resources. The key word is “resource-constrained”, tional statistics — has only intensified over the past year. What are
which almost suggests we are playing a zero-sum game. In tinyML, your thoughts now?
we must make informed decisions on how best to optimize the perfor-  
mance of our algorithm in terms of application- and hardware-spe- Stewart: I think this is still an important issue in academia. My article
cific constraints. on this subject was in response to the reproducibility crisis which first
  surfaced over the controversy of some work done on the topic of power
poses by Amy Cuddy, a former Harvard Business School professor.

lektor Embedded & Tools 63


Andrew Gelman wrote an influential paper decrying poor research Stewart: Generally speaking, I think many people working in this
practices in the field of psychology that involved disingenuous data area are anticipating the advent of tinyML in one form or another to
analysis using techniques such as p-hacking, post-hoc rationalization, kickstart a new industrial revolution. For this reason, some have taken
and cherry picking of data to produce statistically significant results. to referring to this newly envisioned stage of industry as “Industry 4.0.”
This led to a series of experiments aiming to reproduce some import- Any industry working with large numbers of IoT devices will see large
ant results in the psychological literature, many of which were not benefits from using tinyML by virtue of the reduced power consump-
reproducible. This exposed a flaw in the research process, wherein tion and network loads associated with tinyML.
reproducibility studies were often not funded as they were seen as  
unnecessary and a waste of resources. Since this time, the repro- More specifically, there are certain industries that are likely to obtain
ducibility crisis has also been found to have impacted other fields, greater benefits from the new capabilities offered by tinyML if leveraged
including literature and economics. correctly. Agriculture is a good example. The use of tinyML in agricul-
ture may allow for intelligent sensing capabilities without requiring
connection to a power grid, that could help to determine when certain
“Any industry working with large numbers crops should be harvested or require additional fertilizer or water.
 
of IoT devices will see large benefits from
Another good example is heavy industry, as alluded to previously,
using tinyML.” whereby performing predictive maintenance using anomaly detection
could result in cost savings and an increase in efficiency. Pre-empting
  issues in large machinery is likely to be less expensive and result in a
Naturally, this corruption of the integrity of the research process leads smaller loss of productivity than the aftermath of a catastrophic failure.
to concerns about the use of large data sets and machine learning.  
Given a large enough number of variables in a dataset, it is ultimately Abate: What about companies interested in developing energy-ef-
inevitable that some statistically significant results will be present. ficient computing solutions?
This suggests that spurious correlations will be easier to find, but will  
only be valid if the experiment was designed to specifically test this Stewart: Apple and ARM are probably the biggest companies focus-
hypothesis, not a plurality of hypotheses simultaneously. So, big data ing on energy-efficient computing at the moment. The development of
makes it easier to “cheat” with data, but what about machine learn- high-performance and power-efficient architectures has been crucial
ing? The use of machine learning makes it easier to “hide” the cheat- in the smartphone industry for improving battery life while also provid-
ing. The reduced interpretability, nuanced behavior of many machine ing increased functionality and speed. In recent years, we have seen
learning algorithms, and lack of machine learning education in many mobile architectures improve substantially in terms of performance
research communities will make it more difficult to uncover these and power efficiency, whereas more traditional architectures from
issues in published research. Fortunately, the solution to this problem rivals such as Intel have been comparatively stagnant. Consequently,
is quite simple — fund reproducibility studies, and educate researchers mobile architectures now rival those of more traditional architectures,
about the proper design of experiments and use of machine learning but have several additional advantages including high power efficiency.
for research purposes. This came to a head recently with the announcement by Apple for
  the new ARM-based M1 chip, boasting that it will provide the “longest
Abate: You made an interesting point in your article: “One of the other battery life ever in a Mac.” This move by Apple is seen by some as a
problems of machine learning algorithms is that the algorithm must watershed moment in the computing industry that will have ripple
make a prediction. The algorithm cannot say ‘I didn’t find anything’.” It effects across the community for years to come.
sounds like there are times when machine learning is not the right fit.  
  Abate: Tell us about your work with drones and chemical-monitoring
Stewart: While I would agree that machine learning is not the right systems. What roles does tinyML play in your research?
fit for some tasks, I do not think it is for this reason. For example, one  
of the issues presented by tasks cast as binary classification problems Stewart: Work using tinyML for several microdrone applications has
is that they may in fact not be best summarized as such, resulting in a already been published. The focus of this is to create lightweight drones
false dichotomy. In some circumstances, it may be more suitable for that are able to intelligently navigate an environment using embed-
data lying close to a decision boundary to be assessed in more detail ded reinforcement learning methods. This could be very useful in the
by a human instead of letting the algorithm make a definitive decision. future such as for detecting gas leaks or locating pollutant emission
This type of decision-making is sometimes referred to as human-in- sources, for both indoor and outdoor applications.
the-loop decision-making, and would be most useful in circumstances  
where the decision being made has important ramifications, such as For chemical monitoring systems more broadly, tinyML may provide
decisions related to the offer of a loan or whether someone has cancer. the ability to create remotely located sensor networks that are discon-
  nected from the power grid, as well as more intelligent use of chemical
Abate: In which industries do you see the biggest opportunities for sensor information. For example, instead of continuously transmitting
innovation with tinyML? data to a cloud server, the system could be designed to focus only
  on anomalous data. This would reduce loads on the communication
network and also the power consumption associated with perform-
ing continuous monitoring. These aspects will become increasingly

64 Elektor Industry 1/2021 www.elektormagazine.com


More on Machine Learning

Want to learn more about Mathew Stewart’s work or machine


learning in general? Check out these resources: Stewart: Unfortunately, one of the downsides of cutting-edge
  technology is that there are often only a handful of resources avail-
> Mathew Stewart: https://mpstewart.net/ able. That being said, we are starting to see a steady release of peer-re-
> Towards Data Science: “Matthew Stewart - Tiny ML and the viewed literature on the subject of tinyML (although often under a
future of on-device AI,” 11/25/2020: different name). A sizable portion of this literature is published on the
http://bit.ly/video-tinyML preprint server arXiv in the category of hardware architecture [4], but
> W. Trojan, “Artificial Intelligence for Beginners,“ ElektorMaga- I suspect we will soon see several journals focused on the topic that
zine.com, 4/10/2020: will supersede this. Another resource is the TinyML Research Sympo-
www.elektormagazine.com/ai-beginners sium (https://www.tinyml.org/researchsymposium2021/) hosted by
> C. Valens, “Artificial intelligence and the AIY Vision the TinyML Foundation, scheduled for March 2021, where we will likely
Kit,” ElektorMagazine.com, 10/15/2020: see some new and exciting developments for the field.
www.elektormagazine.com/aiy-vision-kit 210014-01
> C. Valens, “Build Your Own Smart Assistant with the AIY
Voice Kit V2,“ ElektorMagazine.com, 8/13/2020:
www.elektormagazine.com/news/aiy-voice-kit-v2 WEB LINKS

[1] Machine Learning (Elektor):


www.elektormagazine.com/tags/machine-learning
[2] C. Abate, “The Future of Machine Learning: An Inter-
important in years to come as the number of deployed IoT devices view with Daniel Situnayake,” ElektorMagazine.com,
continues to increase exponentially. 8/26/2020: www.elektormagazine.com/ml-situnayake
 
[3] M. Stewart, “The Machine Learning Crisis in Sci-
Abate: Your articles and research will likely inspire many members
entific Research,” TowardsDataScience.com,
of our community to take a closer look at tinyML. Do you recommend
11/18/2019: http://bit.ly/ml-crisis-stewart
any resources — besides a book like Pete Warden and Daniel Situnay-
ake’s TinyML — for professional engineers and serious electronics [4] Cornell University, “Hardware Architecture,“
enthusiasts who are interested in learning more about the subject? arXiv.org: https://arxiv.org/list/cs.AR/recent
 

Easily check price and availability


for every part you need

• •

mouser.co.uk/price-availability-assistant

Pricing and Availibility-185x124mm-UK.indd 1 02.12.20 10:32

lektor Embedded & Tools 65


store
www.elektor.com

The Elektor Store


Never expensive, always surprising
The Elektor Store has developed from the that we ourselves are enthusiastic about or that
community store for Elektor’s own products we simply want to try out. If you have a nice
like books, magazines, kits and modules, into suggestion, we are here (sale@elektor.com).
a mature webshop that offers great value for Our main conditions:
surprising electronics. We offer the products never expensive, always surprising!

Raspberry Pi Pico
Microcontroller Board
Price: €4.95

www.elektor.com/19562

JOY-iT JT-RD6006 DC Power Supply (360 W)

Price: €89.95
Member Price: €80.96

www.elektor.com/19564

66 Elektor Industry 1/2021 www.elektormagazine.com


e-zine
Your dose of electronics

Every week that you don’t subscribe to Elektor’s e-zine


is a week with great electronics-related articles and
projects that you miss!

So, why wait any longer? Subscribe today at


www.elektor.com/ezine and also receive free
Raspberry Pi project book!

What can you expect?


Editorial Promotional Partner mailing
Every Friday, you’ll receive the best Don’t miss our shop promotions, You want to stay informed about
articles and projects of the week. every Tuesday and Thursday we the ongoing activities within the
We cover MCU-based projects, IoT, have a special promotion for you. industry? Then this e-mail will give
programming, AI, and more! you the best insights. Non-regular
but always Wednesdays.
PRINTED CIRCUIT BOARDS
NEW: 1-CLICK STENCIL ORDER
Simply add to the PCB
1-48 layers | from 1WD Express

Hightech PCB Precision SMD-Stencil All from one source • Ultra finest-line
• Filmless laser-direct-imaging (LDI)
• Impedance control, from 4WD
• HDI boards
Inclusive
0.1mm tracks or or 2 layer PCB
• Blind & Buried Vias
• Microvias, also lasered
+ • Via Filling / Via in Pad overplated
0.2mm drills
• Stacked & Staggered Vias
2 layers e.g. 1pc. 80mm x 100mm e.g. 1pc. 100mm x 120mm SMD-Stencil • Plated-through slits
• Countersink holes
UNIT PRICE UNIT PRICE TOTAL PRICE
• Z-axis milling
4 WD € 35, net 00

€ 41,65 gross 1 WD
€ 9, 90
net in 4 WD
€ 44,90 net
€ 53,43 gross
• Plated halfholes
• Sideplating

8 WD
€ 29,80 net €11, 78
gross in 8 WD € 39,70 net
€ 47,24 gross
• Custom layer-buildup
• Thin laminates
€ 35,46 gross incl. German VAT 19% • PCB thickness up to 7mm
• Backplanes, Backdrill
ALREADY INCLUDED ALREADY INCLUDED YOUR ADVANTAGE • PCI cards, Goldfingers
0.1mm tracks & annular ring, Unlimited pads, thickness 100- 2 Layer PCB • Thick copper
0.2mm drills, FR4 1.55mm 35µm 120µm, PCB name half-lasered on • Panel production
together with
Cu, surface HAL lead-free, 2x sol- squeegee side, optional pad reduc- • UL certified (E198312)
der-stop green, 1x legend print tion, finishing treatment deburring on SMD-Stencil
• IPC-A-600
white, E-Test, Design Rule Check both sides, axial tolerance only ±2µm Only 1x shipping
Surface finish e.g.:
• HAL lead-free • chem. Gold (ENIG)
SMD-Stencil for €9,90 - Hightech makes it possible: DEBURRING: • ENEPIG, Bondgold. ...
Our high-performance laser systems for SMD stencils meet the highest
quality standards with optimum cutting quality (axial deviation only ± 2µm). Special material e.g.
All common quick clamping frames (for example ZelFlex, Pag- • Rogers • FR4 HTg
gen, VectorGuard, etc.) and aluminum frames are available. All • Alu core (1.0 - 8.0 W/mK)
SMD-Stencils from Multi-CB are deburred on both sides. Addition-
al finishing treatments include electropolishing and nano coating.
Your advantage - Deburring avoids time-consuming reworking.
DISTRIBUTORS wanted
PCBs including 0.1mm Tracks, 0.2mm Drills, 4WD Standard! PCB experts only
Comparing pays off, why pay more for less performance?
High-tech makes it possible without surcharge! ALL-INCLUSIVE Contact England: Contact Germany:
PRICING: Multi Circuit Boards Ltd.
Business Centres, HC
Multi Leiterplatten GmbH
Brunnthaler Str. 2
GB-Poole BH17 7FJ DE-85649 Brunnthal

4 Layers €59,- €49,80 net


- FR4 1.55mm 35µm Cu
FR4 1.55mm

net - Surface finish info@multi-cb.com


5 WD 9 WD
€70, €59, - 2 x solder-stop green Hotline DE / EN:
1 pc. 80 x 100mm
21 26
gross gross
HAL lead-free - 1 x legend print white
+49 (0) 81 04/628 0
incl. German VAT 19%

6 Layers €98,- net €93,10 net


- E-Test, Design Rule Check
- A.O.I. & X-Ray +44 (0)1425/489 111
6 WD 9 WD
€116, €110, - Milling (inner, outer)
1 pc. 80 x 100mm
62 79
gross gross Prices plus delivery costs from €8,03 gross/ €6,95 net.
chem. Gold (ENIG) - PTH slits Sales only to business customers and public institutions.

Calculate price and production time comfortably online: www.multi-cb.com

Circuit Boards SMD-Stencils Flex & Rigid-Flex Alu core (IMS)


HTg, HDI, HF, etc. also clamping frames up to 12 layers 1 & 2 layers PTH

Zelflex, Quattroflex, Paggen, Essemtec,


Metz, VectorGuard etc.

Payment Directly from


options: Invoice Prepayment your data e.g.:

You might also like