corpnewt / USBMap

Python script for mapping USB ports in macOS and creating a custom injector kext.
MIT License
1.04k stars 88 forks source link

Not successfully changing port type #1

Closed riley21 closed 5 years ago

riley21 commented 5 years ago

Having difficulty changing usb port type from 3 to 255 for my internal usb 2. I have a bluetooth pcie card plugged into one of the ports, so sleep doesn't work unless I unplug it or change the port type to 255.

I've built my plist and changed them to type 255: https://i.imgur.com/f7lveax.png

But after a reboot, I don't think the ports have been correctly changed, as sleep still doesn't work, and when I rediscover the ports it lists them as type 3: https://i.imgur.com/eLD1dCJ.png

Anything super obvious I'm missing?

Thanks again for an awesome script!

Copy of my plist:


<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleGetInfoString</key>
    <string>v1.0</string>
    <key>CFBundleIdentifier</key>
    <string>com.corpnewt.USBMap</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>USBMap</string>
    <key>CFBundlePackageType</key>
    <string>KEXT</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>IOKitPersonalities</key>
    <dict>
        <key>iMac18,3-XHC</key>
        <dict>
            <key>CFBundleIdentifier</key>
            <string>com.apple.driver.AppleUSBHostMergeProperties</string>
            <key>IOClass</key>
            <string>AppleUSBHostMergeProperties</string>
            <key>IONameMatch</key>
            <string>XHC</string>
            <key>IOProviderClass</key>
            <string>AppleUSBXHCIPCI</string>
            <key>IOProviderMergeProperties</key>
            <dict>
                <key>port-count</key>
                <data>
                GgAAAA==
                </data>
                <key>ports</key>
                <dict>
                    <key>HS03</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        AwAAAA==
                        </data>
                    </dict>
                    <key>HS05</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        BQAAAA==
                        </data>
                    </dict>
                    <key>HS06</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        BgAAAA==
                        </data>
                    </dict>
                    <key>HS07</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        BwAAAA==
                        </data>
                    </dict>
                    <key>HS08</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        CAAAAA==
                        </data>
                    </dict>
                    <key>HS10</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        CgAAAA==
                        </data>
                    </dict>
                    <key>HS11</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>255</integer>
                        <key>port</key>
                        <data>
                        CwAAAA==
                        </data>
                    </dict>
                    <key>HS12</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>255</integer>
                        <key>port</key>
                        <data>
                        DAAAAA==
                        </data>
                    </dict>
                    <key>HS13</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        DQAAAA==
                        </data>
                    </dict>
                    <key>SS03</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        EwAAAA==
                        </data>
                    </dict>
                    <key>SS05</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        FQAAAA==
                        </data>
                    </dict>
                    <key>SS06</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        FgAAAA==
                        </data>
                    </dict>
                    <key>SS07</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        FwAAAA==
                        </data>
                    </dict>
                    <key>SS08</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        GAAAAA==
                        </data>
                    </dict>
                    <key>SS10</key>
                    <dict>
                        <key>UsbConnector</key>
                        <integer>3</integer>
                        <key>port</key>
                        <data>
                        GgAAAA==
                        </data>
                    </dict>
                </dict>
            </dict>
            <key>model</key>
            <string>iMac18,3</string>
        </dict>
    </dict>
    <key>OSBundleRequired</key>
    <string>Root</string>
</dict>
</plist>```
corpnewt commented 5 years ago

The port type doesn't change during discovery, as the script just guesses which type it thinks it should be by the controller it's on. I may remove that output at some point as it can be confusing. The code where the type is checked is below:

                # Find out which controller we're on
                if pnum > xhc_start and pnum < eh2_start:
                    # XHC Controller
                    ct = "XHC"
                    port = pnum - xhc_start
                    ty = 3
                elif pnum > eh2_start and pnum < eh1_start:
                    # EH02 Controller
                    ct = "EH02"
                    port = pnum - eh2_start
                    ty = 0
                else:
                    # EH01 Controller
                    ct = "EH01"
                    port = pnum - eh1_start
                    ty = 0

As you can see, the script just checks the controller, and assigns a type of either 0 or 3 depending on whether it's EHCI or XHCI. I may see if there's a way that I can validate the type - but I don't know that it would show up in ioreg. In the meantime, I'll omit the type output during discovery to avoid confusion.

-CorpNewt