sickcodes / osx-serial-generator

Mac Serial Generator - Generate complete sets of Serial Numbers for OSX-KVM, Docker-OSX and of course, OpenCore.
GNU General Public License v3.0
1.57k stars 132 forks source link

Getting USB to work #4

Closed mlozier closed 2 years ago

mlozier commented 3 years ago

This script is awesome!! I'm having difficulty getting USB to work. I want to connect an iPhone to my host laptop and have it show in the MacOS guest. Also, my laptop's webcam is connected to the USB bus -- I would like for it to show so that FaceTime can be used. Do you have any information on this?

Thanks so much!

sickcodes commented 3 years ago

Connecting the iPhone is near the top of the list.

Yes I believe you can passthrough a USB webcam quite easily.

I have only attempted the iPhone passthrough, a few months ago.

See for generic passthrough https://github.com/sickcodes/Docker-OSX#allow-usb-passthrough

Alternatively, it would be possibly to connect using Linux + checkra1n's usbmuxd hax and then passthrough the iPhone that way. I'll work on it after I finish up what I'm currently doing but here is what might work https://github.com/libimobiledevice/usbmuxd

sickcodes commented 3 years ago

Working guide here by Reddit user "stochad"

https://www.reddit.com/r/hackintosh/comments/f31wx0/macos_on_kvm_and_xcode_and_iphone_usb_passthrough/

On my laptop everything runs on the same IOMMU group for whatever strange reason... So I either cannot use any USB's and just the iPhone or passthrough. Working on this, however.

Snipped from: https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Setting_up_IOMMU

#!/bin/bash
shopt -s nullglob
for g in `find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V`; do
    echo "IOMMU Group ${g##*/}:"
    for d in $g/devices/*; do
        echo -e "\t$(lspci -nns ${d##*/})"
    done;
done;

Whichever group the iPhone is within, everything within that IOMMU group must be passed in together.

sickcodes commented 3 years ago

iPhone passthrough has been solved here: https://github.com/sickcodes/Docker-OSX/issues/133#issuecomment-836855901

I am yet to try it but it is confirmed working.

sickcodes commented 2 years ago

This is still an issue due to usb resetting in non-vfio mode.

However, if the stars align and your iommu groups are separated properly, or you have linux-zen with acs override patch (extremely dangerous security-wise), you can split the groups up and pass through the iPhone in an orderly fashion.

At your own risk, see dangers: https://vfio.blogspot.com/2014/08/iommu-groups-inside-and-out.html

Tutorial: https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Bypassing_the_IOMMU_groups_(ACS_override_patch)

Arch users easy-way to test:

Every time I return to this my keyboard/trackpad/external drives get sucked into the VM through the phat iommu group and need to reboot.

TL;DR, Laptops BTFO, Desktops OK

Cool way would be use usbredirserver: https://github.com/sickcodes/dock-droid#passthrough-android-webcam-camera-over-the-network

sickcodes commented 2 years ago

Interesting article from @MacMiniVault about USB redirections: https://www.macminivault.com/sharing-a-usb-device-with-a-remote-mac/

I swear we should be able to just literally usb redir the iPhone like this lol https://github.com/sickcodes/dock-droid#passthrough-android-webcam-camera-over-the-network

sickcodes commented 2 years ago

This has now been fixed, uploading docs soon

https://github.com/sickcodes/Docker-OSX/issues/36

sickcodes commented 2 years ago

Fixed in https://github.com/sickcodes/Docker-OSX/commit/911dad8b58b08a4d1a984527b745ede5fd88d017

For webcams, use https://github.com/sickcodes/dock-droid#docker-virtual-machine-webcam