Lab II - Advanced Windows CE Platform Builder


Windows CE .NET Hands on Lab

Abstract

The objective of thise hands- on lab is to show advanced features of the Windows CE .NET tools and the operating system. To achieve this goal, you will create, customize, build, download, debug, and use Remote tools against a Windows CE image running on thea NMCEPC computer I SH4 uNET hardware .reference platform.

This hands-on lab is divided into 4 parts. Each part provides step-by-step guides to follow. It will take approximately 60 minutes to complete this lab.

The lab will take approximately 60 minutes to complete.


Table of Contents

Part 1 – Creating a Platform Image 434

Step 1: Create a new Platform Workspace 434

Part 2 – Customize and build the Platform 888

Step 1: Select Platform - Debug 888

Step 2: Enabling Profiling Kernel and Event Tracking. 888

Step 3: Adding Additional Features to the Platform. 899

Step 4: Build the Platform 151515

Part 3 – Download the Platform 161616

Step 1: Configure download/debug transport 161616

Step 2: Download the operating system 171717

Part 4 – Remote Tools & Memory Leaks 191919

Step 1: Remote Performance Monitor 191919

Step 2: Enabling Debug Zones in the MemLeak Application… 222222

Step 3: Kernel Tracker 282828

Step 4: LMEMDEBUG 313131

Step 5: Download the operating system 363636

Step 6: Using Memalyzer 373737

Part 5 – Lab Summary 444443

Congratulations! - You’ve completed all the steps. 444443

Part 1 – Creating a Platform Image

During the first part of this lab you will use the New Platform Wizard within Platform Builder to create an initial platform workspace which you will then modify by adding applications, and modifying the registry.

Start Platform Builder Start | All Programs | Windows CE .NET | Platform Builder (there may also be a shortcut on the desktop)

Step 1: Create a new Platform Workspace

You will now create a platform using the Platform Wizard.

·  Select File | New Platform

The initial Dialog that is displayed below outlines the process of creating a platform – there are a number of steps to creating a new platform, you will step through the wizard and make selections as appropriate.

·  Click Next

You will build a project for the CEPC computer NMI SH4 reference board.

·  Select INTRINSYC- USH4CEPC:X86

·  Click Next

You could select more than one BSP (Board Support Package). For example, it may be useful to select the emulator and a hardware reference platform; the emulation environment can be used by your internal/external application developers to build applications for your device while hardware is still being developed.

Change the following figure

You are now given a number of sample platforms to choose from as the starting point for this project, or, if none of the options match your needs you can simply select ‘Custom’ and build the image based on the components you select from the catalog.

For the purposes of this tutorial you will be using the Industrial Controller configuration.

For the purposes of this tutorial you will be using the Industrial Controller configuration. The Industrial Controller configuration will build a display based configuration, for the purposes of this lab we will treat the configuration as ‘headless’ – you will notice that the Intrinsyc SH4 reference board doesn’t have any video out, keyboard, or mouse connectors – when building, and debugging the platform we will rely on the integrated development environment (IDE) debug tools, and remote tools – The NMI reference board does ship with a Remote Display Application, this won’t be used in this lab.

·  Select Industrial Controller from the list of platform configurations

·  You also need to provide the name of our platform, this will be MyPlatform

·  Click Next

There are a number of options which can be selected for each of the sample platforms. For example, the Industrial Controller can include the .NET Compact Framework, Internet Explorer. Be aware that you can further customize your platform by including components from the catalog, or by removing components from your project workspace.

We will remove some of the Application and Media Features

·  Remove .NET Compact Framework

·  Click Next

The Networking and Communication Settings are ok, we can move to the next step.

·  Click Next

We’re done! – The wizard is complete. You’ve configured the Windows CE .NET platform, and can now further customize the platform by adding and/or removing components from the platform.

·  Click FinishDone

At this point you have a platform workspace containing all of the o/s components which have been selected from the Platform Wizard. At this point you could further customize the platform by adding additional technologies and platform specific drivers to the workspace.

Part 2 – Customize and build the Platform

Step 1: Select Platform - Debug

The default option for building a platform is Release, but you need to switch this to Debug since you will be using the Platform Builder Debugger.

·  Use the Toolbar to Switch from Release Build to Debug Build

Step 2: Enabling Profiling Kernel and Event Tracking.

You’re now about ready to build the platform. We will be using the Kernel Tracker later in the lab. The Kernel Tracker tool requires that we have enabled Profiling Kernel.

You enable the Profiling Kernel by selecting the following options:

·  Select Platform | Settings

You will notice that the tools are currently set to build a Debug image of the platform. You have “Kernel Debugging” enabled, but in order to use the Kernel Tracker tool you also need to enable the Profiling Kernel and Event Tracking.

·  Select Enable Profiling

·  Select Enable Event Tracking During Boot

·  Click OK

Step 3: Adding Additional Features to the Platform.

We will be tracking memory leaks within applications which will be added to the platform – there are a number of tools/features included with Platform Builder that can be used to track leaks, one of the components which can assist with this process is LMEMDEBUG – this is a platform feature which can be added directly from the catalog.

The goal of LMEMDEBUG is to allow OEMs and application developers to get a better understanding of memory allocations within their device. LMEMDEBUG can be used or memory leak tracing as well as performance analysis.

Note that the source for LMEMDEBUG is available with Platform Builder and can be found here – C:\WINCE4210\PUBLIC\COMMON\OAK\DRIVERS\LMEMDEBUG.

·  Locate LMEMDEBUG in the feature catalog

·  CORE OS | Display Based Devices | Core OS Services | Debugging Tools | LMEMDEBUG

We wouldYou then typically add this component to the platform by Right Clicking on LMEMDEBUG and selecting “Add to Platform”, however, we’ve pre-build the LMEMDEBUG.DLL component and will add this to the build output folder by hand, the reason for doing this is because we will be using another memory tracking tool later in the lab, LMEMDEBUG will be loaded into our process address space, and will directly call heap functions, this could introduce false positives into the memalyzer tool..

We have three applications to add to our platform, these are celogload, memLeak, and Leak – these have already been written and can simply be added to the platform.

·  Select Project | Insert | Existing Project

·  Browse to C:\CEDemo\memLeak

·  Select memLeak.pbp

·  Click OK

The memLeak application will be added to your platform – this application will be used to show Debug Zones to display additional, focused debug information from an application or driver, Remote Performance Monitor to monitor memory load within the operating system, and how CELOGDATA can be used to output custom data items into the Kernel Tracker data stream. Memleak is a multi-threaded console based application which was created using the Platform Builder ‘Application Wizard’ – we will examine the code used in this application later in the lab.

We will also add the Leak application

·  Select Project | Insert | Existing Project

·  Browse to C:\CEDemo\Leak

·  Select Leak.pbp

·  Click OK

Leak will be used to show how LMEMDEBUG, and Kernel Tracker can be used to locate memory leaks within a process or driver.

We will also add the celogload application – this is used to load celog.dll into the kernel process address space, more on this later.

·  Select Project | Insert | Existing Project

·  Browse to C:\CEDemo\celogloaduse our own celogload project (the default does not work)

·  Select celogload.pbp

·  Click OK

Celogload is used to load celog.dll, we can then start logging memory allocations into a file called celog.clg which will be created in the %_FLATRELEASEDIR%.

We can see that our project workspace has been updated to show the three applications (celogload, memleak, and leak), these are located in the “User Features” folder of the project workspace.

The Memleak, and Leak applications were developed to work with Emulation and CEPCd SH4 reference platforms – let’s confirm that we’re building for the correct platform.

·  Select the ClassView tab from your workspace.

We can see from the image below that the application is Leak is the currently selected application, and that we’re currently set to build for emulation.

·  Set the build toolbar to CEPCNMI-X86 ELECTRONICS-USH4 Win32 (WCE X86SH4) Debug

We also need to make sure that during the build process for leak.exe we’re building a .MAP file (we will find out why later).

·  Select Project | Settings

You will notice that CeLogLoad, Leak, and memleak are selected in the project settings window.

·  Select Leak from the list of available applications

·  Click the Link tab of the project settings dialog.

·  Confirm that Generate Mapfile is enabled.

·  Click OK to dismiss the Project Settings dialog.

We should also check the build settings for the memleak project.

·  Select Project | Set Active Project | memleak

·  Confirm that we’re building memleak for the CEPCe NMI SH4 Debug platform.

We should also check the build settings for the CeLogLoad project.

·  Select Project | Set Active Project | CeLogLoad

·  Confirm that we’re building CeLogLoad for the NMI SH4CEPC computer De Debug platform.

We now have all of the components we need to build and deploy our operating system.

Step 4: Build the Platform

You’re now ready to build the platform.

·  Select the Feature View from your project workspace (otherwise you will only be able to build applications)

·  Select Build | Build Platform

NOTE: The build process will take approximately 5 minutes to complete.

Once the operating system has been built we will need to copy the LMEMDEBUG files to our build output folder.

·  Confirm that you have 0 Errors from the build process.

·  Select Build | Open Build Release Directory

·  In the Command Window, enter copy \cedemo\lmemdebug

·  Hit Enter – this will copy lmemdebug.dll (pdb, and map) to your build folder.

LMEMDEBUG is loaded by the heap management functions – we could examine the private source C:\WINCE410\PRIVATE\WINCEOS\COREOS\CORE\LMEM to see how lmemdebug is loaded.

Part 3 – Download the Platform

Step 1: Configure download/debug transport

You are now ready to download and debug the Windows CE o/s image – before you download let’s check to make sure the debug and kernel transports are configured.

·  Select Target | Configure Remote Connection

The following dialog will be displayed

·  Confirm that Ethernet has been configured for download and Kernel Transport.

·  Click Configure for the Download Service

The following dialog is used to select the device you will be using in this lab. This will have been pre-configured for you – the example below shows that UENGINE13 CEPC56964 is being used – when devices are booted onto the network they broadcast a BOOTME message, if all the lab devices were booted at the same time the available devices list would fill with device names.

·  Select Cancel

·  Click OK to close the Configure Remote Connection dialog

Step 2: Download the operating system

You can now download the operating system.

·  Select Target | Download

You will be prompted with the following KITL Warning – the device will have access to your build release folder, this is a cool feature, giving you the ability to drop data files, and applications into your desktops build release folder and have these available to the running Windows CE device.

·  Click Yes

·  Switch the NMI Reference board on – the download will take a few seconds to start.

The operating system image will be downloaded, once the o/s is downloaded you will see a number of debug messages being displayed in Platform Builder.

Part 4 – Remote Tools & Memory Leaks

Step 1: Remote Performance Monitor

The Remote Performance Monitor is a graphical tool for measuring the performance of a remote Windows CE system. You can view the behavior of performance objects, such as processors, memory, threads, and processes.

We will be using Remote Performance Monitor to monitor memory load on the reference board, this is useful to track memory load over a period of time, if memory load increases over time this could be normal behavior of the currently running processes and drivers, or this could indicate a memory leak. We will use the memLeak application to show how Remote Performance Monitor can be used.

To start PerfMon –

·  Within Platform Builder Select Tools => Remote Performance Monitor

You will be prompted for the device to connect to.

·  Select Windows CE .NET Default Device

·  Click OK