Send mail to the author(s)

April 26, 2007

Connecting to a Windows CE 5.0 device from Visual Studio 2005 and Vista

Contents

Preliminaries
Step 1: Unzip the USB RNDIS driver software
Step 2: Attach the Windows CE 5.0 device via USB
Step 3: Install the driver software
Step 4: Configure the new RNDIS network device on the PC
Step 5: Configure Visual Studio to use the USB RNDIS network connection
Step 6: Configure CoreCon on the device

Preliminaries

Before we head on into this tutorial, it is important to mention that for you to connect to your device over RNDIS, your platform must have the necessary support already in place. An easy way to check for this is to look at the following registry key on the device:

[HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\RNDIS]

If it exists, then your platform already has the USB RNDIS support added to the OS image. If not, then you will either need to add the USB RNDIS support from the catalog in Platform Builder or contact your OEM.

By default, most Windows CE 5.0 devices will try to use ActiveSync over USB. This can be changed so that the default is the RNDIS driver by setting the following registry key:

[HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers]
        "DefaultClientDriver"="RNDIS"

Step 1: Unzip the USB RNDIS driver software

After downloading the zip file containing the USB RNDIS driver for Windows CE 5.0, unzip the contents to a folder of your choice. For the rest of this article, we will assume that this is a folder on the desktop. The zip file contains the 3 files shown in the image below.

Unzip the USN RNDIS driver

Step 2: Attach the Windows CE 5.0 device via USB

With the Windows CE 5.0 device powered up and booted into the Windows CE shell, attach the USB cable to the USB port on the device. Similarly, attach the free end of the USB cable to a USB port on your PC.

Step 3: Install the driver software

Upon attaching the device to the PC, Vista will detect the device and prompt you to locate the driver for the device, as shown in the figure below. Select the Locate and install driver software option from the Found New Hardware dialog. With the new security improvements introduced in Vista, you must install drivers using an elevated security level. On clicking the Locate and install driver software button, you will be prompted grant permission to the operating system to continue with the driver installation procedure. Click the Continue button.

Step1a

At the point, Vista will search through all the drivers currently installed to see if there is an existing driver that matches the device.

Step1b

If this is the first time you have attempted to install the driver, Vista will prompt you to insert the disc containing the device driver. Since you will have downloaded the driver, click the I don't have the disc. Show me other options button shown in the figure below.

Step1c

On the next page of the Found New Hardware wizard, click the Browse my computer for the driver software button.

Step1d

Browse to the OpenNETCF RNDIS Driver folder on the desktop (where you unzipped the device driver in Step 1) and click Next

Since the USB RNDIS driver has not been signed, you will be presented with a security warning similar to the figure below. Click Install this driver software anyway to continue with the installation.

Step1e

Vista will then continue to install the USB RNDIS driver and configure a new network device within your operating system configuration. This may take a few moments. Once the driver software installation has completed, you will be presented with the screen shown below. Click the Close button.

Step1f

After successfully completing the Found New Hardware wizard, Vista will take great joy in announcing this to you. The balloon notification shown below will disappear after a few moments.

Step1g

Step 4: Configure the new RNDIS network device on the PC

The RNDIS driver you have just installed will allow you to use the TCP protocol over a USB connection. Since this virtual network does not have access to a DHCP server, you will have to manually configure the IP address settings on both the PC and the Windows CE 5.0.

The first step in process is to open the Network and Sharing Center. This is achieved by clicking the View network status and tasks link under the Network and Internet section in the Control Panel.

Step2

On the left of the Network and Sharing Center, you will see is task list. The second to last option is Manage network connections. Click on this link and a new window will open showing the network connections you have available on your PC. Right-click the network connection that is using the USB Remote NDIS driver and select Properties.

Step2a

In the Network Properties dialog box, select the Internet Protocol Version 4 (TCP/IPv4) option and then click the Properties button.

Step2b

We are now at the point where you will configure the IP address that the PC will use to communicate with the Windows CE 5.0. Enter the IP address 169.0.0.1 with a subnet mask of 255.0.0.0, exactly as shown below. Click OK to dismiss the TCP/IPv4 Properties dialog and click OK again to dismiss the Network Properties dialog.

Step2c

Now that we have assigned an IP address to the RNDIS network device on the PC, we need to assign a similar IP address to the Windows CE 5.0 device so that the 2 end points can successfully communicate. In order to do this, you will need to switch to the Windows CE 5.0 device.

Click the Start button, followed by Settings and then Network and Dial-up Connections.

Step2d

Locate the RNDIS network device and right-click it. Select Properties. This will display the 'Remote-NDIS Host' Settings dialog box as shown below. Enter the IP address as 169.0.0.2 and subnet mask of 255.0.0.0, exactly as shown in the figure.

Step2e

That's it! The USB RNDIS network has been configured and at this point you should be able to successfully ping the IP address of the Windows CE 5.0 device from the PC. The next step is to configure Visual Studio to use the USB RNDIS connection to communicate with the device.

Step2f

Step 5: Configure Visual Studio to use the USB RNDIS network connection

In order for Visual Studio to connect to the Windows CE 5.0 device, it needs to know the IP address that the device is configured with. Visual Studio provides an easy way for this through its Options dialog box. Click Tools and then Options to open the Options dialog box. On the left of this dialog box is a list of the various configuration sections. Find the Device Tools section and expand the section. From the newly displayed options, select Device. On the right of the dialog box, you will now see a selection of devices based upon the platform selected in the top drop down list, as shown below.

Step3a

From the drop down list, select Windows CE 5.0. This will filter the list of Devices in the list below the drop down list. By default, there will just be one, named Windows CE 5.0 Device, but there may be more depending on the SDKs you have installed. Select Windows CE 5.0 Device and then click the Properties button. This will display the Windows CE 5.0 Device Properties dialog, similar to the one below.

Step3b

In this dialog box, make sure that the Transport is set to TCP Connect Transport and the Bootstrapper setting is ActiveSync Startup Provider. Click the Configure button next to the Transport option.

Step3c

In the Configure TCP/IP Transport dialog box, make sure that the Use fixed port number option is unchecked and that the Use specific IP address option is selected. Enter a value of 169.0.0.2 for the IP address. Click OK three times to save the changes you have made and exit the Options dialog box.  

Step 6: Configure CoreCon on the device

The final step in the process is to configure Core Connectivity (CoreCon) on the device so that Visual Studio can connect to it for deploying and debugging your applications. The first phase of this is to deploy the CoreCon tools to the device. These tools can be found in %ProgramFiles%\Common Files\microsoft shared\CoreCon\1.0\Target\wce400\. In this folder is a series of folders named by CPU architecture. Make sure you use the tools from the correct folder for your device.

Step4a

The files you will need to copy to the device are as follows:

  • clientshutdown.exe
  • CMAccept.exe
  • ConmanClient2.exe
  • DeviceDMA.dll
  • eDbgTL.dll
  • TcpConnectionA.dll

Copy these files to the \Windows folder on your device.

The next phase is to add the development machine connection details to the registry so that we don't have to manually configure the device each time it is reset.

Create the following key and values:

[HKEY_LOCAL_MACHINE\Software\OpenNETCF]
        "DevMachineIP"="169.0.0.1"
        "DevMachinePort"=DWORD:5000

Next, create shortcuts on the desktop for the following:

  • ConmanClient2.exe
  • CMAccept.exe
  • CEMGRC.EXE /S /T:TCPIPC.DLL /Q /D:169.0.0.1:5000

Next, override CoreCon security so that you can connect by setting the following registry value:

[HKEY_LOCAL_MACHINE\System]
        "CoreConOverrideSecurity"=DWORD:0x01

Lastly, launch \Windows\ConmanClient2.exe. Now you should be able to connect to the device from Visual Studio. Within Visual Studio, click Connect to Device... from the Tools menu.

Step7a

Select Windows CE as the Platform and then select Windows CE 5.0 Device from Devices. Now click Connect.

Step7b

After a few moments, you should presented with a dialog announcing a successful connection.

Step7c

We realize that the above steps are tedious and time consuming, so we've created a utility that will automatically configure CoreCon for you. The download contains the full source code for the utility. You can download the utility from here (607KB, zip).

The RNDIS driver used in this article can be downloaded here (26KB, zip).

A PDF version of this article is available here