CONTENTS
Part I: Introducing Embedded Development
Chapter 1: Embedded Development
What Is an Embedded Device?
What Is Embedded Software?
Development Considerations
Summary
Chapter 2: Windows Embedded Compact 7
What Is Windows Embedded Compact?
Why Windows Embedded Compact?
Summary
Chapter 3: Development Station Preparation
Development Computer Requirements
Windows Embedded Compact 7 Software
Development Environment Setup
Summary
Chapter 4: Development Process
Planning
Hardware Selection
Software Selection
Typical Development Processes
Summary
Chapter 5: Development Environment and Tools
Development Environment
Platform Builder for Windows Embedded Compact 7
Target Device Connectivity
Application for Compact 7
Windows Embedded Compact Test Kit
Summary
Part II: Platform Builder And OS Design
Chapter 6: BSP Introduction
BSP Provided by Platform Builder
BSP Components, Files, and Folders
Clone an Existing BSP
Customize the Cloned BSP
Summary
Chapter 7: OS Design
What Is an OS Design?
Develop an OS Design
Generate SDK from the OS Design
Summary
Chapter 8: Target Device Connectivity and Download
Target Device Connectivity
Connecting to the Target Device
Download OS Run-time Image to Target Device
Target Device Connectivity Setting
Summary
Chapter 9: Debug and Remote Tools
Debugging Environment
Debugging the OS Design
Remote Tools
Target Control
Summary
Chapter 10: The Registry
Windows Embedded Compact Registry
Registry for Windows Embedded Compact Component
Useful Registry References
Windows Embedded Compact Registry Files
Accessing the Registry
Summary
Chapter 11: The Build System
The OS Design Build Process
Build System Tools
Best Practice to Save Time and Minimize Problems
Summary
Chapter 12: Remote Display Application
Access Compact 7 Desktop Remotely
Add Remote Display Application to an OS Design
How-To: Use Remote Display Application
Using Remote Display Application on Headless Device
Summary
Chapter 13: Testing With Compact Test Kit
Compact Test Kit
Establishing Connectivity for CTK
Testing Compact 7 Device with CTK
Summary
Part III: Application Development
Chapter 14: Application Development
Developing Compact 7 Applications
Connectivity to Deploy and Debug Application
Summary
Chapter 15: .NET Compact Framework
.NET Compact Framework Application
.NET CF Application Considerations
Summary
Chapter 16: Corecon Connectivity
Implementing CoreCon for Application Development
Connecting to a Target Device with CoreCon
Summary
Chapter 17: Visual Studio Native Code Application Example
Prerequisites and Preparation
Develop a Native Code Application for Compact 7
Summary
Chapter 18: Managed Code Application Example
Prerequisites and Preparation
Developing a Managed Code Application for Compact 7
Summary
Chapter 19: Platform Builder Native Code Application Example
Prerequisites and Preparation
Developing a Virtual PC OS Design
Developing a Platform Builder Native Code Application for Compact 7
Debugging a Platform Builder Native Code Application
Summary
Chapter 20: Developing Embedded Database Applications
Introducing Microsoft SQL Server Compact
Microsoft SQL Server Compact
Compact Database Requirements
Managed Code Requirements
Building a SQL Compact Database Application Using Visual Data Designers
A Media Playlist List Application
Text File Data and XML Serialization
Building the Managed Code Data Application (Text and XML)
Building a Managed Code Remote Database Application
Building a Managed Code Compact Database Application
Summary
Chapter 21: Silverlight For Windows Embedded
Silverlight: User Interface Development Framework
Silverlight for Windows Embedded
Development Environment and Tools
Development Process
Summary
Chapter 22: Silverlight For Windows Embedded Application Examples
Prerequisites and Preparation
Develop a Compact 7 OS Design with Silverlight Support
Develop the SWE Application Project Using Expression Blend 3
Port a XAML Code Project to Native Code Using Windows Embedded Silverlight Tools
Add the SWE Application as a Subproject, Compile, and Launch
Add Event Handler to Silverlight XAML Code Project
Update the SWE Application Subproject
Create a User Control
Update the SWE Application Subproject to Include Animation
Summary
Chapter 23: Auto Launching Applications
Configuring the Registry to Auto Launch Application
Auto Launch Application from Startup Folder
Using the AutoLaunch Component
AutoLaunch Multiple Applications
Summary
Chapter 24: Application Deployment Options
Deploying a Compact 7 Applications
Options
Summary
Part IV: Deploy Windows Embedded Compact 7 Devices
Chapter 25: Deploy OS Run-Time Images
Considerations
Deploying an OS Run-time Image
Summary
Chapter 26: Bootloaders
Compact 7 Bootloader
Ethernet Bootloader (Eboot)
Serial Bootloader (Sboot)
Loadcepc
BIOSLoader
Compact 7 Bootloader Framework
Summary
Chapter 27: Biosloader
BIOSLoader Startup Parameters
BIOSLoader Files and Utility
Using BIOSLoader
Summary
Chapter 28: The Diskprep Power Toy
Prerequisites and Preparation
Using DiskPrep Power Toy
Summary
Part V: Device Drivers, Boot Loader, BSP, and OAL Development
Chapter 29: An Overview of Device Drivers
What Is a Device Driver?
Operating System Structure
Windows Embedded Compact Drivers
Custom Drivers
Summary
Note
Chapter 30: Device Driver Architectures
Introducing Device Driver Architectures
Kernel and User Driver Modes
Native and Stream Drivers
Monolithic and Layered Driver Models
Stream, Block, Bus, and USB Drivers
How to Check if the Bluetooth Stack Is Loaded
Using the Compact 7 Bluetooth Components
Summary
Chapter 31: Interrupts
Polling and Interrupts
Compact 7 Interrupt Architecture
Watchdog Timer
A Watchdog Timer Driver and Application
Using the WDT Test Application
Creating a Console Application with a Dynamic Link Library
Summary
Chapter 32: Stream Interface Drivers
Loading a Driver
Stream Drivers
Stream Driver Functions
Stream Driver Configuration
Driver Context
Driver Classes
Application Streaming APIs
Power Management
An Application to Test if a Stream is Loaded
Summary
Chapter 33: Developing A Stream Interface Driver
Stream Interface Driver Development Overview
The Stream Interface Functions
A Simple Stream Driver Project
A Compact 7 Stream Driver Project
Building a Stream Driver for Testing
CEDriver Wizard
Implementing IOCTLs
Driver Context and Shared Memory
Registry Access from a Driver
Implementing Power Management
Summary
Chapter 34: Stream Driver API and Device Driver Testing
Debugging Overview
Build Configurations
First Some Simple Checks
Breakpoints
Debug Macros
Using Remote Tools
Stream Driver API and Test Applications
Windows Embedded Test Kit (CTK)
Other Compact 7 Debugging Features
CeDebugX
Summary
Chapter 35: The Target System
BSP Overview
Some Compact 7 Target Boards
BSP Components
Bootloader
OAL
KITL
BSP Configuration Files and Folders
Device Drivers
Developing a BSP
Adding an IOCTL to the OAL
Summary
Part VI: Advanced Application Development
Chapter 36: Introduction to Real-Time Applications
Real-Time Application Overview
Windows Embedded Compact 7 and Real Time
Summary
Chapter 37: A Simple Real-Time Application
Developing a Simple Real-Time Application
Summary
Chapter 38: Extending Low-Level Access To Managed Code
The Native Managed Interface
Techniques for Low-Level Access to Managed Code
Summary
Chapter 39: Extending Low-Level Access To Managed Code With Messages
Communicating from Native to Managed Code
Summary
Chapter 40: A Web Server Application
Embedded Web Server with Compact 7
Summary
Chapter 41: A USB Camera Application
Using a USB Camera on Compact 7
Summary
Part VII: Sample Projects
Chapter 42: Develop A Windows Network Projector
Windows Network Projector Application
Developing a Windows Network Projector
Using Windows Network Projector
Summary
Chapter 43: Phidgets Devices
Phidgets Devices
Phidgets Devices Application
Summary
Chapter 44: FTDI Devices
FTDI Devices
FTDI Hardware Interface
FTDI as the USB Interface to a System
FTDI Device Drivers
CEComponentWiz: Adding Content to an Image
FTDI Drivers as Catalog Items
Third-Party FTDI Application Modules
Serial Port Access from a Compact 7 Application
A Custom FTDI Stream Driver
Summary
Chapter 45: Integrating Managed Code Projects
Native Code
Managed Code Applications and Windows Embedded Compact 7
Package a .NET Application for Inclusion in the OS Image
Deploy a .NET Application Directly over KITL
Include the Build of a Managed Code Application in the OS Build
What Now?
Summary
Appendix A: Virtual PC Connectivity
Configure Virtual PC Connectivity
Virtual PC 2007
Virtual PC Information Resources
Appendix B: Microsoft Resources
Evaluation Software
Drivers and Utilities
Windows Embedded Compact Forums
Appendix C: Community Resources
Windows Embedded Community
Community Projects for Compact 7
Other Community Projects
Other Resources
Appendix D: Embedded Hardware
Embedded Hardware Consideration
Summary
Foreword
Introduction
Advertisement

Professional Windows® Embedded Compact 7
Published by
John Wiley & Sons, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2011 by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-05046-0
ISBN: 978-1-118-16750-2
ISBN: 978-1-118-16748-9
ISBN: 978-1-118-16747-2
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats and by print-on-demand. Not all content that is available in standard print versions of this book may appear or be packaged in all book formats. If you have purchased a version of this book that did not include media that is referenced by or accompanies a standard print version, you may request this media by visiting http://booksupport.wiley.com. For more information about Wiley products, visit us at www.wiley.com.
Library of Congress Control Number: 2011934627
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Windows is a registered trademark of Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
ABOUT THE AUTHORS
SAMUEL PHUNG has worked in the technology field for more than 20 years. In the early 1990s, he led a financial database software development team, developing software for the banking industry. Later he led a software team developing Windows-Based telephony applications for a venture capital-funded startup. He started to work in the embedded computing field in the late 1990s and engaged with the Windows Embedded product team, starting with Windows NT 4.0 Embedded. He has been working with Windows Embedded Compact since version 2.12 was introduced.
As the VP of sales and marketing for ICOP Technology, a hardware manufacturer headquartered in Taiwan with a branch office in the United States and a manufacturing facility in China, Samuel is responsible for strategic business development for ICOP in the North America region. In 2003, he created the Vortex86 branding and started an initiative focused on developing business around Windows Embedded technology for ICOP.
In 2009, he wrote Professional Microsoft Windows Embedded CE 6.0.
Samuel enjoys working with technology, actively engages with the academic community, and received the Windows Embedded MVP recognition from Microsoft since 2005. As part of his involvement in the academic community, Samuel actively works with university teaching professionals in the United States, China, and Taiwan and other regions to adopt Windows Embedded technology as part of their teaching curriculum.
As part of his Windows Embedded community activities, Samuel maintains a personal website: www.embeddedpc.net, to provide information resources related to Windows Embedded. In 2010, he initiated the Embedded101 Windows Embedded community portal, www.embedded101.com.
DAVID JONES has a Master of Engineering degree from RMIT University and BSc(Hon) from Melbourne University. David has been actively engaged in Embedded Systems and Computing Technologies for more than twenty years. From 1990 to 2006, he was a University Lecturer in Computer Engineering at RMIT University in Melbourne, Australia. After leaving his university teaching role in late 2006, he joined the Victorian Partnership for Advanced Computing (www.vpac.org) to provide embedded system training, consulting, and development services with a focus on modern Embedded-system technologies. VPAC is a non-profit research agency established in 2000 by a consortium of Victorian Universities to provide advanced computing expertise, training, and support to academia, industry, and government.
While teaching at RMIT, he mentored student teams participating in the Windows Embedded Student Challenge competition sponsored by Microsoft. One of the student teams he mentored won first place during the 2005 worldwide final competition. David actively engages in the Windows Embedded community. He has delivered presentations on behalf of Microsoft in the Asia Pacific region, covering Windows Embedded and .NET technologies. In 2010, he initiated the effort to develop a Device-Driver Wizard and a Component Wizard, both for Windows Embedded CE 6.0 and Windows Embedded Compact 7. He released community versions for both. David is a certified Windows Embedded trainer.
THIERRY JOUBERT is the CTO and co-founder for THEORIS, a technology company in France that provides project management, software consulting, outsourcing, and training services with focus on modern embedded technology. He graduated from the Ecole Centrale de Nantes in France with an engineering degree in computer science. Thierry has been actively engaged in Embedded-system design and real-time application development for over 25 years.
In addition to his responsibility working on commercial projects, Thierry is actively involved in the academic community, delivering Windows Embedded trainings and technical seminars for engineering schools and universities. In 2004, Thierry developed a case study on Windows CE for Microsoft’s MSDN Academic Alliance curriculum, and published multiple technical papers to help teach Windows Embedded technology on the Microsoft Faculty Resource site. To recognize Thierry’s effort and contribution to the Windows Embedded developer community, Microsoft has awarded the Windows Embedded MVP status to Thierry since 2007.
ABOUT THE TECHNICAL EDITOR
DOUG LOYD first learned to write code on his parents’ Commodore 64, drawing inspiration from the pages of BYTE magazine. He earned his degree in Computer and Information Sciences from the University of Delaware and has spent the last 10 years working on Windows CE devices. He lives in rural Maryland with his wife and daughter. You can contact Doug at douglas.loyd@gmail.com.
CREDITS
ACQUISITIONS EDITOR
Paul Reese
PROJECT EDITOR
Ed Connor
TECHNICAL EDITOR
Doug Loyd
PRODUCTION EDITOR
Daniel Scribner
COPY EDITOR
San Dee Phillips
EDITORIAL MANAGER
Mary Beth Wakefield
FREELANCER EDITORIAL MANAGER
Rosemarie Graham
ASSOCIATE DIRECTOR OF MARKETING
David Mayhew
MARKETING MANAGER
Ashley Zurcher
BUSINESS MANAGER
Amy Knies
PRODUCTION MANAGER
Tim Tate
VICE PRESIDENT AND EXECUTIVE GROUP PUBLISHER
Richard Swadley
VICE PRESIDENT AND EXECUTIVE PUBLISHER
Neil Edde
ASSOCIATE PUBLISHER
Jim Minatel
PROJECT COORDINATOR, COVER
Katie Crocker
PROOFREADER
Jen Larsen, Word One
INDEXER
Robert Swanson
COVER DESIGNER
LeAndra Young
COVER IMAGE
©Aleksandr Volkov/iStockPhoto
ACKNOWLEDGMENTS
FIRST, I WANT TO RECOGNIZE the Windows Embedded Compact development team’s effort. Without their hard work, the Windows Embedded Compact product would not be where it is today.
As I went through the process to learn Windows Embedded Compact, I found many information resources on the news group and forum, which helped me learn and resolved problems. I want to thank the developers in the community who helped answer questions on the news group, shared their knowledge, and posted valuable application notes online to help others.
Thanks to David and Thierry for participating in this book project and helping to expand the contents. Throughout the book project, I gained valuable knowledge from David and Thierry.
I want to recognize the following individuals for their helpfulness:
- Michael Fosmire with the MVP team. He is always accommodating and willing to listen. I want to thank Michael for the resources he provided to help the Windows Embedded community.
- Olivier Bloch with the Windows Embedded team. I could count on Olivier to be responsive and help provide answers to the questions we had throughout the book project.
- D’Arcy Salzmann with the Windows Embedded team. D’Arcy initiated the dialog about the book project and motivated us to move forward with this book.
- James Y. Wilson, one of the authors of the Building Powerful Platforms with Windows CE (version 3.0) book. James helped me to get over the initial hurdle to learn and engage in Windows Embedded Compact development. For the more than 7 years that I have known James, he has provided valuable resources and contributions to both the professional and academic developer communities.
As an amateur writer, with English as my second language, writing is not an easy task. I want to thank Ed Connor and San Dee Phillips, editors for the book project, for reviewing my writing, correcting many mistakes that I made, and providing valuable input.
Most of all, I want to thank my wife, Ann, and my children, Aaron, Narissa and Nathan for their understanding and patience while I took time away from the family to work on the book.
—Sam Phung
I WOULD LIKE TO ACKNOWLEDGE the support and assistance I have previously received from Microsoft staff in past, particularly when I was an academic. People in Australia such as Nigel Watson, John Warren, Don Kerr, Tim Schroeder and others have assisted me in many ways. At Redmond I’d also like to thank Mike Hall, Stewart Tansley, Lindsay Kane, and Sondra Weber. Thanks also to Nelson Lin for your assistance and friendship.
I would like to thank the many students who have worked on Windows Embedded projects with me; especially those who competed in Microsoft Windows Embedded Student Challenges. It has been great to act a facilitator of those projects. I am always amazed at the way students can take nebulous ideas and turn them into something substantial and useful.
The current Windows Embedded team at Microsoft have been timely and constructive with their support during this activity. Thanks to Olivier Bloch, D’Arcy Salzmann, and others. They have been busy with the release of Compact 7 but found the time to support us.
I would also like to thank all of those Embedded MVPs and others who have contributed to my understanding of Windows Embedded though books, presentations, newsgroups, forums, and blogs. There are many of you. (“Standing on the shoulders of giants” — Isaac Newton.)
Thanks Sam and Thierry for input to this activity as co-authors. I have known Sam for a number of years through the Windows Embedded forum. His contribution to Windows Embedded through such things as student and Embedded Spark competitions is invaluable. Sam has been at the helm of this project and without his effort it would not have come to fruition. Thierry has been a great help on the technical side. He has much experience with commercial development with Windows Embedded. His feedback has been precise and constructive.
Thanks also to Ed Connor and San Dee Phillips for their reviews and feedback of my chapters. As a first-time author this has been a big learning curve for me. Their assistance is greatly appreciated.
I’d like to finish with a big thank you to my wife Wendy who has had to put up with my long hours working at this project. Thanks Wendy.
—David Jones
I STARTED WORKING WITH Windows CE 3.0 when Microsoft released it in 2000 and the product has come a long way since then to reach Windows Embedded Compact 7. All these years the Windows Embedded development and marketing teams have made sustained efforts to improve their products. I thank Lorraine Bardeen, Myriam Semery, Sondra Webber, Kevin Dallas, Olivier Bloch, Mike Hall, and D’Arcy Salzmann for their availability and openness when we make suggestions.
A special thanks to Samuel, who invited me as a co-author of this book, and to David who contributed to make the writing task enjoyable. I also thank my colleague Vincent Cruz, who gave me the image transformation code in Chapter 41, and our reviewers Ed Connor and San Dee Phillips.
Most of all I want to thank my family for their patience during this long period where I rarely left my desk.
—Thierry Joubert
FOREWORD
It’s July 2011, I’m in New York judging the Embedded competition at the Imagine Cup (www.imaginecup.com), Samuel Phung and Thierry Joubert (two of the authors of this book) are also embedded judges. I’ve known Sam, Thierry and David Jones for a number of years and consider them to be good friends. They have been involved with Windows Embedded as MVPs, through the community, the Windows Embedded Student Challenge and Imagine Cup. Each has extensive knowledge of Windows Embedded technologies and is able to provide experience-based insight into building and deploying embedded systems.
Imagine Cup is a worldwide competition that challenges students to solve big problems through innovative use of technology. The theme for the competition this year is, “Imagine a world where technology helps solve the toughest problems.” Students are given an embedded hardware reference board and a copy of the Windows Embedded Compact 7 development tools and are then let loose on building something cool that also solves real world problems. Projects range from smart control of street lights, controlling the growth of Algae (for use in bio fuels), self-guiding robots, patient monitoring systems, self-navigating helicopters for use in disasters, harmonica-based lung function training device, smart baby monitoring, intelligent fire escape systems, and TV-based social/communication systems for the elderly.
Now think about all the embedded devices you touch in a single day. This might include a Set Top Box, Digital Picture Frame, Automotive Infotainment device, smart traffic light systems, home automation, thin client devices, conference room projectors, video conference device, ATMs, Point of Sale systems, medical monitoring devices, etc . . . Embedded systems are all around us. These devices are smart, connected, and are able to consume and share data across the internet. Conservative estimates predict billions of devices being connected to the internet by 2014, and we’ve already passed the point where more devices are connected to the internet than people.
Windows Embedded Compact 7 is a small footprint, componentized, real-time embedded operating system that runs on ARM, x86, and MIPS processor architectures. The embedded development tools integrate into Visual Studio and enable rapid prototyping of operating system images, user experiences and applications on physical hardware or desktop based emulators. Whether you are building a consumer device that requires a web browser, Flash, and media playback, or an enterprise device that provides a task-based user experience, local database and data sync capabilities, or industrial device that requires hard real-time capabilities, Compact 7 has the tools and technologies you need to bring a smart, connected device to market quickly.
Building an embedded system requires skills ranging from hardware design, driver development, operating system configuration/build, debugging, testing, performance analysis, user interface design and application development — a very diverse set of skills! This book provides novice and experienced embedded developers with practical and hands-on working examples of building embedded devices using Windows Embedded Compact 7.
Now the challenge! Given your newly acquired Windows Embedded Compact 7 skills, and seeing some of the amazing projects students are working on for the Imagine Cup 2011 competition, how do you imagine a world where technology helps solve the toughest problems?
—Mike Hall
Principal Software Architect
Windows Embedded Business
Microsoft Corporation
INTRODUCTION
WINDOWS EMBEDDED Compact 7 (Compact 7) is a 32-bit, small-footprint, hard real-time operating system (OS) with great graphics and multimedia support, developed by Microsoft to support handheld, mobile, automotive, multimedia, retail, medical, industrial, robotics, and other embedded devices. It’s designed to support multiple processor architectures, including ARM, MIPS, and x86.
Windows Embedded Compact development supports subsets of Win32, .NET Framework, and Silverlight and uses the popular Visual Studio integrated development environment to provide a developer-friendly environment to develop embedded applications.
The first version initially released to the public in 1996 as Windows CE; Microsoft subsequently changed the product name to Windows Embedded Compact for the current release. This OS platform has cumulated more than 15 years of continuous development and improvement and evolved to become a mature and robust OS platform. Along with the efficient and developer-friendly environment, Windows Embedded Compact provides the latest networking, multimedia, Silverlight for Windows Embedded, and application development framework that enables the product development team to rapidly develop smart, connected, and service-oriented devices with an exciting and visually compelling user interface.
New Generation of Embedded Devices
During the past three decades, technology has been through a phenomenal growth and is one of the key contributing factors that helped to improve our lives. As technology evolves, new generations of System-on-Chip (SoC) are being built with faster and more powerful processors. Each new generation of SoC is designed with additional integrated peripherals in a smaller package with more built-in features. Although the SoC becomes faster, more powerful, and has more built-in features, the increased demand in the market helps lower the cost. As a new generation of SoC evolves, it enables developers to design and deliver to consumers a new generation of embedded devices with far more capability, at a lower cost than its predecessors. Computers, smartphones, media players, navigation devices, and game consoles are just some of the prime examples.
Aside from the consumer market, a new generation of SoC provides the core engine that enables developers to create a new generation of medical, retail, industrial, robotic, and communication devices that are the critical building blocks to help shape the living environment around us.
Embedded devices are everywhere. Knowingly and unknowingly, we use and interact with embedded devices throughout our daily living, as we travel, work, and go about our everyday life. Think about the ATM, gas pump, ticketing machine, credit card terminal, vending machine, digital camera, remote control, security alarm system, mobile phone, GPS navigation device, and more.
New Generation of Development Platform
As the evolving technology enables a new generation of embedded devices to be built with more functions and features, it also raises consumers’ expectation for better products. To keep up with customers’ demands and remain competitive in the market, many legacy device manufacturers have to find an efficient and effective development platform to redesign their product with new technology to incorporate additional features and functions, to meet their customers’ expectations.
Different development environments require different tools. The environment needed to develop aerospace technology has a different focus than the environment needed to develop general consumer devices. Like an ancient saying in Asia, you do not use a butcher knife to kill a mosquito. To be an efficient and productive developer, you need to identify and select the right development tools for the project.
The Windows Embedded Compact development platform provides the proper balance between the need for a small-footprint OS with hard real-time capability and ease of development, where you can use native code to develop highly efficient applications to meet hard real-time requirements as well as a high-level language such as Visual Basic and C# to rapidly develop applications for different types of devices, servicing the following markets:
- Automotive
- Consumer and entertainment
- Engineering and scientific instrument
- Home and building automation
- Industrial automation, process control, and manufacturing
- Information kiosk and self-serve terminal
- Medical
- Mobile phone and communication
- Office equipment
- Retail and hospitality
- Robotics
In the fast-paced and unforgiving technology market, rapid application development, fast time-to-market, and the ability to manage development risk and minimize cost are key factors contributing to a successful project.
Windows Embedded Compact provides an efficient and effective development environment that helps developers simplify complicated tasks and enables project managers to establish a manageable development plan and schedule.
WHO THIS BOOK IS FOR
This book is written for system integrators who need to create the operating system for a new hardware platform and for application developers who need to develop software for a device. No specific knowledge of Windows Embedded Compact or operating systems is required to understand the content of the book.
Whether you have experience with managed code using C# and Visual Basic or native code using C and C++, the information in this book can help establish the foundation for you to engage in Windows Embedded Compact development.
WHAT THIS BOOK COVERS
Embedded development involves tinkering with hardware, developing interesting devices and writing codes to control and interact with the device. Windows Embedded Compact provides a development environment that enables serious developers to develop highly efficient hard real-time applications using native code to access low-level system resources and hardware. At the same time, entry-level developers can take advantage of the .NET Compact Framework that supports managed code development using the developer-friendly programming languages such as Visual Basic and C# to develop real-life embedded applications.
The Windows Embedded Compact development environment involves multiple development disciplines that cover a broad range of technologies and development expertise. It’s not within this book’s objectives to cover application development concepts and how to write code.
One of the keys to learn and engage in Windows Embedded Compact development is to know your way around the tools and what they can do for you. This book is written to provide practical information about the Windows Embedded Compact development environment, showing how to use the tools and the debugging and testing facilities.
This book talks about the development environment for Windows Embedded Compact and provides simple exercises, when applicable, to demonstrate how to perform different development tasks. Following is a list of the covered subjects:
- Windows Embedded Compact operating system overview
- Development environment overview and required software
- Board support package, OAL, and bootloader
- Windows Embedded Compact OS design
- Target device connectivity using KITL and CoreCon
- Debugging and debugging tools
- Developing managed code applications for Windows Embedded Compact devices using Visual Studio
- Developing native code applications for Windows Embedded Compact devices using Visual Studio
- Windows Embedded Compact system registry
- Deployment of Windows Embedded Compact OS and auto-launch application during startup
- DiskPrep power toy and BIOSLoader
- Developing stream interface drivers
- Real-time application
- Extending low-level system access to managed code applications with messages
- Web service applications for Windows Embedded Compact
HOW THIS BOOK IS STRUCTURED
The content for each chapter is written with minimal dependency on the other chapters. The book contents are organized in seven parts.
Part I: Introducing Embedded Development
- Chapter 1, “Embedded Development” — This chapter talks about embedded development in general, covering hardware, software, and development considerations for embedded devices.
- Chapter 2, “Windows Embedded Compact 7” — This chapter introduces Windows Embedded Compact 7 and talks about its features and a little bit of history.
- Chapter 3, “Development Station Preparation” — This chapter talks about the development station requirements and required software and development station setup.
- Chapter 4, “Development Process” — This chapter talks about the process to develop a Windows Embedded Compact 7 device.
- Chapter 5, “Development Environment and Tools” — This chapter talks about the Platform Builder development environment, target device connectivity, and Compact Test Kit.
Part II: Platform Builder and OS Design
- Chapter 6, “BSP Introduction” — This chapter talks about the board support package and works through the exercise to clone and customize a board support package.
- Chapter 7, “OS Design” — This chapter talks about Windows Embedded Compact 7 OS design and works through the exercises to develop an OS design and generate an SDK from the OS design.
- Chapter 8, “Target Device Connectivity and Download” — This chapter talks about target device connectivity and downloading an OS runtime image to the target device.
- Chapter 9, “Debug and Remote Tools” — This chapter talks about debugging a Compact 7 OS design, debugging the build process, and using remote tools.
- Chapter 10, “The Registry” — This chapter talks about the Windows Embedded Compact system registry.
- Chapter 11, “The Build System” — This chapter talks about the build process that compiles and generates the OS run-time image.
- Chapter 12, “Remote Display Application” — This chapter talks about the remote display application, a useful utility to access a Compact 7 device’s desktop remotely.
- Chapter 13, “Testing with Compact Test Kit” — This chapter talks about the Compact Test Kit and works through the exercises showing the steps to configure and use the test kit.
Part III: Application Development
- Chapter 14, “Application Development” — This chapter talks about the general environment to develop an application for Windows Embedded Compact.
- Chapter 15, “NET Compact Framework” — This chapter talks about application development consideration using the .NET Compact Framework.
- Chapter 16, “CoreCon Connectivity” — This chapter talks about CoreCon and connectivity between the development station and target device to deploy the Visual Studio 2008 application for testing and debugging.
- Chapter 17, “Visual Studio Native Code Application Example” — This chapter works through an exercise showing the steps to develop a Visual Studio 2008 C++ native code application.
- Chapter 18, “Managed Code Application Example” — This chapter works through an exercise showing the steps to develop a managed code application using C#.
- Chapter 19, “Platform Builder Native Code Application Example” — This chapter works through an exercise showing the steps to develop a native code application as a subproject to an OS design in Platform Builder.
- Chapter 20, “Developing Embedded Database Applications” — This chapter talks about database applications for Compact 7 devices.
- Chapter 21, “Silverlight for Windows Embedded” — This chapter talks about Silverlight for Windows Embedded, a user interface development framework.
- Chapter 22, “Silverlight for Windows Embedded Application Examples” — This chapter works through multiple exercises showing the steps to create a Silverlight for Windows Embedded application.
- Chapter 23, “Auto Launching Applications” — This chapter talks about different options to automatically launch one or more applications during startup.
- Chapter 24, “Application Deployment Options” — This chapter talks about the different options to deploy Compact 7 applications.
Part IV: Deploy Windows Embedded Compact 7 Devices
- Chapter 25, “Deploy OS Run-time Images” — This chapter talks about the options and considerations for deploying a Compact 7 OS runtime image to a device.
- Chapter 26, “Bootloader” — This chapter talks about the bootloader for Compact 7.
- Chapter 27, “BIOSLoader” — This chapter talks about the BIOSLoader, a bootloader for x86 devices.
- Chapter 28, “The DiskPrep Power Toy” — This chapter talks about the DiskPrep power toy, a utility that helps simplify the effort to deploy a Compact 7 OS run-time image onto bootable flash media.
Part V: Device Drivers, Bootloader, BSP, and OAL Development
- Chapter 29, “An Overview of Device Drivers” — This chapter introduces device drivers for the Windows Embedded Compact environment.
- Chapter 30, “Device Driver Architectures” — This chapter talks about device driver architectures for Windows Embedded Compact.
- Chapter 31, “Interrupts” — This chapter talks about interrupts in Windows Embedded Compact.
- Chapter 32, “Stream Interface Drivers” — This chapter talks about stream interface drivers for Windows Embedded Compact.
- Chapter 33, “Developing a Stream Interface Driver” — This chapter works through an exercise showing the steps to develop a stream interface driver.
- Chapter 34, “Stream Driver API and Device Driver Testing” — This chapter talks about debugging and testing stream interface drivers.
- Chapter 35, “The Target System” — This chapter talks about the board support package and OEM adaptation layer development and the required Kernel Independent Transport Layer to support debugging.
Part VI: Advanced Application Development
- Chapter 36, “Introduction to Real-Time Applications” — This chapter describes the notion of time determinism for embedded systems, and lists the OS-dependent items. It explains why and how Compact 7 can be used for real-time applications.
- Chapter 37, “A Simple Real-Time Application” — This chapter works through an exercise to create a simple real-time application in order to measure the determinism of Windows Embedded Compact 7 timer drivers.
- Chapter 38, “Extending Low-level Access to Managed Code” — This chapter talks about accessing low-level system resources from managed code, and focuses on P/invoking the stream driver interface from applications in C-Sharp.
- Chapter 39, “Extending Low-Level Access to Managed Code with Messages” — This chapter talks about accessing a managed application from native code, it explains how low-level code as a device driver can notify a managed code application with messages.
- Chapter 40, “A Web Server Application” — This chapter talks about using the HTTP protocol to provide an interface to access a headless device, and works through an exercise to develop a web server application that enables you to access a Compact 7 device’s registry remotely from a web browser.
- Chapter 41, “A USB Camera Application” — Due to the nonstandard hardware environment, the Windows Embedded Compact driver for USB camera is still not readily available. This chapter talks about the USB camera driver project on Codeplex, the Windows CE Webcam project, and works through an exercise showing the steps to use this driver with Compact 7.
Part VII: Sample Projects
- Chapter 42, “Develop a Windows Network Projector” — This chapter talks about the Windows network projector sample application provided as part of the Windows Embedded Compact to enable the OEM and system integrator to rapidly develop a network-enabled projector device that supports the Connect to Network Project Wizard, available as part of the Windows Vista and Windows 7 OS, and works through an exercise to create a Windows Network Project device.
- Chapter 43, “Phidgets Devices” — This chapter talks about interfacing a Windows Embedded Compact device to external peripherals. Using the RFID reader module from Phidgets, this chapter works through an exercise showing the steps to develop a simple Compact 7 application to capture data from RFID tags.
- Chapter 44, “FTDI Devices” — This chapter talks about interfacing a Compact 7 device to FTDI peripherals through an USB interface.
- Chapter 45, “Integrating Managed Code Projects” — This chapter provides information showing what is needed to include a managed code application project as a subproject to a Compact 7 OS design and to debug the application, as it runs on the target device, using a Kernel Independent Transport Layer (KITL).
In addition to the above chapters, the following appendixes provide additional information resources:
- Appendix A, “Virtual PC Connectivity” — This appendix provides information about using a Virtual PC as the target device to support Windows Embedded Compact development.
- Appendix B, “Microsoft Resources” — This appendix provides information about Windows Embedded Compact resources available from Microsoft.
- Appendix C, “Community Resources” — This appendix provides information about Windows Embedded Compact community resources independent of Microsoft.
- Appendix D, “Embedded Hardware” — This appendix provides information about embedded hardware.
WHAT YOU NEED TO USE THIS BOOK
To work through the sample code and exercises provided as part of this book, you need a development station and a target device configured to support the Windows Embedded Compact 7 development environment.
Development Station
The development station needs to have the following software installed:
- Windows 7, Windows Vista with service pack 2, or Windows XP with service pack 3 and later
- Visual Studio 2008
- Visual Studio 2008 service pack 1
- Microsoft .NET Framework 3.5
- Microsoft Expression Blend 3 (needed for the Silverlight for Windows Embedded exercise)
- Platform Builder for Windows Embedded Compact 7
Target Device
A target device is needed for the exercises to deploy the Compact 7 OS runtime image and application.
The eBox-3310A-MSJK is used as the target device for the exercises in the book, as shown in Figure I-1.
More information about the eBox-3310A-MSJK is available in Appendix D, “Embedded Hardware.”
You can use a Virtual PC machine as the target device. To use an alternative hardware platform as the target device, you need the following resources to work through the exercises in this book:
- Board support package for Compact 7
- Ethernet connectivity
- Ethernet driver for Compact 7 that is able to support Compact 7’s Kernel Independent Transport Layer (KITL)
- Bootloader to launch Compact 7 OS run-time image from local storage
- Bootloader to download Compact 7 OS runtime image from development station
CONVENTIONS
To help you get the most from the text and keep track of what’s happening, we’ve used a number of conventions throughout the book.
Notes, tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.
For styles in the text:
- We italicize new terms and important words when we introduce them.
- We show keyboard strokes like this: Ctrl+A.
- We show filenames, URLs, and code within the text like so: persistence.properties.
- We present code in two different ways:
We use a monofont type with no highlighting for most code examples.
SOURCE CODE
As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All the source code used in this book is available for download at www.wrox.com. When at the site, simply locate the book’s title (either by using the Search box or by using one of the title lists) and click the Download Code link on the book’s detail page to obtain all the source code for the book. Code that is included on the Web site is highlighted by the following icon:

Listings include the filename in the title. If it is just a code snippet, you’ll find the filename in a code note such as this:
Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-1-118-05046-0.
After you download the code, just decompress it with your favorite compression tool. Alternatively, you can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.
ERRATA
We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be grateful for your feedback. By sending in errata you may save another reader hours of frustration, and at the same time you can help us provide even higher quality information.
To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all errata that has been submitted for this book and posted by Wrox editors. A complete book list including links to each book’s errata is also available at www.wrox.com/misc-pages/booklist.shtml.
If you don’t spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We’ll check the information and, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of the book.
P2P.WROX.COM
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.
At p2p.wrox.com you can find a number of different forums to help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:
1. Go to p2p.wrox.com and click the Register link.
2. Read the terms of use and click Agree.
3. Complete the required information to join as well as any optional information you want to provide, and click Submit.
4. You will receive an e-mail with information describing how to verify your account and complete the joining process.
You can read messages in the forums without joining P2P but to post your own messages, you must join.
After you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to This Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.