天天看点

定制基于Visual studio 2005平台Windows CE(ARM V4I)中文模拟器

(本文译自Microsoft DeviceEmulatorBSP中Using the CE DeviceEmulator.rtf文件,并对该文件说明做了相应补充,旨在定制基于ARM4I平台Visual Studio 2005环境中文模拟器,建立用于Platform Builder 5.0+Visual Studio 2005嵌入式Windows CE 5.0开发环境)

一、生成OS 

1. 安装Windows CE 5.0(记得CPU类型里把ARMV4I选上)装完之后装DeviceEmulatorBSP.msi(本站下载),这是ARMV4I模拟器的BSP。 

2. 运行Platform Builder,新建一个Platform,给你的新Platform取一个名字,我这里取为MyCEEmu。BSP选择Microsoft DeviceEmulator:ARMV4I,Design Template选择Mobile Handheld,Application & Media随你选,Networking & Communications只选择Local Area Network(LAN)->Wired Local Area Network,其余都去掉。最后完成向导。 

3. 添加网卡。在Catalog View的Device Drivers->Networking->Local Area Networking (LAN) devices目录下,把NE2000-compatible(PCMCIA car)添加进来。 

4. 如果要开发托管程序,添加Catalog View的Core OS->Windows CE Devices->Applications – End User->CAB File Installer/Uninstaller。 

5. 添加ActiveSync(可选),在Catalog View的Core OS->Windows CE Devices->Applications – End User目录下。 

6. 添加闪存支持。有三个部件:SMFlash,Partition Driver和FAT。 

  先转到Catalog View: 

  SMFlash在BSP->Microsoft Device Emulator->Storage Drivers->MSFlash Drivers->SmartMedia NAND Flash Driver (SMFLASH), 

  Partition Driver在Core OS->Windows CE Devices->File Systems and Data Store-> Storage Manager->Partition Driver 

  FAT在Core OS->Windows CE Devices->File Systems and Data Store->Storage Manager->FAT File System。 

7. 打开菜单Platform->Setting,这里有三个地方要设置: //本部分DeviceEmulator.rtf中未说明

1) Build Options选项卡下,去掉Enable CE Target Control Support和Enable KITL; 

2) Environment选项卡,添加环境变量CE_MODULES_SERIAL=1,这是用来将DMA添加进来; 

3) Locale选项卡,用来添加你想要的语言支持,可改可不改。我这里先Clear All然后选了中文(中国)和英语(美国)。Default Language选为中文。 

8. 视情况添加其他所需的组件,我添加了MSXML的支持。 

9. BuildOS->Sysgen。 

二、生成SDK 

1. 运行SDK Wizard(Platform->SDK->New SDK),填写必要的信息之后,把支持的开发工具都勾上,完成。下面是配置SDK(选择Platform->SDK->Configure SDK),要是觉得没有什么好配置的也可以跳过。 

2. 打开ExportSdk.sdkcfg文件(先做好备份,这个文件一般在项目根目录下,就是在New Platform Wizard的第2步中所指定的目录,默认是%_WINCEROOT%/PBWorkspaces下)。这是一个XML格式的文本文件,找到这两行: 

    <PropertyBag NAME=”DeviceEmulation”> 

    </PropertyBag> 

把这两行替换为如下的片断: 

<PropertyBag NAME=”DeviceEmulation”> 

        <Property NAME=”Default Image”>1 </Property> 

        <PropertyBag NAME=”1″> 

            <Property NAME=”ImageName”>MyCEEmu </Property> 

            <Property NAME=”VMID”> </Property> 

            <Property NAME=”Default Skin”/> 

            <Property NAME=”Height”>240 </Property> 

            <Property NAME=”Width”>320 </Property> 

            <Property NAME=”BitDepth”>16 </Property> 

            <Property NAME=”Memory”>128 </Property> 

            <Property NAME=”Bin Dest”>Emulation/nk.bin </Property> 

            <Property NAME=”Fixed Screen”>1 </Property> 

            <Property NAME=”CpuName”>ARMV4I </Property> 

            <Property NAME=”DPIX”>96 </Property> 

            <Property NAME=”DPIY”>96 </Property> 

            <Property NAME=”SupportRotation”>0 </Property> 

            <Property NAME=”Enabled”>1 </Property> 

            <Property NAME=”Bin Path”> </Property> 

            <Property NAME=”Ethernet”>1 </Property> 

            <Property NAME=”Ports”>1 </Property> 

            <Property NAME=”AdditionalParameters”> </Property> 

            <PropertyBag NAME=”Skins”/> </PropertyBag> 

</PropertyBag> 

<PropertyBag NAME=”Added Files”> 

        <PropertyBag NAME=”{3B388597-0924-4102-ADFA-2519D2C3E11B}”> 

            <Property NAME=”Source”>C:/WINCE500/MyCEEmu/ReleaseImage </Property> 

            <Property NAME=”Destination”>Emulation </Property> 

            <Property NAME=”Subfolders”>0 </Property> 

        </PropertyBag> 

</PropertyBag> 

3. 设定变量。上面替换的代码中有几个变量需要设定,分别是: 

1) ImageName:这是程序员在Visual Studio IDE里所看到的名字; 

2) VMID:一个GUID,可以用GuidGen.exe来生成一个; 

3) Height/Width:模拟器屏幕的宽高; 

4) BitDepth:颜色深度; 

5) Memory:分配给模拟器的RAM大小; 

6) DPIX/DPIY:屏幕DPI; 

7) Source:这是一个目录,包含编译生成的NK.bin。建议最好在%_WINCEROOT%下新建一个目录,专门用于存放NK.bin。 

这里我设为C:/WINCE500/MyCEEmu/ReleaseImage。 

修改完成后保存。 

3. 生成SDK。Platform->SDK->Build SDK。一切顺利的话应该可以在当前工程目录的SDK目录下找到打包成msi文件的SDK安装包。 

三、配置Visual Studio 2005 

1. 先安装生成好的SDK。运行Visual Studio 2005,选择菜单“工具->选项”,打开选项设置对话框,从左边的树型列表中选择“设备工具->设备”,右边的下拉列表框拉到底可以看到“MyCEEmu”,这就是我们刚刚生成的那个Platform。下面的设备列表里有两项,双击MyCEEmu,设定传输为DMA传输,再点击“仿真器选项”,在“显示”选项卡里设定好模拟器屏幕尺寸,颜色深度等,全部保存。 

2. 新建一个智能设备项目,向导第2步选择平台的时候用我们的MyCEEmu替换Pocket PC 2003,完成。然后按F5运行程序,不出意外的话模拟器应该就出来了。

继续阅读