Results 1 to 8 of 8
  1. #1

    USB/IP on android

    I'm working on a project that requires an android port of the USB/IP project. I managed to build the required modules for the phone kernel (using the NDK) and build the user space application (using crosstool-ng for glibc requirements) but I cannot find any information on the net how to set the correct permissions for the usbip userland application. When I execute the usbip binary I get "sh: usbip: permission denied" although I'm logged in on the phone as root (su) and the permissions are correct.

    Any help will be appreciated.

  2. #2
    Hi evdsande,

    I am doing similar thing. I can compile kernel modules. But when I tried to compile userspace application, I realized that libsysfs.so was removed from Android, which is required by usbip application. How did you compile it?

    If you can compile it, then you can avoid "permission denied error" by using eng build of android.

    bernard



  3. #3
    Hi Bernard,

    I solved the "permission denied issue" some time ago but ran into a new issue involving an segfault at the getopt() call in usbip client app. This I'm still not able to solve.
    I used crosstool-ng using this -- http://forum.xda-developers.com/show...49&postcount=5 -- as a guide to create the toolchain. Then I used the following sequence to build usbip

    Get the following libraries from gnu: glib-2.18.4.tar.bz2, sysfsutils-2.1.0.tar.gz

    For glib-2.18.4:

    echo "glib_cv_long_long_format=ll
    glib_cv_stack_grows=no
    glib_cv_sane_realloc=yes
    glib_cv_have_strlcpy=no
    glib_cv_va_val_copy=yes
    glib_cv_rtldglobal_broken=no
    glib_cv_uscore=no
    glib_cv_monotonic_clock=no
    ac_cv_func_nonposix_getpwuid_r=no
    ac_cv_func_posix_getpwuid_r=no
    ac_cv_func_posix_getgrgid_r=no
    glib_cv_use_pid_surrogate=yes
    ac_cv_func_printf_unix98=no
    ac_cv_func_vsnprintf_c99=yes
    ac_cv_func_realloc_0_nonnull=yes
    ac_cv_func_realloc_works=yes" > arm.cache

    ./configure --host=arm-unknown-linux-gnueabi --target=$TOOLCHAIN_EABI CFLAGS="-g -O0" CPPFLAGS="$TOOLCHAIN_INCLUDES" \
    LDFLAGS="$TOOLCHAIN_LIBS" --prefix="$PREFIX" --enable-static --enable-shared --cache-file=arm.cache

    Used settings are:
    TOOLCHAIN_EABI=arm-unknown-linux-gnueabi
    TOOLCHAIN_INCLUDES=-I$HOME/data/include -Ipath_to_x-tools/arm-unknown-linux-gnueabi/include
    TOOLCHAIN_LIBS=-L$HOME/data/lib -Lpath_to_x-tools/arm-unknown-linux-gnueabi/lib
    PREFIX=$HOME/data

    $HOME/data is my local installation directory


    For libsysfs:

    ./configure --build=i686-pc-linux-gnu --host=arm-unknown-linux-gnueabi --target=$TOOLCHAIN_EABI --prefix="$PREFIX" \
    CFLAGS="-g -O0" CPPFLAGS="$TOOLCHAIN_INCLUDES" LDFLAGS="$TOOLCHAIN_LIBS" --enable-shared --enable-static

    For libsysfs:
    TOOLCHAIN_INCLUDES=-I$HOME/data/include -Ipath_to_x-tools/arm-unknown-linux-gnueabi/include -I$HOME/data/include/glib-2.0

    the make install of glib-2.0 misses the copy of glibconfig.h to the $HOME/data/include directory so you have to do that by hand

    Now usbip/usbipd can be build, I use the following configure build up from info found in this NDK example: http://www.bekatul.info/content/nati...cation-android

    ./configure --host=arm-unknown-linux-gnueabi --target=$TOOLCHAIN_EABI --enable-static=libusbip \
    CPPFLAGS="$TOOLCHAIN_INCLUDES" PACKAGE_CFLAGS="$TOOLCHAIN_INCLUDES" CFLAGS="-nostdlib $TOOLCHAIN_LIBS" \
    LDFLAGS="-nostdlib -Wl,--entry=main,-rpath=$TARGET_DATAPATH,-rpath-link=$PREFIX/lib,-dynamic-linker=$TARGET_LIBPATH/ld-linux.so.3 -lsysfs -lglib-2.0 -lc" \
    --prefix=$PREFIX --datarootdir=$PREFIX/data --datadir=$PREFIX/data --with-usbids-dir=$TARGET_DATAPATH \
    --includedir=$PREFIX/include --libdir=$PREFIX/lib


    TARGET_DATAPATH=/data/data/usbip # will be located on the phone
    TARGET_LIBPATH=/lib # will be located on the phone

    To run the usbip application you have to copy it to the phone in a partition that allows execution, e.g. /lib and next you copy the libraries (libc-2.14.1.so,libgcc_s.so.1,ld-2.14.1.so from x-tools and the created libraries to /lib on the phone) to /lib on the phone (this is identified in the configure with -rpath=). Then you make the symbolic links (libc.so.6->libc-2.14.1.so, ld-linux.so.3->ld-2.14.1.so, glib-2.0.so.0->glib-2.0.so.0.1800.4 and libsysfs.so.2->libsysfs.so.2.0.1 and libusbip.so.0->libusbip.so.0.0.1). You can find the dependencies of usbip with running arm-unknown-linuxgnueabi-ldd on usbip (root=$HOME/data). Both usbip and ld-linux.so.3 need permissions be set 777.

    From here on I'm stuck, I'm able to remote debug the application but on execution of getopt() it will segfault. I have not yet figured out what the cause is.

    If you have any ideas for me how to get past the segfault I will be pleased.

    Best regards, Eric



  4. #4
    Hi Eric,

    I feel that my existing toolchain can compile kernel modules and applications, it is not reasonable to change it for this application. getopt() is in libc, It should have existed on your phone before you overwrote it. Having an incompatible libc.so might be the reason of your segfault.

    I saw the comments somewhere that libsysfs is not much useful so it was removed from Android. But I found the following source code.

    https://github.com/Sanghyun-Lee/Andr...commits/master

    The code is confusing to me. But I copied the sysfslib from it to my own staging/usbip/userspace folder. With some minor changes, I was able to compile it as shared library, and compile usbip. I can't compile usbipd without glib, which I don't need at the moment.

    I am debugging usbip now. I got usbip_net_send() error. It didn't work yet because I am using existing usbip server and it is not compatible.

    Best wishes

    Bernard



  5. #5
    Hi Bernard,

    Can you tell me which toolchain you use to compile the code?

    Best Regards, Eric



  6. #6
    prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-g++



  7. #7
    Hi Bernard,

    I'm trying to follow your path in using the ndk, but I get different errors now

    Are you willing to share your configuration/Makefiles?

    Eric



  8. #8
    A very very late answer to Eric's question: the segfault is because the arguments in command line are not passed to the main() function in bind-driver.c, i.e., argv is null. When getopt() tries to access the strings in null pointer argv, segfault happens. My solution is using scanf to pass strings, instead of through arguments for main().



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •