Functional Debugging for the USB OTG Port on the RK3568 Platform

Validated and debugged the Device Tree code for the USB subsystem. Through in-depth analysis of the hardware principles of plug-and-play, the configuration was optimized to the best possible solution for the existing hardware: forcing the port into Host mode, thereby removing support for device-mode connections to ensure maximum product functionality and stability.

Project Overview

Background In a custom project based on the Rockchip RK3568, the objective was to re-evaluate the on-board USB interfaces using the public SDK and resolve an issue where the on-board USB 3.0 OTG (Type-A) port could not correctly recognize U-disks and other Host-mode devices under the default BSP configuration.

My Role and Contributions: As the BSP engineer for the project, I was solely responsible for diagnosing and resolving this USB functionality issue. My core contributions include:

  • Executed a systematic troubleshooting process, covering everything from hardware schematic verification, functional validation, and fault analysis to kernel Device Tree (DTS) code development, debugging, sysfs runtime state analysis, and performance baseline testing.
  • Led and implemented the solution: Verified the operation of two USB-A ports and one USB-C port against the product’s hardware schematics. The final solution was established by modifying the Device Tree (DTS): forcibly changing the dr_mode of the usbdrd_dwc3 controller from "otg" to "host".
  • Pinpointed the root cause: The ID pin of the OTG port was not present in the current hardware design, which prevented the controller from automatically detecting plug-in events and switching between Host/Device modes.
  • Completed full performance and functional validation, ensuring that the modified port not only reliably recognized devices but also achieved data transfer speeds compliant with the USB 3.0 standard.
  • Documented the entire debugging process and technical analysis into a detailed technical report, providing a clear reference for similar issues in the future.

My Methodology: Embedded Peripheral Debugging Workflow

This debugging effort followed a standardized diagnostic workflow, moving from the surface level to the core and from software to hardware:

  1. Documentation and Circuit Functional Analysis:

    • Studied the RK3568 Technical Reference Manual (TRM) to understand its USB subsystem architecture (including 2x USB 3.0 controllers, OHCI/EHCI controllers, Combo PHY, etc.).
    • Cross-referenced the hardware schematics to confirm the physical connections of the OTG port, paying special attention to the ID and VBUS pins.
    • Mapped out the data flow paths for the two USB-A ports and one USB-C port.
  2. Device Tree (DTS) & Driver Mapping:

    • Conducted an in-depth analysis of chip-level device tree files like rk3568.dtsi to map the configurations and relationships between core nodes such as usbdrd30 (OTG), usbhost30 (Host), and usb2phy.
    • Clarified the phys property references between controllers and PHYs, summarizing the findings in a table.
  3. Runtime State Diagnosis:

    • Utilized the extcon interface in sysfs (/sys/class/extcon/extcon0) to check the kernel’s real-time perception of the OTG port state (USB-HOST=0), which confirmed the hypothesis that it was not entering Host mode.
    • Revisited the hardware schematics to study the plug-in detection principles for USB-A, mini-USB, micro-USB, and Type-C interfaces to find a solution.
  4. Solution Implementation & Verification:

    • In the board-level DTS file, created an overlay node for &usbdrd_dwc3 and forcibly set its dr_mode property to "host".
    • Recompiled and flashed the firmware, then re-verified the fix by testing with hdparm.
    • With the SoC’s USB port acting as a host, it rejects connections from any other host-mode devices and supplies power. Therefore, firmware upgrades (a typical device-mode application) were re-routed to be triggered by an external button press to enter Maskrom mode.
    • After the system successfully boots, the USB-A port functions as a standard host port.
  5. Technical Summarization and Documentation:


Project Outcomes

  • Functionality Restored: The OTG port can now reliably recognize U-disks and other USB host devices.
  • Performance Goals Met: After the fix, tests using hdparm -t /dev/sda showed the port’s read speed restored to ~48MB/s, in line with the USB 3.0 standard.
  • Solution Hardened: The final DTS modification was merged into the product’s codebase, becoming the standard configuration for this hardware.
  • Knowledge Capitalized: The complete debugging process, code analysis, and related materials were organized and archived.

Tech Stack & Tools

  • Hardware Platform: Rockchip RK3568 SoC
  • Software Environment: Linux Kernel 5.10, Buildroot
  • Core Technologies: Device Tree (DTS), USB 2.0/3.0 Subsystem, OTG, XHCI/EHCI/OHCI, Kernel extcon Framework
  • Debugging Tools: hdparm, sysfs, dmesg, Serial Console