NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

USB Test Mode on DWC3

From Texas Instruments Wiki
Jump to: navigation, search

The USB2.0 Specs (Section 7.1.20) define five test modes to facilitate compliance testing.

  • Test_SE0_NAK
  • Test_J
  • Test_K
  • Test_Packet
  • Test_Force_Enable

The DWC3 controller supports the test modes in both device and host mode. The following sections use AM437x EVM as an example to explain how to enter the test mode in DWC3 device or host mode in Linux. The AM437x EVM by default has USB0 port in device mode and USB1 port in host mode.


In Device Mode[edit]

The Linux DWC3 driver has the debugfs entry 'testmode' for each controller. Writing one of the following strings to 'testmode' entry enables corresponding test mode.

  • test_se0_nak
  • test_j
  • test_k
  • test_packet
  • test_force_enable

For example, the steps to generate the test packet on USB0 port of AM437x EVM:

 - load a gadget driver:
   # modprobe g_zero
 - connect the USB0 port to a USB host port
 - start test packet:
   # echo test_packet > /sys/kernel/debug/48390000.usb/testmode

The testmode debugfs entry for USB1 port is /sys/kernel/debug/483d0000.usb/testmode.

If the setup is not allowed to connect the DWC3 USB port to a host, the port could be configured to host mode using the following patch then use the instructions in the next section to enter the test mode in xHCI USB 2.0 host mode.

diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index 9f08e4d..88154b8 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -984,7 +984,7 @@
                                phys = <&usb2_phy1>;
                                phy-names = "usb2-phy";
                                maximum-speed = "high-speed";
-                               dr_mode = "peripheral";
+                               dr_mode = "host";
                        };
                };

In Host Hode[edit]

The Linux DWC3 driver does not have a user space interface for host port test mode yet as of now, but we could directly manipulate the registers to enter the test mode for the USB2.0 host port.

The xHCI Specs Section 4.19.6 describes the requirement for "Port Test Modes".

For exampe, the set of commands to trigger test packet mode for AM437x EVM USB1 port is

  # devmem2 0x483D0420 w 0xA0
  # devmem2 0x483D0020 w 0x04
  # devmem2 0x483D0424 w 0x40000000

The bit[31:28] of the last register 0x483D0424 specifies the test modes. The folllowing lists the bit values and corresponding test modes. Refer to the xHCI Specs Section 5.4.9.2 for the register details.

value Test Mode
0 Test mode not enabled
1 Test J_STATE
2 Test K_STATE
3 Test SE0_NAK
4 Test Packet
5 Test FORCE_ENABLE
6-14 Reserved
15 Port Test Control Error

The registers for USB0 port of AM437x are 0x48390420, 0x48390020, 0x48390424 respectively.

Archived[edit]

Sitara Linux SDK 08.00.00.00

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article USB Test Mode on DWC3 here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article USB Test Mode on DWC3 here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article USB Test Mode on DWC3 here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article USB Test Mode on DWC3 here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article USB Test Mode on DWC3 here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article USB Test Mode on DWC3 here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article USB Test Mode on DWC3 here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article USB Test Mode on DWC3 here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article USB Test Mode on DWC3 here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity