Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

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

hitech95hitech95 Member Posts: 4
edited January 7 in NTDEV

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
5. Start a timer to poll the sensor
6. 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ò

Comments

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,583

    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
    @OSRDrivers

  • hitech95hitech95 Member Posts: 4

    @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:

  • hitech95hitech95 Member Posts: 4

    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.

  • Eric_WittmayerEric_Wittmayer Member Posts: 37

    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 .

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE