Tech Note 23: Using the Microsoft Device Emulator

April 11, 2008

Copyright 2008 NS BASIC Corporation

Starting with NS Basic/CE 6.0, the Microsoft Device Emulator (MDE) can be used to test your application on the desktop without an attached device. The MDE can emulate a variety of devices, include Pocket PC 2003 Second Edition and Windows Mobile 5.

The MDE is a true emulator: it uses an actual ROM image, as would be installed in a device, within an ARM emulated environment. As a result, the quality of the emulation is considerably higher than previous emulators. Since it interfaces to NS Basic/CE via an ActiveSync connection, it is easy to load software on to and control.

You'll need a fairly fast desktop system to get performance anywhere close to a real device. Using the standard NS Basic/CE Benchmark program, it scores 9013 on a 3 ghz desktop CPU, a bit more than 1/3 the speed of an actual device with a 300 mhz ARM processor. Microsoft's ActiveSync also has to be installed, to transfer your program to the emulator once it is running.

Note that the downloads are large. If you do not have a broadband connection, you are better off using Virtual CE to connect to an actual device. You need to be running Windows 2000 or XP with the latest service packs. You must be running ActiveSync 4.1 or later if you want to emulate Window Mobile 5 devices.

Microsoft also has a tutorial on their site.

1. Downloading and Installing

You will need the Emulator itself, plus an image for the device you want to emulate.

A. Download the Microsoft Device Emulator 2.0:
http://www.microsoft.com/downloads/details.aspx?FamilyId=13F5DE85-30CD-4506-9C5B-A2068FA1EE9E&displaylang=en (1.1 megs)

B. Install it and run Register Device Emulator from the Microsoft Device Emulator 2.0 Preview Start menu.

C. Download the images.

D. You may also need to install Microsoft's Virtual Machine Network Driver. It is installed as part of Virtual PC 2007. http://www.microsoft.com/downloads/details.aspx?FamilyId=04D26402-3199-48A3-AFA2-2DC0B40A73B6&displaylang=en

Be sure to follow Microsoft's instructions for installation. It is not unusual to have to reboot. If ActiveSync does not connect, try registering the Device Emulator again.

If the options for the Windows Mobile 5 and Windows Mobile 6 emulators do not appear in the Device Emulator Manager, you may need to install the Windows Mobile 5 and Windows Mobile 6 SDKs, which are available on Microsoft's website.

If you have questions, Microsoft has a newsgroup for the Emulator here:
http://forums.microsoft.com/msdn/showforum.aspx?forumid=76&siteid=1

2. Starting up the Emulator

If you are running the Pocket PC emulator, choose which emulator you wish to run

Only the Pocket PC emulators will be useful: NS Basic/CE does not support Smartphone. If you choose Restore, the previous session will continue; otherwise a new session will start.

The Emulator will then start. It will take a few seconds for it to complete this. While you are waiting, start the Device Emulator Manager. Your screen will look like this:

Now right click on "PocketPC 2003 SE" and select Cradle. The Emulator will now connect to ActiveSync (you have that running already, of course?) just like a real device would if you put it into its cradle.

There is some useful documentation in the Emulator under its Help menu. It describes a number of useful options, include setting up a folder that can be shared with the desktop.

3. Using NS Basic/CE

All that is left to do is install NS Basic/CE. Use the regular Basic.ppc.exe installer: it will work just as if you were attached to a real device. (If you are using the demo, use the RuntimeFat.ppc.exe installer). Set the serial number using Register under the Help menu of the Desktop IDE, and you will be able to use NS Basic/CE.

4. Some advanced notes

The emulator can be launched from the command line, giving additional options. Here is a sample to start up a Pocket PC 2003 device with 128 megs of memory. (You'll need to have the appropriate images and files installed).

"C:\Program Files\Microsoft\Device Emulator 2.0 Preview\DeviceEmulator.exe" "C:\Program Files\Microsoft Visual Studio 8\SmartDevices\Emulators\Images\PocketPC\2003\VGAPortrait\1033\PPC_2003_SE_VGA_WWE_ARMv4.bin" /n /defaultsave /skin "C:\Program Files\Microsoft Visual Studio 8\Smartdevices\Skins\PocketPC_2003\PocketPC_2003_VGA\1033\PocketPC_2003_VGA_Skin.xml" /memsize 128
Here is another command line for starting the emulator in German:
deviceemulator ppc_ger.bin /flash save.bin /memsize 128 /sharedfolder storagecard