Debugging a device driver in WinCE 6.0 RRS feed

  • Question

  • Hi all,

       I have a WinCE 5.0 device driver code and now going to port it to WinCE 6.0 but having several problems.

    1. I can not debug the driver. What should I do to connect to the driver? What executable that I need to call first (the remote executable)? Or do I need to attach to existing process?

    2. The registry settings, I wrote it like below:



    I took the setting from WinCE 5.0, can I use it directly in WinCE6.0? Is there any change from WinCE 5.0?

    I am using VS2005 on XP system. I've Installed WinCE 6.0 R3.

    Thanks for the answer

    • Edited by roscoe_x Thursday, August 2, 2012 8:50 AM remove unwanted text
    Thursday, August 2, 2012 7:01 AM

All replies

  • What do you mean exactly with 'can not debug the driver'? You cannot connect to the device from PB? You set a break point and it's never hit? ...?

    Check the .bib files for the driver DLL and try adding the 'k' flag, for example change




    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom Check my blog:

    Thursday, August 2, 2012 7:56 AM
  • Hi,

      Thanks for the quick reply.

    I cannot debug the device because I do not know where to attach my debugger because my project is a *.dll. If I select Project properties => configuration properties => debugging => remote executable => fill it with *.dll, then what I get when I press debug (F5) is "A non-executable project cannot be started directly. Please set a command to use to start debugging this project. Do you wish to continue?"

    Maybe my question is which process called a device driver?

    My old setting is


    What's the meaning of this additional H & K?

    Thursday, August 2, 2012 8:49 AM
  • For debugging you have to attach to device (via KITL) via PB and set breakpoint inside the source code...

    H stands for hidden ... the file is hidden inside Windows directory

    K stands for Kernel .. the driver is loaded in Kernel Mode

    Thursday, August 2, 2012 9:16 AM
  • Hi,

      And how can I attach to device (via KITL)? Here I only see "Connect to device" from "Tools" menu. And after it connect a window showed telling me Connection suceeded. I stil cannot debug my driver.

    Thursday, August 2, 2012 9:37 AM
  • And possibly you have to build a debug version of the OS or at least enable the kernel debugger, or add some RETAILMSG to your driver to see if it's loading, ...

    In Windows Embedded CE 6.0 you can load device drivers in user mode or in kernel mode:  I bet that your driver needs to be loaded in kernel mode (all the USB related drivers are loaded in kernel mode) so you need to add the 'K' flag and rebuild the OS.

    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom Check my blog:

    Thursday, August 2, 2012 9:42 AM
  • Hi Luca,

       I follow your suggestion. I build the image on debug mode. Now the image size is around 44MB (from 23MB on release mode), but after finished downloading, WinCE6.0 won't start. The messages I can get are:


    PB Debugger Warning:  Debugger service map is set to none.  If your image has debugging support it may not boot properly.
    PB Debugger Cannot initialize the Kernel Debugger.
    PB Debugger Debugger could not initialize connection.
    PB Debugger The Kernel Debugger is waiting to connect with target.
    PB Debugger The Kernel Debugger has been disconnected successfully. 


    4294786484 PID:400002 TID:2620002 OSAXST1: >>> Loading Module 'usbmtk.dll' (0x83866768) at address 0xC0DA0000-0xC0DC0000 in Process 'NK.EXE' (0x82F8FC80)
    4294786494 PID:400002 TID:2620002 Exception 'Access Violation' (14): Thread-Id=02620002(pth=8386089c), Proc-Id=00400002(pprc=82f8fc80) 'NK.EXE', VM-active=00400002(pprc=82f8fc80) 'NK.EXE'
    4294786494 PID:400002 TID:2620002 PC=c00e6c18(k.coredll.dll+0x00046c18) RA=c00e698d(k.coredll.dll+0x0004698d) SP=d073ee30, BVA=c0dbc3ec
    PB Debugger The Kernel Debugger has been disconnected successfully. 
    usbmtk.dll is the driver that I've built. Any idea what went wrong now?

    Thursday, August 2, 2012 10:48 AM
  • You need to setup your bootloader so that it enables KITL. Does your board have serial output? Check the bootloader source for options (usually in your BSP in \SRC\BOOTLOADER, or SRC\EBOOT)

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog:

    Microsoft Embedded Partner
    Consultancy, training and development services.

    Thursday, August 2, 2012 11:55 AM
  • Hi Michel,

    Thanks for the reply.

    I think I already set my bootloader to enable KITL.

    I don't use a board, I use a usual desktop PC to put my WinCE6.0 image. Yes, the desktop has a serial port. But what's the serial port for?

    I think by using a desktop my debugging process can be as usual debugging with remote debugging. Can I do that?


    I saw this discussion by Michael Koster, he pointed out that "The Visual Studio 2005 application debugger won't allow debugging kernel mode drivers (managed by device.dll). To debug these drivers you'll need the PB 6.0 kernel debugger."

    So as far as I know most WinCE 6.0 drivers are kernel-mode drivers, and therefore I cannot do debugging using VS2005 and I must use  PB 6.0 kernel debugger. Is this correct?

    • Edited by roscoe_x Friday, August 3, 2012 2:16 AM Add more detail
    Friday, August 3, 2012 1:13 AM
  • The options you show enable KITL for the Windows CE image. You need to setup your bootloader (EBOOT) so it initializes the KITL connection and tells the kernel to enable KITL. Most bootloaders have this option. Are you using loadcepc with eboot on the desktop PC? Does the PC have a network card that is supported by EBOOT for KITL connections?

    You need Platform Builder to debug Windows CE kernel mode drivers, but you are building the kernel right? Platform Builder is a plugin in VS2005, and you have it already.

    I think you need to read up on the basics. It seems you are missing a lot of information and are grasping at straws here. Get a good book (there's many on Windows CE 6.0) or do a basic CE training course.

    I can't possibly explain all the basics here... To cover basic CE stuff is normally a day, then device drivers another and debugging techniques another.

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog:

    Microsoft Embedded Partner
    Consultancy, training and development services.

    Friday, August 3, 2012 3:04 AM
  • Hi Michel,

       So do you know what kind of good books out there that can teach me how to debug a driver in WinCE 6.0?

    Thank you...

    Friday, August 3, 2012 5:25 AM
  • Better books on Windows CE 6.0 are the following :

    Windows Embedded CE 6.0 Fundamentals (Microsoft Press)

    Programming Windows Embedded CE 6.0 Developer Reference 4th edition (Microsoft Press)

    Professional Microsoft Windows Embedded CE 6.0 (Wrox)

    They explains the Windows CE architecture from the base.

    Friday, August 3, 2012 6:28 AM
  • Hi all,

       I think I cannot solve the problem only by reading books. We're still looking for professionals nearby. And this website still my main source to get help for now.

    Now I've setup my BSP using below settings:

    And then I attach device, here's what I get:

    1. A window showed up to find below directory: d:\dublin2-13\private\winceos\coreos\core\dll

    2. A window showed up to find loader.cpp, which I found in: 

    3. A window showed up with the message: First-chance exception in K.COREDLL.DLL (0XC0000005: Access Violation)

    4. And the output window in VS2005 showed the message:

    PB Debugger Loaded 'C:\WINCE600\OSDESIGNS\MICROTEK1\MICROTEK1\RELDIR\MICROTEK_BSP_X86_RELEASE\USBMTK.DLL', no matching symbolic information found.
      87711 PID:400002 TID:2ea0002 Exception 'Access Violation' (14): Thread-Id=02ea0002(pth=8310495c), Proc-Id=00400002(pprc=81d17940) 'NK.EXE', VM-active=01210002(pprc=83f61a48) 'shell.exe

    What's the error message mean? How can I get more message from the usbmtk.dll? In the source code of the library there's already many DEBUGMSG() command, but I just don't know where to read it.

    Thanks again.

    Wednesday, August 8, 2012 1:34 AM
  • I assume your issue is resolved now.

    - Chandra

    Monday, May 6, 2013 9:16 AM
  • Come on Guyz, this is almost an year old post. Now the asker is not active. There is no point in filling the forum unnecessarily.

    Grow UP!! ;)

    Monday, May 6, 2013 11:14 AM
  • Hi everyone,

    I still have the same problem, I've read posts, but I don't see the answer to fix this problem. Please, share something that helps us.

    Thanks you very much.


    Tuesday, December 3, 2013 11:53 AM
  • Can you help us to know what is the problem you are facing ?

    Probably posting the log and describing what you trying would provide a better picture.

    It would be better if you create a new thread

    --- Misbah

    Senior Design Engineer T.E.S Electroni Solutions (Bangalore-India)

    • Edited by Misbah Khan Tuesday, December 3, 2013 12:15 PM
    Tuesday, December 3, 2013 12:14 PM