Embedded Software Design Philosophy - Embedded Software Design - A Practical Approach To Architecture, Processes, and Coding Techniques
Embedded Software Design Philosophy - Embedded Software Design - A Practical Approach To Architecture, Processes, and Coding Techniques
The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
J. Beningo, Embedded Software Design
https://doi.org/10.1007/978-1-4842-8279-3_1
Jacob Beningo1
(1) Linden, MI, USA
The first microprocessor, the Intel 4004, was delivered to Busicom Corp
in March 1971 for use in their 141-PF calculators.1 The 4004 flaunted a
4-bit bus running at 0.74 MHz with up to 4 KB of program memory and
640 bytes of RAM.2 The 4004 kicked off a hardware revolution that
brought more computing power to the world at lower costs and led to
faster, more accessible software development. In time, fully integrated
processors designed for real-time control in embedded systems were
developed, including the microcontroller.
The software was viewed as a necessary evil; it’s still sometimes con-
sidered an essential evil today, even though the hardware is relatively
agnostic. Microcontrollers come in a wide variety of flavors with bus
architectures including 8-bit, 16-bit, and 32-bit. One might be tempted
to believe that 32-bit microcontrollers are the dominant variants in the
industry, but a quick look on Digikey or Mouser’s website will reveal
that 8-bit and 16-bit parts are still just as popular.5 Microcontroller
clock speed varies widely from 8 MHz all the way up to 268 MHz in
Arm Cortex-M4 parts. Although there are now offerings exceeding 1
GHz. Finding parts with sporting 512 KB program memory and 284 KB
RAM is fairly common. In fact, there are now multicore microcon-
trollers with 1000 MHz system clocks, over 1024 KB of program memo-
ry, and 784 KB of RAM!
Every developer and team faces inherent challenges when designing and building
their system. Likewise, every industry will have unique challenges, varying even
within the same company between the embedded software developers and the
hardware designers. For example, some teams may be faced with designing an
intuitive and easy-to-use graphical user interface. Another may face tough security
challenges that drive nearly every design aspect. However, no matter the team or
developer, there are several tried and true challenges that almost all teams face that
contribute to the modern developers’ design philosophy. These fundamental
challenges include
Figure 1-1 The project management iron triangle demonstrates that teams balance the demands of
You may have heard project managers say that they can pick any
two between quality, cost, and delivery time, and the third must suffer.
However, what is often overlooked is that scope is just as important in
the trade-off. If a project is going over budget or past the deadline,
scope reduction can be used to bring them back into balance. So these
properties are trading off against each other. Unfortunately, this model,
in general, is NOT sufficient alone, but it at least visually provides
teams with the primary business challenges that every team is grap-
pling with. So, let’s quickly look at some challenges and see how they
can impact developers.
Every team that I encounter is designing their product under a limit-
ed budget. I don’t think I have ever met a team with an unlimited bud-
get and was told to spend whatever it takes to get the job done. (If you
work for one of those rare companies, my contact information is
[email protected].) For the most part, businesses are always trying to
do more with smaller budgets. This makes sense since a business’s core
goal isn’t to change the world (although they will tell you it is) but to
maximize profits! Therefore, the smaller the development budget and
the more efficient the engineers are, the higher the potential profit
margins.
Budgets can also affect software packages and tools, such as net-
work stacks, compilers, middleware, flash tools, etc. Because it’s “free,”
the big push for open source software has been a major, if not some-
times flawed, theme among teams for the last decade or more (we will
discuss this in more detail later in the book). I often see teams unwill-
ing to spend money on proper tools, all in an attempt to “save” money.
Usually, it’s a trade-off between budget and extra development time.
Missed deadlines
More debugging
Integration woes
Scalability is not just a need for a product in the field; it can be a need for an
entire product line. Systems today often have similar features or capabilities. The
ability to have a core foundation with new features added to create a wide variety of
products is necessary. It’s not uncommon for a single code base to act as the core for
a family of several dozen products, all of which need to be maintained and grown
over a decade. Managing product lines over time can be a dramatic challenge for a
development team to face, and a few challenges that are encountered include
I believe every team should follow seven modern design philosophy principles to
maximize their chances for success. These include
Principle #1 – Data Dictates Design
Principle #2 – There Is No Hardware (Only Data)
Principle #3 – KISS the Software
Principle #4 – Practical, Not Perfect
Principle #5 – Scalable and Configurable
Principle #6 – Design Quality in from the Start
Principle #7 – Security Is King
Let’s examine each principle in detail.
Best PracticeCreate a list of your design principles, print them out, and
keep them in a visible location. Then, as you design your software, en-
sure that you adhere to your principles!
Principle #1 – Data Dictates Design
The core idea behind this principle is that embedded software de-
sign is all about the data. Anything else focused on will lead to bloated
code, an inefficient design, and the opportunity to go over budget and
deliver late. So instead, developers can create an efficient design by
carefully identifying data assets in the system, the size of the data, and
the frequency of the operations performed with the data.
When we focus on the data, it allows us to generate a data flow diagram that
shows
Focusing on the data in this way allows us to observe what we have in the system
and how it moves through the system from input to output, enabling us to break
down our application into system tasks. A tool that can be very useful with this
principle is to develop a data flow diagram similar to the one shown in Figure 1-2.
Figure 1-2 A simple data flow diagram can help developers identify the data assets in their system and
Everything about our design and how our system behaves is data driven.
Developers must accept that there is no hardware, only data, and build successful
business logic for the software! Therefore, your design at its core must be hardware
agnostic and only rely on your data assets! A general abstraction for this idea can be
seen in Figure 1-3.
Figure 1-3 Application design should view hardware as agnostic and focus on the system data's inputs,
This idea, at first, can be like Neo from The Matrix, having to accept
that there is no spoon! For us developers, there is no hardware! Only
data! Data acts as an input; it’s then processed and used to produce sys-
tem outputs (remember, it might also be stored). Before you do any-
thing drastic with that pitchfork in your hand, let me briefly explain
the benefits of thinking about design in this way.
First, a data-centric and hardware-agnostic software system will
naturally abstract itself to be more portable. It is not designed for a spe-
cific hardware platform, making the code more “mobile.” Second, the
software will more readily integrate with test harnesses because the in-
terfaces are designed to not be hardware dependent! This makes it
much easier to connect them to a test harness. Third, the abstractions
make it much easier to simulate the application! Developers can run
the application on a PC, target hardware, or any convenient computing
machine even if the hardware designers haven’t yet produced proto-
types. (And let’s be honest, even if you have a prototype, you can’t al-
ways trust that it will work as intended.) Fourth, suppose we decouple
the application from hardware. In that case, we can rapidly develop
our application by removing tedious compile, program, and debug cy-
cles by doing all the debugging in a fast and hosted (PC) environment!
I’m just warming up on the benefits, but I think you get the point.
Look again at Figure 1-3. You can see how this principle comes into
practice. We design tasks, classes, modules, and so forth to decouple
from the hardware. The hardware in the system is either producing
data, processing that data, or using the data to produce an output. We
create data abstraction barriers (DABs), which can be abstractions,
APIs, or other constructs that allow us to operate on the data without
direct access to the data. A DAB allows us to decouple the hardware and
then open up the ability to use generators, simulators, test harnesses,
and other tools that can dramatically improve our design and how we
build systems.
The KISS software principle reminds us that we should be trying to design and
write the simplest and least complex software possible. Minimizing complexity has
several advantages, such as
Keep the software design simple and smart! Avoid being clever and
make the design as clear as possible. Brian W. Kernighan stated, “De-
bugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by defi-
nition, not smart enough to debug it.”
There are many reasons why developers are writing embedded soft-
ware. Still, the primary purpose for many reading this book is profes-
sional engineers developing a product, an entrepreneur starting a busi-
ness, or those perhaps interested in building a do-it-yourself (DIY)
project and looking to improve their skills. In general, the purpose is to
create a product that creates value for the user and generates profit for
a business.
Developers and entrepreneurs often lose sight of the purpose of developing their
software. The excitement or the overarching vision starts to cloud their judgment,
and they begin to fall into perfectionism. Perfectionism is “a flawless state where
everything is exactly right. But, it can also be the act of making something
perfect.”11 There are two categories of perfectionism that we need to discuss:
Best PracticeThe 80/20 rule states, “80% of software features can be de-
veloped in 20% of the time.”12 Focus on that 80% and cut out the rest!
It’s helpful to mention right now that there is no such thing as a perfect
system. If you were to start writing the ideal Hello World program right
now, I could check in with you when I retire in 30 years, at age 70, and
find that you almost have it, just a few more tweaks to go. Developers
need to lose the baggage that everything needs to be perfect. Anyone
judging or condemning that the code isn’t perfect has a self-esteem is-
sue, and I would argue that any developer trying to write perfect code
also has one.
Since our goal is not to build “one system to rule them all” or build the
perfect system, we want to set a goal to at least make something scal-
able and configurable. We create a product starting with our minimum
feature set, deploy it, and then continue to scale the system with new
features and make it adaptable through configuration. Software needs
to be scalable and configurable for a product to survive the rapidly
evolving business conditions developers often find themselves in.
When we discuss designing quality into software, keep in mind at this point that
quality is a “loaded” term. We will define it and discuss what we mean by quality
later in the book. For now, consider that building quality into a system requires teams
to
The design principles we discussed all support the idea that testing should be
tightly integrated into the development process. Therefore, the design will ensure
that the resultant architecture supports testing. Building the software will then
provide interfaces where test cases can simultaneously be developed, as shown in
Figure 1-4.
Figure 1-4 Embedded software can be designed to easily interface to a test harness that can automati-
The IoT has been taking over nearly every business and industry.
Practically everything is in the process of being connected to the
Internet: vehicles, home appliances, and even human beings. Even the
simple mousetrap is now an Internet-connected device.13 (Don’t believe
me, check out the footnote link!) All this connectivity leads to a crucial
point and a principle that many developers can no longer ignore: secu-
rity is king.
This relationship between design and processes can be seen easily in Figure 1-5.
We’ve already established that core challenges lead to design solutions. The design
and challenges direct the processes, which in turn provide the likelihood of success.
This relationship can also be traversed in reverse. We can identify what is needed for
success, which directs the processes we use, which can lead our design, telling us
what challenges we are solving.
Figure 1-5 The software design and build processes balance each other to determine the project's likeli-
hood of success and to establish the challenges that are solved by design
Typically, the average software build process looked like Figure 1-6. The process
involved hand-coding most software, starting with the low-level drivers and working
up to the application code. The operating system and the middleware may have been
open source, but teams often developed and maintained this code in-house. Teams
generally liked to have complete control over every aspect of the software.
Figure 1-6 Traditional embedded software development leverages a hand-coded software stack that
First, notice that we still have our traditional software stack of driv-
ers, OS, middleware, and application code. The software stack is no
longer constrained to only hand-coded modules developed in-house.
Most software stacks, starting with low-level drivers through the mid-
dleware, can be automatically generated through a platform configura-
tion tool. Platform configuration tools are often provided by the micro-
controller vendor and provide development teams with an accelerated
path to get them up and running on hardware faster.
It’s important to note that vendor-provided platform configuration tools are often
designed for reuse and configuration, not for execution efficiency. They can be a bit
more processor cycle hungry, but it’s a trade-off between development speed and
code execution speed. (Don’t forget principle #4! Practical, not perfect! We may do it
better by hand, but is there a tangible, value-added benefit?)
Figure 1-7 Modern embedded software applies a flexible approach that mixes modeling and configura-
tion tools with hand-coded development. As a result, the code is easily tested and can be compiled for on-
CI/CD is a set of practices that enable developers to frequently test and deploy
small changes to their application code.15 CI/CD is a set of best practices that, when
leveraged correctly, can result in highly robust software that is easy to deploy to the
devices regularly as new features are released. A general overview of the process for
embedded developers can be seen in Figure 1-8.
Figure 1-8 Modern development processes utilize a CI/CD server with various instances to continuously
Every team will have slightly different needs, which allows them to customize
their CI/CD process. We will discuss CI/CD in more detail later in the book. For
now, it’s helpful to understand that it is a great way to automate activities such as
Final Thoughts
The challenges that we face as teams and developers will dictate the
principles and processes we use to solve those challenges. The chal-
lenges that embedded software teams face aren’t static. Over the last
several decades, they’ve evolved as systems have become more com-
plex and feature rich. Success requires that we not just define the prin-
ciples that will help us conquer our challenges, but that we continuous-
ly improve how we design and build our systems. We can continue to
use traditional ideas and processes, but if you don’t evolve with the
times, it will become more and more difficult to keep up.
Action Items
To put this chapter's concepts into action, here are a few activities the reader can
perform to start applying design philosophies:
First, make a list of the design challenges that you and your team
are facing.
From your list of challenges, what are the top three big ones that re-
quire immediate action?
Next, review the seven modern design philosophy principles and
evaluate which ones can help you solve your design problems.
Identify any additional design philosophies that will guide your
designs.
Identify the behaviors that are decreasing your chances for success.
Then, what can you do over the next week, month, or quarter to
mitigate these behaviors?
Review your design and development processes. Are there any ar-
eas where you need to add more processes? Any areas where they
need to be lightened up?
Does your development more closely resemble traditional or mod-
ern development? What new modern technique can you focus on
and add to your toolbox?
Evaluate whether your entire team, from developers to executives,
are on the same page for following best practices. Then, work on
getting buy-in and agreement to safeguard using best practices even
when the heat is on.
These are just a few ideas to go a little bit further. Carve out time in
your schedule each week to apply these action items. Even minor ad-
justments over a year can result in dramatic changes!
Footnotes
1 https://spectrum.ieee.org/tech-history/silicon-revolution/chip-
hall-of-fame-intel-4004-microprocessor
2 https://en.wikichip.org/wiki/intel/mcs-
4/4004#:~:text=The%204004%20was%20a%204,and%20640%20bytes%20of%20RAM
3 https://en.wikipedia.org/wiki/Texas_Instruments_TMS1000
4 High-end, modern microcontrollers are looking more and more like general
computing devices …
5 www.embedded.com/why-wont-the-8-bit-microcontroller-die/
6 www.merriam-webster.com/dictionary/philosophy
7 Atkinson, Roger (December 1999). “Project management: cost, time and quali-
ty, two best guesses and a phenomenon, its time to accept other success
criteria.” International Journal of Project Management. 17 (6): 337–342.
doi:10.1016/S0263-7863(98)00069-6.
8 www.pmi.org/learning/library/beyond-iron-triangle-year-zero-6381
10 https://en.wikipedia.org/wiki/Software_design_pattern
11 www.vocabulary.com/dictionary/perfection
12 https://en.wikipedia.org/wiki/Pareto_principle
13 www.zdnet.com/article/victor-aims-to-use-iot-to-build-a-better-
mousetrap/
16 www.merriam-webster.com/dictionary/simulation