平台
libusb版本:libusb-1.0.20
Ubuntu: 14.04
NDK:android-ndk-r9d
测试手机:三星S4
开发板:GD32
==================
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-build".(需要设置环境变量或者使用绝对路径)
The libusb library, examples and tests can then be found in:
"android/libs/$ARCH"
Where $ARCH is one of:
armeabi(测试使用此架构,armeabi-v7a未测试)
armeabi-v7a
x86
Installing:
-----------
For a rooted device it is possible to install libusb into the system
image of a running device:
1. Connect the device to a machine running ADB.
2. 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
Test:
-----------
1. new project file
1) 任意目录下mkdir libusb_for_android
2) 在libusb_for_android/ 添加libusb1.0.so、libusb.h、usbtest2.0.c,并且新建jni目录
3) 在jni/ 新建Android.mk和Application.mk
2. 在jni/下运行:/opt/android_ndk/android-ndk-r9d/ndk-build
在libusb_for_android/libs/armeabi/下即可找到产生的可执行文件usbtest
3. 将usbtest adb push到手机的sdcard/
4. 将开发板和手机相连,然后再手机的超级终端下运行:./usbtest