Changing the embedded development model with Microsoft .NET Micro Framework
Microsoft .NET programming in a much lighter, more embedded environment coupled with an embedded microcontroller sounds too good to be true, but it's possible now, thanks to a small .NET platform well-suited for next-generation devices.
The development model for embedded devices is traditionally viewed as extremely complex, requiring highly specialized design expertise in and deep knowledge of a target's intricate software and hardware design aspects. In addition to this complexity, the development model typically involves prolonged design cycles and competing project timelines resulting in high development costs and long time to market.
While it is true that many different embedded applications need complete and highly granular control over all operational aspects of a device, other embedded applications can easily do without. And given that almost everyone has to deal with engineering resource constraints on a daily basis, it is ideal to engage the nonembedded engineering software team as well as reuse existing code from the server/desktop side. After all, today's constant push toward pervasive, networked device collaboration implies tight integration with the back-end network infrastructure, which is typically built on software utilizing nonembedded desktop and server-class systems.
Signs of an increasing trend to pull enterprise server and desktop application software components into the embedded space are already visible across other major platforms. This action often comes at the expense of severely elevated hardware requirements due to the lack of optimization for embedded targets. However, the .NET Micro Framework can help alleviate the burden of these requirements by providing a fresh and innovative perspective in the form of a new embedded development option.
.NET Micro Framework architecture
Introduced in early 2007, Microsoft's .NET Micro Framework is a lightweight implementation of the .NET Framework. It offers a subset of the full .NET Framework/.NET Compact Framework and is focused on the specific requirements of embedded applications. Compared to the smallest managed configuration of Windows Embedded CE, it's a fraction of the size – a few hundred kilobytes instead of multiple megabytes. Even though it is very small and by design does not offer the complete Windows Embedded CE feature set, it still scales nicely from simple, single-function devices to more sophisticated and powerful multifunction devices with state-of-the-art user interfaces.
The .NET Micro Framework particularly focuses on the growing number of network-enabled embedded devices with 32-bit processors, which are rapidly displacing the previously dominant 8- and 16-bit based devices. Specifically designed to meet the requirements and extended capabilities of this new generation of 32-bit devices, the .NET Micro Framework platform (shown in Figure 1) was built from the ground up instead of derived from an existing Microsoft embedded platform.
From an internal architecture point of view, the .NET Micro Framework consists of the following layers:
- Application Layer: C# application utilizing built-in and user libraries/services
- Class Library Layer: Core subset of .NET libraries and application services
- Hardware Layer: Processor platform and integrated peripherals
- Runtime Component Layer with three components:
- Common Language Runtime (CLR): A runtime environment providing an execution engine, thread management, garbage collection, exception handling, and other services
- Platform Abstraction Layer (PAL): A hardware-independent abstraction layer providing services to the CLR, including memory management, debugging, and asynchronous procedure calls
- Hardware Abstraction Layer (HAL): The interface between PAL and the hardware or operating system providing access to hardware functions
The CLR interprets language-independent intermediate code (Common Intermediate Language or CIL) generated by the Visual Studio compiler and handles aspects such as type safety and garbage collection, including safeguards resolving common application software problems caused by memory leaks and unsafe pointers. While this sophisticated level of code management results in nondeterministic application behavior, it also provides an exceptionally robust and safe environment for several embedded applications that do not require real-time performance. Completely independent from the application programming language and underlying hardware, the CLR concept makes the .NET Micro Framework a future-proof platform with unique programming language flexibility and virtually unlimited porting capabilities.
Changing the software development model
The .NET Micro Framework offers a C# managed code environment and seamless integration into the Microsoft Visual Studio environment, including full on-device debug support. This means that developers already experienced with the .NET Framework and Visual Studio tools can take immediate advantage of their skills and enjoy designing embedded applications without going through a significant learning curve.
C# is powerful and easy to learn, allowing developers unfamiliar with the language to get work done quickly. The actual C# application development process is completely shielded from the low-level design details of the hardware platform by simply utilizing the provided .NET class libraries, application services such as Devices Profile for Web Services (DPWS), and hardware-specific interface support. An XML-defined and extensible hardware emulator is also included with the development tools, making testing and software development possible without involving any actual target hardware. If needed, managed drivers can be written in C# for components attached to device interfaces, such as Serial Peripheral Interface (SPI) or I2C, given that they are already supported by the .NET Micro Framework libraries.
In addition to these benefits, existing .NET code used in enterprise server and desktop applications can be shared easily with a .NET Micro Framework application on an embedded device, dramatically reducing traditional design risks and greatly accelerating the software development process.
Community-provided software for the .NET Micro Framework is widely available through .NET Framework sample code and is continuing to expand into platform-specific development activities such as the C# implementation for DNS, ZigBee, POP, SMTP, and HTTP Web server support provided by Microsoft MVP Michael Schwarz on CodePlex. Other hands-on resources include Pavel Bansky's blog and the Microsoft newsgroup.
Changing the hardware development model
While the software aspect is certainly a key factor, the best software cannot live up to its expectations without the supporting hardware. Processor support for the .NET Micro Framework is available for a variety of 32-bit platforms, including ARM7 and ARM9 models as well as ADI Blackfin.
The Microsoft Porting Kit allows customers to adapt the .NET Micro Framework to their target hardware. However, porting the .NET Micro Framework to custom hardware requires specific skill sets that may or may not be available in an organization. A much more efficient approach that fully embraces the new .NET Micro Framework software development model is using embedded processor modules rather than engaging in discrete hardware design efforts whenever possible.
Embedded processor modules provide a complete and functional system with processor, memory, and supporting circuitry on a compact, single-component module design. Combining the .NET Micro Framework's benefits with off-the-shelf, low-cost, network-enabled embedded processor modules creates a rapid product development solution that has proven to get customers from development to functional product within 3-6 months.
Modules change the hardware development model in the same dramatic way that the .NET Micro Framework changes the traditional software development model, with benefits such as:
- Reducing product design cycles and time to market
- Enabling software designs to start immediately on actual hardware platforms
- Creating precertified module designs that further reduce overall hardware design risks
- Making carrier board design simpler, less expensive, and less likely to go through re-spins
- Providing a single vendor that supports both the hardware and software platforms
- Offering an optional migration path to component integration, matching high-volume production cost expectations and/or mechanical design considerations
Developers should look for module manufacturers with a strong .NET Micro Framework offering, including complete and easy-to-use development kits providing the Microsoft .NET Micro Framework Software Development Kit and full platform support, allowing immediate C# application development. The ideal hardware solution is built on a manufacturer's own processor platform, which makes a potential future migration to a discrete design much easier from a final product integration and cost point of view.
Embedding the .NET Micro Framework
The Digi Connect ME (Figure 2) provides an example of an embedded module that can be used with the .NET Micro Framework. The module integrates Digi's ARM7TDMI-based NS7520 processor running at 55 MHz with 2 MB flash, 8 MB RAM, a UART interface, GPIO, and a 10/100 Mb Ethernet interface in a compact RJ-45 form factor. Complete development kits currently support the .NET Micro Framework 2.5 release.
This module is used in a ZigBee-to-Ethernet gateway for a tank level monitoring application. The .NET Micro Framework application on the gateway collects and processes information from the individual ZigBee-enabled sensors and feeds it back to a central location through an on-site DSL connection. Reusing existing .NET Framework code from the enterprise server side seamlessly integrates the solution into the corporate back end with only minor development effort.
The application also provides simple Web server functionality for on-site configuration and local status monitoring. ZigBee connectivity in the gateway is incorporated by utilizing a Digi XBee-PRO RF module connected to the module's UART interface. Systems like this deployed in other applications can take advantage of the accelerated customization capabilities offered by the .NET Micro Framework and a modular hardware platform design.
The Microsoft .NET Micro Framework delivers on the promise of dramatically improved productivity and highly accelerated software development by extending the reach of .NET Framework technology and the desktop computing model to intelligent connected devices. By significantly reducing design risks and time to market, it creates a new software development model complemented by the hardware development model for embedded modules. This powerful platform introduces a dramatic paradigm shift that simplifies embedded development and makes it immediately accessible to an entirely new developer audience and class of devices.
Mike Rohrmoser is senior product manager for Digi International, based in Minnetonka, Minnesota. He has more than nine years of international product management experience for complex hardware/software networking products, including wired and wireless embedded and nonembedded technologies. He is experienced in network design, system- and application-level software development, and technical product support. Prior to Digi International, Mike worked for ITK/Digi in Germany.