使用DWC3模块将USB-C端口置于主机模式

使用DWC3模块将USB-C端口置于主机模式

我有一个项目,其中包括使用运行 Ubuntu 服务器的设备,该设备将通过 USB-C/USB-A 电缆连接到 Windows 计算机。 USB-C 将连接 Ubuntu 设备,USB-A 连接至 Windows 计算机。然后,PC 将通过该电缆将数据发送到 Ubuntu 模拟大容量存储。

我必须对 BIOS、ACPI 或其他方面进行哪些更改才能实现此目的?

sudo lspci -nn -d ::0c03 -v为我提供了这个输出:

00:14.0 USB controller [0c03]: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller [8086:9d2f] (rev 21) (prog-if 30 [XHCI])
        DeviceName: Onboard - Other
        Subsystem: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller [8086:7270]
        Flags: bus master, medium devsel, latency 0, IRQ 125
        Memory at df530000 (64-bit, non-prefetchable) [size=64K]
        Capabilities: [70] Power Management version 2
        Capabilities: [80] MSI: Enable+ Count=1/8 Maskable- 64bit+
        Kernel driver in use: xhci_hcd

00:14.1 USB controller [0c03]: Intel Corporation Device [8086:9d30] (rev 21) (prog-if fe [USB Device])
        DeviceName: Onboard - Other
        Subsystem: Intel Corporation Device [8086:7270]
        Flags: bus master, fast devsel, latency 0, IRQ 17
        Memory at df000000 (64-bit, non-prefetchable) [size=2M]
        Memory at df54f000 (64-bit, non-prefetchable) [size=4K]
        Capabilities: [80] Power Management version 3
        Capabilities: [90] Vendor Specific Information: Len=14 <?>
        Kernel driver in use: dwc3-pci
        Kernel modules: dwc3_pci

编辑:

我已经将该g_mass_storage模块加载到我的内核和CONFIG_USB_DWC3_DUAL_ROLE=y.config 文件中。

我尝试debugfs使用您的命令挂载虚拟文件系统@telcoM,并得到以下输出:

mount: /sys/kernel/debug: none already mounted on /sys/fs/bpf.

我认为这不是问题,但我只是想指出以防万一。

我检查了我的/sys/kernel/debug目录,但找不到任何<hexa number>.usb目录。我在 中根本找不到任何文件/sys/fs/bpf

编辑2:

这是我的 ACPI 配置:

BIOS-e820: [mem 0x00000000851cb000-0x00000000851cbfff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x000000008c6ea000-0x000000008ca93fff] ACPI NVS
[    0.013210] ACPI: Early table checksum verification disabled
[    0.013214] ACPI: RSDP 0x00000000000F05B0 000024 (v02 ALASKA)
[    0.013218] ACPI: XSDT 0x000000008C6EA0B0 0000DC (v01 ALASKA A M I    01072009 AMI  00010013)
[    0.013224] ACPI: FACP 0x000000008C713958 000114 (v06 ALASKA A M I    01072009 AMI  00010013)
[    0.013230] ACPI: DSDT 0x000000008C6EA220 029734 (v02 ALASKA A M I    01072009 INTL 20160422)
[    0.013233] ACPI: FACS 0x000000008CA93F00 000040
[    0.013236] ACPI: APIC 0x000000008C713A70 000084 (v03 ALASKA A M I    01072009 AMI  00010013)
[    0.013239] ACPI: FPDT 0x000000008C713AF8 000044 (v01 ALASKA A M I    01072009 AMI  00010013)
[    0.013242] ACPI: FIDT 0x000000008C713B40 00009C (v01 ALASKA A M I    01072009 AMI  00010013)
[    0.013246] ACPI: MCFG 0x000000008C713BE0 00003C (v01 ALASKA A M I    01072009 MSFT 00000097)
[    0.013249] ACPI: SSDT 0x000000008C713C20 000359 (v01 SataRe SataTabl 00001000 INTL 20160422)
[    0.013252] ACPI: SSDT 0x000000008C713F80 003165 (v02 SaSsdt SaSsdt   00003000 INTL 20160422)
[    0.013256] ACPI: HPET 0x000000008C7170E8 000038 (v01 INTEL  KBL-ULT  00000001 MSFT 0000005F)
[    0.013259] ACPI: SSDT 0x000000008C717120 0011AA (v02 INTEL  Ther_Rvp 00001000 INTL 20160422)
[    0.013262] ACPI: SSDT 0x000000008C7182D0 0009B3 (v02 INTEL  xh_rvp07 00000000 INTL 20160422)
[    0.013265] ACPI: UEFI 0x000000008C718C88 000048 (v01 ALASKA A M I    00000002      01000013)
[    0.013269] ACPI: SSDT 0x000000008C718CD0 0017AE (v02 CpuRef CpuSsdt  00003000 INTL 20160422)
[    0.013272] ACPI: LPIT 0x000000008C71A480 000094 (v01 INTEL  KBL-ULT  00000000 MSFT 0000005F)
[    0.013275] ACPI: SSDT 0x000000008C71A518 000141 (v02 INTEL  HdaDsp   00000000 INTL 20160422)
[    0.013278] ACPI: SSDT 0x000000008C71A660 00029F (v02 INTEL  sensrhub 00000000 INTL 20160422)
[    0.013282] ACPI: SSDT 0x000000008C71A900 003002 (v02 INTEL  PtidDevc 00001000 INTL 20160422)
[    0.013285] ACPI: SSDT 0x000000008C71D908 000517 (v02 INTEL  TbtTypeC 00000000 INTL 20160422)
[    0.013288] ACPI: SSDT 0x000000008C71DE20 0002E9 (v02 INTEL  Wwan     00000001 INTL 20160422)
[    0.013291] ACPI: DBGP 0x000000008C71E110 000034 (v01 INTEL           00000002 MSFT 0000005F)
[    0.013294] ACPI: DBG2 0x000000008C71E148 000054 (v00 INTEL           00000002 MSFT 0000005F)
[    0.013297] ACPI: DMAR 0x000000008C71E1A0 0000B0 (v01 INTEL  EDK2     00000001 INTL 00000001)
[    0.013300] ACPI: ASF! 0x000000008C71E250 0000A0 (v32 INTEL   HCG     00000001 TFSM 000F4240)
[    0.013304] ACPI: WSMT 0x000000008C71E2F0 000028 (v01 ALASKA A M I    01072009 AMI  00010013)
[    0.013312] ACPI: Local APIC address 0xfee00000
[    0.046794] ACPI: PM-Timer IO Port: 0x1808
[    0.046796] ACPI: Local APIC address 0xfee00000
[    0.046803] ACPI: LAPIC_NMI (acpi_id[0x01] high edge lint[0x1])
[    0.046804] ACPI: LAPIC_NMI (acpi_id[0x02] high edge lint[0x1])
[    0.046805] ACPI: LAPIC_NMI (acpi_id[0x03] high edge lint[0x1])
[    0.046806] ACPI: LAPIC_NMI (acpi_id[0x04] high edge lint[0x1])
[    0.046840] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.046841] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.046843] ACPI: IRQ0 used by override.
[    0.046844] ACPI: IRQ9 used by override.
[    0.046846] Using ACPI (MADT) for SMP configuration information
[    0.046848] ACPI: HPET id: 0x8086a201 base: 0xfed00000
[    0.112942] ACPI: Core revision 20190816
[    0.145825] PM: Registering ACPI NVS region [mem 0x851cb000-0x851cbfff] (4096 bytes)
[    0.145825] PM: Registering ACPI NVS region [mem 0x8c6ea000-0x8ca93fff] (3842048 bytes)
[    0.145825] ACPI: bus type PCI registered
[    0.145825] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
[    0.149423] ACPI: Added _OSI(Module Device)
[    0.149425] ACPI: Added _OSI(Processor Device)
[    0.149426] ACPI: Added _OSI(3.0 _SCP Extensions)
[    0.149428] ACPI: Added _OSI(Processor Aggregator Device)
[    0.149431] ACPI: Added _OSI(Linux-Dell-Video)
[    0.149433] ACPI: Added _OSI(Linux-Lenovo-NV-HDMI-Audio)
[    0.149435] ACPI: Added _OSI(Linux-HPI-Hybrid-Graphics)
[    0.202623] ACPI: 11 ACPI AML tables successfully acquired and loaded
[    0.211141] ACPI: Dynamic OEM Table Load:
[    0.211150] ACPI: SSDT 0xFFFF9F1A65816800 00060F (v02 PmRef  Cpu0Ist  00003000 INTL 20160422)
[    0.213026] ACPI: \_PR_.PR00: _OSC native thermal LVT Acked
[    0.214941] ACPI: Dynamic OEM Table Load:
[    0.214948] ACPI: SSDT 0xFFFF9F1A64CAEC00 0003FF (v02 PmRef  Cpu0Cst  00003001 INTL 20160422)
[    0.216719] ACPI: Dynamic OEM Table Load:
[    0.216725] ACPI: SSDT 0xFFFF9F1A64C78480 0000BA (v02 PmRef  Cpu0Hwp  00003000 INTL 20160422)
[    0.218405] ACPI: Dynamic OEM Table Load:
[    0.218411] ACPI: SSDT 0xFFFF9F1A64EAC800 000628 (v02 PmRef  HwpLvt   00003000 INTL 20160422)
[    0.220598] ACPI: Dynamic OEM Table Load:
[    0.220607] ACPI: SSDT 0xFFFF9F1A6532B000 000D14 (v02 PmRef  ApIst    00003000 INTL 20160422)
[    0.223342] ACPI: Dynamic OEM Table Load:
[    0.223349] ACPI: SSDT 0xFFFF9F1A64CAD400 000317 (v02 PmRef  ApHwp    00003000 INTL 20160422)
[    0.225173] ACPI: Dynamic OEM Table Load:
[    0.225180] ACPI: SSDT 0xFFFF9F1A64CAF800 00030A (v02 PmRef  ApCst    00003000 INTL 20160422)
[    0.230370] ACPI: Interpreter enabled
[    0.230422] ACPI: (supports S0 S3 S4 S5)
[    0.230425] ACPI: Using IOAPIC for interrupt routing
[    0.230476] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    0.231867] ACPI: Enabled 6 GPEs in block 00 to 7F
[    0.241288] ACPI: Power Resource [WRST] (on)
[    0.263566] ACPI: Power Resource [FN00] (off)
[    0.263696] ACPI: Power Resource [FN01] (off)
[    0.263828] ACPI: Power Resource [FN02] (off)
[    0.263951] ACPI: Power Resource [FN03] (off)
[    0.264074] ACPI: Power Resource [FN04] (off)
[    0.265863] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-fe])
[    0.277730] ACPI: PCI Interrupt Link [LNKA] (IRQs 3 4 5 6 10 *11 12 14 15)
[    0.277808] ACPI: PCI Interrupt Link [LNKB] (IRQs 3 4 5 6 *10 11 12 14 15)
[    0.277882] ACPI: PCI Interrupt Link [LNKC] (IRQs 3 4 5 6 10 *11 12 14 15)
[    0.277956] ACPI: PCI Interrupt Link [LNKD] (IRQs 3 4 5 6 10 *11 12 14 15)
[    0.278030] ACPI: PCI Interrupt Link [LNKE] (IRQs 3 4 5 6 10 *11 12 14 15)
[    0.278103] ACPI: PCI Interrupt Link [LNKF] (IRQs 3 4 5 6 10 *11 12 14 15)
[    0.278176] ACPI: PCI Interrupt Link [LNKG] (IRQs 3 4 5 6 10 *11 12 14 15)
[    0.278250] ACPI: PCI Interrupt Link [LNKH] (IRQs 3 4 5 6 10 *11 12 14 15)
[    0.279095] ACPI: bus type USB registered
[    0.279095] PCI: Using ACPI for IRQ routing
[    0.321967] pnp: PnP ACPI init
[    0.322408] system 00:00: Plug and Play ACPI device, IDs PNP0c02 (active)
[    0.322461] pnp 00:01: Plug and Play ACPI device, IDs PNP0303 PNP030b (active)
[    0.322520] pnp 00:02: Plug and Play ACPI device, IDs PNP0f03 PNP0f13 (active)
[    0.322736] system 00:03: Plug and Play ACPI device, IDs PNP0c02 (active)
[    0.322862] pnp 00:04: Plug and Play ACPI device, IDs PNP0b00 (active)
[    0.322912] system 00:05: Plug and Play ACPI device, IDs INT3f0d PNP0c02 (active)
[    0.323266] system 00:06: Plug and Play ACPI device, IDs PNP0c02 (active)
[    0.323337] system 00:07: Plug and Play ACPI device, IDs PNP0c02 (active)
[    0.323739] system 00:08: Plug and Play ACPI device, IDs PNP0c02 (active)
[    0.325460] system 00:09: Plug and Play ACPI device, IDs PNP0c02 (active)
[    0.326686] pnp: PnP ACPI: found 10 devices
[    0.716581] ACPI: Sleep Button [SLPB]
[    0.718428] ACPI: Power Button [PWRB]
[    0.720134] ACPI: Power Button [PWRF]
[    0.723097] ACPI: Thermal Zone [TZ00] (28 C)
[    0.724786] ACPI: Thermal Zone [TZ01] (30 C)
[    7.658677] ACPI: Video Device [GFX0] (multi-head: yes  rom: no  post: no)

答案1

您是在询问 USB 控制器的 OTG 功能,还是具体询问 BIOS 设置?

要回答前者,有必要知道您的机器上使用的是哪个 USB 控制器;它可能就像加载 USB 主机控制器驱动程序或 US“gadget”驱动程序模块一样简单。

对于后者,您应该指定计算机的品牌和型号,以便我们可以尝试查明是否有供应商提供的工具或其他方法可以在操作系统内更改 BIOS 设置。


您有两个 USB 控制器。第一个是芯片组内置的常规 USB3 控制器:

00:14.0 USB controller [0c03]: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller [8086:9d2f] 

第二个与你的问题更相关:

00:14.1 USB controller [0c03]: Intel Corporation Device [8086:9d30]
...
Kernel driver in use: dwc3-pci
Kernel modules: dwc3_pci

模块名称dwc3_pci表明它是一个DesignWare USB 3.0 双角色设备控制器。换句话说,这是一个控制器从主机角色切换到设备角色,反之亦然。

从这里我找到了角色切换过程的描述。请注意,它说:

动态更改操作模式对于调试目的很有用,但绝不应该在生产中使用。

您需要CONFIG_USB_DWC3_DUAL_ROLE在内核配置中选择所需的 USB Gadget 驱动程序,以实现您在设备角色中所需的功能,例如g_mass_storage使该系统充当 USB 存储设备的模块。

首先,您需要安装debugfs虚拟文件系统:

mount -t debugfs none /sys/kernel/debug

然后,您应该找到一个或多个名为 的目录/sys/kernel/debug/<some hexadecimal number>.usb。每个目录都将包含名为link_statemoderegdump的文件testmode。通过读取该mode文件,您将看到控制器当前正在运行的角色;通过写入该文件,您可以更改角色。

cd /sys/kernel/debug/<something>.usb
echo host > mode    # switch to host role
echo device > mode  # switch to device role

免责声明:我没有以任何方式实际使用此 USB 控制器的经验;这完全基于阅读我链接的文档。我可能错了。如果有人阅读本文了解更多信息,请随时编辑此答案。

相关内容