Issue
I have an android device with usb ports. I'm trying to do an android application that stores a file to a usb stick. First, I need to validate it on an emulator before I can deploy it in the device. My problem is that the emulator doesn't mount well the usb stick. So far, I can detect the usb connection (in app and with lsusb) but I cannot find the path to save my file as the usb stick seems not to be mounted. To reproduce:
connect usb to pc:
$ lsusb
Bus 001 Device 016: ID ffff:5678
Create dev rules for this specific usb in /etc/udev/rules.d/99-usb-android.rules
:
SUBSYSTEM=="usb", ATTRS{idVendor}=="ffff", ATTRS{idProduct}=="5678", MODE="0666"
SUBSYSTEM=="usb_device", ATTRS{idVendor}=="ffff", ATTRS{idProduct}=="5678", MODE="0666"
Reload udev rules:
sudo udevadm control --reload-rules
Run the emulator with usb support:
emulator -avd x86-machine -qemu -usb -device usb-host,vendorid=0xffff,productid=0x5678
Once it starts I see some repeating errors on the dmesg
[ 36.300218] usb 1-1: reset full-speed USB device number 2 using uhci_hcd
[ 37.240093] usb 1-1: reset full-speed USB device number 2 using uhci_hcd
[ 38.180262] usb 1-1: reset full-speed USB device number 2 using uhci_hcd
[ 38.652826] sd 2:0:0:0: [sda] Unaligned partial completion (resid=4095, sector_sz=512)
[ 38.659008] sd 2:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[ 38.664371] sd 2:0:0:0: [sda] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[ 38.668527] print_req_error: I/O error, dev sda, sector 0
[ 38.671306] Buffer I/O error on dev sda, logical block 0, async page read
[ 38.674756] Dev sda: unable to read RDB block 0
[ 39.100212] usb 1-1: reset full-speed USB device number 2 using uhci_hcd
[ 40.040269] usb 1-1: reset full-speed USB device number 2 using uhci_hcd
However, I can see the usb if I connect to the shell
$ adb root
$ adb shell
emulator:# lsusb
Bus 001 Device 001: ID 1d6b:0001
Bus 001 Device 002: ID ffff:5678
and I have an app which recognizes when an usb key is connected and shows a message with its info. I have read in some questions that the usb stick is mounted in /mnt/media_rw/[HEX-NUM]
but I have nothing in that folder
emulator:/mnt/media_rw # ls
emulator:/mnt/media_rw #
Is the usb stick being really mounted? if not, how can I do it? thanks
Solution
I ran the emulator this way and it works now
./emulator @AVD_NAME -no-snapshot -qemu -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,vendorid=0xffff,productid=0x5678
Answered By - afvmil
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.