[UMDF 2.0] DIYer is trying to write an ALS ACPI/I2C universal sensor driver

Hi,
I’m an absolute noob on Windows development. I’m mostly a linux guy.

I’m tring to write a driver to add support for a sensor under Windows; the device is a chromebook so linux support is native and its working fine.
The sensor is a simple I2C device, It simply works by reading two registers.

I’ve read some articles on the Microsoft documentation website and I’ve started to write some code.
I’ve started with the sample ADL345acc driver. I’ve cloned the repository. Copied the project files to a new directory and I’ve created a new project based on thoose.

I’ve then started to look into the “sensor combo driver” to see the ALS parameters to send back to the OS.

I “should” have wrote a more or less complete driver. But the device/driver fails after installing the driver. (At least it matches the ACPI _HID and get probably loaded.)
Now, I have no idea on how I can troubleshoot it. As far I know the demo driver have a lot of debug informations on some sort of output.
And I would like to know how can I access that information to see whats going wrong.

The sensor flow:
It is quite simple. Only polling, no HW threshold. (The sensor have an active low IRQ pin but only for threshold Overflow/Undeflow)

  1. Write 0x00 on register 0x08
  2. Write 0x01 on register 0x01
  3. Write (0x05 << 5) on register 0x00 to start the sensor
  4. Start a timer to poll the sensor
  5. On timer expire read the sensor data: Read register 0x02 and 0x03, combine them to have the 16bit ADC value and multiply it by scale.)

References:

Another question that i’m having is about the GUID, how can I generate one? Rightnow i’m using the one provided by the Sensor combo sample

Any help would be great, for me writing a MS/Windows driver is a lot harder than the one for Linux due to lack of experience.
Regards,
Nicolò

Looks like you’re on the right track.

You asked:

I have no idea on how I can troubleshoot it

Your driver is a user-mode driver, and you can debug it with Good Old Visual Studio. Set break points, single step… enjoy!

I would like to know how can I access that information to see whats going wrong

The driver uses WPP tracing. You can read using about WPP Tracing here.

Another question that i’m having is about the GUID, how can I generate one?

In Visual Studio, “Tools”… “Create GUID”:

@“Peter_Viscarola_(OSR)” said:
Looks like you’re on the right track.

You asked:

I have no idea on how I can troubleshoot it

Your driver is a user-mode driver, and you can debug it with Good Old Visual Studio. Set break points, single step… enjoy!

I’m a a big noob. :neutral: How can I run the driver from VS? Right now I’m building the driver, opening the debug directory and installing the driver. (DX click on .inf > install)

I would like to know how can I access that information to see whats going wrong

The driver uses WPP tracing. You can read using about WPP Tracing here.

Uhm… I’ve tried to follow that, but I’m not getting anything out. Or at lest is marked as “unknown”.
(Not sure if I’m doing something wrong. I’ve added the GUID to TraceView and start the data acquisition)

Another question that i’m having is about the GUID, how can I generate one?
In Visual Studio, “Tools”… “Create GUID”:

Ok, done :smiley:

This is what WPP logs are saying:


Quite sure I’m doing something really stupid, and thats the reason why I get no log info!

When I try to run the DRiver from VS I’m getting this (Debuging tools - Local Debugger is selected):

No idea on how I can configure the deployment.

You are very close to having traceview working. The Unknown …GUID lines indicate that traceview can’t find the .tmf files needed to decode our logs into text. Check out this page https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/creating-a-trace-session-with-a-control-guid steps 5 & 6, and here for info on creating the TMF files for your driver. https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/creating-a-trace-session-with-a-control-guid
I believe you can automate the TMF generation in VS .