microsoft / NCM-Driver-for-Windows

The Windows NCM drivers (host-side and function-side) are the NetAdapterCx based NIC drivers that implements Network Control Model (CDC NCM) specification defined by USB-IF
MIT License
67 stars 25 forks source link

How to view trace messages from the driver? #12

Closed kripton closed 2 years ago

kripton commented 3 years ago

Hi, I'm currently developing a firmware that uses CDC-NCM over USB. On Linux and macOS, the device works perfectly. It enumerates without any problem and ICMP ping messages go both ways.

For Windows, I first had to add the "MS OS 2.0 descriptors" to automatically load this driver. Even then, the Windows Device Manager reports that the "device failed to start" with an error code of 0xC0000483 (which according to http://errorco.de/win32/ntstatus-h/status_device_hardware_error/0xc0000483/ means "STATUS_DEVICE_HARDWARE_ERROR"). In the source code of this driver, I can find many references to that error message, all of them in "device.c" and mostly related to the USB descriptor tables.

I am running Windows 10, 64 bit.

Since the Device Manager only displays the error code and not the associated "message", I investigated a bit on how I could access them. This brought me to "TraceView", so I installed VS 2019 and the WDK SDK 10. When starting TraceView, I've added a new report source and added this driver's Control GUID (from https://github.com/microsoft/NCM-Driver-for-Windows/blob/release_2004/inc/trace.h#L25). TraceView reports that the trace is running but when I plug my USB device, the "events counter" stays at 0.

Is there anything else I have to do to get the driver's trace messages?

kripton commented 3 years ago

Update: I can now see events coming in in TraceView. The problem was that I had "flags" still at 0x0. With 0xFFFFFFFF, events are coming in. However, it only shows GUIDs and cannot decode them, presumably because I'm missing the TMH files.

If I compile the source code myself, I assume the resulting TMH file won't help me much since the GUIDs will be differrent, right?

Thus, are the TMH files of the UsbNcm shipped with Windows available somewhere or could you please share them? An XML based Manifest seems to be an alternative as well ...

brandonjiang commented 2 years ago

Hey, NCM driver uses WPP for tracing. You can compile the source code yourself and load that NCM driver you built for the device in question, so this way TraceView should be able to decode the traces from your private NCM driver.