USB device & hibernation

Hello all.

I have WDM driver for a USB device. Everything is tested and works fine, except for one thing: after hibernation the device is not accessible until I disconnect it and connect back again. I tried to debug the problem, but have got strange result:

  1. I don’t get POWER IRP when Windows is going to hibernate. Is it Ok?
  2. After restoring from hiberfil.sys, WinDbg doesn’t see the driver in memory. I didn’t check presence of the driver in raw memory yet, but ‘lm’ shows only one module loaded: ‘nt’. It doesn’t look correct but it looks like that OS kinda ‘loses’ my driver until the device is reconnected.

So, I don’t even know how to debug the problem. Would be glad to get any directions/debugging tricks/recommendations.

Thanking In Advance,
Mikae.

xxxxx@yahoo.com wrote:

I have WDM driver for a USB device. Everything is tested and works fine, except for one thing: after hibernation the device is not accessible until I disconnect it and connect back again. I tried to debug the problem, but have got strange result:

  1. I don’t get POWER IRP when Windows is going to hibernate. Is it Ok?

You should get a power IRP, indicating the system power state changing
to S4. What leads you to believe you don’t? Where did you get your
IRP_MJ_POWER code from? Are you debugging using a second computer?

Does everything work OK if you suspend and resume?

  1. After restoring from hiberfil.sys, WinDbg doesn’t see the driver in memory. I didn’t check presence of the driver in raw memory yet, but ‘lm’ shows only one module loaded: ‘nt’. It doesn’t look correct but it looks like that OS kinda ‘loses’ my driver until the device is reconnected.

You might try doing “.reload”. All of the drivers are still in memory
after restoring from S4.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

1 are you not getting an s irp or d irp? Are you calling postartnextpowerirp for each irp you complete?
2 try .reload and then check the loaded module list

What os and architecture is this on?

d

debt from my phone


From: xxxxx@yahoo.com
Sent: 1/4/2012 4:45 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB device & hibernation

Hello all.

I have WDM driver for a USB device. Everything is tested and works fine, except for one thing: after hibernation the device is not accessible until I disconnect it and connect back again. I tried to debug the problem, but have got strange result:

  1. I don’t get POWER IRP when Windows is going to hibernate. Is it Ok?
  2. After restoring from hiberfil.sys, WinDbg doesn’t see the driver in memory. I didn’t check presence of the driver in raw memory yet, but ‘lm’ shows only one module loaded: ‘nt’. It doesn’t look correct but it looks like that OS kinda ‘loses’ my driver until the device is reconnected.

So, I don’t even know how to debug the problem. Would be glad to get any directions/debugging tricks/recommendations.

Thanking In Advance,
Mikae.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

When some 5 years ago I wrote a WDM driver for a FX2- based USB device, I found that it needs quite exact sequence of power IRP handling and configuration requests. These days, I believe WDF/KMDF should handle it for you.

If you only see nt after hibernation, try to issue .reload command in the debugger. It doesn’t mean all drivers are unloaded. It only means the debugger is out of sync with the SUT.

Turn verbose mode on (Ctrl+Alt+V), and turn the initial breakpoint on (Ctrl+Alt+K).

Tim,

  1. I put a bp on my POWER handler and it wasn’t called. Well, I did it only once and was a bit tired (it was at 3:00 AM). Probably I missed something. Have to try again. I debug using VMWare.

Does everything work OK if you suspend and resume?

Didn’t get what you meant. If you speak about “stand by” mode – then everything is Ok. My driver handles it correctly, a user app doesn’t loose connection with the device. If you speak about hibernation, then behavior is what I described above.

  1. Thank you, I’ll try to issue ‘.reload’ to debugger.

Doron, it looks that I didn’t get neither S nor D POWER IRPs. But again, I have to check more, because it looks too strange. Probably I missed something.

The architecture is XP SP2 on x86 on VMWare. Also tried the same driver on Win7 x86-64 on VMWare, but got strange BSoD, saying that IRP that came from OS is NULL. I don’t trust VMWare when working with hardware (even tested and proved drivers that work with USB generate BSoDs on VMWare), but the problem still reproducible in XP SP2 on x86 on VMWare. So I think about trying to debug on XP SP2 x86 on VMWare, if it is not possible then will look how to connect to real PC.

Alex, could you explain what did you mean saying:

I found that it needs quite exact sequence of power IRP handling and configuration requests.

Also I’ll try (Ctrl+Alt+V) and (Ctrl+Alt+K), thank you.

I am out of the device for a few days, will continue working with it on Sunday evening. So now I can just reread POWER handler’s code without any real debugging :(. Probably will try to reproduce the problem on this weekend with other USB hardware if will find any…

Try it on a non vm system. Only then can you say hat the vm is not introducing this error. The usb stack in the vm is entirely synthetic so who know what is going on in it.

d

debt from my phone


From: xxxxx@yahoo.com
Sent: 1/5/2012 3:30 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB device & hibernation

Tim,

  1. I put a bp on my POWER handler and it wasn’t called. Well, I did it only once and was a bit tired (it was at 3:00 AM). Probably I missed something. Have to try again. I debug using VMWare.

Does everything work OK if you suspend and resume?

Didn’t get what you meant. If you speak about “stand by” mode – then everything is Ok. My driver handles it correctly, a user app doesn’t loose connection with the device. If you speak about hibernation, then behavior is what I described above.

  1. Thank you, I’ll try to issue ‘.reload’ to debugger.

Doron, it looks that I didn’t get neither S nor D POWER IRPs. But again, I have to check more, because it looks too strange. Probably I missed something.

The architecture is XP SP2 on x86 on VMWare. Also tried the same driver on Win7 x86-64 on VMWare, but got strange BSoD, saying that IRP that came from OS is NULL. I don’t trust VMWare when working with hardware (even tested and proved drivers that work with USB generate BSoDs on VMWare), but the problem still reproducible in XP SP2 on x86 on VMWare. So I think about trying to debug on XP SP2 x86 on VMWare, if it is not possible then will look how to connect to real PC.

Alex, could you explain what did you mean saying:

I found that it needs quite exact sequence of power IRP handling and configuration requests.

Also I’ll try (Ctrl+Alt+V) and (Ctrl+Alt+K), thank you.

I am out of the device for a few days, will continue working with it on Sunday evening. So now I can just reread POWER handler’s code without any real debugging :(. Probably will try to reproduce the problem on this weekend with other USB hardware if will find any…


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

I second that suggestion.

When I last tried this (a couple of years back) I had nothing but trouble debugging even the simplest USB driver in a VM. ALL sorts of strange happenings.

You definitely need to plug your device into a “real” machine and debug your driver there.

Peter
OSR

xxxxx@yahoo.com wrote:

  1. I put a bp on my POWER handler and it wasn’t called. Well, I did it only once and was a bit tired (it was at 3:00 AM). Probably I missed something. Have to try again. I debug using VMWare.

Well, that is an entirely different kettle of fish. Who knows how
VMware handles this? It might shut down the VM by just snapshotting the
memory state and exiting, without any power events at all. You should
test this on real hardware.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Ok, what I have for now:

I tested the driver on real machine. No BSoDs, but when I put the machine to hibernate and then wake it up I see that client program says “Disconnected”. In the case of Win XP 32 I have to disconnect the device and reconnect back again. Then restart the client program. In the case of Win7 64 it is enough to just to restart the client program. I’ve read the following article about USB debugging: http://blogs.msdn.com/b/usbcoreblog/archive/2010/10/25/setting-up-kernel-debugging-with-usb-2-0.aspx#_Optional:_Determine_the It looks like that target machine supports USB debugging (checked device capabilities). The only thing that I didn’t get is which type of cable I need. Tha article says:

“This is a dedicated USB debugging device with two USB-B ports. A USB debug cable/device requires two USB-A to USB-B cables to connect to the debug computer and target computer.”

So, do I need two USB-B or two USB-A ports? I have to explain it somehow in a shop, salesmen there usually don’t know these technical details…

Sadly since their advice to search for ?‘USB Debug Cable’ in your favorite search engine" appeared the results are flooded with Android USB debug cables. This webpage shows the infumous NET20DC which has a pair of B sockets so you probably need a pair of standard A->B USB cables:
http://www.codeproject.com/KB/system/windows-debug-using-usb.aspx

Good luck,
Tim.


From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com [xxxxx@yahoo.com]
Sent: 08 January 2012 21:24
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB device & hibernation

Ok, what I have for now:

I tested the driver on real machine. No BSoDs, but when I put the machine to hibernate and then wake it up I see that client program says “Disconnected”. In the case of Win XP 32 I have to disconnect the device and reconnect back again. Then restart the client program. In the case of Win7 64 it is enough to just to restart the client program. I’ve read the following article about USB debugging: http://blogs.msdn.com/b/usbcoreblog/archive/2010/10/25/setting-up-kernel-debugging-with-usb-2-0.aspx#_Optional:_Determine_the It looks like that target machine supports USB debugging (checked device capabilities). The only thing that I didn’t get is which type of cable I need. Tha article says:

“This is a dedicated USB debugging device with two USB-B ports. A USB debug cable/device requires two USB-A to USB-B cables to connect to the debug computer and target computer.”

So, do I need two USB-B or two USB-A ports? I have to explain it somehow in a shop, salesmen there usually don’t know these technical details…


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

On 08-Jan-2012 23:24, xxxxx@yahoo.com wrote:

Ok, what I have for now:

I tested the driver on real machine. No BSoDs, but when I put the machine to hibernate and then wake it up I see that client program says “Disconnected”. In the case of Win XP 32 I have to disconnect the device and reconnect back again. Then restart the client program. In the case of Win7 64 it is enough to just to restart the client program. I’ve read the following article about USB debugging: http://blogs.msdn.com/b/usbcoreblog/archive/2010/10/25/setting-up-kernel-debugging-with-usb-2-0.aspx#_Optional:_Determine_the It looks like that target machine supports USB debugging (checked device capabilities). The only thing that I didn’t get is which type of cable I need. Tha article says:

“This is a dedicated USB debugging device with two USB-B ports. A USB debug cable/device requires two USB-A to USB-B cables to connect to the debug computer and target computer.”

So, do I need two USB-B or two USB-A ports? I have to explain it somehow in a shop, salesmen there usually don’t know these technical details…

You need a thing like this:
http://pavel_a.fastmail.fm/temp/usbdebugcable.jpg

(only one cable connected)

– pa

It looks like there is only one vendor of such cables: Ajays NET20DC, right? I will search for exactly this vendor in this case.