arşiv

yazılar buna göre etiketlendi; ‘Virtual PC’

WinCE Tutorial – 7 – Running WinCE under Virtual PC – 3

Cumartesi, 14 Kas 2009

WinCE Tutorial – 6 – Running WinCE under Virtual PC – 2

Debugging

After establishing a connection between development image Visual Studio and WinCE test image, it is relatively easy to use debug facilities. In the following sections, an example Hello World application debugging and an example network driver (passthru) debugging will be explained.

User Mode Program Debugging

  1. Create a new Hello World subproject to your solution (File → New → Subproject, WCE Console Application, A typical “Hello World” application).
  2. Right click to your OSDesign and select “Build All Subprojects”. After building the subproject, Platform Builder will automatically create a new NK.bin.
  3. Upload this new NK.bin to the test system. After WinCE boot, you can open the source code and set break points. To start the program, you have two options. The first one is starting the application directly from WinCE. HelloWorld.exe is normally located at Windows directory. To see the file, you first need to change the directory settings to see hidden files. The second option is running the application from Visual Studio. From Target → Run Programs you can see all programs currently available in WinCE. Select HelloWorld.exe from there and hit the Run button.

VS Run Program Screen

User Mode Program Debugging

WinCE Running Hello World on Virtual PC

Kernel Driver Debugging

Passthru driver located under $(WINCEROOT)\PUBLIC\COMMON\OAK\DRIVERS\NETSAMP\PASSTHRU will be used as an example.

  1. Copy the entire directory under $(WINCEROOT)\PLATFORM\VirtualPC\SRC\drivers. Create SRC and drivers directories. Create dirs files under src and drivers directories.
    Src directory dirs file content:

    DIRS= \

    drivers \

    drivers directory dirs file content:

    DIRS= \

    passthru \

    Modify the $(WINCEROOT)\PLATFORM\VirtualPC\dirs file by adding src directory as a line.

  2. Change the $(WINCEROOT)\PLATFORM\VirtualPC\FILES\platform.reg file and add the following line:

    #include “$(_TARGETPLATROOT)\src\drivers\passthru\passthru.reg”

  3. Change the $(WINCEROOT)\PLATFORM\VirtualPC\FILES\platform.bib file and add the following line:

    passthru.dll  $(_FLATRELEASEDIR)\passthru.dll    NK SHK

  4. Enable KITL and kernel debugger from the project Build Options.
  5. Rebuild the solution and load the generated NK.bin image to the test system.
  6. In output window, you will start to see the passthru driver messages.
    VS Output Window
  7. You can also set breakpoints to your code.VS BreakpointNote: Sometimes the breakpoints do not become active although the dll is loaded. In this condition, starting a command line instance in WinCE magically solves the problem.

This was the last part of the WinCE tutorial series. I hope you enjoyed it!

Emin Bilgisayar, WinCE Tutorial , , ,

WinCE Tutorial – 6 – Running WinCE under Virtual PC – 2

Çarşamba, 11 Kas 2009

WinCE Tutorial – 5 – Running WinCE under Virtual PC – 1

Running the Image in Virtual PC

You can find the ready Virtual PC image under the VM directory of the packet downloaded from the internet. You can delete the .vfd file if you wish. This file is a floppy image for the bootloader. We will create our own image to see the kernel and driver debug messages using COM port.

Booting the Operating System

Local Install

You can follow the local install steps explained for VMware. This time, use your new NK.bin. You can mount an .iso image after running the virtual machine from the CD menu of the virtual machine window.

Capture ISO Image

Remote Download&install Using Serial Connection

This install mode has not been tried yet but following the steps explained for Vmware will be sufficient to download and install the image using serial connection.

Note: Floppy image formats of vmware and virtualbox are different. Vmware can open .img and .flp images and can only create .flp images. Virtual PC can open .vfd, .img, .ima and .dsk images. However, the only difference of .flp and .ima is the file extension. .flp images created by Vmware can be renamed and used with Virtual PC.

Remote Download&install Using Ethernet Connection

We first need to set up a working network between Vmware development image and Virtual PC WinCE image. To keep the physical connections as few as possible, networking can be done using a virtual network adapter.

Steps for setting up a network are as follows:

  1. Install Microsoft Loopback Adapter. It is explained here in detail.
  2. Associate one of the Vmware networks with the loopback adapter. You can do this using Virtual Network Editor of Vmware.
  3. VMware Virtual Network Editor

  4. Change the development vm network from the VMware image options to use the network with loopback adapter.
  5. Virtual Machine Settings

  6. Manually configure the network settings of the development image as following:
    IP Address: 192.168.1.101
    Subnet Mask: 255.255.255.0
    Default Gateway: 192.168.1.1
  7. Set up a dhcp server. An example with Tftpd32 will be explained here. After downloading it, copy it to the development vm and start the exe. Configure the program and the server like the following pictures.

    tfpd32

    tfpd32 settings

    IMPORTANT: Using a dhcp server in a company network may cause problems. If you choose using the physical network instead of virtual one, you may need to establish a connection with static ip. It is explained here.

  8. Set up the Virtual PC networking. Assign 2 cards (one of the cards will be used for debug communication and the other is for “normal” network). Change both adapters to Microsoft Loopback Adapter.
    Virtual PC Network Settings
  9. Prepare a new floppy image to boot Virtual PC VM. You can follow the steps written under Serial Connection for Vmware. After creating the floppy image, change the eboot.bin file with the one found under $(WINCEROOT)\PLATFORM\VirtualPC\BIN\BOOT. After that, unmount it and change the image file extension from .flp to .ima to use it with Virtual PC.
  10. Start the Virtual PC image and capture the floppy image. If everything runs correctly, you will see the dhcp entry of the Virtual PC ethernet card in Tftpd32.
    dhcp entry on tftpd32
  11. Open development image Visual Studio Connectivity Options. Choose Ethernet from the download and transport combo boxes. Click the settings button next to the download combo box. You will see the Virtual PC image in the Active target devices list. Select the device, apply the changes and return back to the ethernet
    VS Ethernet download settings
  12. Shut down the WinCE image. Select “Attach Device” option from visual Studio → Target.  You will see a window like the following:Download Runtime Image
  13. Start the WinCE image again. After a few seconds, download will be started. After download completes, you will see Windows Embedded CE 6.0 running in Virtual PC.
    Running WinCE 6.0 on Virtual PC

Connection with a Static IP

It is also possible to connect development and test systems without using a dhcp server. We must only start the ethernet bootloader with a static IP parameter. Boot the Virtaul PC vm with the floppy you created in the previous sections. Choose the clean boot option.

Boot options

After that, start loadcepc.exe with eboot and give the static ip as a parameter.

Example:

A:\> loadcepc.exe /E:0:0:192.168.1.105 /L:800x600x16 eboot.bin

You can also change the floppy autoexec.bat and config.sys and add the static ip option. Modified files can be downloaded from here.

WinCE Tutorial – 7 – Running WinCE under Virtual PC – 3

Emin Bilgisayar, WinCE Tutorial , ,

WinCE Tutorial – 5 – Running WinCE under Virtual PC – 1

Çarşamba, 11 Kas 2009

WinCE Tutorial – 4 – Running WinCE under VMware – 3

Virtual PC – Creating and Running the CE Image

You need to install Virtual PC if you haven’t done it already. It can be found in this address.

Preparing the BSP and Creating the CE Image

A custom bsp specifically tailored for Virtual PC can be found in this address. After extracting the zip content, copy the vm directory to the host system and copy the other contents to the $(WINCEROOT)\platform directory of your development system. After doing that, open the visual studio of your development system. You can either create a new solution and select the new bsp from the wizard or change the bsp of your current solution. Detailed explanations of these operations can be found in previous sections of the tutorial.

You can also configure the bsp to use one of the ethernet cards directly as a debug card and the other one as a product ethernet card. To do this, follow these steps:

  1. Set the following environment variables:
    KERNELNOSHAREETH = 1
    BSP_NOSHAREETH = 1
    OSDesign Property Pages Screen
  2. Open platform.reg file of the bsp and find the following lines:

    IF IMGNOKITL

    #include “$(_TARGETPLATROOT)\files\dc21x4.reg”

    ENDIF

    Change with

    ;IF IMGNOKITL

    #include “$(_TARGETPLATROOT)\files\dc21x4.reg”

    ;ENDIF

  3. Open platform.bib file of the bsp and find the following lines:

    IF IMGNOKITL

    ndis_dc21x4.dll   $(_TARGETPLATROOT)\bin\drivers\$(WINCEDEBUG)\ndis_dc21x4.dll      NK SHK

    ENDIF IMGNOKITL

    Change with

    ;IF IMGNOKITL

    ndis_dc21x4.dll   $(_TARGETPLATROOT)\bin\drivers\$(WINCEDEBUG)\ndis_dc21x4.dll      NK SHK

    ;ENDIF IMGNOKITL

After those, rebuild the project and generate NK.bin.

If you skip these steps, vmini driver will be used if you enable KITL. You may still use normal ethernet functionality and debug the system at the same time. However, it is not recommended in this project because of the reasons mentioned here.

Note: You may encounter a problem about OAL.exe in the build process. This is because of an error in make files. You can change the makefile.def files of the kitl and oal to overcome this problem. The files can be found under:

$(WINCEROOT)\PLATFORM\VirtualPC\bin\kitl\makefile.inc

$(WINCEROOT)\PLATFORM\VirtualPC\bin\oal\makefile.inc

Find the line starting with “copy”, and change it with the appropriate lines given below:

copy $(_TARGETPLATROOT)\bin\oal\$(WINCEDEBUG)\oal.* $(_TARGETPLATROOT)\cesysgen\files\

copy $(_TARGETPLATROOT)\bin\kitl\$(WINCEDEBUG)\kitl.* $(_TARGETPLATROOT)\cesysgen\files\

After rebuilding the kitl and oal, nk.bin will automatically be created. However, in some of the build modes, this solution does not work. If this is the case, for a workaround, copy all files from $(WINCEROOT)\PLATFORM\VirtualPC\BIN\OAL\debug and $(WINCEROOT)\PLATFORM\VirtualPC\BIN\KITL\debug and paste them to the same directory you normally copy NK.bin from. Example directory path: C:\WINCE600\OSDesigns\OsDesign_VMware\OsDesign_VMware\RelDir\VirtualPC_x86_Release

Make sure that you copy the necessary files to your current solution directory.

Copy always contents from debug directory. After that, generate NK.bin by choosing “Make Run-Time” image option shown below.

Make Runtime Image

WinCE Tutorial – 6 – Running WinCE under Virtual PC – 2

Emin Bilgisayar, WinCE Tutorial , ,

WinCE Tutorial – 1 – Introduction & Installation

Pazar, 08 Kas 2009

A couple of months ago, we started a new project about a device driver for Windows Embedded CE 6.0. In this project, my first task was preparing a toolchain. We needed a running environment for the operating system and because of some reasons which I won’t mention here, we didn’t want to buy a real hardware. So, I started searching virtualization solutions. At first, I thought that it will be easy to find a running WinCE bsp for one of the virtual machines. After a dozen of unsuccessful Google searches, it started to be clear that I could not find an easy solution. After that, I started collecting some bits and pieces from many different web sites. Adding my own experience created this tutorial. Your comments and corrections are always welcome.

I also want to clarify why I’ve chosen English here: As I’ve written in my previous posts, I don’t normally write anything English into this blog. However, I decided to make an exception for this tutorial. First of all, most of this tutorial is already written in English and I don’t have enough time to translate it into Turkish. Secondly, it is very difficult to find a tutorial which covers all of the following sections written. Personally, I couldn’t find any. I thought that it can be better to publish all these information in English for a broader audience.

Ok, one more last thing: I am not responsible for any loss resulting from the use of this tutorial.

Toolchain

The development environment will look like the following schema:

Toolchain Schema

The reason of developing in a VM instead of the host PC is keeping the native system clean. Also, snapshots can be taken and reverted back in the learning process if something goes terribly wrong. Note that some Platform Builder versions won’t work if installed side-by-side and may corrupt or even crash your installation.

To develop a Windows Embedded CE 6.0 image (NK.bin file), copy all device-specific sources from ClearCase into the Platform-Builder-Directories of the virtual machine. Make your changes and build an image.

To debug the image you created, set your create and configure a network for your development and test virtual machines. After that, you can transfer the generated data to your target-device and start debugging.

Following sections explain the development processes in detail.

Preparing the Environment for WinCE Development

There are a couple of steps to follow before starting application/driver development for Windows Embedded CE 6.0. These are:

  1. Installing the required packages to development system.
  2. Preparing the bsp and creating the CE image.
  3. Running the image in target VM.

Second and third steps are dependent upon the target virtual machine we are using. You can think of different virtual machine programs as different physical machines which contain different hardware. Since bsp is created for a specific hardware platform, we need different bsps for different virtual machines.

For development system, Vmware is chosen as the virtual machine because of its advanced settings and speed. It has already been used for some other jobs by some of the developers of the team, which also affected the choice. We’ve already had the required license for the software (workstation), but it is theoretically possible to use the free alternatives VMware Player and VMX Builder.

For the test VM, VMware was tried first. After some effort, it was understood that debugging an application or a driver would be very difficult in Vmware because of the lack of ethernet debug drivers. Hence, Vmware WinCE images could only be debugged using trace messages, which is very uncomfortable.

As a second option, Virtual PC was taken into consideration. It was at first difficult to set up a working network between Vmware development system and Virtual PC test system in our corporate network. After setting up a functioning network, WinCE image could be loaded and debugged with the ethernet interface successfully.

In the following sections, both of the target virtual systems, as well as detailed information about the things done to support debugging using ethernet card in VMware will be explained. The user can choose one of the target systems. Note that two VMware images cannot be emulated using VMware Player at the same time.

Installing Packages

The following packages should be installed into the development computer for Windows Embedded CE Development:

Other monthly update packages may also be released at the time you are reading this document. Please check Microsoft download site and install all updates.

Note: At the time the original document was written, R3 hasn’t been released yet. You can directly install R3 after installing R2. R3 probably includes monthly updates given above.

Because of a proxy problem, one may not install the Windows Embedded CE 6.0 and R2 from the links above (It was the case for me). If you encounter a problem installing these packages, you have two options to overcome it:

  1. Installing from the CD: Microsoft sends the Evaluation edition CDs without cost (except shipping) if requested.
  2. Hacking the internet installation: The problem is that the setup tries to download some packages during install. If you have a proxy with authentication, setup cannot download the required packages and installation fails (probably because of a bug in the setup). If you can manually download the packages and put them under the same directory of the msi file of the setup, setup uses these files and installs the embedded cd without any problem. msi files of the Embedded CE and R2 are automatically created under temp (C:\Documents and Settings\<username>\Local Settings\Temp) directory after clicking the setup.exe downloaded from the links above. All packages that may be used in install process can be found here (Required files are extracted from the msi files by opening them with Orca Msi Editor ). Depending on the checkboxes you selected in the install process, actual required packages might be a subset of them. After downloading the files given above, just execute .msi files.

Installing the packages is straightforward. Only make sure that you installed x86 support. Installing “Shared source” may also be useful in the future.

WinCE Tutorial – 2 – Running WinCE under VMware – 1

Emin Bilgisayar, WinCE Tutorial , , , , , ,

Yeni Projem

Pazar, 05 Tem 2009

S7-PCT’nin geliştirilmesini Türkiye’ye aktardığımızdan beri biz de takım olarak yeni projelere giriştik. Evosoft’un planı bizi başından beri PROFINET alanında yetiştirip Siemens’in bu taraftan gelecek projelerini üstlenebilmekti. Yeni projelerimiz bu plan doğrultusunda PROFINET üzerine oldu. Takım arkadaşlarımızdan biri doğrudan PROFINET geliştirme ofisinde çalışıyor. Diğer arkadaşlarla birlikte ben de başka bir proje için ofisimizden çalışmaya devam ediyoruz.

Proje aslında ilk aşamasında oldukça belirsizdi. Bir PROFINET sürücüsünü bir platformdan başka bir platforma aktaracaktık. Önceleri hedef platform Vista ya da Win7 olarak konuşuldu ama daha sonradan Windows Embedded CE 6.0 olmasına karar verildi. Şimdilik ilk adımları atıyoruz. Benim başından beridir görevim çalışma ortamını ayarlamak. Bu nedenle birkaç aydır kurulumlar ve ayarlarla boğuşuyorum diyebilirim. İlk önce Windows Vista ve 7′nin “checked” versiyonlarını indirip kurdum. Bu checked versiyon denilen şey Microsoft terminolojisinde hata ayıklama (debug) sembollerine sahip olan versiyon anlamında kullanılıyor. Bunları kurduktan sonra doğrudan işletim sistemi çekirdeğinden gelen mesajları görme imkanına sahip oluyorsunuz, ki bu da sürücü geliştirmesinde faydalı olabiliyor(muş). Debug penceresinden örnek bir görüntüyü aşağıya yapıştırdım (Windows 7 RC):

Win7Debug-1

Denemelerimin tamamını Vmware altında yaptığım için tahminen normalde çıkmayan bazı hatalarla karşılaştığım zamanlar da oldu. Örneğin Vista, normal çalıştırıldığında daimi mavi ekran veriyordu. Kernel debug modunda çalıştırıldığında sebebi anlaşılıyordu: Hata yakalanmış (debug assertion), devam et demeden ileri gitmiyor sistem. Aşağıda bunun da ekran görüntüsü var.

VistaDebug-2

Neyse, hedef sistem olarak Windows Embedded CE 6.0 (WinCE diyeceğim bundan sonra) seçilince yukarıda yaptıklarım biraz anlamlarını yitirdiler tabi. Bu sefer WinCE’yi Vmware üzerine kurmak ile uğraşmaya başladım.

Bir süre sonra farkına vardım ki WinCE konusunda internetteki bilgi yok denecek kadar az. Bir dizi Çinli internet sitesi çıkıyor google aramalarında devamlı. Durum o kadar vahim ki bu Çince siteleri Google translate ile okumak durumunda kaldım. Bu arada burada yeri gelmişken bir parantez açmak istiyorum. WinCE’nin hedef işletim sistemi olarak seçilmesinde bizim etkimiz sıfır. Hatta bana kalsa bu işe başlamazdım. Gerçek zamanlı ve/veya gömülü sistemler için çalışan daha özgür ve daha iyi birçok alternatif varken WinCE’yi bir platform olarak seçmek çok akıl karı bir iş değil bence. Bir de normalde Microsoft’un en büyük avantajlarından biri olan yaygınlık ve destek bu sistem için mevcut değilken yapılan iş biraz saçma kaçıyor. Ama tabii ki her zaman için geliştiriciler ile pazarlamacılar aynı fikirde olmayabiliyor. Para da pazarlamacıların elinde olduğu için bu tarz seçimler yapılabiliyor.

Neyse, bir süre uğraştırdı ama şu anda Vmware altında çalışan bir WinCE’miz mevcut. Yalnız bu sistem ethernetten debug edilme ihtiyacını karşılayamadığı için bir başka alternatif olan Virtual PC’ye yöneldim. Birkaç gün sonra ethernet debug desteği ile birlikte o da hazır hale geldi.

wince_vmware

Özellikle bu sanallaştırma yazılımları altında WinCE çalıştırma konusunda edindiğim bilginin diğer birçok geliştiriciye de yardımcı olabileceğini düşünüyorum. Bu işleri yaparken bir yandan da unutmamak için yaptıklarımı doküman haline getirdim. Proje liderimden de izin çıktı, onları da şöyle güzel bir makale haline getirip bir yerlerde yayınlayacağım. Normalde buraya İngilizce yazı yazmıyorum ama bu seferlik bir istisna yapabilirim.

Bu şekilde başlamış olduk projeye. Çalışma ortamı birkaç küçük testin ardından geliştirmeye hazır hale gelecek. Umarım sonu da başlangıcı gibi iyi olur.

Emin Bilgisayar , , , , , ,