Wednesday, April 24, 2019
Monday, December 26, 2011
USB MTP Host mode
We are working on USB MTP host mode on android ICS.
1.) We have enabled USB FS at kernel level and we are building test application
“\frameworks\base\media\mtp\test\ => CameaBrowser.”
2.) CameraBrowser test application uses USB Host API, LibMTP and LibUSB and USBFS
We shown In diagram 1 shown below.
3.) For usb host hardware feature I am adding below file in system folder.
“system/etc/permissions/android.hardware.usb.host.xml”
4.) But CameraBrowser application, running on board, does not detect MTP device.
(I am using Acer tab as MTP device and board as MTP host).
Do you know if we are missing some configuration, for enabling MTP/USB host?
5.) Could you suggest, how to debug this issue, I am planning to put prints inside
a) Java test application,b) putting prints inside MTPLib / LibUSB and enabling debug printsof
USBFS.
This way I can figureout which specific block in Diagram 1 is causing issue.
Diagram 1
6.) Just for validation purpose, we have taken opensource libraries libmtp-1.1.1.tar.gz and libusb-0.1.12.tar.gz
And ported these libraries to Android environment. To remove Bionic/libc dependency, I builded “mtp-connect”
Test application statically(this test app came along with libmtp-1.1.1.tar.gz package) . With this test application
USB Host mode is working fine. This use case is depicted in Diagram 2 below:
But this static test application does not use standard Android MTP host API. So this open source test application
Cannot be used for validating complete MTP framework at android level.
Diagram 2
Building libmtp for ARM:
1.)download package "libmtp-1.1.1.tar.gz"
2.)export LDFLAGS=-L/data/cmstore13/avinashk/MTP/libusb-0.1.12/lib/usr/local/lib/
3.)./configure --host=arm-none-linux-gnueabi
4.)make install DESTDIR=/data/cmstore13/avinashk/MTP/libmtp-1.1.1/lib
Step 2.) will give exception for missing libusb, so we need to build libusb also with below commands:
Building libusb for ARM:
1.) download package "libusb-0.1.12.tar.gz"
2.) export CPPFLAGS=-I/data/cmstore13/avinashk/MTP/libusb-0.1.12/lib/usr/local/include
3.) ./configure --host=arm-none-linux-gnueabi
4.) make install DESTDIR=/data/cmstore13/avinashk/MTP/libusb-0.1.12/lib
We need to statically build “mtp-connect”, application. Following command can be used for this.
Other build commands for libmtp and libusb is same, as discussed in my previous mail thread.
arm-none-linux-gnueabi-gcc --static -g -O2 -Wall -Wmissing-prototypes -o .libs/mtp-connect connect.o delfile.o getfile.o newfolder.o sendfile.o sendtr.o pathutils.o util.o -L/data/cmstore13/avinashk/MTP/libusb-0.1.12/lib/usr/local/lib/ ../src/.libs/libmtp.a /data/cmstore13/avinashk/MTP/libusb-0.1.12/lib/usr/local/lib//libusb.a -Wl,-rpath -Wl,/static/lib -Wl,-rpath -Wl,/data/cmstore13/avinashk/MTP/libusb-0.1.12/lib/usr/local/lib/
