USB Host mode on Motorola Droid

本文介绍了一种使Motorola Droid支持USB主机模式的方法,通过简单的硬件改造即可实现。用户可以为Droid接入各种USB设备,如键盘等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

USB Host mode on Motorola Droid

http://www.tombom.co.uk/blog/?p=124

February 9th, 2010 by Chris in Uncategorized

Yes, it’s true – Android (at long last!) has access to USB Host mode. I had been waiting for this to happen on the Nexus 1 or N900 some time soon, but as it turns out it’s the Droid that takes the crown. It’s a neat little hack that I heard about at Shmoocon; I’d like to thank to Mike Kershaw from Kismet and Mike Baker from OpenWRT for sharing :) Here’s how it works.

The USB hardware on the Droid is actually capable of USB-OTG (meaning that it can act as both host and peripheral), however it only possesses a standard USB Micro-B port instead of the Micro-AB port that you would normally get from an OTG device (such as the N810). With a minimal amount of effort (and tolerance of a few bugs) it’s possible to enable the B port as a host interface (as OTG says you should be able to do), meaning it supplies power and acts as the bus controller. It’s actually pretty easy; I can easily think of about a hundred million ways to make this useful on the Droid (think: plug any USB hardware you like into your Droid, as long as it works in Linux it should work in Android).

You’ll need to make two things, a micro-dongle to enable the port (you plug it in during boot time) and a cable with the right connectors on each end (for connecting your peripheral). To do this you’ll need three cables:
- A car charging cable (off-the-shelf at the Verizon store)
- A Micro-USB cable (as above)
- A USB extender cable (the teeny ones that sometimes come free with USB keys work great)

Start with the car charging cable. Break open the micro-usb connector (it comes apart fairly easily) and look at the little PCB inside – there should be a single tiny surface-mount resistor and two wires from the charger cable. Unsolder both wires and the resistor, and then bridge the pads where the resistor used to be so that it’s completely shorted. The end result should look something like this:


This is your micro-dongle.

Next up, you need to make your connector cable. Cut the end off the USB extender cable, you want to keep the socket end and discard the plug. Cut the micro-usb cable as well, but on this one you want to keep the plug and discard the socket. You should now have a micro-usb plug that’ll fit into your droid and a usb socket that you could plug a memory stick into. Strip the wires off the ends of both cables and join them to each other, connecting like colours (and the shield) together. When it’s finished it should look something like this:


(You’ll obviously want to insulate the wires afterwards, this is just to show how the colours are connected).

You don’t even need to root your droid in order to verify it works (although I rooted mine using the instructions here anyway), just do the following:
- Turn your Droid off
- Plug the micro-dongle into the USB port
- Turn the droid on
- Unplug the micro-dongle as soon as the Motorola logo disappears (as the Droid lodo is appearing).
Once your Droid is booted, pull up a terminal and look at dmesg – after plugging in your USB peripheral using the cable you made earlier you should see the usual kernel notifications about new USB devices being connected; they’ll also turn on (or start charging) if they’re powered by USB. You’ll only be able to plug in one peripheral before the port reverts to peripheral mode; you’ll have to reboot with the micro-dongle if you want to go back into host mode. Also, if you leave the micro-dongle plugged in too long it triggers another bug, the port gets stuck supplying power to devices but not actually recognising them. Hopefully the drivers are sufficiently open-source that these are easy bugs to squash, and that dynamically switching between host mode and peripheral mode won’t be too hard to add either.

Unsurprisingly there’s not much driver support for USB peripherals in the standard Android kernel (I couldn’t mount a USB key for example), but it’s easy enough for the ROM developers to start adding drivers – I’ll be flashing Sholes shortly to see how it does. Expect to see a whole new generation of Android hackery to start soon :)

//edit: Andrew de Quincey has apparently also gotten Host mode working on the Hero, and pointed out that while the stock Android kernel may not support USB storage it does support USB keyboards. Plugging one into my Droid using the steps above, it Just Works. It’s kinda nice to have a proper keyboard on a cellphone…:)


<think>我们正在处理关于USB主机模式配置和使用的问题。根据用户提供的引用,我们可以总结出以下几点关键信息:1.引用[1]和[2]涉及usb_modeswitch的移植和usb-storage驱动程序的编译,这通常用于切换USB设备的模式(例如从存储设备切换到调制解调器)以及加载USB存储驱动。2.引用[3]提到了在RK3588Android13的TvSetting中增加USB模式切换(Host/OTG)的界面修改,这直接关联到用户对USB主机模式配置的需求。3.引用[4]提到了一款USB-C控制器(VL102),它支持DisplayPort Alt-mode和PD3.0,这可能与USBType-C接口的多种模式切换有关。用户的问题集中在USB主机模式的配置和使用上。因此,我们需要从以下几个方面进行回答:-什么是USB主机模式(HostMode)? -如何配置USB主机模式(包括硬件和软件层面)?-在Linux系统中如何配置(包括驱动编译和加载)? -在Android系统中如何配置(特别是引用[3]中提到的在设置界面添加切换选项)?-常见问题及调试方法。由于引用[3]提供了具体的Android代码修改示例,我们可以重点解释在Android系统中如何添加USB模式切换的设置选项。 下面开始组织回答。</think>### USB主机模式配置与使用指南 USB主机模式(Host Mode)允许设备作为主控制器管理外接USB设备(如键盘、存储设备等)。以下是配置与使用的关键步骤: #### 一、硬件层配置 1. **硬件支持**:设备需具备USB OTG(On-The-Go)物理接口,支持ID引脚检测(用于主机/设备模式切换) 2. **控制器要求**: - 内核需启用USB主机控制器驱动(如`CONFIG_USB_EHCI_HCD`) - 存储设备需加载`usb-storage`模块(引用[2]) #### 二、Linux系统配置 1. **内核配置**: ```bash # 启用USB主机模式核心支持 CONFIG_USB=y CONFIG_USB_SUPPORT=y # 启用存储设备驱动(编译为模块) CONFIG_USB_STORAGE=m ``` 2. **动态加载驱动**: ```bash sudo modprobe usb-storage # 加载USB存储驱动 sudo modprobe ehci-hcd # 加载USB 2.0主机控制器 ``` 3. **模式切换工具**: - 使用`usb_modeswitch`切换设备模式(引用[1]): ```bash ./configure --prefix=/path/to/install --enable-shared ``` #### 三、Android系统配置(以RK3588为例) 1. **添加系统设置选项**(引用[3]): ```xml <!-- 在res/values/strings.xml中添加 --> <string name="usb_mode_configuration_title">USB Mode</string> <string name="select_usb_configuration_title">Select USB Configuration</string> ``` 2. **模式切换逻辑**: - 通过`UsbManager.setCurrentFunction()`API切换`UsbManager.FUNCTION_HOST` #### 四、Type-C高级配置 对于USB-C接口: - 需支持Alt-mode协议(如DisplayPort Alt-mode) - 使用PD 3.0控制器(如VL102芯片)协商供电和数据角色(引用[4]) #### 五、验证与调试 1. **检查当前模式**: ```bash cat /sys/kernel/debug/usb/devices # 查看USB设备树 ``` 2. **内核日志分析**: ```bash dmesg | grep usb # 检查USB设备枚举过程 ``` **典型问题解决方案**: - **外设无法识别**:检查`dmesg`输出,确认驱动加载状态 - **供电不足**:使用外接电源的USB Hub - **模式切换失败**:更新`usb_modeswitch`配置数据库
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值