corpnewt / USBMap

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

What are Types of Ports? #37

Open walteweiss opened 2 years ago

walteweiss commented 2 years ago

The documentation, list 9 says it this way:

Go into the P. Edit & Create USBMap.kext menu and change the types to match the physical port types and toggle which ports (up to 15) you want to preserve.

Okay, so in the terminal, while using the tool, it says:

But… what is the type?

I assume the type is written with big and small letters, so it's why it's Tt there. Or not?

Is it S or A?

Is it 2 and 3?

Is it HS and SS?

Is it H plus s and S plus s?

Is it always T plus only different type in the end of the line?


In my listing I have it written this way:

[#]  1. HS01 | AppleUSB20XHCIPort |  1 (01000000) | 14100000 | Type 3
    Front-Left-USB2
...
[#] 18. SS04 | AppleUSB30XHCIPort | 19 (13000000) | 14200000 | Type 3
    Back-Down-6-USB3

So what a type is here? HS and SS in the beginning of the line, or the number after each Type word? I have 3 for all the ports I have.

I assume this step is needed, that's why it's written. But I have absolutely no idea what does it do here, why won't I skip it and how to make it.

Would be great to explain.

walteweiss commented 2 years ago

I see there is an issue #1 here, which reflects a similar subject, but there is no answer to what should be instead of those T and t.

walteweiss commented 2 years ago

I found that when I use USBMap.command and USBMapInjectorEdit.command the interfaces are slightly different. And in the latter, there is a kind of help when you press T, which shows it this way:

0: Type A connector
1: Mini-AB connector
2: ExpressCard
3: USB 3 Standard-A connector
4: USB 3 Standard-B connector
5: USB 3 Micro-B connector
6: USB 3 Micro-AB connector
7: USB 3 Power-B connector
8: Type C connector - USB2-only
9: Type C connector - USB2 and SS with Switch
10: Type C connector - USB2 and SS without Switch
11 - 254: Reserved
255: Proprietary connector

Per the ACPI 6.2 Spec.

So

Ok. That suggests that there's a number. So, is my latest assumption correct, and I need to use letter T, then ports, then 0 or 3?

E.g.

walteweiss commented 2 years ago

Yes, it works when I did T:1,3,4,5,6,10,11:0. Also it works when later I did T:7:0, so it works like a toggle.

The documentation needs to be clarified, as it’s unclear on most steps, and only trials and errors help. I may try to contribute when I understand this better myself.

walteweiss commented 2 years ago

Also, may be an off-topic, but what type should it be for Bluetooth/Wi-Fi module? The line in the tool looks like this:

[#]  7. HS07 | AppleUSB20XHCIPort |  7 (07000000) | 14700000 | Type 3
    Bluetooth-WiFi
    - Bluetooth USB Host Controller

It shows as HS, not SS, but if I’ll mistakenly make it HS, when it’s SS, could that make it slower somehow? Like forcing it to use USB 2 (HS) instead of USB 3 (SS).

walteweiss commented 2 years ago

In the end of the Dortania’s USB Mapping with huge banner:

This guide is outdated, see USBMap's README for updated information until this guide is rewritten.

In the end of the page there is the info about those types, so the primary part from my many questions is already answered. I suggest to mention the number somewhere, as it’s unclear for novices, but as you need to map your ports just once, everyone is a novice.

The Bluetooth is unclear to me at this point, as it states it should be 255, not 0 or 3.

Right now I have it as 3, not 255, and it works very well. I’m going to update it to 255 right now, just in case. I assume this part is not outdated.

walteweiss commented 2 years ago

So, summarizing the long post. I think it may be closed, as my issue was solved, by trials and errors.

But before doing that I would recommend to add some info for the type somewhere (at least Readme.md)

Maybe add some more info in the tool, like that:

Change types using this formula T:1,2,3,4,5:t where t is the type (number from 0 to 10, or 255, see the documentation)

But where is that documentation?

or

Change types using this formula T:1,2,3,4,5:t where t is the type (number from 0 to 10, or 255), e.g. T:1:0 for USB-2 A port or T:16:3 for USB-3 A port.


Also, one question is still relevant:

What if we won’t do that? What’s the difference?

corpnewt commented 2 years ago

Hey there - it seems that you've found out what the type values are for (they represent the physical port the port personality is attached to). Yes, type 0 is for USB 2 Type-A, and type 3 is for USB 3 Type-A ports. Worth noting that USBMap also has a T menu in the P. Edit & Create USBMap.kext menu which displays the same table as USBMapInjectorEdit (relevant code linked here).

As for why we set the types - macOS uses that information to determine whether things can be hot-plugged (plugged in after boot), and setting proper port types can help with some sleep issues.

Regarding documentation - I've been trying to get the drive to write a full fledged guide on the topic - but there's tons to cover, and I haven't gotten around to it yet. I know it's difficult to locate at times, and there are some cyclic sources out there. If you have other questions, feel free to ask here, and if I know the answers I'll chime in though.

-CorpNewt