# aaos-hardware-usb **Repository Path**: hanhai-modules/aaos-hardware-usb ## Basic Information - **Project Name**: aaos-hardware-usb - **Description**: 来自黑芝麻智能科技(bstai)瀚海(hanhai)的hardware-usb组件,用于管理设备端与主机端的 USB 功能,负责 USB 设备枚举、角色切换及与上层框架的通信。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: RC_IVI_1.1.0 - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-04-26 - **Last Updated**: 2025-12-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Stat The master branch is outdate. Please refer to the latest branch. USB HAL Implementation (Based on hardware/interfaces/usb/1.3 and gadget/1.2) # Overview This module implements the USB HAL for Android Automotive OS (AAOS), based on: USB HAL v1.3 — Host-side management (path: hardware/interfaces/usb/1.3/) USB Gadget HAL v1.2 — Device-side management (path: hardware/interfaces/usb/gadget/1.2/) It provides the following core features: USB Port Reset Role Switching (data / power) Port Status Query and Callback Notifications USB Gadget Configuration and Function Switching The goal is to provide a reliable and testable USB subsystem for AAOS, enabling robust management of host and device modes in automotive environments. Directory Layout ``` ├── usb │   ├── Android.bp │   ├── LICENSE │   ├── README │   ├── Usb.cpp │   ├── Usb.h │   ├── android.hardware.usb@1.3-service.bst.rc │   ├── android.hardware.usb@1.3-service.bst.xml │   ├── gadget │   │   ├── Android.bp │   │   ├── UsbGadget.cpp │   │   ├── UsbGadget.h │   │   ├── android.hardware.usb.gadget@1.2-service.bst.rc │   │   ├── android.hardware.usb.gadget@1.2-service.bst.xml │   │   ├── lib │   │   │   ├── Android.bp │   │   │   ├── MonitorFfs.cpp │   │   │   ├── UsbGadgetUtils.cpp │   │   │   └── include │   │   │   └── UsbGadgetCommon.h │   │   └── service.cpp │   └── service.cpp ``` Key Interfaces USB HAL (v1.3) | Function | Description | | --------------------------------------------------------------- | ---------------------------------------------------- | | `switchRole(const std::string &portName, const PortRole &role)` | Switch data or power role | | `queryPortStatus()` | Retrieve the current state of all USB ports | | `enableContaminantPresenceDetection()` | Enable contaminant (moisture) detection | | `enableUsbData()` | Enable or disable USB data path | USB Gadget HAL (v1.2) | Function | Description | | ---------------------------------------------------------------------------- | ------------------------------------------------ | | `setCurrentUsbFunctions(uint64_t functions, bool charging, int64_t timeout)` | Configure Gadget functions (MTP, ADB, AOA, etc.) | | `reset()` | Reset gadget device state | | `getCurrentUsbFunctions()` | Get the currently active functions | # Notes Reset logic may vary by SoC (different PHY or hub control). If not supported, return Status::NOT_SUPPORTED. Frequent port resets can interrupt Android Auto / CarPlay sessions. Version Info | Item | Version | | -------------- | ------------------------------------ | | USB HAL | v1.3 | | USB Gadget HAL | v1.2 | | Target | Android Automotive OS (Android 13 +) | | Author | bst |