In part-3 of this Windows Embedded Compact 7 (Compact 7) getting started series, we will work through an exercise to develop a Compact 7 OS design, generate an OS runtime image and download the image to a target device.

Note:

The Compact 7 getting started series consist of 9 different articles, covering the following subjects:

1.        Introduction.

2.        Development Environment & Tools.

3.        Develop a Compact 7 OS Design.

4.        Develop Managed Code Application for Compact 7.

5.        Develop Native Code Application for Compact 7.

6.        Develop SQL Compact Database Application for Compact 7.

7.        Develop Silverlight for Windows Embedded Application for Compact 7.

8.        Debug and Remote Tools.

9.        Deploy OS Runtime to Target Device for Distribution.

Refer to part-1 (introduction) for more information.

Develop an OS Design

To work through the exercise in this section, we need to have the following software installed to the development PC:

·         Visual Studio 2008 with service pack 1

·         Windows Embedded Compact 7

·         Visual Studio 2008 update for Windows Embedded Compact 7

·         ICOP_eBox3300MX_70D BSP for Compact 7 or a BSP to support the alternative target device.

·         AutoLaunch for Compact 7 (AutoLaunch_v300_Compact7)

The VS2008 IDE provides the facility to develop different type of projects, such as Windows Application, Console Application, Class Library, smart device application, Windows Services, Web Control, etc. 

When starting a new project with VS2008, the VS2008 IDE provides different wizards and templates to help create the initial workspace for the project.  Platform Builder is one of the available project templates.

In this section, we will work through an exercise to develop a Compact 7 OS design.

Create a New Compact 7 OS Design

Work through the following steps to create a new Compact 7 OS design:

1.       From the VS2008 File menu, select New and click on Project to bring up the New Project wizard screen, as shown in Figure 1.

Fig-01

Fig. 1                 

·         From the New Project screen’s left pane, select the Platform Builder project type.

·         From the right pane, select the OS Design template.

·         Enter MyCompact7 as the name for the project.

·         Make sure the Create directory for solution check box is checked.

·         Click OK to continue.

Windows Embedded Compact 7 OS Design Wizard

With the Platform Builder OS design template selected, the OS Design Wizard launches, as shown in Figure 2 and steps through the process to configure the initial OS design project using templates available as part of the VS2008 IDE.

Fig-02

Fig. 2 

·         Click Next to continue and bring up the Create an OS Design - Board Support Packages selection screen.

OS Design Wizard – Board Support Package (BSP)

In the BSP selection step, the OS Design Wizard provides the options to select one or more BSP for the new project from the list of available BSPs.  All of the installed BSPs, including BSPs from Microsoft and third party companies are listed on the Create an OS Design - Board Support Packages screen, as shown in Figure 3.

Fig-03

Fig. 3  

·         From the Select one or more BSPs pane, select the ICOP_eBox3300MX_70D: x86 BSP.

Note:

If you are using an alternative hardware as target device, select the BSP for the device.

·         Click Next to continue and bring up the Create an OS Design - Design Templates screen.

OS Design Wizard – Design Templates

In the design template selection step, the OS Design Wizard provides multiple design templates to choose from, as shown in Figure 4.

Fig-04

Fig. 4     

·         Expand the Enterprise Device node and select the Industrial Controller template.

·         Click Next to continue and bring up the Create an OS Design - Application & Media screen.

OS Design Wizard – Applications & Media

In the applications & media selection step, the OS Design Wizard provides the options to select and include .NET Compact Framework, Internet Explorer, Network User Interface and other components to the OS design, as shown in Figure 5.

Fig-05

Fig. 5             

In addition to the .NET Compact Framework 3.5 component selected by default, select and include the following components to the OS design:

·         Console Window

·         Internet Explorer 7.0

·         Network User Interface

·         Waveform Audio

·         Windows Internet Services

Click Next to continue and bring up the Create an OS Design - Networking & Communication screen.

OS Design Wizard – Networking & Communications

In the networking & communication selection step, the OS Design Wizard provides the options to select communication, networking and security components, as shown in Figure 6.

Fig-06

Fig. 6 

·         For the networking & communication selection step, keep the default selection.

·         Click Next to continue and bring up the Create an OS Design - OS Design Project Wizard Complete screen, as shown in Figure 7.

Fig-07

Fig. 7 

At this point, the OS Design Wizard included the necessary OS components needed to configure the initial OS design project.

·         Click Finish to complete the OS Design Wizard step.

Security Warning - Catalog Item Notification

At the completion of OS Design Wizard step, the Catalog Item Notification screen is raised, with security warning message to warn one or more of the components included in the OS design may pose security risk, as shown in Figure 8. 

Fig-08

Fig. 8

·         Click Acknowledge to acknowledge the warning and close the warning screen.

At the completion of the OS Design Wizard step, the initial project workspace for MyCompact7 OS design project is created in the following directory:

C:\WINCE700\OSDesigns\MyCompact7\           

Configure and Customize the OS Design

At this point, the initial workspace for MyCompact7 OS design is created using the Industrial Controller design template along with the ICOP_eBox3300MX_70D BSP and components selected during the OS Design Wizard steps.

The following project folder and sub-folders are created for the project, under the main Compact 7 OS design project directory:

·         C:\WINCE700\OSDesigns\MyCompact7\              

This is the folder for the MyCompact7 solution. VS2008 supports different project types. A solution provides a centralized work space to keep different project types supporting the same solution in one location.

For example, the MyCompact7 solution may include the “MyCompact7 OS design”, “Visual Basic managed code application”, “Visual C# managed code application” and “Visual C++ native code application”. 

·         C:\WINCE700\OSDesigns\MyCompact7\MyCompact7\

This is the folder for the MyCompact7 OS design project.

The VS2008 IDE should look similar to the screen as shown in Figure 9.

Fig-09

Fig. 9 

Customize the OS Design – Add Additional Components

The OS design can be further customized with the following:

·         Include additional component(s) to the OS design.

·         Remove component(s) from the OS design.

·         Add application and library as subproject to the OS design.

·         Modify system configuration and registry files to customize system behavior.

With MyCompact7 OS design active, from the VS2008 View menu, select Other Windows and click on Catalog Items View to bring up the Catalog Item View window, as shown in Figure 10.

Fig-10

Fig. 10

The Catalog Item View window on the VS2008 IDE contains all of the Compact 7 components, including application, library, driver, utility and 3rd party components installed to the development PC which can be added to MyCompact7 OS design.

From the Catalog Items View window, expand the component nodes and review the components selected during OS Design Wizard steps:

·         Component with a green check mark to the left indicates it was selected during the OS Design Wizard steps, or manually added after the OS Design Wizard steps.

·         Component with a solid green square to the left indicates the component is included to the OS design as the result of being a dependency to another selected component.

·         Component with a red cross to the left indicates the component is selected and is dependent on one or more other components currently not included to the OS design.  (Component with a red cross to the left will not be included to the final image.)

Work through the following steps to customize MyCompact7 OS design:

·         From the Catalog Items View window, expand the \Third Party\BSP node.

·         Expand all nodes under the ICOP_eBox3300MX_70D: X86 node, as shown in Figure 11.

 

Fig-11

Fig. 11 

Verify the following BSP components are selected and included to the OS design:

·         ATAPI (IDE) Storage driver

·         HD Audio driver

·         Hive-based registry support

·         Vortex86MX Display driver

·         Vortex86MX Display driver\VGA-01 640x480x16 @ 60Hz

·         R6040 Ethernet driver

·         PS/2 Keyboard & Mouse driver

·         512MB RAM

·          1st and 2nd Serial Port

·         USB Keyboard & Mouse (HID) class driver

Expand the “\Core OS\Windows Embedded Compact\Applications – End User” folder, locate and include the following components to the OS design to support CAB file installation and application deployment from the Visual Studio 2008 IDE:

·         CAB File Installer/Uninstaller

Expand the “\Core OS\Windows Embedded Compact\Applications and Services Development” folder, locate and include the following components to the OS design to support SQL Compact application development later in this series:

·         SQL Compact

·         SQL Compact Managed Provider

Expand the “\Third Party\Embedded101” folder, select and include the following AutoLaunch components to the OS design, a utility to launch application during startup:

·         AutoLaunch_v300_Compact 7 

·         AutoLaunch_v300_Compact 7\Autolaunch CoreCon

·         AutoLaunch_v300_Compact 7\Autolaunch Remote Display application

Customize the OS Design – Locate Component by Search

The VS2008 IDE provides search function to locate Compact 7 component from the catalog by searching the catalog using key-word or partial key-word associated with the component.  In this section, we will use the search function to locate a component from the catalog and add the component to the OS design.

From the Catalog Item View tab, enter FTP Server in the search text box on the top right, and click on the green arrow to the right of the search text box to locate the FTP Server component, as shown in Figure 12.

Fig-12

Fig. 12 

The search engine locates and highlights the FTP Server component, as shown in Figure 13.

Fig-13

Fig. 13

·         Select and include the FTP Server component in the OS design.

Note:

The FTP Server component provides a convenience mechanism to access the compact 7 device’s file system remotely.  When this component is added to the OS design, it does not include the necessary registry entries to launch the FTP server.

In the later section, the necessary registry entries will be added to support the FTP server.

When the FTP Server component is selected, a security warning is raised, as shown in Figure 14.

Fig-14 

Fig. 14 

·         Click on Acknowledge to acknowledge the warning and continue.

Customize the OS Design – The Registry

The registry plays a key role in controlling how the Compact 7 OS runtime behave, loads driver, application and more.  Improper registry entries can cause series problem and can cause the system failing to complete the boot process.

In the earlier steps, the FTP server component was included to the OS design.  In order for this component to function as intended, appropriate registry entries need to be added to the OS design project to launch the FTP server.

Registry Entries for the AutoLaunch Component

When the AutoLaunch component is added to the OS design, the following registry entries are added to the project as part of the AutoLaunch component, to launch the AutoLaunch.exe executable during startup:

[HKEY_LOCAL_MACHINE\Init]

    "Launch99"="AutoLaunch.exe"

    "Depend99"=hex:0a,00,14,00

When the AutoLaunch utility launches, it searches the following registry key and launch application with proper entries under this key:

[HKEY_LOCAL_MACHINE\Startup]

As part of the AutoLaunch_v300_Compact7 component, two sub-components are included, CoreCon connectivity and Remote Display application components.  When included to the OS design, registry entries for “Process0” and “Process1”, under the HKLM\Startup key are used by these two components, as follow:

[HKEY_LOCAL_MACHINE\Startup]

    "Process0"="ConmanClient2.exe"     

    "Process0Delay"=dword:1388

    "Process1"="cerdisp -c"

    "Process1Delay"=dword:2710

To configure the AutoLaunch utility to launch other application component, start with “Process2” as follow:

[HKEY_LOCAL_MACHINE\Startup]

    "Process2"="App_01.exe"

    "Process2Delay"=dword:3A98

    "Process3"="App_02.exe"

    "Process3Delay"=dword:4E20

Note:

The process delay entries above are randomly selected.  You can configure the delay based on your need.

     3A98 in HEX equal to 15000 in decimal, which represent 15000 ms or 15 seconds

You can configure the delay to control startup sequence between multiple applications.

Adding FTP Registry Entries to the OS Design

By default, the FTP server component, when added to the OS design, is not configured to launch during startup.  Work through the following steps to add the necessary registry entries for the FTP Server to the OS design:

·         From the VS2008 View menu, click on Solution Explorer to bring up the Solution Explorer window.

·         From the Solution Explorer window, expand the \Parameter Files node, and double click on OSDesign.reg to open this file in the code editor window.

·         On the code editor window’s lower left, click on Source to view the OSDesign.reg registry file in source code format.

·         Scroll to the end of the file and add the following entries to OSDesign.reg:

; Registry entries for the FTP server component

[HKEY_LOCAL_MACHINE\COMM\FTPD]

        "IsEnabled"=dword:1

        "UseAuthentication"=dword:0

        "UserList"="@*;"

        "AllowAnonymous"=dword:1

        "AllowAnonymousUpload"=dword:1

        "AllowAnonymousVroots"=dword:1

        "DefaultDir"="\\"

 

Customize the OS Design – Configuration Manager

Using the configuration manager, the OS design can be configured to generate an OS runtime image in checked, debug or release mode.  An OS image built in release mode is optimized for distribution, does not contain ASSERT and not able to output DEBUGMSG.  An image built in debug mode is not optimized and include additional resource to support debugging.  However, a debug mode image, without optimization, can be difficult to debug certain type of timing and performance related problems.  An image built in Checked mode (Checked mode is new to Compact 7), a hybrid between the debug and release modes, is built with compiler optimization, contains ASSERT, DEBUGMSG and RETAILMSG to provide the necessary resources needed for debugging.

A debug mode image will provide more detailed debug messages when the OS image loads and executes applications and modules.  The size of an OS image built in debug mode is generally about 50% larger than an OS image built in release mode, from the same OS design project.  An OS image built in release mode, with KITL enabled, provides sufficient debug information to support most of the general application development environment.  For the exercise in this guide, we will configure the OS design to generate an OS runtime image in release mode. 

·         From the VS2008 Build menu, click on Configuration Manager to bring up the Configuration Manager screen, as shown in Figure 15. 

Fig-15

Fig. 15

·         From the Active solution configuration selection options, select ICOP_eBox3300MX_70D x86 Release and click Close to configure the OS design to generate a release mode image.

By default, the MyCompact7 OS design is configured to generate runtime image in release mode.  The exercise in this section demonstrates the available build options to configure the OS design to generate runtime image in checked, debug and release modes.

Customize the OS Design – Build Options

MyCompact7 OS design can be further customized by editing the project’s build options.

From the VS2008 Project menu, click MyCompact7 Properties to bring up the MyCompact7 Property Pages screen, as shown in Figure 16.

Fig-16

Fig. 16       

From the left pane, expand the Configuration Properties node and select Build Options.

From the right pane, change the following build option:

·         Set the Enable KITL build option to No

Note:

When deploying a Compact 7 OS runtime image, with KITL enabled, to the target device’s local flash storage, the system will search for an unavailable KITL connection during start up and will not be able to complete the boot process.

Click Apply and OK to close the MyCompact7 Property Pages screen.

Build and Generate a Compact 7 OS Runtime Image

In the previous sections, we created an OS design project, configured and customized the OS design.  In this section, we will work through the steps to build and generate a Compact 7 OS runtime image from the MyCompact7 OS design project.

The Build Process – Starting

With MyCompact7 OS design active, from the VS2008 Build menu, select Advanced Build Commands and click on Sysgen (blddemo -q) to build and generate an OS runtime image from the project.

Depending on your development PC’s processor speed and available system resources, the build process may take anywhere from 15 to 20 minutes.

During the build process, the output tab on the VS2008 IDE displays compilation activities, as shown in Figure 17.

Fig-17

Fig. 17 

The Build Process – Completed

When the build process is completed, the VS2008 IDE should look similar to the screen, as shown in Figure 18.

Fig-18

Fig. 18 

The Output tab on the VS2008 IDE shows the result of the build process, with “0” failed task.

Note:

When the build process ended with error, the build process failed and will not generate a Compact 7 OS runtime image file.  When the build process ended with warnings and without any error, the build process is completed with a Compact 7 OS runtime image file generated.

The number of warning may vary depending on the selected components and installed QFE.  When working with a known good BSP, the warnings are generally non critical and do not impact system function.  However, as part of good engineering practice, it’s good to go through the warning messages to identify potential problem.

With a successful build, a Compact 7 OS runtime image file, NK.BIN, is generated in the following build release directories:

·         For OS design configured to generate an image in checked mode:

\WINCE700\OSDesigns\MyCompact7\MyCompact7\RelDir\ICOP_eBox3300MX_70D_x86_Checked

·         For OS design configured to generate an image in debug mode:

\WINCE700\OSDesigns\MyCompact7\MyCompact7\RelDir\ICOP_eBox3300MX_70D_x86_Debug

·         For OS design configured to generate an image in release mode:

\WINCE700\OSDesigns\MyCompact7\MyCompact7\RelDir\ICOP_eBox3300MX_70D_x86_Release

Searching the above directories, with a successful build, there should be a NK.BIN file, which is the Compact 7 OS runtime image file.  After the build process is completed, Platform Builder generates the following log files for the last build process:

·         C:\WINCE700\Build.log (This file list all of the build steps in detail.)

·         C:\WINCE700\Build.wrn (This file list all of the warnings during the build process.)

·         C:\WINCE700\Build.err (This file list all the errors during the build process.  This file is not present for a successful build.)

Download OS Image to Target Device

To download the OS image to the target device (eBox), we need to establish connectivity between the VS2008 development PC and target device.

A target device built with different type of processor and I/O peripherals may require different transport mechanism to establish the connectivity. 

Refer to the following application note for information showing the steps to establish connectivity to the target device and download OS image to the device:  

    Connectivity to Download Compact 7 OS Runtime Image to Target Device

 

Generate SDK from the OS Design

An SDK, from the same OS design that generated the OS runtime image for the Compact 7 device, is needed to support application development for the device.  Refer to the following application note for information showing the steps to generate an SDK from the OS design.