Skip to content

[BUG] Wake up from sleep does not wake pico up, on Seqoia/Mac mini #29

@TheTechnobear

Description

@TheTechnobear

Short summary

Wake up from sleep does not wake pico up, on Seqoia/Mac mini

Severity

minor

Platform

macOS

Hardware

pico

Version

2.2.1

Component

Agent

Agent

pico_manager

Steps to reproduce

  • load Standards Setup Pico
  • put Mac to sleep for an extended period (30 seconds?), deep sleep mode
  • wake up Mac

Pico leds are not on, and its not responding to keys etc, this can be seen in logs
there is no 'pipe woke' message

this only occurs on my MacMini / Sequoia , my Tahoe MacBook works 100% correctly!

difference to #27, is that was on Tahoe AND it was down to led mask not covering main leds, so no restore.
not related to power management as such, it was getting the 'pipe woke' message.

also notably, audio was ok , it was just led mask.
here the pipes are not restarting at all, so no functionality e.g. key presses.

Logs / additional info

I discovered this while testing #27 , but that was a different issue, moved comments here, see below

note: this appears to be linked to Mac power management, if so, is possible that it affects tau/alpha.
however, they will retain power from base station, so its possible they will be ok - explicit testing needed.
so my allocating to pico_manager is arbitrary, its more likely lib_pico/lib_alpha and/or picross (Mac power)

my analysis from #27

k, more complicated (surprise ;))

and... it seems to work absolutely correctly on Tahoe !
I first tried on my laptop, which I just upgraded... does seem to matter how long I sleep it for, wakes up likes come on
(it could also be a laptop function - but seems doubtful)

on my Mac mini with Sequoia, its more subtle...
a brief sleep - works fine.
more than about 30 seconds (?) , deep sleep - lights dont come on, in fact looking at the logs Pico is dead, its not doing anything really.

so, check the code... so the pico does not shutdown, as this USB sleep/wakeup is all part of macOS power protocol.
we can seen in the logs th power management callback for SystemWillSleep and SystemHasPoweredOn.

SystemHasPoweredOn -> reset device = macOS ResetDevice, which return kIOReturnSuccess

on short sleeps on Mac mini, and all sleep on my laptop - this wakes up the usb ports, and everything is ok.
on long sleep on Mac mini, usb ports dont get woken up....


ok, code check......I cannot really see what's wrong....

flow is pretty simple...

generally we have fast thread 'poll' pipes.
basically pipe_running(); and pipes->poll()

sleep -> PIPES_SLEEP ,
then the poll, will 'fail' at not running, which is fine... we are going to sleep ;)
(basically get one error perhaps... or a few as we 'wake up')

wakeup -> reset() , PIPES_IDLE ->

poll/ pipe_running() sees idle -switches to RUNNING -> call_pipe_running()
void pic::usbdevice_t::impl_t::call_pipe_running()

{
    pic::logmsg() << "pipe_running 0x" << std::hex << state_ << " woke pipe";

and this is exactly what we see when its working !

we get the woke pipe, and message start flowing, as usb comes alike

but in the 'fail case'
we never get this... woke pipe.

we see reset(), so we know PIPES_IDLE is set,

we 'know' pipe_running() should wake us up, as that thread comes alive.

and we arent even getting error error messages from the usb ?!

issues is I cannot even put a debugger on this... partly due to the sleep aspect,
but generally if you mess with USB timing, you have a high chance of kernel faulting your Mac.
.. it dont like ;)

hmm, really not sure.. is the a Sequoia issue? or something odd with desktop Macs vs Laptops?


also, one other oddity I see is...
if the pico doesnt have power it be reset to its 'unbooted' state - but I dont see any evidence of this in macOS.
so Im wondering if pico HAS reset, but macOS hasn't noticed..
even if macOS held the connection if we your stated sending messages to an 'unbooted' pico, it would not do anything !

how could this be different with Tahoe/Laptop - Im wondering if its still feeding it power?
so its not powering down fully? so keeps it state?

note: I tried both with and without powered hub, no difference in behaviour (on Mac mini)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions