robotics company robot company  

Go Back   Trossen Robotics Community > Community Tutorials > Introduction

Home Submit Tutorial What's New What's Popular Search

Building an Embedded Operating System using Windows XP Embedded (Page 2)
Old 07-30-2009 09:18 PM
Peskey
Peskey is offline
Abacus
 
Category: Introduction
Views: 9,019
Replies: 1
Difficulty: Low
Estimated Time: 8 hours, including the installation and configuration of the build tools.
Skills Required: A basic understanding of Windows XP.
Parts Required: A Windows compatible Computer system that can boot from a USB drive.
A USB flash disk 512 MB or larger.
Tools Required: The Windows Embedded Toolset
Tutorial Navigation
  1. Page 1
  2. The XPe Build Process
  3. Advanced Functionality
  4. Additional Items
The XPe Build Process
The XPe Buld Process


Lets go through the process of building a simple XP Embedded operating system that boots from a USB flash disk.


Defining Baseline Devices:


The easiest way to begin is by installing a full version of Windows XP Pro on your target machine. It is generally a good idea to build a full version of Windows XP Pro for application debugging anyway.


The first step in developing an embedded system is to define all of the baseline devices/drivers that will be needed for your application. While you can manually pick and choose components in Target Designer, the easiest way to generate a baseline of components is to run tap.exe on your target machine after install Windows XP Pro. As stated previously, tap.exe will create a file called device.pmq. This is a text file that lists all of the devices/drivers that were registered with Windows. Make sure that you have all of the devices that your application requires installed before running this program; devices that show up as question marks in Device Manager will not be picked up by tap.exe.


Copy tap.exe to your target machine and simply double-click it to generate devices.pmq. Rename devices.pmq with a name that will identify your hardware. For example, if you are running on a roboard, call it roboard-devices.pmq. Copy this file back to your host machine.


Creating Components:


Components are created using the Components Designer tool. We'll create three components: one for required hardware devices (based on the output of tap.exe), one that holds the basic Windows functionality that we want and a third that holds the USB Boot capabilities.


Open the Component Designer tool. To create the first component, open the component designer and click File->Import. Select your devices.pmq file and click start. This will search the component database for the components listed in the PMQ file.


Component Designer Import Window


Once the import is complete, read through the log to check for errors and warnings about components not found. If any components that your design requires are not found at this stage, they will not be available to your final OS. To fix these sorts of issues, you may have to construct another custom component to import the desired functionality. When you are finished click Close.


The component designer will now provide a tree view of the new component on the left and the properties of the component on the right. Expand the tree view to show
[hardware]-devices.sld->Win XPE- Client->Components->[hardware]-devices.
Highlight the [hardware]-devices branch to see the component's properties. Verify that the Macro Component checkbox is set.


Component Designer Properties Window


Click the Browse button next to the prototype field and search for the Selector Prototype. Click OK. The component that we have just created is a macro: it doesn't provide any functionality on it's own, it just makes sure that other components are pulled into the design. Choosing the selector prototype enables us to enable or disable which components are pulled in form within the target designer tool. Click File->Save to save the component.


Click File->New to generate a new component. Name it 1-USB Boot. This component will be a macro that holds all of the components that are required to boot from a USB flash disk. Making a component like this simplifies image creation by grouping important components in one place.


On the treeview in the left pane navigate down to
1-USB Boot->Windows XP Embedded Client->1-USB Boot->Components.
Make sure “Macro Component” is checked and select the Selector Prototype. Next, click on the “Component or Group Dependency” branch of the treeview. In the right pane, right click and select Add->Component Dependency. This will bring up a window that allows you to set dependencies for the component. Any dependencies chosen in this way will be automatically entered into the target OS design when your component is added.


Component Designer Add Dependency Window


In “Component Dependency Source”, select Database. Search for and select “Enhanced Write Filter”. Click Apply and then OK. The Enhanced Write Filter component is now displayed in the right pane as a dependency. Repeat this procedure to add the following dependencies:

  • EWF Manager Console Applications
  • EWF NTLDR
  • USB 2.0
  • USB 2.0 Common
  • USB 2.0 Update KB931788
  • USB Boot Mass Storage Device Update KB931788
  • USB NT Hardware Detect
Click File->New to generate a new component. Name it 1-BoilerPlate. This component is a macro that holds all of the components that provide the basic Windows functionality we want in our image. Repeat the previous steps in this new component to add the following list of dependencies:
  • Basic TCP/IP Networking
  • CMD – Windows Command Processor
  • Device Manager
  • Direct X 9.0c
  • Display Controlled
  • English Language Support
  • Explorer Shell
  • FAT Format
  • Kernel Audio Support
  • Legacy and Plug n Play Audio Support
  • Map Network Drives / Network Places Wizard
  • Net.exe Utility
  • Network Setup Wizard
  • NTFS Format
  • OpenGL Support
  • Primitive: MPRUI
  • Registry Editr
  • Software Installation Group Policy Extension
  • Software Installation Group Policy MMC Snap-In
  • System Control Panel
  • Task Manager
  • TCP/IP Networking with File Sharing and Client for MS Networks
  • Terminal Services Runtime
  • USB Mass Storage Device
  • User Interface Core – Security Update KB928255
  • Users Control Panel
  • Windows Installer Service
  • WMI Windows Installer Provider
  • Administration Tools Support
This list of components includes most of the components required for a minimal Windows XP Embedded Image that still looks and feels like Windows. An OS build utilizing these components should be less than 300MB. Because the Selector Prototype was selected for this component, each of these components can be individually enabled or disabled during the image build process.


Loading Components into the Component Database:


Next, we will load our three new components into the Component Database. Open the Database Manager tool and click the Import button.




Component Database Manager Window


This will open the Import SLD window.


Component Database Manager Import Window


Select one of the *.SLD files that were created in the previous step (Click on the “...” button after the “SLD File:” field). Click Import. Read the log to check for errors. If everything was successful (you shouldn't have any problems importing Macro components), click Close. Repeat this process for the other two macro components you created. When you are finished, close the Component Database Manager.


Building the image:


Everything is now in place to actually define and build an XP Embedded operating system. Open the Target Designer tool and click File->New. Give your operating system configuration a name and click OK.


Target Designer New Configuration Window


Target Designer is broken into three panes. The left most pane holds all of the Components available for use in an image. The center pane holds the components you have selected for use in your OS. The right most pane holds property information for the component currently selected in the center pane. Some components (such as components created with the Selector Prototype) have properties that can be changed while others do not.


In the left most pane, double click on the three components we previously created to add them to you OS configuration. Select the settings of your devices and boiler plate components and uncheck any functionality that you do not want included in your image.


Target Designer Main Window


Once you are finished, click Configuration->Check Dependencies. This will run a tool that reads through the macro components currently in your design and adds them to the center pane. The tool will also find any incompatibilities between components that need to be resolved. If any errors are found, the required changes will be enumerated in the “Tasks” tab at the bottom of the Target Designer Window. Resolve each of these tasks before continuing. Once all of the tasks are compete, rerun the Dependency Checker.


Target Designer Dependency Checker


Once the Dependency checker returns without detecting any incompatibilities we can change the settings on any of the components pulled in by the dependency checker. These changes may cause other components to be pulled into the design, so be sure to rerun the Dependency Checker once more. In our design we will make changes to the settings of three Components: User Interface Core, Windows Logon and Windows Firewall.


Target Designer Main Window - Component Settings


In the center pane, select Enhanced Write Filter->Settings. The right pane will change to show the settings for this component. The Enhanced Write Filter is a component that makes create a RAM layer to prevent writes from being made to the boot media. Any writes done by the operating system are written into a RAM overlay that is discarded at reboot. This can be used to prevent users from making changes to the OS and provide a clean slate at each boot up. It is also useful when booting from flash media that can be damaged by excessive writes. Change the overlay type to RAM(Reg). This setting stores the overlay settings in the Windows registry instead of on a hidden disk partition. Uncheck “Start EWF enabled” If EWF starts enabled, any user changes to the OS during setup will be lost.


Now select User Interface Core->Settings. The right pane will display options to tweak the user interface. Check “Show My Computer on Start Menu”.


Select Windows Firewall /Internet Connection Sharing (ICS)->Settings and select Off. Turning the firewall off simplifies software debugging. When debugging is complete, turn this setting back on before doing a final build of the embedded OS.


You may want to browse the settings of all of the other components just to see what changes are possible.


Rerun Dependency Checker one last time. If the dependency check passes, we are ready to build our OS. Click Configuration->Build Target Image. Enter the directory where you want the OS files to be stored in the “Destination:” text box and click Build.


Target Designer Build Window


Read the log to check for any errors. If everything is successful, we're almost ready to boot our OS image for the first time.


USB Disk Preparation:


Before we can boot our OS image, we must prepare the USB flash disk for booting. Insert your USB flash disk into your development computer. Using Windows Explorer, determine the flash disk's drive letter. Open a command prompt and go to
C:\Program Files\Windows Embedded\utilities.
Run the command
ufdprep /ntfs <drive-letter>:
This command will place a MasterBootRecord on your flash drive to allow it to boot. The rest of the drive space will be formatted as an NTFS drive. Make sure you select the proper disk, as this operation will delete all of the contents of the flash drive. Copy the contents of the OS directory defined curing the image build step onto your bootable USB flash disk.


First Boot:


The OS is now ready for it's first boot. Turn on your target computer and enter into the BIOS. Configure the system to boot from USB as the first boot option. You will probably have to first enable USB booting and then set USB boot as the first option elsewhere in the BIOS. Plus in your USB flash disk and reboot the computer. When the system restarts, it will boot into the First Boot Analyzer (FBA).

First Boot Analyzer


The FBA prepares the operating system for use on your target hardware. Once the FBA completes, it will automatically restart the system. Congratulations, you now have no successfully built your first Windows XP Embedded operating system!

View of an XPe system after FBA.
Note: This build did not include the option to show "My Computer" on the start menu.


Runtime Configuration:


We're not quite done yet, though. There are a few items that we must configure during runtime. If there are any drivers that your systems needs that weren't loaded by the Windows XP Embedded toolset, you will need to load those drivers now. I usually wait to load video card drivers until this point, if possible, because it can be difficult to get them integrated into the tool chain coupled with the fact that new drivers are always being released. This is the best place to install the .NET runtime. Including the .NET components in Target Designer can introduce a few issues that I will not go into in this tutorial. This is also the point at which user developed programs (such as your robots AI) would be installed and configured.


The one last step that we need to undertake is to enable the Embedded Write Filter (EWF). The EWF is a component that was included in the “1-USB Boot” macro component defined at the beginning of the tutorial. The purpose of the EWF is to prevent writes to the USB flash disk. A flash drive can only be written to so many times before the drive will fail. Windows must be able to write to its disk during normal operation, which would prematurely shorten the life of a flash disk. To prevent this, the EWF component allocates a section of system RAM to act as a buffer between he OS and the flash disk. Any writes to the system go into RAM instead of being applied to the disk. This may prevent your robot from permanently writing data to the disk, but it will allow the flash disk to operate almost indefinitely.


To enable the embedded write filter on the boot drive, run the command
ewfmgr c: -enable
and reboot. During each successive boot, changes made to the operating system will not be saved to the disk. Each time the computer restarts, it will revert back to the state that the computer was in during the first reboot after enabling the EWF. If further changes are required, the EWF can be disabled by running the
ewfmgr c: -disable
or
ewfmgr c: -commitanddisable
command. Commitanddisable actually applies all of the changes that are stored in the EWF RAM layer to the disk before disabling the EWF.

If your robot must be able to write to the flash disk, you can format the disk to have multiple partitions and only configure EWF to protect the OS partition. A method of combining an EWF protected boot flash disk with large persistent storage is suggested in the Suggested Uses section at the end of this tutorial.
(Page 2 of 4)
Tags: Windows XP Embedded Operating System USB Boot



Replies to Tutorial: Building an Embedded Operating System using Windows XP Embedded
  #1   Report Post  
Old 08-01-2009
motters
motters is offline
Relay
 
Join Date: Jan 2008
Posts: 7
motters
Re: Building an Embedded Operating System using Windows XP Embedded

Ah, this brings back memories. I used Windows NT and then XP embedded extensively at work between 2000 and 2005. The embedded tools were always a real pain to deal with, and I thought the user interfaces were clumsy, non-intuitive and poorly designed. It would also often take quite a while to build a system, and build failures were common. In 2004 it took me about a week of solid effort to build an XP embedded system to fit onto a 1GB flash disk. I also completely hacked NT4 embedded to remove everything which wasn't needed (including Internet Explorer) and got it onto a 128MB Flash disk (the largest size available in 2000/2001). I don't know if things have changed, but the windows embedded tools used to be really expensive - over £1000 - but for work purposes the cost of software was negligible compared to the total cost of the industrial robot.

These days I'd probably use a small linux distro to do the same job, such as Puppy or Tiny Core, or just bolt a netbook onto the robot.

 


All times are GMT -5. The time now is 02:59 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.