Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.Android
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
A toolchain file is provided for cross-compiling this library to an armeabi-v7a platform. See cmake/Toolchain-Android-armeabi-v7a.cmake.
A toolchain file is provided for cross-compiling this library to an armeabi-v7a platform. See cmake/Toolchain-Android-armeabi-v7a.cmake. See cmake/Toolchain-Android-arm64-v8a.cmake for ARM 64 bit support.

The Android build requires a modified version of libusb available here:

https://github.com/libusb/libusb/pull/242

Build libusb-1.0 with an Android NDK toolchain and place the resulting .so and .h files in a convenient location. See the toolchain file for more detailed instructions.
### Instructions
* Build libusb-1.0 with an Android NDK toolchain and place the resulting .so and .h files in a convenient location. See one of the toolchain files for more detailed instructions. For example, have the lib and include folders in <path to libftdi repository>/libusb-android/arm64-v8a/usr/.
* $ rm CMakeFiles CMakeCache.txt (to clean if you need to cmake again)
* $ cmake . -DCMAKE_TOOLCHAIN_FILE=./cmake/Toolchain-Android-arm64-v8a.cmake
* $ make
31 changes: 31 additions & 0 deletions cmake/Toolchain-Android-arm64-v8a.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 28)
set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)

# Seems we don't need the following two with arm64-v8a, only armeabi-v7a
#set(CMAKE_ANDROID_ARM_NEON ON)
#set(CMAKE_ANDROID_ARM_MODE ON)

# Change this path to point to ndk installation location
set(CMAKE_ANDROID_NDK /Users/soliax/Documents/android/android-ndk)
set(CMAKE_ANDROID_STL_TYPE c++_static)

# Change this path to point to armeabi-v7a libusb-1.0.so location
# We also expect to find libusb.h here.
# armeabi-v7a
# usr
# include
# libusb-1.0
# libusb.h
# lib
# libusb-1.0.so
# NOTE: This is a special flavor of libusb. See README for details
SET(CMAKE_FIND_ROOT_PATH /Users/soliax/MMI/codeiMac/libftdi/libusb-android/arm64-v8a)

# Running cmake then make yielding this effort:
# android-ndk/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: liblog.so, needed by /libftdi/libusb-android/arm64-v8a/usr/lib/libusb-1.0.so, not found (try using -rpath or -rpath-link)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
4 changes: 2 additions & 2 deletions src/ftdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,15 +701,15 @@ int ftdi_usb_open2(struct ftdi_context *ftdi, const char *dev_node, int fd)
if (ftdi == NULL)
ftdi_error_return(-8, "ftdi context invalid");
libusb_device_handle *handle;
int wrap_error = libusb_wrap_fd(ftdi->usb_ctx, fd, &handle);
int wrap_error = libusb_wrap_sys_device(ftdi->usb_ctx, fd, &handle);
if (wrap_error == LIBUSB_ERROR_NO_MEM) {
ftdi_error_return(LIBUSB_ERROR_NO_MEM, "LIBUSB_ERROR_NO_MEM");
} else if (wrap_error == LIBUSB_ERROR_ACCESS) {
ftdi_error_return(LIBUSB_ERROR_ACCESS, "LIBUSB_ERROR_ACCESS");
} else if (wrap_error == LIBUSB_ERROR_NOT_SUPPORTED) {
ftdi_error_return(LIBUSB_ERROR_NOT_SUPPORTED, "LIBUSB_ERROR_NOT_SUPPORTED");
} else if (wrap_error) {
ftdi_error_return(-1, "unknown libusb_wrap_fd error");
ftdi_error_return(-1, "unknown libusb_wrap_sys_device error");
}
ftdi_set_usbdev(ftdi, handle);
libusb_device *dev = libusb_get_device(handle);
Expand Down