[轉]Installing Windows CE 6.0 tools on a Windows7 64bit PC

Now, I only find a problem that I can not build SDK due to windows 7 64bit version. I solve it using the step 5.

from  http://geekswithblogs.net/WindowsEmbeddedCookbook/archive/2010/08/31/installing-windows-ce-6.0-tools-on-a-windows7-64bit-pc.aspx

I recently bought a new PC and I choosed a machine based on the 64bit version of Windows 7. 
Using a 64bits OS will allow me to use more than 4GB of RAM and this is quite important for me because it will allow me to run multiple virtual machines to test beta products and keep some customers’ development environment isolated from the others (for example for customers that need to test and certify each installed QFE and may allow me to install them on my development machine some time after their availability). 
On the other side running VS2005 and the Windows CE tools on the “main OS” istead of running them inside the virtual machine will provide better performances and avoid some of the issues of virtualization (limited or wasted disk space, issue with some devices, like USB devices etc.), so I decided to install the tools on Win7-64bit as my main working environment and leave virtual machine for specific configurations. 
This is an unsupported scenario for Windows CE development tools, so I’m not suggesting that you should upgrade your OS to 64bit if you are happy with your current 32bit setup. 
In this post I’ll try to report all the issues that I found with my setup and, hopefully, provide solutions (and maybe workarounds) to make Windows CE development possible on 64-bit machines. 

1. Setup

As usual the first problems may happen during the tools installation. 
First of all if you have newer releases of Visual Studio currently installed on your development machine you should unistall them and re-install them after you have set-upped VS2005 and Windows CE Plaform Builder. 
You should run all the setup application as an Administrator, so you should give administrator rights to your current user (you may need to do that also to run VS2005) or, at least, right click on the setup executable and choose “Run as administrator”. 
The first issue I found is an error (2738) when the setup tries to run some vbscript code to complete the installation. 
To fix this issue you should execute your command prompt as administrator (right click on cmd.exe or use this “trick” to create an administrative command prompt shortcut on your desktop or start menu) and re-register the vbscript runtime. 
First of all, remove current registration information: 
reg delete “HKCU\SOFTWARE\Classes\Wow6432Node\CLSID\{B54F3741-5B07-11CF-A4B0-00AA004A55E8}” /f 
Then register the 64-bit version of vbscript.dll: 
regsvr32 C:\Windows\SysWOW64\vbscript.dll 
(the actual path of the DLL may vary if you have chosen a different path for the Windows folder) 
Now you can run (as administrator!) the required installations: 

– Visual Studio 2005 
– Visual Studio 2005 service pack 1 
– Visual Studio 2005 patch for Vista 
– Windows CE setup 
– Windwows CE 6 Platform Builder SP1 
– Windows CE R2 setup 
– Windows CE R3 setup

Then I suggest to try to build a simple OSDesign to check that all the components of the Windows CE build system are working correcly. 

2. Installing QFEs

On my machine to install QFEs I needed to register again the vbscript runtime. I restarted my PC after VS2005/Windows CE installation and also installed some Windows updates, so you may not need to do that if you install the QFEs immediately after the setup of the main OS. 
To speed-up QFEs setup I usually write a .bat file that install them in sequence using msiexec. Here’s the code of a sample batch file that installs QFEs for ARM and x86 from march to june:

f: 
cd F:\Download\WinCE\QFEs\WINCE600 
reg delete “HKCU\SOFTWARE\Classes\Wow6432Node\CLSID\{B54F3741-5B07-11CF-A4B0-00AA004A55E8}” /f 
regsvr32 c:\windows\syswow64\vbscript.dll 
regsvr32 c:\windows\syswow64\jscript.dll 
start /wait WinCEPB60-100331-2010M03-Armv4I.msi 
start /wait WinCEPB60-100331-2010M03-X86.msi 
start /wait WinCEPB60-100430-2010M04-Armv4I.msi 
start /wait WinCEPB60-100430-2010M04-X86.msi 
start /wait WinCEPB60-100630-2010M06-Armv4I.msi 
start /wait WinCEPB60-100630-2010M06-X86.msi

You may also use the /quiet or /passive command line switch to perform non-interactive setup of all the QFEs, but I suggest to keep the setup interactive the first time you install QFEs on a new machine to ensure that you’ll be notified about any setup issue. 
You can create your batch file by running: 
dir /on /b > mybatch.bat 
Inside your Windows CE QFEs directory. 

3. Security

Some of the VS2005/Windows CE components may require network access to work. If you have the Windows Firewall enabled you will be prompted with the following authorization dialog:

 warning

This will happen also on 32bit machine. 

4. RNDIS

Some devices use a USB connection for downloading and debugging of the OS image on the target. Some of them use RNDIS to emulate a network connection over USB and require a driver to operate. 
This driver is part of the Windows7 install, but you need to tell to the system where it can find it. 
As soon as your device is detected the OS will try to automatically find a driver for it, but fails:

01

Now you can go to the computer management console (right click on “my computer” and choose “manage”), and open device manager:

02 

The RNDIS kitl device is marked with an exclamation mark to point out that its driver is not running. 
Right click on it and choose “update driver”, you’ll be prompted with the driver selection wizard. 
On the first step:

03

select “Browse my computer for driver software” and you will be prompted with the driver selection dialog:

04

Choose “Let me pick from a list of device drivers on my computer” and you’ll see the device category list:

05

Select “Network adapters” (RNDIS emulates a network connection) , and then “Microsoft Corporation” (don’t ask me about the differences between “Microsoft” and “Microsoft Corporation” here!):

06 

Now you should select: “Remote NDIS compatible device”:

07

Now your new KITL device is up and running and you’ll be able to download your OS images to it as you do with devices with a “regular” ethernet connection to your PC.

 08

If you need to connect to a RNDIS device from a virtual machine is usually easier to set-up the RNDIS driver on your “real” machine and then share it with the virtual machine as you do  with other network connections.

If you are running Windows CE development tools on a 64bit machine and found other issues that I did not cover in this entry (and did not experience!) and want to share some tips-and-tricks with other developers, write a comment here and I’ll be happy to update this entry, giving you credit for the tip, of course.

5. Generate an SDK

Usually after you’ve built and tested your OS image you need to generate an SDK to provide to application developers all the libraries, include files and documentation they need to develop applications targeted to your specific device.

The SDK configuration wizard works with no issues on my 64bit machine, but the build SDK command generated an error:

‘C:\Program’ Files (x86)\Microsoft Visual Studio 8\Common7\IDE>”C:\Program Files (x86)\Microsoft Platform Builder\6.00\cepb\IdeVS\GenSdk.exe” “C:\WINCE600\OSDesigns\S4WE\S4WE\SDKs\SDK1\obj\BuildSDK1.xml” 
Required files may be missing. To resolve the issue, reinstall Platform Builder.

This happens because GENSDK.EXE (the tool that “packs” all the files required for your SDK in a MSI file that you can redistribute and install on developer’s machines) is a .NET application that is spawned from PB and runs in 64bit mode. 64bit mode has its own registry and the configuration keys generated by PB setup are only in the 32bit registry. That generates the problem.

To fix it we can just develop a small .NET application, force it to run as 32bit (x86) and reference GENSDK.EXE as an external assembly, invoking its main method from our new 32bit app. This will force GenSdk to run as a 32bit app, finding all the registry information it needs to complete the SDK build.

To create this new project select “File\New Project…” from the VS2005 menu.

The new project wizard appears:

09

Select Visual C#\Windows as project type and “Console Application” as template. I called my “wrapper” GenSDK32.

Chose “OK” and you are ready to develop your GenSDK wrapper application.

The first step is to add a reference to the “real” GenSDK application. Right click on the “references” entry in your project inside Solution exporer:

10

The Add Reference dialog appears:

11

Select the “Browse” tab and navigate to the directory where gensdk.exe is located (usually “C:\Program Files (x86)\Microsoft Platform Builder\6.00\cepb\IdeVS”), select GenSdk.exe and press “OK”.

12Now a reference to GenSdk assembly has been added to your project.

If you double click on it you’ll be able to discover the object and namespace that it implements:

13as you can see it implements just one object (the main application class), that implement method Main.

Let’s see how we can call it from your code.

This is the code that the wizard generated for our application:

using System;
using System.Collections.Generic;
using System.Text;
 
namespace GenSdk32
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}

To call the Main method of GenSDK we need to add just one line, inside our own Main method:

static void Main(string[] args)
{
    Microsoft.PlatformBuilder.Sdk.SdkGenerator.GenSdk.Main(args);
}

Before we can build our application we need to configure it as 32bit only. We can do that by double clicking on the “Properties” node in Solution Explorer, this will bring up the project properties page:

14   
Select the “Build” tab, choose “Release” as active configuration, and “x86” as Platform Target for your application.

Now you are ready to build it by choosing “build\build solution” from the VS2005 menu.

Now you can copy gensdk32.exe to the same directory where gensdk is installed.

To build our SDK we have to run gensdk32 from the PB command line. Go back to your OSDesign and choose “Build\Open release directory”.

Now you can copy and paste the command line of the previous failed gensdk.exe execution and replace it with gensdk32.exe:

“C:\Program Files (x86)\Microsoft Platform Builder\6.00\cepb\IdeVS\GenSdk32.exe” “C:\WINCE600\OSDesigns\S4WE\S4WE\SDKs\SDK1\obj\BuildSDK1.xml”

And your SDK will be built!

If you are too lazy to build your own gensdk32 project, you can download mine from here:

7. PBXLUtils

The PBXMLUtils application has the same issue of GenSDK but, unfortunately, it does not provide access to its main application class and so you can’t build a 32-bit wrapper for it.

PBXMLUtils is used to generate makefiles and batch files from a PBXML file and also to update subroject configuration files. If you experienced problems with .bib and .reg settings of your subprojects not being included in the final image, you’ll have to covert PBXMLUtils.exe to 32 bits.

To do this you can use the corflags.exe utility that is part of Visual Studio installation.

Just open the VS Tools command prompt from the Visual Studio folder of your start menu and execute:

CorFlags “C:\Program Files (x86)\Microsoft Platform Builder\6.00\cepb\IdeVS\PBXMLUtils.exe” /32BIT+

(path of PBXLUtils may be different on your PC and it’s a good idea to do a backup copy of that file before you manipulate it.