reset USB bus on MacOS?

Dear Lazyweb, how do you reset a Mac USB bus?

I have a Mac Mini (Core Duo 1,1, 10.5.8) with a pair of external USB drives attached. Sometimes when I reboot it, one or both of the drives doesn't come up. Power-cycling the drive enclosure itself sometimes works; sometimes power-cycling (not just rebooting) the Mac itself is required.

But I'm not in the same building as the machine, so both of these require the hardship of putting on pants.

Is there some software-based way to smack the living shit out of a Mac's USB bus to make it reset and re-probe all attached hardware?

(FWIW, the System Profiler is only seeing one of the two drives right now. Both enclosures are the same model and report as "Sunplus Technology USB to SATA bridge ST31000528 9VP5JYCH").

I think I've asked this before and the answer was "you can't", but I figured I'd try again.

Tags: , , ,

31 Responses:

  1. DC Dan says:

    If you've installed the Apple Developer tools try using USB Prober which lives here /Developer/Applications/Utilities and it has a refresh button. It also has a logger which might point you in the right direction as to what's causing the problem.

    • jwz says:

      Ok, I found a 10.5 copy of it. What am I supposed to do with it? My second drive isn't listed, the "refresh" button changes nothing, and the log logs nothing at level 7.

      • DC Dan says:

        I figured it might work like it did for this guy.

      • DFB says:

        Does USBfamilyMod work for you?

        • jwz says:

          60 seconds of Googling doesn't explain what that does or why I would care. Anyway, I power-cycled the drive, so I can't test any of this crap any more until the next time it happens. It's not easily reproducible.

          • DFB says:

            As far as I can tell it's a patch to the OSX USB drivers which makes them conform to the specification instead of laze around only talking to One True Apple hardware because Apple wants an antitrust smackdown some day too to follow in the footsteps of Junior Gates.

            "This package will install the modified IOUSBFamily.kext into /Extra/Extensions. It will also repair permissions and rebuild caches on /Extra/Extensions. This is a temporary fix, for 10.6.3 USB without an edited DSDT. There is a better solution in the works! ;)"

            Gotta love the emoticons in the docs.

  2. jimgrease says:

    You have probably already tried this, but in the past when I have had that happen, just opening the Disk Utility app and waiting a couple of seconds has made the external usb drives magically appear, mount correctly etc.

  3. Stab in the dark hail mary pass, but try reset your SMC:

    1. Shut down the computer.
    2. Unplug the computer's power cord.
    3. Wait 10 seconds (may I suggest performing a short jig while waiting).
    4. Press and hold the power button for 5 seconds.
    5. Release the power button.
    6. Attach the computers power cable.
    7. Summon Cthulhu.
    8. Press the power button to turn on the computer.
    9. Test with a reboot.


  4. jb says:

    have you tried a sleep/wake cycle? you can force the machine to sleep from the command line with "pmset sleepnow" and if this machine supports it, you can wake it up again with a WOL packet.

    although i have never tried it, i wonder if you could do a kextunload of or maybe{U,E}HCI and then reload the kext. of course those kexts have so many child deps that you'd probably have to work your way up the tree to those kexts which might be a big pain in the ass.

  5. Andrew says:

    Maybe the OS is indexing the drive or fsck-ing it.

  6. Jeff says:

    Does "system_profiler SPUSBDataType" show anything?

  7. Andrew says:

    Usually not the problem with the Mac nor it's USB kexts, I've seen this happen with cheap Chinese enclosures. They use knockoff or shitty binned bridge chips that can cause all sorts of untraceable grief.

    Additionally, the controller board on that Seagate drive may be going out, not uncommon, but probably not the case here.

    Solution: Go to Central next to Moscone and buy a Nexstar brand enclosure, the Nexstar CX cases are -very- nice and cheap, but most importantly, reliable.

    Protip: Get a firewire enclosure, actual reliability FTW

    • jwz says:

      I have had this problem periodically over the last... 7 years with 2 or 3 different Macs. In that time, I have also gone through 3 or 4 different brands of drive enclosure (not to mention different drives, some IDE some SATA).

      Every one of these enclosures was purchased at Central.

      Every one of these enclosures was the only model that Central had in stock at the time.

      So if the problem is that these are all bottom-rung Chinese shit, then your theory that Central sells something other than bottom-rung Chinese shit is wrong.

      • Andrew says:

        Ahh, yes, Central is the lowest rung of Chinese crap, but that's besides the point. (They rack-ah dissa-prin!)

        I recommend the Nexstar case because they use real Oxford Semi bridge chips which are known to have 100% compatibility with OSX. I have several protools machines here that use those particular enclosures with no bus reset issues, ever.

        But Firewire sidesteps that whole USB mess and just works. The bridge/controller chip doesn't require resources from the host CPU during transfers, has it's own DMA architecture, and provides faster and more reliable sustained transfers. Yeah, it's a few $$$ more, but how expensive is your time when you have to fiddle with USB with no pants on?

        Hell, it's the data bus used in the F-35 joint strike fighter.

      • Try isolating the drives via a powered USB hub. Sometimes software is not the answer.

        You'll have to get up a few times at first, but then the USB ports will be less vulnerable to this kind of probably surge-related power problem.

        Of course, if you buy a hub with an on/off switch you could probably get THAT to remotely reset with some cheap robotics, USB IO, and C++ or even a pay-as you go cell phone could be used to actuate the robotic switch. Of course now you're wearing pants A LOT to get it setup.

        I've been a fan since 2001 and have lots of respect for you. keep up the excellence.

    • Bill Paul says:

      Jamie, I know you don't want to hear it, but, this. ^^^^^

      Sadly, there exists such a thing as the "if it works with Windows, it must be okay" syndrome, and USB devices are one common place where it manifests. (The other being buggy ACPI implementations.) The USB spec is a little subtle in places, with the result being that USB software stacks sometimes disagree about certain things, such as how to handle the toggle bit. In USB, as in comedy, timing is important: sometimes it's less a matter of what you do than it is when you do it, and in what sequence. The USB-SATA bridge in your enclosures probably expects the host's mass storage class driver to engage in a specific ritual at shutdown, and the MacOS driver might be getting it wrong some of the time, with the result being that a reboot puts the bridge chip into an inconsistent state that won't clear until you do a power cycle.

      "But I did power-cycle the enclosures," I hear you say, while shaking your tiny fists, "it seems like sometimes that's not enough." Next time, unplug the USB cable from the disk and then power-cycle the drives. It's possible that even when you cut the enclosure power, the bridge chip is still drawing power from the USB cable, which prevents it from resetting.

      When you reboot the Mac, the kernel will reload the USB host controller drivers, and one of the first things those drivers should do is a host controller reset. (I'm pretty sure there will be a port reset done as well.) You can't really do anything harsher than that from the host side. If the disk doesn't show up on the bus even after that, then there's not much else you can do since resetting the device itself would require issuing a transaction to it, which you can't do in the first place.

      Thus, I'm sorry to have to tell you this, but I think the only solution for now is to learn to stop worrying and love the pants.

      This whole mess happens because the chip vendors validate their hardware by by testing it with Windows. Microsoft's USB stack implements some of the dark USB rituals in a particular way, and hardware is often designed to function properly only with the Windows USB stack's behavior. To keep costs down, the hardware makes no attempt at error recovery in the event that non-Windows behavior is detected, which means even a slight protocol botch leads to the device just going out to lunch.

      And forget about complaining to the manufacturer: first, you have to penetrate the many layers of OEMing to find out just who made the thing in the first place, second, when you do find the company that made the part, they won't talk to you because you're not their direct customer, third, the chip was obsolete five minutes after they shipped it, and anyway, it works with Windows, so it must be okay.

      But I'm not bitter. Really.


      • gryazi says:

        Actually, if you can chase the right one down with hard technical data, the .cn / .tw shops are pretty chatty except for the insurmountable language barriers.

        As a civilization, they haven't grown to the point of learning not to treat potential customers as potential customers, or ignore free advice [if they can figure out what you're trying to tell them].

      • I hate to harsh your bitter, but USB crap isn't all that much more reliable on Windows. Especially in an environment with too much static. "Too much " would be defined as "any" in this case.

      • jwz says:

        So, since this doesn't happen all the time -- most of the time I can reboot the Mac and both drives come up just fine -- do you think that if I just keep rebooting it again and again, eventually the drives will show up? When the drive have vanished, I've certainly tried up to 3 consecutive reboots without them re-appearing before deciding that that wasn't working, but maybe I wasn't persistent enough.

  8. The symptoms sound like it's the USB bus polyfuse cutting off the port. (That's the only thing I know of that will persist even if you disconnect and reconnect a device.)

    Since the devices are externally powered, you might try using a modified USB cable with the +5V line cut. No chance to draw power from the bus means no tripped polyfuse.

    • gryazi says:

      Or for less complexity at the cost of more, just shove them behind a powered hub and see if it magically cures everything. There's a whole other class of SNAFUs with things like HP printers that *demand* their full promised bus current (not always present off motherboards, first for archaic reasons, later for lazy QC ones) or the controller only works a quarter of the time.

      If I were nearer a Mac I could double-check how many (Free)BSDisms they support as far as prodding-USB-from-the-command-line goes, but I'm not.

  9. Edouard says:

    Ahh! Run Windows in a VM, and share the filesystem to the Mac host.

    Hmmm, that actually sounds stupid enough to work. Also, stupid.

    • Edouard says:

      Huh, that was supposed to be a reply to someone else.

      I liked the way LiveJournal let me delete things I posted after I had determined I had a) made a mistake, or b) was dumb. Or both.

    • gryazi says:

      If it were more readily reproducible, Boot Camp wouldn't be a completely insane way to prove (disprove) the 'it all works in Windows' theory, except for that taste of sewer rat.

      Of course [with the missing luxury of reproducibility] you could always Ubuntard it for the quick physical check.

      The useful idea that hasn't been proposed already is to see if Sunplus chips show up in any of the freenixes' "quirks" lists.

  10. What, you don't own a Sari that fits? (With sheepie under-raiments to match the UGGs?)
    The good news is that an Arduino or ShivaPlug can intermediate for less than the price of one o' those IP power twaddlers; d'know how else to easily get a Maxim or Cypress part in there doing support for the power recovery function (though soldering one or the appropriate Improved Support Passives into the Mac sounds like a likely win.) How stuck with pants-free one-shot administration are you; I mean, Trader Joe's people can deliver the sheepie jeggings and add the device, right?