Wakeup the system

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Bla

Wakeup the system

Post by Bla » Tue Jan 19, 2010 4:26 am

Hi,

in my keyboard project I want to implement a key to wake up the computer. Power off / sleep already works, while powering the system on seems to be a problem... nothing happens. I read something about a USB reset and/or "SEO". Any official word or code example on this? Thanks.
BTW, what is "USBATTR_REMOTEWAKE". Is this related?

Thanks.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: Wakeup the system

Post by christian » Tue Jan 19, 2010 7:01 pm

As far as I know, pulling D+ and D- to GND for a short period of time should suffice. This feature may have to be enabled in a descriptor, though. I'd have to read in the USB spec for details on how long to pull D+ and D- to GND and which bit in which descriptor to set...

Bla

Re: Wakeup the system

Post by Bla » Tue Jan 19, 2010 7:06 pm

That would be really great. I experimented with SEO, USB reset and setting D+ to 1 but none of this worked.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: Wakeup the system

Post by christian » Tue Jan 19, 2010 7:23 pm

OK. The USB 1.1 spec (which you can download, it's public) says in section 7.1.7.5 Resume:
A device with remote wakeup capability may not generate resume signaling unless the bus has been
continuously in the Idle state for 5ms (TWTRSM). This allows the hubs to get into their Suspend state and
prepare for propagating resume signaling. The remote wakeup device must hold the resume signaling for
at least 1ms but for no more than 15ms (TDRSMUP). At the end of this period, the device stops driving the
bus (puts its drivers into the high-impedance state and does not drive the bus to the J state).

"J state" is the opposite of "idle state", so my assumption that it would be SE0 is wrong. Note the words "with remote wakeup capability".

And in section 9.6.2 about the configuration descriptor, table 9-8:

Code: Select all

bmAttributes Bitmap
D7: Reserved (set to one)
D6: Self-powered
D5: Remote Wakeup
D4...0: Reserved (reset to zero)
D7 is reserved and must be set to one for
historical reasons.
A device configuration that uses power from
the bus and a local source reports a non-zero
value in MaxPower to indicate the amount of
bus power required and sets D6.  The actual
power source at runtime may be determined
using the GetStatus(DEVICE) request (see
Section 9.4.5).
If a device configuration supports remote
wakeup, D5 is set to one.

Bla

Re: Wakeup the system

Post by Bla » Tue Jan 19, 2010 8:53 pm

Thanks. I must still be missing something. I suspected I had to use "USBATTR_REMOTEWAKE", so I had set this bit all the time.
In the meantime I tried all combinations of D+/D- high/low, still nothing.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: Wakeup the system

Post by christian » Tue Jan 19, 2010 10:22 pm

The spec also says that the device must implement the set/get functions for this attribute. Don't know whether the default implementation handles that....

Bla

Re: Wakeup the system

Post by Bla » Wed Jan 20, 2010 12:50 am

J state or K state?
I just looked into the spec and it says K there. J is idle.

I've set the bit for remote wakeup for USBRQ_GET_STATUS, but still nothing. Hmm.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: Wakeup the system

Post by christian » Wed Jan 20, 2010 1:06 pm

Sorry, I think I have mixed up J and K. Since the bus is in idle during suspend, you must change something. Otherwise the host can't detect the signal.

I have never tried this myself. Have you tried commercial USB devices whether they can wake up the host? This may be a configuration option of the operating system.

Bla

Re: Wakeup the system

Post by Bla » Wed Jan 20, 2010 4:08 pm

Unfortunately I have no commercial USB hardware to test this with. In Windows on some devices you can enable a waking up feature (e.g. wake-on-lan). I've never seen this on HID devices, though. I read somewhere this feature would be enabled by default.

Well, I don't know... would be really great if someone else could do some tests. By the way, a working wake up function would be a cool addition in one of the next releases. :mrgreen:

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: Wakeup the system

Post by christian » Wed Jan 20, 2010 4:19 pm

My computer (a Mac) wakes up from sleep when I disconnect any device. Disconnect is indistinguishable from RESET/SE0 in the first place. So my guess was that USB RESET would wake up the host.

Bla

Re: Wakeup the system

Post by Bla » Wed Jan 20, 2010 5:07 pm

Well. Actually I not only want to wake the system from sleep. I want it to power on as well. I have a PS2 keyboard that can do that. But PS2 is PS2 and USB is USB...
Does your USB keyboard have a power on key?

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: Wakeup the system

Post by christian » Wed Jan 20, 2010 5:12 pm

I don't use an external keyboard. We have old Mac keyboards with a power key, but they fail to wake my computer from power-off. The trivial reason is that there is no USB power during power-off and thus no way for the keyboard to signal anything...

Bla

Re: Wakeup the system

Post by Bla » Wed Jan 20, 2010 6:44 pm

By the way, I just measured that in soft off mode, D- and D+ are low, +5V is present. At the moment I'm in doubt it will ever work at all. At least not on my systems.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Re: Wakeup the system

Post by christian » Wed Jan 20, 2010 7:04 pm

This is not suspend mode, at least according to the specs...

Bla

Re: Wakeup the system

Post by Bla » Wed Jan 20, 2010 10:01 pm

It was stupid to measure with the device disconnected, I guess... since a device has to signal its presence with a high on a data line. So, this is no real problem.
But I don't know what else I could test...

Post Reply