Emin Şenay


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

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 Breakpoint

    Note: 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!