NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ADB and MTP not working for Android phone on NetBSD



When I connect an Android 4.2 device on a NetBSD 10.1 install, running
adb devices doesn't show the device and MTP doesn't work. Resources
about this is scarce on the internet so I'm asking here.

After I unlock PIN on phone and connect the device, I see something like
this on dmesg:

$ doas dmesg | tail
...
[ 36057.840684] umass1: MediaTek (0x0bb4) MT65xx Android Phone (0x0c03), rev 2.00/2.55, addr 3
[ 36057.840684] umass1: using SCSI over Bulk-Only
[ 36057.840684] scsibus1 at umass1: 2 targets, 2 luns per target
[ 36057.860684] sd1 at scsibus1 target 0 lun 0: <Linux, File-CD Gadget, 0000> disk removable
[ 36057.860684] sd1: drive offline
[ 36057.860684] sd2 at scsibus1 target 0 lun 1: <Linux, File-CD Gadget, 0000> disk removable
[ 36057.860684] sd2: drive offline


I had some success seeing the files.

Please note that on phone when I tap on notification titled "Touch for
other USB options." it shows "USB storage" is selected. The above output
is for that mode. It changes when MTP is selected as I'll show later.

From notification I tap "USB connected", then tap on "Turn on USB
storage". Nothing adds to dmesg but I can access files like this:


$ doas mbrlabel /dev/sd1
Found MSDOS partition; size 7736320 (3777 MB), offset 8192
  skipping existing MSDOS partition at slot e.

5 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
d: 7744512 0 unused 0 0 # (Cyl. 0 - 3781*) e: 7736320 8192 MSDOS # (Cyl. 4 - 3781*)

Not updating disk label.
$ doas mkdir -p /media/user/android
$ doas chown user:users /media/user/android
$ doas mount_msdos /dev/sd1e /media/user/android/
$ df /media/user/android/
Filesystem     512-blocks         Used        Avail %Cap Mounted on
/dev/sd1e 7728128 6375872 1352256 82% /media/user/android


My non root username is "user" here. Going into file manager (in my case
pcmanfm) I see "android" on side panel and clicking it shows the files
as expected.


usbdevs shows:

$ doas usbdevs -d
...
  addr 3: MT65xx Android Phone, MediaTek
    umass1
...
$ doas usbdevs -dva 3
Controller /dev/usb0:
addr 3: high speed, self powered, config 1, MT65xx Android Phone(0x0c03), MediaTek(0x0bb4), rev 2.55(0x0255), serial _redacted_
  umass1
Controller /dev/usb1:
...


On phone, tapping notification labeled "Touch for other USB options."
and selecting "MTP", then reconnecting device shows this on dmesg:

[ 37891.934651] ugen0 at uhub2 port 1
[ 37891.934651] ugen0: MediaTek (0x0bb4) MT65xx Android Phone (0x0c02), rev 2.00/2.55, addr 3


MTP mode changes product id to 0x0c02.

This time usbdevs shows:

$ doas usbdevs -d
...
  addr 3: MT65xx Android Phone, MediaTek
    ugen0
$ doas usbdevs -dva 3
Controller /dev/usb0:
addr 3: high speed, self powered, config 1, MT65xx Android Phone(0x0c02), MediaTek(0x0bb4), rev 2.55(0x0255), serial _redacted_
  ugen0
Controller /dev/usb1:
...


Tried to test MTP. libmtp fails:

$ LIBMTP_DEBUG=2 mtp-detect   # from devel/libmtp package
LIBMTP_Set_Debug: Setting debugging level to 2 (0x02) (on)
libmtp version: 1.1.21

Listing raw device(s)
   No raw devices found.


ADB doesn't see the device:

$ adb devices -l   # from devel/android-tools-adb
List of devices attached



On Linux based distros:

$ cat /etc/udev/rules.d/11-android.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", MODE="0640", OWNER="user"
$ sudo udevadm control --reload-rules && sudo udevadm trigger

Some distros require adding user to certain groups. Then connecting
device shows up on adb.

Not sure how to make it work on NetBSD.

I can live without MTP as I can access files using USB storage mode, but
I need adb. Is there any way to get it working?



Home | Main Index | Thread Index | Old Index