Three Keys to Embedded Software Success

Stefanie Diesi, Staff Engineer

Writing software on an embedded device can be difficult for any number of reasons, but smart design choices up front can help mitigate some of the pain down the road. There are entire books and college courses devoted to this topic. However, I think the following three items are a good place to start.

Layered Architecture

Start with a layered architecture which simply means slice the design into horizontal layers. The scope is often to communicate between hardware (sensors, buttons, cables, etc) and a user interface (LCD screen, LEDs, app, etc). In that generic case, we can split the design into three layers.

The application layer handles all of the business logic surrounding what the thing is actually supposed to do, i.e. set a timer, check the temperature, turn on a fan, unlock the door, and so on. It determines what actions need to be taken based on various inputs. Many of these inputs come directly from the hardware abstraction layer or HAL. This layer interfaces directly to the hardware elements, handles all of the specifics about how to talk to each piece of hardware, and receives the notifications that are sent directly from the hardware itself. The hardware/application interface layer sits between the two. It translates the hardware events, actions, and commands into application speak and vice versa.

Implicit in this design is the firm restriction that each layer only talks to adjoining layers, so the application layer doesn’t talk to the hardware or even the hardware abstraction layer. Instead, it tells the hardware application interface layer what needs to be done, then the interface layer translates that into hardware speak, and finally, the HAL communicates with the hardware.

Separating the design into distinct layers allows for easy parallel development if desired. The clean separation allows for defining interfaces that can eventually be tested (more on this later). It also makes problems much easier to isolate and debug.

Modular Implementation

Once the layers have been identified, move towards slicing each layer into smaller, modular components. Each component should have one purpose or function, and it should own that. Here’s an example of our layered architecture split into modules.

This separation has a number of benefits. Before beginning to implement, the code is easy to understand conceptually and therefore easier to write and read. It also attempts to avoid intermixing or coupling logic unnecessarily which can lead to massive headaches while trying to maintain the code later on.  

Finally, it makes the entire design more flexible to change. If a new hardware part is required, the interface to that part can easily be swapped out with minimal modifications to other areas of the code. Similarly, code can be reused on future projects or reused from previous projects to help cut down on re-writing the same code over and over.

Plan for Test

We all know the value of testing, but it can be difficult to maintain the personal, team, and management discipline to add in tests especially when the schedule seems to be slipping. However, the two guidelines above make test design easier. Test planning is almost built into the design itself if you work from the inside out. Test each module by itself. Then test the interactions between modules. Once each layer looks good on its own, test the interfaces between the layers themselves, and finally test the entire system end to end. It looks a little something like this:

It can be tempting to skip this step, but remember that your code will get tested eventually if not by you then by your customers.

Start with a layered architecture, develop modular code, and test along the way. These tips do not guarantee success, but they provide a solid foundation on which to build embedded firmware.

Cardinal Peak
Learn more about our Audio & Video capabilities.

Dive deeper into our IoT portfolio

Take a look at the clients we have helped.

We’re always looking for top talent, check out our current openings. 

Contact Us

Please fill out the contact form below and our engineering services team will be in touch soon.

We rely on Cardinal Peak for their ability to bolster our patent licensing efforts with in-depth technical guidance. They have deep expertise and they’re easy to work with.
Diego deGarrido Sr. Manager, LSI
Cardinal Peak has a strong technology portfolio that has complemented our own expertise well. They are communicative, drive toward results quickly, and understand the appropriate level of documentation it takes to effectively convey their work. In…
Jason Damori Director of Engineering, Biamp Systems
We asked Cardinal Peak to take ownership for an important subsystem, and they completed a very high quality deliverable on time.
Matt Cowan Chief Scientific Officer, RealD
Cardinal Peak’s personnel worked side-by-side with our own engineers and engineers from other companies on several of our key projects. The Cardinal Peak staff has consistently provided a level of professionalism and technical expertise that we…
Sherisse Hawkins VP Software Development, Time Warner Cable
Cardinal Peak was a natural choice for us. They were able to develop a high-quality product, based in part on open source, and in part on intellectual property they had already developed, all for a very effective price.
Bruce Webber VP Engineering, VBrick
We completely trust Cardinal Peak to advise us on technology strategy, as well as to implement it. They are a dependable partner that ultimately makes us more competitive in the marketplace.
Brian Brown President and CEO, Decatur Electronics
The Cardinal Peak team started quickly and delivered high-quality results, and they worked really well with our own engineering team.
Charles Corbalis VP Engineering, RGB Networks
We found Cardinal Peak’s team to be very knowledgeable about embedded video delivery systems. Their ability to deliver working solutions on time—combined with excellent project management skills—helped bring success not only to the product…
Ralph Schmitt VP, Product Marketing and Engineering, Kustom Signals
Cardinal Peak has provided deep technical insights, and they’ve allowed us to complete some really hard projects quickly. We are big fans of their team.
Scott Garlington VP Engineering, xG Technology
We’ve used Cardinal Peak on several projects. They have a very capable engineering team. They’re a great resource.
Greg Read Senior Program Manager, Symmetricom
Cardinal Peak has proven to be a trusted and flexible partner who has helped Harmonic to deliver reliably on our commitments to our own customers. The team at Cardinal Peak was responsive to our needs and delivered high quality results.
Alex Derecho VP Professional Services, Harmonic
Yonder Music was an excellent collaboration with Cardinal Peak. Combining our experience with the music industry and target music market, with Cardinal Peak’s technical expertise, the product has made the mobile experience of Yonder as powerful as…
Adam Kidron founder and CEO, Yonder Music
The Cardinal Peak team played an invaluable role in helping us get our first Internet of Things product to market quickly. They were up to speed in no time and provided all of the technical expertise we lacked. They interfaced seamlessly with our i…
Kevin Leadford Vice President of Innovation, Acuity Brands Lighting
We asked Cardinal Peak to help us address a number of open items related to programming our systems in production. Their engineers have a wealth of experience in IoT and embedded fields, and they helped us quickly and diligently. I’d definitely…
Ryan Margoles Founder and CTO, notion