Added modified libusb files
This commit is contained in:
116
libusb/android/README
Normal file
116
libusb/android/README
Normal file
@@ -0,0 +1,116 @@
|
||||
libusb for Android
|
||||
==================
|
||||
|
||||
Building:
|
||||
---------
|
||||
|
||||
To build libusb for Android do the following:
|
||||
|
||||
1. Download the latest NDK from:
|
||||
http://developer.android.com/tools/sdk/ndk/index.html
|
||||
|
||||
2. Extract the NDK.
|
||||
|
||||
3. Open a shell and make sure there exist an NDK global variable
|
||||
set to the directory where you extracted the NDK.
|
||||
|
||||
4. Change directory to libusb's "android/jni"
|
||||
|
||||
5. Run "$NDK/ndk-build".
|
||||
|
||||
The libusb library, examples and tests can then be found in:
|
||||
"android/libs/$ARCH"
|
||||
|
||||
Where $ARCH is one of:
|
||||
armeabi
|
||||
armeabi-v7a
|
||||
mips
|
||||
mips64
|
||||
x86
|
||||
x86_64
|
||||
|
||||
Installing:
|
||||
-----------
|
||||
|
||||
If you wish to use libusb from native code in own Android application
|
||||
then you should add the following line to your Android.mk file:
|
||||
|
||||
include $(PATH_TO_LIBUSB_SRC)/android/jni/libusb.mk
|
||||
|
||||
You will then need to add the following lines to the build
|
||||
configuration for each native binary which uses libusb:
|
||||
|
||||
LOCAL_C_INCLUDES += $(LIBUSB_ROOT_ABS)
|
||||
LOCAL_SHARED_LIBRARIES += libusb1.0
|
||||
|
||||
The Android build system will then correctly include libusb in the
|
||||
application package (APK) file, provided ndk-build is invoked before
|
||||
the package is built.
|
||||
|
||||
|
||||
For a rooted device it is possible to install libusb into the system
|
||||
image of a running device:
|
||||
|
||||
1. Enable ADB on the device.
|
||||
|
||||
2. Connect the device to a machine running ADB.
|
||||
|
||||
3. Execute the following commands on the machine
|
||||
running ADB:
|
||||
|
||||
# Make the system partition writable
|
||||
adb shell su -c "mount -o remount,rw /system"
|
||||
|
||||
# Install libusb
|
||||
adb push obj/local/armeabi/libusb1.0.so /sdcard/
|
||||
adb shell su -c "cat > /system/lib/libusb1.0.so < /sdcard/libusb1.0.so"
|
||||
adb shell rm /sdcard/libusb1.0.so
|
||||
|
||||
# Install the samples and tests
|
||||
for B in listdevs fxload xusb sam3u_benchmark hotplugtest stress
|
||||
do
|
||||
adb push "obj/local/armeabi/$B" /sdcard/
|
||||
adb shell su -c "cat > /system/bin/$B < /sdcard/$B"
|
||||
adb shell su -c "chmod 0755 /system/bin/$B"
|
||||
adb shell rm "/sdcard/$B"
|
||||
done
|
||||
|
||||
# Make the system partition read only again
|
||||
adb shell su -c "mount -o remount,ro /system"
|
||||
|
||||
# Run listdevs to
|
||||
adb shell su -c "listdevs"
|
||||
|
||||
4. If your device only has a single OTG port then ADB can generally
|
||||
be switched to using Wifi with the following commands when connected
|
||||
via USB:
|
||||
|
||||
adb shell netcfg
|
||||
# Note the wifi IP address of the phone
|
||||
adb tcpip 5555
|
||||
# Use the IP address from netcfg
|
||||
adb connect 192.168.1.123:5555
|
||||
|
||||
Runtime Permissions:
|
||||
--------------------
|
||||
|
||||
The default system configuration on most Android device will not allow
|
||||
access to USB devices. There are several options for changing this.
|
||||
|
||||
If you have control of the system image then you can modify the
|
||||
ueventd.rc used in the image to change the permissions on
|
||||
/dev/bus/usb/*/*. If using this approach then it is advisable to
|
||||
create a new Android permission to protect access to these files.
|
||||
It is not advisable to give all applications read and write permissions
|
||||
to these files.
|
||||
|
||||
For rooted devices the code using libusb could be executed as root
|
||||
using the "su" command. An alternative would be to use the "su" command
|
||||
to change the permissions on the appropriate /dev/bus/usb/ files.
|
||||
|
||||
Users have reported success in using android.hardware.usb.UsbManager
|
||||
to request permission to use the UsbDevice and then opening the
|
||||
device. The difficulties in this method is that there is no guarantee
|
||||
that it will continue to work in the future Android versions, it
|
||||
requires invoking Java APIs and running code to match each
|
||||
android.hardware.usb.UsbDevice to a libusb_device.
|
||||
75
libusb/android/config.h
Normal file
75
libusb/android/config.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Android build config for libusb
|
||||
* Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* Start with debug message logging enabled */
|
||||
/* #undef ENABLE_DEBUG_LOGGING */
|
||||
|
||||
/* Message logging */
|
||||
#define ENABLE_LOGGING
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Linux backend */
|
||||
#define OS_LINUX 1
|
||||
|
||||
/* Enable output to system log */
|
||||
#define USE_SYSTEM_LOGGING_FACILITY 1
|
||||
|
||||
/* type of second poll() argument */
|
||||
#define POLL_NFDS_TYPE nfds_t
|
||||
|
||||
/* Use POSIX Threads */
|
||||
#define THREADS_POSIX 1
|
||||
|
||||
/* Default visibility */
|
||||
#define DEFAULT_VISIBILITY __attribute__((visibility("default")))
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <poll.h> header file. */
|
||||
#define HAVE_POLL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/filter.h> header file. */
|
||||
#define HAVE_LINUX_FILTER_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/netlink.h> header file. */
|
||||
#define HAVE_LINUX_NETLINK_H 1
|
||||
|
||||
/* Define to 1 if you have the <asm/types.h> header file. */
|
||||
#define HAVE_ASM_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
23
libusb/android/jni/Android.mk
Normal file
23
libusb/android/jni/Android.mk
Normal file
@@ -0,0 +1,23 @@
|
||||
# Android build config for libusb, examples and tests
|
||||
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
include $(LOCAL_PATH)/libusb.mk
|
||||
include $(LOCAL_PATH)/examples.mk
|
||||
include $(LOCAL_PATH)/tests.mk
|
||||
24
libusb/android/jni/Application.mk
Normal file
24
libusb/android/jni/Application.mk
Normal file
@@ -0,0 +1,24 @@
|
||||
# Android application build config for libusb
|
||||
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
|
||||
APP_ABI := all
|
||||
|
||||
# Workaround for MIPS toolchain linker being unable to find liblog dependency
|
||||
# of shared object in NDK versions at least up to r9.
|
||||
#
|
||||
APP_LDFLAGS := -llog
|
||||
134
libusb/android/jni/examples.mk
Normal file
134
libusb/android/jni/examples.mk
Normal file
@@ -0,0 +1,134 @@
|
||||
# Android build config for libusb examples
|
||||
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
LIBUSB_ROOT_REL:= ../..
|
||||
LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
|
||||
|
||||
# listdevs
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/examples/listdevs.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LIBUSB_ROOT_ABS)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libusb1.0
|
||||
|
||||
LOCAL_MODULE:= listdevs
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# xusb
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/examples/xusb.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LIBUSB_ROOT_ABS)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libusb1.0
|
||||
|
||||
LOCAL_MODULE:= xusb
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# hotplugtest
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/examples/hotplugtest.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LIBUSB_ROOT_ABS)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libusb1.0
|
||||
|
||||
LOCAL_MODULE:= hotplugtest
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# fxload
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/examples/fxload.c \
|
||||
$(LIBUSB_ROOT_REL)/examples/ezusb.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LIBUSB_ROOT_ABS)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libusb1.0
|
||||
|
||||
LOCAL_MODULE:= fxload
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# sam3u_benchmake
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/examples/sam3u_benchmark.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LIBUSB_ROOT_ABS)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libusb1.0
|
||||
|
||||
LOCAL_MODULE:= sam3u_benchmark
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# dpfp
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/examples/dpfp.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LIBUSB_ROOT_ABS)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libusb1.0
|
||||
|
||||
LOCAL_MODULE:= dpfp
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# dpfp_threaded
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/examples/dpfp_threaded.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LIBUSB_ROOT_ABS)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libusb1.0
|
||||
|
||||
LOCAL_MODULE:= dpfp_threaded
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
54
libusb/android/jni/libusb.mk
Normal file
54
libusb/android/jni/libusb.mk
Normal file
@@ -0,0 +1,54 @@
|
||||
# Android build config for libusb
|
||||
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
LIBUSB_ROOT_REL:= ../..
|
||||
LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
|
||||
|
||||
# libusb
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LIBUSB_ROOT_REL:= ../..
|
||||
LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/libusb/core.c \
|
||||
$(LIBUSB_ROOT_REL)/libusb/descriptor.c \
|
||||
$(LIBUSB_ROOT_REL)/libusb/hotplug.c \
|
||||
$(LIBUSB_ROOT_REL)/libusb/io.c \
|
||||
$(LIBUSB_ROOT_REL)/libusb/sync.c \
|
||||
$(LIBUSB_ROOT_REL)/libusb/strerror.c \
|
||||
$(LIBUSB_ROOT_REL)/libusb/os/linux_usbfs.c \
|
||||
$(LIBUSB_ROOT_REL)/libusb/os/poll_posix.c \
|
||||
$(LIBUSB_ROOT_REL)/libusb/os/threads_posix.c \
|
||||
$(LIBUSB_ROOT_REL)/libusb/os/linux_netlink.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LOCAL_PATH)/.. \
|
||||
$(LIBUSB_ROOT_ABS)/libusb \
|
||||
$(LIBUSB_ROOT_ABS)/libusb/os
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDES := \
|
||||
$(LIBUSB_ROOT_ABS)/libusb
|
||||
|
||||
LOCAL_LDLIBS := -llog
|
||||
|
||||
LOCAL_MODULE := libusb1.0
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
56
libusb/android/jni/tests.mk
Normal file
56
libusb/android/jni/tests.mk
Normal file
@@ -0,0 +1,56 @@
|
||||
# Android build config for libusb tests
|
||||
# Copyright © 2012-2013 RealVNC Ltd. <toby.gray@realvnc.com>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
LIBUSB_ROOT_REL:= ../..
|
||||
LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
|
||||
|
||||
# testlib
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/tests/testlib.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LIBUSB_ROOT_ABS)/tests
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDES := \
|
||||
$(LIBUSB_ROOT_ABS)/tests
|
||||
|
||||
LOCAL_MODULE := testlib
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
|
||||
# stress
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(LIBUSB_ROOT_REL)/tests/stress.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LIBUSB_ROOT_ABS)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES += libusb1.0
|
||||
LOCAL_STATIC_LIBRARIES += testlib
|
||||
|
||||
LOCAL_MODULE:= stress
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
Reference in New Issue
Block a user