My wife is a preschool teacher, and she is a master of reuse. When I see a toilet paper roll is
used up, I think of tossing that tube in recycling. But to her, that tube is a versatile component
that still has much to give and should be stockpiled. When she starts a project, she turns to her
vast collection of tubes, jars, buttons, felt, cardboard, pipe cleaners and paper. Then the
creativity starts and these components combine to produce some cute little craft. I do get jealous
of her ability to look at a forgotten torn egg crate and envision the caterpillar it will evolve
Figure 1: Reusing existing components in a new design, like using an egg crate and pipe cleaners
to create a toy caterpillar
I am also a fan of reuse, although I can’t compete with her creativity. My philosophy is, “Why
reinvent the wheel if I can reuse something that already does the job?” During application
development, code reuse is one of the major benefits and attractions for using open-source
software. When developing application-specific software, our time and innovation should be spent
on that which will differentiate; not on the common building blocks and components that are
already available. In the analogy with my wife, we want to create the ‘caterpillar’, not the egg
crate. But a major question with code reuse, particularly when that code originates elsewhere, is
“Can we depend on it?” Especially when these ‘caterpillars’ need go to production, we have
concerns about the quality of the reused code, how vetted it is and whether or not it will it be
This is where NXP’s MCUXpresso software development kit (SDK) can help. This SDK is a software
package specific to NXP’s EdgeVerse™ platform of microcontrollers, containing
peripheral drivers, connectivity stacks and other middleware. NXP delivers software reliability
through high-quality production-grade software in this SDK. For example, drivers and startup code
are MISRA-C compliant and checked with Coverity® static analysis tools. NXP also
checks SDK runtime tests on a vast board farm, using development boards of the different product
families supported. Every night, the latest SDK code runs on the boards, logging any issues
introduced in recent code changes. Today, these tests run on 46 platforms and run over 80,000 test
cases. Also, this SDK code base is well vetted in production through our many customers and their
end products, with more than 360,000 downloads globally.
The open-source Zephyr OS also benefits from code reuse. The
Zephyr Project was
conceived to provide a new RTOS option and has developed a vibrant, active community continually
contributing new code. Learn more about what makes Zephyr unique at the blog post
“Zephyr OS LTS 2 Release Adds Full Platform Support for i.MX RT600 Crossover MCUs”. But the Zephyr Project also integrates other open-source modules, for those instances when the
wheel does not need to be reinvented and code reuse can be leveraged.
For example, Zephyr OS integrates
LVGL for graphics,Mbed TLS crypto library and
MCUboot for secure bootloader and firmware updates. In addition, NXP’s product portfolio strongly
aligns with Zephyr OS and NXP is one of the founding members of the Zephyr Project. NXP is
committed to Zephyr, and contributes to the Project by upstreaming code to the Zephyr repository.
Much of this code is focused on enabling Zephyr OS and its features on NXP hardware, and the
foundation of that hardware support is reused from MCUXpresso SDK. NXP also contributes by testing
Zephyr releases on the same board farm used to test the SDK. Today over 5000 Zephyr test cases are
run on 17 platforms in the board farm.
Zephyr OS provides a set of drivers for common hardware-related features, like Flash and UART
drivers. These Zephyr drivers are written to be hardware agnostic and enable Zephyr applications
to easily port across the supported hardware platforms. These Zephyr drivers are built on a
hardware abstraction layer (HAL), illustrated in the figure below. NXP’s HAL is comprised of the
peripheral drivers and device support directly from the MCUXpresso SDK. That code reuse delivers
all the same quality from the testing and production use (discussed earlier), providing a robust
and proven foundation for the HAL.
Looking at a specific example, below are the Zephyr software layers including the hardware
platform support for the
i.MX RT1060 MCU. The i.MX RT1060 uses external flash connected to the FlexSPI peripheral. The low-level FlexSPI
driver is the same driver from the MCUXpresso SDK. On top of this, NXP upstreams a shim driver
into the Zephyr repository, which directs Zephyr’s hardware-agnostic memory APIs, like the Flash
driver, to the MCUXpresso SDK drivers that directly control the peripheral. This builds the NXP
HAL on top of the SDK drivers, and then the Zephyr kernel, drivers and upper layers all build on
top of that HAL.
Figure 2: Zephyr Software Layers over NXP MCUXpresso SDK drivers
To better experience, download the
The MCUXpresso SDK code reuse in Zephyr OS provides additional benefits beyond quality.
Improvements and features added to the SDK drivers can be quickly and easily integrated into a
Zephyr application. If bugs are found in these drivers, whether by Zephyr users or other NXP
users, the bug fixes in the MCUXpresso SDK can be rapidly up-streamed to benefit all Zephyr users.
Plus, sharing the same underlying MCUXpresso SDK HAL enables easier portability for Zephyr across
the NXP portfolio, including NXP devices supported by the SDK, but not yet included in the Zephyr
Project – meaning the SDK reuse also enables a software migration path to Zephyr (for non-Zephyr
applications already using MCUXpresso SDK). If the developer of that existing application wants to
evaluate with Zephyr OS, they can continue using the same MCUXpresso drivers and focus their
porting efforts on adopting Zephyr OS and its features. The Zephyr application can be built using
the same direct APIs into the SDK drivers. Porting to the general Zephyr drivers is not required
and could even be done later if desired.
The Zephyr Project and code reuse of MCUXpresso SDK drivers help jump-start embedded application
development so that developers can focus on the end application and benefit from the existing
robust HAL. Plus, the high-quality production-ready code provided by the SDK provides confidence
in the software. So the next time you develop a caterpillar, and you want to reuse an existing and
reliable egg crate, consider all the code reuse and benefits offered by the Zephyr Project with
NXP MCUXpresso SDK.
Visit our last blog
Zephyr OS LTS 2 Release Adds Full Platform Support for i.MX RT600 Crossover MCUs