Chapter 2 Building and Deploying a Run-Time Image

The Microsoft® Windows® Embedded CE 6.0 R2 build process is very complex. This process includes several phases and relies on a variety of tools to initialize the Windows Embedded CE build environment, compile the source code, copy modules and files to a common release directory, and create the run-time image. Batch files and build tools, such as the Sysgen tool (Sysgen.bat) and the Make Binary Image tool (Makeimg.exe), automate this process. You can run these tools directly at the command prompt or start the build process in Microsoft Platform Builder for Windows Embedded CE 6.0 R2. The Platform Builder integrated development environment (IDE) relies on the same processes and tools. In either case, a thorough understanding of the build process and the steps required to deploy the resulting runtime image is essential if you want to create run-time images efficiently, troubleshoot build errors, or deploy Board Support Packages (BSPs) and subprojects as part of a run-time image on a target device.

Exam objectives in this chapter:

■ Building run-time images

■ Analyzing build results and build files

■ Deploying a run-time image on a target device

Before You Begin

■ To complete the lessons in this chapter, you must have:

■ An understanding of operating system (OS) design aspects, including catalog items and the configuration of environment variables and SYSGEN variables, as explained in Chapter 1, "Customizing the Operating System Design."

■ At least some basic knowledge about Windows Embedded CE software development, including source code compilation and linking.

■ A development computer with Microsoft Visual Studio® 2005 Service Pack 1 and Platform Builder for Windows Embedded CE 6.0 R2 installed.

Lesson 1: Building a Run-Time Image

The Windows Embedded CE build process is the final step in the run-time image development cycle. Based on the settings defined in the OS design, Platform Builder compiles all components, including subprojects and the BSP, and then creates a runtime image that you can download to the target device. The build process entails several build phases, automated by means of batch files. You must understand these phases and the build tools if you want to configure build options correctly, create runtime images efficiently, and solve build-related issues.

After this lesson, you will be able to:

■ Understand the build process.

■ Analyze and fix build issues.

■ Deploy a run-time image to target hardware.

Estimated lesson time: 40 minutes.

Build Process Overview

The Windows Embedded CE build process includes four main phases, as illustrated in Figure 2-1. They follow each other sequentially, but you can also carry them out independently if you know the purpose and tools used for each phase. By selectively running the build tools, you can perform individual build steps in a targeted way, which helps to save build time and ultimately increases your efficiency.

Figure 2-1 Build phases and build tools

The build process includes the following key phases:

Compile phase Compiler and linker use source code and resource files to generate executable (.exe) files, static (.lib) libraries, dynamic-link library (.dll) files, and binary resource (.res) files according to the selected locales. For example, the build system compiles the source code in the Private and Public folders into .lib files during this phase. This process can take several hours to complete, but fortunately it is seldom required to rebuild these components because binaries are already provided by Microsoft. In any case, you should not modify the source code in the Private and Public folders.

Sysgen phase The build system sets or clears SYSGEN variables based on the catalog items and dependency trees included in the OS design, filters the header files and creates import libraries for the Software Development Kits (SDKs) defined in the OS design, creates a set of run-time image configuration files for the OS design, and builds the BSP based on the source files in the Platform directory.

Build phase The build system processes the source files of your Board Support Package and applications using the files generated during the Sysgen phase. At this time, hardware-linked drivers and the OEM adaptation layer (OAL) are built. Although the processes during the build phase are carried out automatically during the Sysgen phase, it is important to understand that if you modify only the BSP and subprojects, then you can rebuild the BSP and subprojects without running the Sysgen tool again.

Release Copy phase The build system copies all files required to create the runtime image to the OS design's release directory. This includes the .lib, .dll, and .exe files created during the Compile and Sysgen phases, as well as binary image builder (.bib) and registry (.reg) files. The build system might skip this phase if headers and libraries are up-to-date.

Make Run-time Image phase The build system copies project-specific files (Project.bib, Project.dat, Project.db, and Project.reg) to the release directory and assembles all files in the release directory into a run-time image. Directives based on environment variables specified in .reg and .bib files control which catalog items the build system includes in the final run-time image. The run-time image is typically a file named Nk.bin, which you can download and run on the target device.

Building Run-Time Images in Visual Studio

During the installation of Windows Embedded CE 6.0 R2 on your development workstation, Platform Builder integrates with Visual Studio 2005 and extends the Build menu so that you can control the build process directly in the Visual Studio IDE. Figure 2-2 shows the Platform Builder commands that are available on the Build menu when you select the OS design node in Solution Explorer.

Figure 2-2 Windows Embedded CE build commands in Visual Studio 2005

You can use the Platform Builder commands on the Build menu to perform selective build steps or a combined series of steps that span multiple build phases. For example, you can use the Copy Files To Release Directory command to ensure that the build system copies updated .bib and .reg files to the release directory even if header files and libraries have not changed. Otherwise, the build system skips the Release Copy phase and .bib file or .reg file changes are not applied to the run-time image.

Table 2-1 summarizes the purpose of the Windows Embedded CE build commands.


Table 2-1 Windows Embedded CE build and rebuild commands

Menu Option Description
Build Solution Equivalent to the Sysgen command on the Advanced Build Commands submenu.
Rebuild Solution Equivalent to the Clean Sysgen command on the Advanced Build Commands submenu.
Clean Solution Cleans the release directory by deleting all intermediate files.
Build <OS Design Name> Helpful in solutions that include multiple OS designs. In solutions with a single OS design, these options correspond to the Build Solution, Rebuild Solution, and Clean Solution commands.
Rebuild >
Clean >
Advanced Build Commands Sysgen Runs the Sysgen tool and links the .lib files in the Public and Private folders to create the files for the run-time image. The files remain in the WinCE folder of the OS design. Depending on global build settings, the build process can automatically advance to the Release Copy and then Make Run-time Image phases.
Clean Sysgen Cleans out intermediate files created during previous builds before running the Sysgen tool. Use this option if you added or removed files or catalog items after a previous Sysgen session to reduce the risk of build errors.
Build And Sysgen Compiles the entire contents of the Public and Private folders, and then links the files by using the settings in your OS design. This process takes several hours and is only necessary if you modified the contents of the Public folder. Unless you modi­fy the Windows Embedded CE code base (not recommended), you should not use this option.
Rebuild And Sysgen Cleans out intermediate files created during previous builds in the Public and Private folders, and then runs the Build and Sysgen steps. You should not use this option.
Build Current BSP And Subprojects Builds the files in the directory for the current BSP and any subprojects in the OS design, and then runs the Sysgen tool. Note that this option will build other BSPs than the ones used in the current OS design, so make sure your BSPs are compatible with each other or remove unused BSPs.
Rebuild Current BSP And Subprojects Cleans out intermediate files created during previous builds, and then runs the Build Current BSP And Subprojects steps.
Build All Subprojects Compiles and links all subprojects, skipping any files that are up-to-date.
Rebuild All Subprojects Cleans, compiles, and links all subprojects.
Build All SDKs Builds all SDKs in the project and creates corresponding Microsoft Installer (MSI) packages. Because there is generally no reason to create debug versions of MSI packages, use this option only for a Release build configuration.
Copy Files To Release Directory Copies the files generated for the BSP and other components during the Compile and Sysgen phases to the release directory in order to include these file in the run-time image.
Make Run-Time Image Takes all the files in the release directory to create the run-time image. Following this step, you can download the run-time image to a target device.
Open Release Directory In Build Window Opens a Command Prompt window, changes into the release directory, and sets all necessary environment variables to run batch files and build tools manually. Use this to perform build steps at the command prompt. The standard Command Prompt window does not initialize the development environment to run the build tools successfully.
Global Build Settings Copy Files To Release Directory After Build Enables or disables automatic advancement to the Release Copy phase for all commands.
Make Run-Time Image After Build Enables or disables automatic advancing to the Make Run-time Image phase after any build operation.
Targeted Build Settings Make Run-Time Image After Build Enables or disables the Make Run-time Image phase.
Batch Build Enables you to perform multiple builds sequentially.
Configuration Manager Enables you to add or remove build configurations.

The Advanced Build Commands submenu provides access to several Platform Builder-specific build commands that you might find useful on a regular basis. For example, you need to run the Sysgen or Clean Sysgen command when you add or remove catalog components to or from the OS design to create the binary versions for the run-time image. Exceptions to this rule are components that do not modify SYSGEN variables, such as components in the ThirdParty folder. It is not necessary to run Sysgen or Clean Sysgen when you select or deselect these items. Following the Sysgen phase, Platform Builder continues the build process similar to running the Build Current BSP And Subprojects command.

You can select the Build Current BSP And Subprojects or the Rebuild Current BSP And Subprojects commands in Visual Studio if you want to compile and link the source code in the Platform directory and any subprojects in the OS design and put the code into the target directory under Platform\<BSP Name>\Target and Platform\<BSP Name>\Lib. This is necessary, for instance, if you modify the source code in the Platform directory. Depending on the Copy Files To Release Directory After Build and Make Run-Time Image After Building options, Platform Builder copies the files to the release directory and creates the run-time image. You can also perform these steps individually either through the menu or by running the Buildrel.exe and Makeimg.exe tools at the command prompt.

CAUTION
Clean Sysgen affects multiple build configurations

If you run the Clean Sysgen command in one build configuration, you also have to run Sysgen for the other build configurations later. Keep in mind that the Clean Sysgen command deletes all files generated for other build configurations, as well as for the current build configuration.

Building Run-Time Images from the Command Line

The Platform Builder for CE6 R2 plug-in for Visual Studio 2005 provides convenient access to batch files and build tools, but you can also run these batch files and build tools directly at the command prompt. Each build command in Visual Studio with Platform Builder corresponds to a specific build command, as listed in Table 2-2. Remember, however, to use the Open Build Window command in Visual Studio to open a Command Prompt window for this purpose. The standard command prompt does not initialize the development environment. The build process will fail without the presence of the required environment variables.


Table 2-2 Build commands and command line equivalents

Build Command Command Line Equivalent
Build blddemo -q
Rebuild blddemo clean -q
Sysgen blddemo -q
Clean Sysgen blddemo clean -q
Build And Sysgen* Blddemo
Rebuild And Clean Sysgen* blddemo clean cleanplat -c
Build Current BSP And Subprojects blddemo -qbsp
Rebuild Current BSP And Subprojects blddemo -c -qbsp

* Not recommended

Windows Embedded CE Run-Time Image Content

As illustrated in Figure 2-3, the run-time image includes all items and components that you want to deploy and run on a target device as part of the OS design, such as kernel components, applications, and configuration files. The most important configuration files for developers are binary image builder (.bib) files, registry (.reg), database (.db), and file system (.dat) files. These files determine the memory layout and specify how Platform Builder initializes the file system and the system registry. It is important to know how to work with these files. For example, you can modify the .reg and .bib files for a BSP directly in the OS design or create a subproject to add custom settings to the run-time image in a more componentized way. As mentioned in Chapter 1, it is generally faster and more convenient to modify the .reg and .bib files of an OS design directly, yet subprojects facilitate the reuse of customizations across multiple OS designs.

Figure 2-3 Contents of a run-time image

Binary Image Builder Files

The Windows Embedded CE build process relies on .bib files to generate the content of the run-time image and to define the final memory layout of the device. At the end of the build process, during the Make Run-time Image phase, the Make Binary Image tool (Makeimg.exe) calls the File Merge tool (Fmerge.exe) to combine all applicable .bib files, such as Config.bib and Platform.bib from the Platform\<BSP Name>\Files folder, Project.bib, Common.bib, and any subproject .bib files, into a file named Ce.bib in the release directory. The Make Binary Image tool then calls the ROM Image Builder tool (Romimage.exe) to process this file and determine which binaries and files to include in the run-time image.

A .bib file can include the following sections:

MEMORY Defines the parameters for the memory layout. You can typically find this section in the Config.bib file for your BSP, such as C:\Wince600\Platform\DeviceEmulator\Files\Config.bib.

CONFIG Defines configuration options for Romimage.exe to customize the binary run-time image. You can typically find this section in the Config.bib file for your BSP. This section is optional.

MODULES Specifies a list of files that Romimage.exe marks to be loaded into RAM or executed in place (XIP). Only uncompressed object modules can execute directly from read-only memory. You can list native executable files in this section, but not managed binaries, because the Common Language Runtime (CLR) must convert the Microsoft Intermediate Language (MSIL) content into native machine code at run time.

FILES References executables and other files that the operation system should load into RAM for execution. You should specify managed code modules in this section.

.BIB File MEMORY Section The MEMORY section in the Config.bib file defines reserved memory regions, assigning each region a name, address, size, and type. A good example is the MEMORY section that you can find in the Config.bib file in the Device Emulator BSP. This Device Emulator BSP is available with Platform Builder for CE 6.0 R2 out-of-the-box. You can find Config.bib in the PLATFORM\<BSP Name>\FILES directory. Figure 2-4 shows this MEMORY section in Visual Studio 2005.

Figure 2-4 MEMORY section from a .bib file

The fields in the MEMORY section define the following parameters:

Name This is the name of the MEMORY section. The name must be unique.

Address This hexadecimal number represents the starting address of the memory section.

Size This hexadecimal number defines the total length of the memory section in bytes.

Type This field can have one of the following values:

RESERVED Indicates that this area is reserved. Romimage.exe skips these sections during image creation. For example, the Ce.bib file shown in Figure 2-4 includes several RESERVED sections, such as an ARGS section to provide a shared memory area for the boot loader (EBOOT) to pass data to the system after startup (ARGS) and a DISPLAY section for a display buffer. The Ce.bib file of other OS designs might include different RESERVED sections for memory areas that the kernel is not supposed to use as system memory.

RAMIMAGE Defines the memory area that the system can use to load the kernel image and any modules you specified in the MODULES and FILES sections of .bib files. A run-time image can only have one RAMIMAGE section and the address range must be contiguous.

RAM Defines a memory area for the RAM file system and for running applications. This memory section must be contiguous. If you need a noncontiguous memory section, such as for extension dynamic RAM (DRAM) present on the device, you can allocate noncontiguous memory by implementing the OEMGetExtensionDRAM function in the OAL of the BSP. Windows Embedded CE supports up to two sections of physical noncontiguous memory.

.BIB File CONFIG Section The CONFIG section defines additional parameters for the run-time image, including the following options:

AUTOSIZE Automatically combines RAMIMAGE and RAM sections and allocates any unused memory in the RAMIMAGE section to RAM, or if necessary takes memory from the RAM section and provides it to the RAMIMAGE.

BOOTJUMP If specified, moves the boot jump page to a specific area within the RAMIMAGE section, rather than by using the default area.

COMPRESSION Automatically compresses writable memory sections in the image. The default value for this option is ON.

FIXUPVAR Initializes a kernel global variable during the Make Binary Image phase.

FSRAMPERCENT Sets the percentage of RAM used for the RAM file system.

KERNELFIXUPS Instructs Romimage.exe to relocate memory writable by the kernel. This option is generally enabled (ON).

OUTPUT Changes the directory that Romimage.exe uses as the output directory for the Nk.bin file.

PROFILE Specifies whether the image includes the profiler.

RAM_AUTOSIZE Expands the size of RAM to the end of the last XIP section.

RESETVECTOR Relocates the jump page to a specified location. This is required for MIPS processors to boot from 9FC00000.

ROM_AUTOSIZE Resizes XIP regions, taking into account the ROMSIZE_AUTOGAP setting.

ROMFLAGS Configures the following options for the kernel:

Demand paging Fully copying a file into RAM before executing it or paging in parts of it.

Full kernel mode Run every OS thread in kernel mode, which leaves the sys­tem vulnerable to attack but improves performance.

Trust only ROM modules Marks only files in ROM as trusted.

Flush the X86 TLB onX86 systems Improves performance but adds a security risk.

Honor the /base linker setting Defines whether or not to use the /base linker setting in DLLs.

ROMOFFSET Enables you to run the run-time image in a memory location that is different from the storage location. For example, you can store the run-time image in FLASH memory, and then copy and run it from RAM.

ROMSIZE Specifies the size of the ROM in bytes.

ROMSTART Specifies the ROM's starting address.

ROMWIDTH Specifies the number of data bits and how Romimage.exe splits the run-time image. Romimage.exe can put the entire run-time image into one file, split the run-time image into two files of even and odd 16-bit words, or create four files of even and odd 8-bit bytes.

SRE Determines whether Romimage.exe generates a .sre file. Motorola S-record (SRE) is a file format recognized by most ROM burners.

X86BOOT Specifies whether or not to add a JUMP instruction at the x86 reset vector address.

XIPSCHAIN Enables the creation of Chain.bin and Chain.lst files to set up an XIP chain, so that you can split an image into multiple files.

.BIB File MODULES and FILES Sections BSP and OS design developers must frequently edit the MODULES and FILES sections of a .bib file to add new components to a run-time image. The format for the MODULES and FILES section is practically identical, although the MODULES section supports more configuration options. The key difference is that the MODULES section lists files not compressed in memory to support XIP, while the FILES section lists files that are compressed. The operating system must decompress the data when accessing the files.

The following listing shows two small MODULES and FILES sections from a Platform.bib file. For a complete example, check out the Platform.bib file of the Device Emulator BSP.

MODULES

; Name         Path                Memory Type

; --------------    ----------------------------    -----------

; @CESYSGEN IF CE_MODULES_DISPLAY

IF BSP_NODISPLAY !

DeviceEmulator_lcd.dll $(_FLATRELEASEDIR)\DeviceEmulator_lcd.dll NK SHK

IF BSP_NOBACKLIGHT !

backlight.dll     $(_FLATRELEASEDIR)\backlight.dll     NK SHK

ENDIF BSP_NOBACKLIGHT !

ENDIF BSP_NODISPLAY !

; @CESYSGEN ENDIF CE_MODULES_DISPLAY


FILES

; Name      Path             Memory Type

; -------------- ---------------------------- -----------

; @CESYSGEN IF CE_MODULES_PPP

dmacnect.lnk   $(_FLATRELEASEDIR)\dmacnect.lnk  NK SH

; @CESYSGEN ENDIF CE_MODULES_PPP

You can define the following options for file references in MODULES and FILES sections:

Name The name of the module or file as it appears in the memory table. This name is usually the same as the file name in the run-time image.

Path The complete path to the file that Romimage.exe incorporates into the run-time image.

Memory References the name of a memory area in the MEMORY section of the Config.bib file into which Romimage.exe loads the module or file. It is usually set to NK to integrate the file in the NK area defined in the MEMORY section.

Section Override Enables you to specify modules in a FILES section and files in a MODULES section. Essentially, Romimage.exe ignores the section in which the entry resides, and treats the entry as a member of the specified section. This parameter is optional.

Type Specifies the file type and can be a combination of flags, as shown in Table 2-3.


Table 2-3 File type definitions for MODULES and FILES sections

MODULES and FILES Sections MODULES Section Only
■ S The file is a system file. ■ K Instructs Romimage.exe to assign a fixed virtual address to the DLL's public exports and runs the module in kernel mode rather than user mode. Drivers must run in kernel mode to have direct access to the underlying hardware.
■ H The file is hidden. ■ R Compress resource files.
■ U The file is uncompressed. (The default setting for files is compressed.) ■ C Compress all data in the file. If the file is already in RAM, it will be decompressed again into a new section of RAM, which results in higher RAM consumption.
■ N The module is not trusted. ■ P Do not check the CPU type on a per-module basis.
■ D The module cannot be debugged. ■ X Sign the module and include the signature in the ROM.
■ M Signals that the kernel must not page the module on demand. (See Chapter 3 for more information on the effects of demand paging.)
■ L Instructs Romimage.exe not to split the ROM DLL.

Conditional .bib File Processing It is important to note that .bib files support conditional statements based on environment variables and SYSGEN variables. You can set environment variables through catalog items, and then check these variables in IF statements in a .bib file to include or exclude certain modules or other files. For SYSGEN variables, use @CESYSGEN IF statements instead.

The MODULES and FILES listing in the previous section illustrates the use of @CESYSGEN IF and IF statements for processing conditions based on SYSGEN and environment variables. For example, the @CESYSGEN IF CE_MODULES_DISPLAY statement in the MODULES sections specifies that the BSP should automatically include the display driver if the OS design includes a display component. You can verify that Platform Builder adds the display component to the BSP automatically if you display the Catalog Items View in Visual Studio for an OS design that uses a display, as illustrated in Figure 2-5.

Figure 2-5 Core OS components that depend on the display item

Registry Files

Registry (.reg) files are used to initialize the system registry on the remote device. These files are almost identical to registry files of Windows desktop operating systems, except that the CE .reg files do not start with a header and version information. If you accidentally double-click a CE .reg file on your development computer and confirm that you want to add the settings to the desktop registry, a dialog box appears to inform you that the .reg file is not a valid registry script. Another difference is that CE .reg files can include conditional statements similar to .bib files, so that you can import registry settings according to the selected catalog items. The following snippet from the Platform.reg file of the Device Emulator BSP illustrates the use of preprocessing conditions.

; Our variables

#define BUILTIN_ROOT HKEY_LOCAL_MACHINE\Drivers\BuiltIn

;#define PCI_BUS_ROOT $(BUILTIN_ROOT)\PCI

#define DRIVERS_DIR $(_PUBLICROOT)\common\oak\drivers


; @CESYSGEN IF CE_MODULES_RAMFMD

; @CESYSGEN IF FILESYS_FSREGHIVE

; HIVE BOOT SECTION

[HKEY_LOCAL_MACHINE\init\BootVars]

"Flags"=dword:1 ; see comment in common.reg

; END HIVE BOOT SECTION

; @CESYSGEN ENDIF FILESYS_FSREGHIVE

; @CESYSGEN IF CE_MODULES_PCCARD

; @XIPREGION IF DEFAULT_DEVICEEMULATOR_REG


IF BSP_NOPCCARD !

#include "$(_TARGETPLATROOT)\src\drivers\pccard\pcc_smdk2410.reg"

#include "$(DRIVERS_DIR)\pccard\mdd\pcc_serv.reg"

[HKEY_LOCAL_MACHINE\Dri vers\PCCARD\PCMCIA\TEMPLATE\PCMCIA]

"Dll"="pcmcia.dll"

"NoConfig"=dword:1

"NoISR"=dword:1 ; Do not load any ISR.

"IClass"=multi_sz:"{6BEAB08A-8914-42fd-B33F-61968B9AAB32}=

PCMCIA Card Services"

ENDIF ; BSP_NOPCCARD !

; @XIPREGION ENDIF DEFAULT_DEVICEEMULATOR_REG

; @CESYSGEN ENDIF CE_MODULES_PCCARD

Database Files

Windows Embedded CE relies on database (.db) files to set up the default object store. The object store is a transaction-based storage mechanism. In other words, it is a repository for databases in RAM that operating system and applications can use for persistent data storage. For example, the operating system uses the object store to manage the stack and memory heap, to compress and decompress files, and to integrate ROM-based applications and RAM-based data. The transaction-oriented nature of the storage mechanism ensures data integrity even in the event of a sudden power loss while data is being written to the object store. When the system restarts, Windows Embedded CE either completes the pending transaction, or reverts to the last known good configuration prior to the interruption. For system files, the last known good configuration can mean that Windows Embedded CE must reload the initial settings from ROM.

File System Files

File system (.dat) files, specifically Platform.dat and Project.dat, contain settings to initialize the RAM file system. When you cold start the run-time image on a target device, Filesys.exe processes these .dat files to create the RAM file system directories, files, and links on the target device. The Platform.dat file is typically used for hardware-related entries while the Project.dat file applies to the OS design, yet you can use any existing .dat file to define file system settings because the build system eventually merges all .dat files into one file named Initobj.dat.

For example, by customizing the Project.dat file, you can define root directories in addition to the Windows directory for a run-time image. By default, items placed in the ROM image appear in the Windows directory, yet by using a .dat file, you can make files also appear outside the Windows directory. You can also copy or link to files in the ROM Windows directory. This is particularly useful if you want to place shortcuts on the desktop or add links to your applications to the Start menu. Similar to .reg and .bib files, you can use IF and IF ! (if not) conditional blocks in .dat files.

The following listing illustrates how to use a Project.dat file to create two new root directories named Program Files and My Documents, create a My Projects subdirectory under Program Files, and map the Myfile.doc file from the Windows directory into the My Documents directory.

Root:-Directory("Program Files")

Root:-Directory("My Documents")

Directory("\Program Files"):-Directory("My Projects")

Directory("\My Documents"):-File("MyFile.doc", "\Windows\Myfile.doc")

Lesson Summary

A thorough understanding of the build system can help to decrease development time and therefore project costs. You must know the steps performed during each phase of the build process if you want to test source code changes quickly and without unnecessary compilation cycles. You must also know the purpose and location of the run-time image configuration files, such as .reg, .bib, .db, and .dat files, to create and maintain OS designs efficiently.

The Windows Embedded CE build system combines the various .reg, .bib, .db, and .dat files during the Make Run-time Image phase into consolidated files that the build system then uses to configure the final run-time image. It is a good idea to check these files if you want to verify that a specific setting or file made it into the final image without having to load the run-time image on the target device. You can find the various run-time image configuration files in the release directory of the OS design. If you discover that expected entries are missing, check the conditional statements and the environment variables and SYSGEN variables defined in your catalog items.

The build system creates the following run-time image configuration files during the Make Run-time Image phase:

Reginit.ini Combines the Platform.reg, Project.reg, Common.reg, IE.reg, Wceapps.reg, and Wceshell.reg files.

Ce.bib Combines the Config.bib, Platform.bib, Project.bib, and Subproject bib files.

Initdb.ini Combines the Common.db, Platform.db, and Project.db files.

Initobj.dat Combines the Common.dat, Platform.dat, and Project.dat files.

Lesson 2: Editing Build Configuration Files

In addition to run-time image configuration files, Windows Embedded CE also uses build configuration files to compile and link source code into functional binary components. Specifically, the build system relies on three types of source code configuration files: Dirs, Sources, and Makefile. These files provide the Build tool (Build.exe) and the compiler and linker (Nmake.exe) with information about the source-code directories to traverse, the source code files to compile, and what type of binary components to build. As a CE developer, you frequently must edit these files, such as when cloning public catalog items, by following the procedures discussed in Chapter 1.

After this lesson, you will be able to:

■ Identify the source code configuration files used during the build process.

■ Edit build configuration files to generate applications, DLLs, and static libraries.

Estimated lesson time: 25 minutes.

Dirs Files

Dirs files identify directories that contain source-code files to be included in the build process. When Build.exe finds a Dirs file in the folder in which it is run, it traverses the subdirectories referenced in the Dirs file to build the source code in these subdirectories. Among other things, this mechanism enables you to update parts of a run-time image selectively. If you make changes to the source code in Subprojectl, you can rebuild this subproject selectively by running Build.exe in the Subprojectl directory. You can also exclude directories in the source code tree from the build process by removing the corresponding directory references from the Dirs file, or by using conditional statements.

Dirs files are text files with a straightforward content structure. You can use the DIRS, DIRS_CE, or OPTIONAL_DIRS keyword, and then specify the list of subdirectories on a single line, or on multiple lines if you terminate each line with a backslash to continue on the next line. Directories referenced by using the DIRS keyword are always included in the build process. If you use the DIRS_CE keyword instead, Build.exe only builds the source code if the source code is written specifically for a Windows Embedded CE run-time image. The OPTIONAL_DIRS keyword designates optional directories. Keep in mind, however, that Dirs files can contain only one DIRS directive. Build.exe processes the directories in the order they are listed, so be sure to list prerequisites first. It is also possible to use the wildcard "*" to include all directories.

The following listing, taken from default Windows Embedded CE components, illustrates how to include source code directories in the build process by using Dirs files.

# C:\WINCE600\PLATFORM\DEVICEEMULATOR\SRC\Dirs 

# --------------------------------------------------- 

DIRS=common \ 

 drivers \ 

 apps   \ 

 kitl   \ 

 oal   \ 

 bootloader 

# C:\WINCE600\PLATFORM\H4SAMPLE\SRC\DRIVERS\Dirs 

# --------------------------------------------------- 

DIRS= \ 

# @CESYSGEN IF CE_MODULES_DEVICE 

 buses \ 

 dma \ 

 triton \ 

# @CESYSGEN IF CE_MODULES_KEYBD 

 keypad \ 

# @CESYSGEN ENDIF CE_MODULES_KEYBD 

# @CESYSGEN IF CE_MODULES_WAVEAPI 

 wavedev \ 

# @CESYSGEN ENDIF CE_MODULES_WAVEAPI 

# @CESYSGEN IF CE_MODULES_POINTER 

 touch \ 

 tpagent \ 

# @CESYSGEN ENDIF CE_MODULES_POINTER 

# @CESYSGEN IF CE_MODULES_FSDMGR 

 nandflsh \ 

# @CESYSGEN ENDIF CE_MODULES_FSDMGR 

# @CESYSGEN IF CE_MODULES_SDBUS 

 sdhc \ 

# @CESYSGEN ENDIF CE_MODULES_SDBUS 

# @CESYSGEN IF CE_MODULES_DISPLAY 

 backlight \ 

# @CESYSGEN ENDIF CE_MODULES_DISPLAY 

# @CESYSGEN IF CE_MODULES_USBFN 

 usbd \ 

# @CESYSGEN ENDIF CE_MODULES_USBFN 

# @CESYSGEN ENDIF CE_MODULES_DEVICE 

# @CESYSGEN IF CE_MODULES_DISPLAY 

 display \ 

# @CESYSGEN ENDIF CE_MODULES_DISPLAY 

NOTE
Editing Dirs files in Solution Explorer

The Solution Explorer in Visual Studio with Platform Builder for Windows Embedded CE 6.0 R2 uses Dirs files to generate a dynamic view of the Windows Embedded CE directory structure in an OS design project. However, you should not add or remove directories in Solution Explorer, because editing Dirs files in Solution Explorer can lead to a changed build order, which can result in build errors that require a second build to resolve.

Sources Files

If you check the folders and files of a standard OS design, such as C:\Wince6OO\OSDesigns\OSDesignl, you will find that the project includes no Dirs files by default. If you include subprojects for custom components and applications, you will find a Sources file in each subproject's root folder instead. The Sources file provides more detailed information about the source-code files, including build directives, which a Dirs file cannot provide. However, a source-code directory can only contain one Dirs file or one Sources file, not both. That means that a directory with a Sources file cannot contain subdirectories with more code. During the build process, Nmake.exe uses the Sources files to determine what file type to build (.lib, .dll, or .exe), and how to build it. Similar to Dirs files, Sources files expect you to specify declarations in a single line, unless you terminate the line with a backslash to continue the declaration on the next line.

The following listing shows the content of a Sources file in the Device Emulator BSP. By default, you can find this file in the C:\Wince600\Platform\DeviceEmulator \Src\Drivers\Pccard folder.

WINCEOEM=1


TARGETNAME=pcc_smdk2410

TARGETTYPE=DYNLINK

RELEASETYPE=PLATFORM

TARGETLIBS=$(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\coredll.lib \

      $(_SYSGENOAKROOT)\lib\$(_CPUINDPATH)\ceddk.lib


SOURCELIBS=$(_SYSGENOAKROOT)\lib\$(_CPUINDPATH)\pcc_com.lib


DEFFILE=pcc_smdk2410.def

DLLENTRY=_DllEntryCRTStartup


INCLUDES=$(_PUBLICROOT)\common\oak\drivers\pccard\common;$(INCLUDES)


SOURCES= \

Init.cpp \

PDSocket.cpp \

PcmSock.cpp \

PcmWin.cpp


#xref VIGUID {549CAC8D_8AF0_4789_9ACF_2BB92 599470D}

#xref VSGUID {0601CE65_BF4D_453A_966B_E20250AD2E8E}

You can define the following directives in a Sources file:

TARGETNAME This is the name of the target file, without file name extension.

TARGETTYPE Defines the type of file to be built, as follows:

DYNLINK A dynamic-link library (.dll).

LIBRARY A static-link library (.lib).

PROGRAM An executable file (.exe).

NOTARGET Build no file.

RELEASETYPE Specifies the directory where Nmake.exe places the target file, as follows:

PLATFORM PLATFORM\<BSP Name>\<Target>.

OAK, SDK, DDK %_PROJECTROOT%\Oak\<Target>.

LOCAL The current directory.

CUSTOM A directory specified in TARGETPATH.

MANAGED %_PROJECTROOT%\Oak\<Target>\Managed.

TARGETPATH Defines the path for RELEASETYPE=CUSTOM.

SOURCELIBS Specifies libraries to be linked with the target file specified in TARGETNAME to create the final binary output. This option is typically used for creating a .lib file but not .dll or .exe files.

TARGETLIBS Specifies additional libraries and object files to link to the final binary output, typically used for creating .dll or .exe files but not for .lib files.

INCLUDES Lists additional directories to search for include files.

SOURCES Defines the source files to be used for this particular component.

ADEFINES Specifies parameters for the assembler.

CDEFINES Specifies parameters for the compiler, which can be used as additional DEFINE statements for use in IFDEF statements.

LDEFINES Sets linker definitions.

RDEFINES Specifies DEFINE statements for the resource compiler.

DLLENTRY Defines the entry point for a DLL.

DEFFILE Defines the .def file which contains a DLL's exported symbols.

EXEENTRY Sets the entry point of an executable file.

SKIPBUILD Marks the build of the target as successful without an actual build of the target.

WINCETARGETFILE0 Specifies nonstandard files that should be built before building the current directory.

WINCETARGETFILES This macro definition specifies nonstandard target files that Build.exe should build after Build.exe links all other targets in the current directory.

WINCE_OVERRIDE_CFLAGS Defines compiler flags to override default settings.

WINCECPU Specifies that the code requires a certain CPU type and should only be built for that particular CPU.

NOTE
Performing specific actions before and after the build

In addition to the standard directives, Windows Embedded CE Sources files support the direc­tives PRELINK_PASS_CMD and POSTLINK_PASS_CMD. You can use these directives to perform custom actions based on command-line tools or batch files before and after the build process, such as PRELINK_PASS_CMD = pre_action.bat and POSTLINK_PASS_CMD = post_action.bat. This is useful, for example, if you want to copy additional files to the release directory when developing a custom application.

Makefile Files

If you look closer at the contents of a subproject folder, you can also find a file named Makefile to provide default preprocessing directives, commands, macros, and other expressions to Nmake.exe. However, in Windows Embedded CE, this Makefile includes only a single line that references %_MAKEENVROOT%\Makefile.def. By default, the environment variable %_MAKEENVROOT% points to the C:\Wince6OO\Public\Common\Oak\Misc folder and the Makefile.def file in this location is the standard Makefile for all CE components, so you should not modify this file. Among other things, the Makefile.def file contains include statements to pull in Sources file, such as !INCLUDE $(MAKEDIR)\sources, which specify the Sources file from the subproject folder. You should edit the Sources file in the subproject folder to adjust the way Nmake.exe builds the target file.

Lesson Summary

The Windows Embedded CE 6.0 R2 development environment relies on Makefile, Sources, and Dirs files to control how Build.exe and Nmake.exe compile and link source code into functional binary components for the run-time image. You can use Dirs files to define the source code directories included in the build process or Sources files to specify compile and build directives in greater detail. The Makefile, on the other hand, requires no customization. It merely references the default Makefile.def file with general preprocessing directives, commands, macros, and other processing instructions for the build system. You must thoroughly understand the purpose of files and how they control the build process if you want to clone public catalog items or create new components efficiently.

Lesson 3: Analyzing Build Results

You are certain to encounter build errors during the software-development cycle. In fact, it is not uncommon to use compile errors as a syntax check for source code, although IntelliSense® and other coding aids available in Visual Studio 2005 help to reduce the amount of typos and other syntax errors. Syntax errors are relatively uncomplicated to fix because you can double-click the corresponding error message in the Output window and jump right to the critical line in the source code file. However, compiler errors are only one type of build errors that can occur. Other common build errors are math errors, expression evaluation errors, linker errors, and errors related to run-time image configuration files. In addition to error messages, the build system also generates status messages and warnings to help you analyze and diagnose build issues. The amount of information generated during the build process can be overwhelming. You need to know the different types and general format of build messages if you want to identify, locate, and solve build errors efficiently.

After this lesson, you will be able to:

■ Locate and analyze build reports.

■ Diagnose and solve build issues.

Estimated lesson time: 15 minutes.

Understanding Build Reports

When you perform a build either in the Visual Studio IDE or the command prompt, the build process outputs a significant amount of build information. The build system tracks this information in a Build.log file. Details about compilation or linker warnings and errors also can be found in the Build.wrn and Build.err files. If you started a complete build or a Sysgen operation for an OS design by using one of the corresponding commands on the Build menu in Visual Studio, the build system writes these files in the %_WINCEROOT% folder (by default, C:\Wince600). On the other hand, if you perform a build for only a particular component, such as by right- clicking a subproject folder in Solution Explorer and clicking the Build command from the context menu, the build system writes these files in that specific directory. In either case, the Build.wrn and Build.err files only exist if you encounter warnings and errors during the build process. However, you do not need to open and parse through these files in Notepad or another plain-text editor. Visual Studio 2005 with Platform Builder for CE 6.0 R2 displays this information during the build process in the Output window. You can also examine status messages, warnings, and errors in the Error List window that you can display by clicking Error List, which is available under Other Windows on the View menu.

Figure 2-6 shows the Output window and the Error List window in undocked view. The Output window displays the Build.log content if you select Build from the Show Output From list box. The Error List window displays the contents Build.wrn and Build.err files.

Figure 2-6 Output window and Error List window with build information in Visual Studio

Specifically, you can find the following information in the build log files:

■ Build.log Contains information about the individual commands issued within each phase during the build process. This information is useful for analyzing both the build process in general, and build errors in particular.

Build.wrn Contains information about warnings generated during the build process. If possible, try to eliminate or at least identify the reasons for the warnings. The information in Build.wrn is also included in Build.log.

Build.err Contains specific information about build errors encountered during the build process. This information is also available with additional details in Build.log. This file is created only when an error occurs.

NOTE
Identifying the build step

The build system keeps track of skipped and entered build phases in the Build.log file. For example, the entry CEBUILD: Skipping directly to SYSGEN phase indicates that the build system skipped the Compile phase for a component. You can determine where the Sysgen phase begins, how the build process transitions from SYSGEN to BUILD, and how BUILD eventually leads to MAKEIMG.

Troubleshooting Build Issues

While analyzing build log files can give you great insight into the build process in general, it is most useful when troubleshooting build errors. If an error message is related to a source code file, you can jump to the relevant line of code by double- clicking the message entry in the Error List window. However, not all build errors are related to source code. Linker errors due to missing library references, sysgen errors due to missing component files, copy errors due to exhausted disk capacities, and make run-time image errors due to incorrect settings in run-time image configuration files can also cause a build process to fail.

Errors during the Sysgen Phase

Sysgen errors are generally the result of missing files. The Build.log file might provide detailed information about the reason. Components that you recently added to or removed from an OS design can cause this type of error if the required dependencies are unavailable. To diagnose a Sysgen error, it is a good idea to verify all changes related to catalog items and their dependencies. Also note that some components require you to perform a clean Sysgen build instead of a regular Sysgen cycle. Typically, you should not use the Clean Sysgen command because performing a clean Sysgen in Release or Debug build configuration requires you to perform a regular Sysgen in the other build configuration as well. However, when adding or removing catalog items and encountering Sysgen build errors afterward, during the next regular Sysgen, you might have to perform a clean Sysgen build to solve the issue.

Errors during the Build Phase

Build errors are typically caused by compiler errors or linker errors. Compiler errors are syntax errors, missing or illegal parameters in function calls, divisions by zero and similar issues that prevent the compiler from generating valid binary code. By double- clicking a compiler error, you can jump to the critical line of code. Keep in mind, however, that compiler errors can be the results of other compiler errors. For example, an incorrect variable declaration can cause numerous compiler errors if the variable is used in many places. It is generally a good idea to start at the top of the error list, fix the code, and recompile. Even small code changes can often eliminate a very large number of errors from the list.

Linker errors are harder to troubleshoot than compiler errors. They are typically the result of missing or incompatible libraries. Incorrectly implemented APIs can also result in linker errors if the linker cannot resolve external references to exported DLL functions. Another common cause has its root in incorrectly initialized environment variables. Build files, specifically the Sources file, use environment variables instead of hard-coded directory names to point to referenced libraries. If these environment variables are not set, the linker will not be able to locate the libraries. For example, %_WINCEROOT% must point to C:\Wince600 if you installed Windows Embedded CE in the default configuration and %_FLATRELEASEDIR% must point to the current release directory. To verify the values of environment variables, open the Build menu in Visual Studio and select Open Release Directory in Build Window, and then at the command prompt use the set command with or without an environment variable, such as set _winceroot. Running the set command without parameters displays all environment variables, but be aware that this list is long.

Errors during the Release Copy Phase

Buildrel errors encountered during the Release Copy phase are generally a sign of inadequate hard drive space. During the Release Copy phase, the build system copies files to the release directory. It might be necessary to free up hard drive space or place the OS design folder on a different drive. Make sure that the new path to the OS design folder contains no spaces because spaces in the path or in the OS design name cause errors during the build process.

Errors during the Make Run-Time Image Phase

Errors encountered during this final phase in the build process generally result from missing files. This can happen if a component failed to build in an earlier step, but the build process nevertheless continued to proceed to the Make Run-time Image phase. Syntax errors in .reg files or .bib files can lead to this situation when the build system is unable to create the Reginit.ini file or Ce.bib file. Makeimg.exe calls the FMerge tool (FMerge.exe) during the build process to create these files, and if this fails, such as due to incorrect conditional statements, you encounter a make-image error. Another possible error is Error: Image Exceeds (X), which means the image is larger than the maximum possible size specified in Config.bib.

Lesson Summary

Platform Builder for Windows Embedded CE 6.0 R2 integrates with the build-logging system of Visual Studio 2005 to provide you with convenient access to status information, warnings, and error messages generated during the build process and tracked in Build.log, Build.wrn, and Build.err files. Depending on how you start the build process in Visual Studio, these files reside either in the %_WINCEROOT% folder or in a subproject directory, yet the actual location of the files is not important because you can analyze the content from these files directly in the Output window and the Error List window in Visual Studio. It is not necessary to open these files in Notepad or another text editor.

By analyzing build log files, you can gain a better understanding of the build process in general and build issues in particular. Typical build issues you might encounter occasionally are compiler errors, linker errors, Sysgen errors, build errors, and other errors generated during the Release Copy and Make Run-time Image phases. If a build error is related directly to a line in a source code file, you can double-click the message entry in the Error List window, and Visual Studio automatically opens the source-code file and jumps to the critical line. Other issues, such as buildrel errors due to inadequate hard drive space, require you to perform troubleshooting steps outside of the Visual Studio IDE.

Lesson 4: Deploying a Run-Time Image on a Target Platform

Having solved all build issues and successfully generated a run-time image, you are ready to deploy Windows Embedded CE on the target device. There are several ways to accomplish this task. The method you choose depends on the startup process you use to load Windows Embedded CE on the target device. There are several ways you can start a Windows Embedded CE 6.0 run-time image. You can start an image directly from ROM, in which case you must deploy the run-time image on the target device by using a ROM tool. You can also use a boot loader, and then either download the run-time image every time the device starts or store the image in persistent memory for reuse. Windows Embedded CE 6.0 R2 comes with generic boot-loader code that you can customize according to your specific needs. It is also straightforward to implement a third-party boot loader. Essentially, Windows Embedded CE can accommodate almost any start environment, and makes it easy to download new run-time images quickly and conveniently during the development cycle and for release to the end user.

After this lesson, you will be able to:

■ Decide how to deploy a run-time image on a target device.

■ Configure Platform Builder to select the correct deployment layer.

Estimated lesson time: 15 minutes.

Choosing a Deployment Method

In order to deploy a run-time image, you must establish a connection to the target device. This requires you to configure several communication parameters that determine how Platform Builder communicates with the device.

The Core Connectivity infrastructure of Windows Embedded CE supports various download methods and transport mechanisms to accommodate hardware platforms with varying communication capabilities. To define the communication parameters for your target device, open the Target menu in Visual Studio and select Connectivity Options, which displays the Target Device Connectivity Options dialog box. By default, Platform Builder provides a target device named CE Device in the Target Device list box, as illustrated in Figure 2-7, but you can also create additional devices with unique names by clicking the Add Device link.

Figure 2-7 Target Device Connectivity Options window

Download Layer

The Download list box and associated Settings button enable you to configure the download service used for downloading the run-time image to your target device. The Core Connectivity infrastructure supports the following download layers for deploying a run-time image:

Ethernet Downloads the run-time image over an Ethernet connection. Use the Settings button to configure the Ethernet download service. The development workstation and the target device must be on the same subnet; otherwise, you cannot connect to the target device.

Serial Downloads the run-time image over an RS232 connection. Use the Settings button to configure the port, baud rate, and other serial communication parameters.

Device Emulator (DMA) Downloads the run-time image to a device emulator through Direct Memory Access (DMA). Use the Settings button to configure the device emulator.

USB Downloads the run-time image over a Universal Serial Bus (USB) connection. There are no settings to configure.

Image Update Updates the image in the device's flash memory. There are no settings to configure.

None Select this option if you do not want to download or update the run-time image.

Transport Layer

After transferring the run-time image to the remote device, you can attach to the device if you enabled Kernel Independent Transport Layer (KITL) in the OS design. In general, the selected kernel transport service should match the download service that you selected in the Download list box. The Core Connectivity infrastructure supports the following transport layer options:

Ethernet Communicates with the target device over an Ethernet connection. The connection uses the same settings as the download service.

Serial Communicates with the target device over an RS232 connection. The connection uses the same settings as the download service.

Device Emulator (DMA) Communicates with a device emulator through DMA.

USB Communicates with the target device over a USB connection.

None Disables communication with the target device.

Debugger Options

If you enabled support for one or more debuggers in the OS design, the debugger names will appear as options in the Debugger list box. By default, the following debugger options are available:

Sample Device Emulator eXDI2 Driver This is a sample Extensible Resource Identifier (XRI) Data Interchange (XDI) driver included in Windows Embedded CE 6.0 R2. XDI is a standard hardware-debugging interface.

KdStub This is the Kernel Debugger. KdStub stands for kernel debugger stub, which instructs Platform Builder and Visual Studio to use the software debugger.

CE Dump File Reader If you added the Error Report Generator catalog item to your OS design, you can use this option for postmortem debugging.

None Select this option if you do not want to use a debugger.

Attaching to a Device

Having configured the device connection, you are ready to transfer the run-time image to the target device or device emulator by using the Core Connectivity infrastructure. This is accomplished in Visual Studio 2005 by using the Attach Device command that is available on the Target menu. Even if you do not plan to use KITL or the Core Connectivity infrastructure for debugging, you must attach to the device so that Platform Builder can download the run-time image.

Following the image download, the start process commences, KITL becomes active if enabled on the target device, and you can use the Kernel Debugger to follow the start process, and debug operating system components and application processes. By using KITL, you can also exploit remote tools available in Visual Studio with Platform Builder on the Target menu, such as File Viewer to interact with the device's file system, Registry Editor to access the device's registry settings, Performance Monitor to analyze resource utilization and response times, and Kernel Tracker and other remote tools to view detailed information on the running system. You can find more information about system debugging in Chapter 4, "Debugging and Testing the System."

Lesson Summary

Windows Embedded CE supports run-time image deployment over a variety of device connections to accommodate hardware platforms with varying requirements and capabilities, including Ethernet connections, serial connections, DMA, and USB connections. For example, DMA is the right choice if you want to deploy CE 6.0 R2 on a Device Emulator. You only need to configure the communication parameters and you are ready to deploy Windows Embedded CE by clicking the Attach Device command on the Target menu in Visual Studio 2005 with Platform Builder.

EXAM TIP

To pass the certification exam, you must be familiar with the varioust ways to deploy a Windows Embedded CE run-time image. In particular, make sure you know how to deploy a run-time image for a Device Emulator.

Lab 2: Building and Deploying a Run-Time Image

In this lab, you build and deploy an OS design based on the Device Emulator BSP, analyze the build information in the Visual Studio Output window to identify the start of the various build phases, and then configure a connection to a target device in order to download the run-time image. To demonstrate how to customize a target device, you modify the Device Emulator configuration to support a larger screen resolution and to enable network communication. In a final step, you download the run-time image and attach to the target device with the Kernel Debugger, so you can examine the Windows Embedded CE start process in detail. To create the initial OS design in Visual Studio, follow the procedures outlined in Lab 1, "Creating, Configuring, and Building an OS Design."

NOTE
Detailed step-by-step instructions

To help you successfully master the procedures presented in this Lab, see the document "Detailed Step-by-Step Instructions for Lab 2" in the companion material for this book.

Build a Run-Time Image for an OS Design

1. After completing Lab 1, select Sysgen under Advanced Build Commands on the Build menu in Visual Studio, as illustrated in Figure 2-8. Alternatively, you can select Build Solution under the Build menu, which will perform a build starting with the Sysgen step.

TIP
Sysgen operations

Sysgen operations can take up to 30 minutes to complete. To save time, do not run Sysgen every time you change the OS design. Instead, run Sysgen after adding and removing all desired components.

2. Follow the build process in the Output window. Examine the build information to identify the SYSGEN, BUILD, BUILDREL, and MAKEIMG steps. You can press Ctrl+F to display the Find And Replace dialog box, and then search for the following text to identify the start of these phases:

a. Starting Sysgen Phase For Project The SYSGEN steps start.

b. Build Started With Parameters The BUILD steps start.

c. C:\WINCE600\Build.log The BUILDREL steps start.

d. BLDDEMO: Calling Makeimg — Please Wait The MAKEIMG steps starts.

3. Open the C:\Wince600 folder in Windows Explorer. Verify that Build.* files exist.

4. Open the Build.* files in a text editor, such as Notepad, and examine the content.

Figure 2-8 Building an OS design

Configure Connectivity Options

1. In Visual Studio, open the Target menu and select Connectivity Options to display the Target Device Connectivity Options dialog box.

2. Verify that CE Device is selected in the Target Device list box.

3. Select Device Emulator (DMA) from the Download list box.

4. Select Device Emulator (DMA) from the Transport list box.

5. Select KdStub from the Debugger list box, as illustrated in Figure 2-9.

Figure 2-9 Setting Target Device Connectivity Options

Change the Emulator Configuration

1. Next to the Download list box, click the Settings button.

2. In the Emulator Properties dialog box, switch to the Display tab.

3. Change the Screen Width to 640 pixels and the Screen Height to 480 pixels.

4. Switch to the Network tab.

5. Select the Enable NE2000 PCMCIA Network Adapter And Bind To check box, then select the Connected Network Card option from the list box, as illustrated in Figure 2-10, and then click OK.

6. Click Apply to save the new device configuration.

7. Click Close to close the Target Device Connectivity Options dialog box.

Figure 2-10 Device Emulator network options

Test a Run-Time Image on the Device Emulator

1. In Visual Studio, open the Target menu, and then click Attach Device.

2. Verify that Visual Studio downloads the run-time image to the target device. The download can take several minutes to complete.

3. Follow the debug messages during the start process in the Visual Studio Output window.

4. Wait until Windows Embedded CE has completed the start process, and then interact with the Device Emulator and test the features of your OS design, as illustrated in Figure 2-11.

Figure 2-11 Windows Embedded CE device emulator

Chapter Review

The Windows Embedded CE build process includes several phases and relies on a variety of build and run-time image configuration files to compile the source code and create the run-time image. It includes a compile phase to generate .exe files, static libraries, DLLs, and binary resource (.res) files for the BSP and subprojects; a Sysgen phase to filter and copy source code based on SYSGEN variables from the Public folder for catalog items selected in the OS design, and create a set of run-time image configuration files; a Release Copy phase to copy the files from the BSP and subprojects required to build the run-time image into the release directory; and finally a Make Run-time Image phase to create the run-time image from the content in the release directory according to the setting specified in .bib, .reg, .db, and .dat files.

You can examine the build process if you analyze the information that Platform Builder generates and tracks in Build.log, Build.wrn, and Build.err files. The Build.log file contains detailed information about every build command issued in each build phase. Build.wrn and Build.err contain the same information, but filtered for warnings and errors encountered during the build process. You do not need to open these text files directly in Notepad. It is more convenient to work with build status information and error messages in Visual Studio. The Output window and the Error List window provide convenient access.

Build errors can occur for a variety of reasons. The most common causes are compiler and linker errors. For example, running build commands in an incorrectly initialized build environment will lead to linker errors when environment variables that identify library directories in the Sources file point to invalid locations. Other important build configuration files, such as Dirs files and Makefile.def, can also rely on SYSGEN variables and environment variables in conditional statements and in directory paths.

Having successfully generated a run-time image, you can deploy Windows Embedded CE on a target device. This requires you to configure a device connection based on the Core Connectivity infrastructure. The final deployment step is simply to click the Attach Device command that you can find on the Target menu in Visual Studio with Platform Builder for Windows Embedded CE 6.0 R2.

It is important that you are familiar with the following configuration files, which control the Windows Embedded CE build process:

■ Binary image builder (.bib) files Configure the memory layout and determine the files included in the run-time image.

Registry (.reg) files Initialize the system registry on the target device.

Database (.db) files Set up the default object store.

File system (.dat) files Initialize the RAM file system layout at start time.

Dirs files Determine which directories to include in the build process.

Sources files Define preprocessing directives, commands, macros, and other processing instructions for the compiler and linker. Take the place of Makefile files in the Visual Studio with Platform Builder IDE.

Makefile files Reference the default Makefile.def file and should not be edited.

Key Terms

Do you know what these key terms mean? You can check your answers by looking up the terms in the glossary at the end of the book.

■ Sysgen

■ Buildrel

■ Flat release directory

■ Connectivity options

■ KITL

Suggested Practice

To help you successfully master the exam objectives presented in this chapter, complete the following tasks:

Start the Build Process from the Command Line

To increase your understanding of the Windows Embedded CE build processes, perform the following steps:

Sysgen process Run sysgen -q from the command line after setting an environment variable in a catalog item.

Build process Open a Command Prompt window, change into the current BSP folder (%_TARGETPLATROOT%) and run build-c with and without setting the WINCEREL environment variable to 1 (set WINCEREL=1). Check the content of the %_FLATRELEASEDIR% folder before and after the build.

Deploy Run-Time Images

Deploy a Windows Embedded CE run-time image to a Device Emulator by using different download, transport, and debugging settings for the target device in Platform Builder.

Clone a Public Catalog Component Manually

Clone a component from the %_WINCEROOT%\Public folder by copying the source files to a BSP, as explained in Chapter 1, "Customizing the Operating System Design." Next, run sysgen_capture to create a Sources file that defines the component dependencies. Modify the new Sources file to build the component as part of your BSP. For detailed step-by-step information to accomplish this advanced development task, read the section "Using the Sysgen Capture Tool" in the Platform Builder for Microsoft Windows Embedded CE product documentation available on the Microsoft MSDN® website at http://msdn2.microsoft.com/en-us/library/aa924385.aspx.

Загрузка...