Tutorial: Building
a Run-Time Image for the Emulator
This guide helps you become familiar with Platform Builder and the new
functionality of the Windows CE operating system (OS). It provides a
step-by-step tutorial for creating and debugging a custom run-time image and a
simple application that runs in the Emulator.
In this tutorial you create an Enterprise Web Pad running the Hello World
application that runs in the Emulator.
This tutorial makes the following assumptions:
- You have installed Platform Builder and Windows CE as described in the
installation instructions.
- You have selected the Emulator as one of the installed CPUs.
- You are familiar with the terms defined in .
This tutorial takes approximately 50 minutes to complete.
In this tutorial, you complete the following steps:
Tutorial Step
1: Creating a Custom OS Design for the Emulator
In this step, you use the New Platform Wizard to create a custom OS
design.
To create a custom OS design for the Emulator
- On the development workstation, launch the Platform Builder application.
- From the File menu, choose New Platform, and when the New
Platform Wizard appears, choose Next.
- In the Name box, enter MyOSDesign as the name for your OS
design.
- In the Path box, enter or select the path to the root directory where
you want your OS design to be located; then choose Next.
For this tutorial, accept the default location, which is
%_WINCEROOT%\PBWorkspaces\MyOSDesign.
- From the list of available board support packages (BSPs) installed on your
development workstation, select EMULATOR: X86 and choose Next.
- From the list of available OS design templates, select Enterprise
Web Pad and choose Next.
- Accept the default selections for Applications & Media by
choosing Next.
- Accept the default selections for Networking & Communications by
choosing Next.
- Acknowledge the Special Notifications by choosing Next.
- Save your settings and close the New Platform Wizard by choosing
Finish.
Platform Builder creates two configurations for your OS design:
- A Debug configuration
- A Release configuration
After these files are created, you now build a custom run-time image.
Tutorial
Step 2: Building the Custom Run-Time Image for the Emulator
After you create an OS design, you can build a run-time image based on that
OS design. In this step, you build a custom run-time image from the OS design
you created in Tutorial Step 1.
For this tutorial, when you build the custom run-time image, choose a Debug
configuration for your OS design. By building a run-time image based on the
default Debug configuration, you can later debug your run-time image on the
target device from Platform Builder.
In addition, because the size of a run-time image based on a Debug
configuration is greater than the size of a run-time image based on a Release
configuration, you must also change the value of an environment variable to
accommodate a larger run-time image.
To build the custom run-time image for the Emulator
- From the Platform Builder Build OS menu, choose Set Active
Configuration.
- From the list of configurations, select EMULATOR: X86_Debug and
choose OK.
Platform Builder updates the list of Catalog items in your OS design.
- From the Platform menu, choose Settings.
- In the Configuration list, be sure EMULATOR: x86_Debug is
selected.
- Choose the Build Options tab and verify that the following check
boxes are selected:
- Close the Platform Settings dialog box and save your changes by
choosing OK.
- Choose the Build OS menu and verify that the following are selected:
- Copy Files to Release Directory after Build
- Make Run-Time Image After Build
By default, these are selected when you create a workspace in Platform
Builder.
- To build a run-time image based on your OS design, from the Build OS
menu, choose Build and Sysgen.
For information about other build options you can choose, see Build OS Menu
Options.
The time required by Platform Builder to build the run-time image depends on
the number of Catalog items in the OS design.
In this example, you are building a run-time image based on a large OS design
that contains many items, so it can take up to 20 minutes to build the OS image.
- Observe the build process in Platform Builder by viewing the output on the
Build tab of the Output window.
When the build is complete, you see the following message: MyOSDesign - 0
error(s), XX warning(s).
You can now set up a connection to the Emulator and download the run-time
image.
Tutorial
Step 3: Setting Up a Connection to the Emulator and Downloading the Run-Time
Image
In this step, you set up and configure a connection to the Emulator; then you
download the custom run-time image to the Emulator.
To set up a connection to the Emulator and download the
run-time image
- From the Target menu, choose Connectivity Options.
- Under Service Configuration, choose Kernel Service Map.
- From the Download list box, choose Emulator.
- Choose the associated Settings button.
- Be sure the settings for Display are set to 640x480x16; otherwise,
the Emulator window might not appear properly on your display.
- In the Memory (MB) box, be sure memory is set to 64 and then
choose OK.
- From the Transport list box, select Emulator.
- From the Debugger list box, be sure KdStub is selected.
- Under Service Configuration, choose Core Service Settings.
- Under Download Image, verify that Always is selected.
- Under KITL Settings, verify that the following check boxes are
selected:
- Enable KITL on device boot
- Clear memory on soft reset
- Enable access to desktop files
- To save your changes and close the dialog box, choose Close.
- or -
To save your changes and keep the dialog box open, choose Apply.
You have configured the services that allow you to connect to the Emulator.
Now you can establish a connection to the Emulator and download the run-time
image.
- From the Target menu, choose Attach Device.
A window appears, displaying the progress of the download to the Emulator.
Then the MyOSDesign - Emulator for Windows CE window appears.
- Wait until the OS appears in the MyOSDesign - Emulator for Windows CE
window.
The length of time required to display the OS depends on the size of the
run-time image being downloaded.
For this tutorial, the OS appears in about a minute.
While the run-time image is being downloaded, in Platform Builder, you can
see intermittent activity in the Debug tab of the Output window.
When the OS boots successfully, the Windows CE OS appears in the
MyOSDesign - Emulator for Windows CE window.
You can now debug the OS.
Tutorial
Step 4: Debugging the OS on the Emulator Using the Kernel Debugger
After you download and boot the run-time image in the Emulator, you can debug
the OS.
By default, when the OS boots, Platform Builder starts the kernel debugger
and displays the Debug toolbar.
To debug the run-time image, you must halt the running OS, because
breakpoints cannot be set while the OS is running. You then use the kernel
debugger to debug your custom OS.
To debug the OS on the Emulator using the kernel
debugger
- From the Platform Builder Debug menu, choose Break.
This halts the running OS on the Emulator, which does not respond to user
input while in this state.
- From the File menu, choose Open.
- Browse to %_WINCEROOT%\Platform\Emulator\Src\Drivers\Kbdmouse\Emulkbms,
select ps2mouse.cpp, and then choose Open.
You have opened the Ps2mouse.cpp file, which contains source code for the
mouse driver.
- From the Edit menu, choose Find.
- In the Find what box, type _move and choose Find Next.
You jump to a section of code in the Ps2mouse.cpp file that handles a mouse
move event.
- Set a breakpoint in the source code at the mouse move event by pressing the
F9 key.
A red dot in the margin shows that the breakpoint has been set.
- From the Debug menu, choose Go.
- In the MyOSDesign - Emulator for Windows CE window, move the cursor
over the window.
The breakpoint activates.
- Switch to the Platform Builder window.
A yellow instruction point or current instruction arrow on the breakpoint
symbol appears in the source code.
- Remove the breakpoint you set by doing one of the following:
- From the Debug toolbar, choose Breakpoints and then choose
Clear All Breakpoints.
- In the source code, right-click the line where you set the breakpoint; then
from the context menu, choose Remove Breakpoint.
- Use the ALT+9 keyboard shortcut to access the Breakpoint List window;
then choose Clear All Breakpoints.
- From the Debug menu, choose Go.
You have successfully halted the OS, set and activated a breakpoint in one of
the drivers, and then removed the breakpoint.
Follow the remaining steps to stop debugging the OS.
- From the Debug menu, choose Stop Debugging.
- From the Target menu, choose Detach Device.
- Shut down the Emulator by accessing the window for the Emulator; then from
the Emulator menu, choose Shut Down.
The Emulator window closes.
After you finish debugging, you can localize your run-time image.
Tutorial Step
5: Localizing the Run-Time Image for the Emulator
Windows CE offers the ability to localize a run-time image into several
languages. In this step, you localize the custom Enterprise Web Pad OS design
into German for the locale of Germany.
To localize the OS design for the Emulator
- From the Platform Builder Platform menu, choose Settings.
- In the Configuration box, select EMULATOR: x86_Release.
- Choose the Locale tab.
- From the Default Language list, select German (Germany); then
verify that the Localize the build check box is selected.
- Close the Platform Settings dialog box by choosing OK.
- From the Build OS menu, verify that the following options are
selected:
- Copy Files to Release Directory After Build
- Make Run-Time Image After Build
- From the Build OS menu, choose Build and Sysgen.
It can take up to 20 minutes to rebuild the run-time image with the changed
build options you selected.
When the build process is complete, you see the following message: MyOSDesign
- 0 error(s), XX warning(s).
- From the Target menu, choose Attach Device.
In approximately one minute, the localized run-time image finishes
downloading to the Emulator.
- In the MyOSDesign - Emulator for Windows CE window, verify that the
icons in the displayed OS are labeled in German.
- From the Platform Builder Target menu, choose Detach Device
and then choose OK.
- In the window for the Emulator, from the Emulator menu, choose
Shut Down.
You have created, built, and downloaded a localized run-time image.
You can now create and build an application based on your run-time image.
Tutorial
Step 6: Creating and Building an Application for the Emulator
In this step, you create and build a simple application using Platform
Builder.
To create and build an application for the Emulator
- From the Platform Builder File menu, choose New Project or
File.
- Choose the Projects tab and select WCE Application.
- In the Project name box, type Hello, verify that Workspace
project is selected, and choose OK.
- In the Feature name box, for the purposes of this tutorial, name your
application Hello and choose Next.
This name is used in the Readme.txt file that Platform Builder creates, and
is optional.
- Choose A typical "Hello World!" application and then choose
Finish.
- In the Workspace window, select the FileView tab; then from the
Projects node, select your application.
- From the Build Project menu, select the following:
- Clean Before Building
- Make Run-Time Image After Build
- Build the application by choosing Build Current Project from the
Build Project menu.
When the build is complete, in the Build window, you see the following
message: Hello.exe - 0 error(s), 0 warning(s).
To see this message, you might need to jump to the end of the output by
pressing the CTRL and END keys simultaneously.
You have created an application.
You can now run the application in the Emulator.
Tutorial
Step 7: Running the Application in the Emulator on the Custom Run-Time
Image
In this step, you run the newly created Hello.exe application in the
Emulator.
By default, Hello.exe is not included in the run-time image. It is downloaded
to the target device from the development workstation at run time. This allows
you to further develop the application without rebuilding the run-time image
after each change you make to the application.
To run the application in the Emulator on the custom
run-time image
- From the Platform Builder Target menu, choose Attach Device.
In approximately two minutes, your localized OS appears in the MyOSDesign
- Emulator for Windows CE window.
- From the Target menu, choose Run Programs.
- In the Available Programs list, select Hello.exe and choose
Run.
The Hello.exe application downloads from the development workstation to the
Emulator. The application then runs in the Emulator.
- In the MyOSDesign - Emulator for Windows CE window, verify that the
Hello.exe application has run successfully..
You have run a custom application on the Emulator.
- Shut down the Emulator so you can create and export a software development
kit (SDK):
- From the Platform Builder Target menu, choose Detach Device.
- In the window for the Emulator, from the Emulator menu, choose
Shut Down.
You can now create and export an SDK.
Tutorial Step 8:
Creating an SDK for eMbedded Visual C++
After you customize your OS design and boot and debug the run-time image, you
can use Platform Builder to create, configure, and build an SDK for the run-time
image.
Developers can use this SDK to create applications based on the run-time
image you created.
In this step, you create an SDK for Microsoft® eMbedded Visual C++®.
To create and build an SDK for eMbedded Visual C++
- From the Platform Builder Platform menu, choose SDK and then
choose New SDK.
- When the SDK Wizard appears, choose Next.
- In the Product name that is displayed when .msi file runs box, type
MyOSDesignSDK.
- In the Manufacturer name box, type MyCompany, and then choose
Next.
- Verify that the eMbedded Visual C++ 4.0 support check box is
selected, and then choose Next.
- On the final page, choose Close this wizard and continue configuring your
SDK.
The wizard closes and the SDK Settings dialog box opens.
- In the SDK Settings dialog box, choose the EULA/Readme tab and
select the Include custom end-user license agreement check box.
- In the End-user license agreement path box, enter the location and
name of a file as a Rich Text Format (.rtf) file that you want to use as a
sample custom End User License Agreement (EULA).
- or -
Choose Browse, select an .rtf file that you want to use as a sample
EULA, and then choose Open.
The custom EULA you include is displayed in a separate dialog box when the
SDK is installed.
- Choose the Emulation tab, and then, in the Configuration
field, verify that you have selected a build configuration for your SDK.
For this tutorial, select a Debug configuration.
Selecting a Debug configuration may help prevent errors from occurring when
you build your SDK.
- Choose OK to close the window and apply the settings to your SDK.
- From the Platform menu, choose SDK and then choose Build
SDK.
The SDK Wizard dialog box displays information while the SDK is being
built.
- When the build is complete, to close the dialog box, choose Done.
Your SDK is in the MyOSDesign_SDK.msi file in the
%_WINCEROOT%\PBWorkspaces\MyOSDesign\SDK directory.
You have completed this tutorial and successfully created and debugged a
custom run-time image and a simple application that runs in the Emulator. You
have also successfully created an SDK for your run-time image.