USB-Serial bridge Android

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
alvarogramirez
Level 1
Level 1
5 sign-ins First reply posted First question asked

I have the CYUSBS234 USB-Serial (Single Channel) Development Kit configured as USB->Serial. I tested the hardware using the  virtual port with  Putty (windows) and moserial (linux). 

I also notice that when plugged to and Android phone the /dev/ttyACM0 is created and working. To test it, I use a generic Serial USB terminal App and the communication works the same as with Windows or Linux.

So, the hardware and chip configuration are working good. At this point, I try to use the proprietary lib to test the GPIO and special chip features using Android. For that purpose I installed the CyUSBSerial.apk from the  USB-Serial Software Development Kit but it crashes and won't open (I have root the phone).

I try to replicate the setup explained in the README and installed Eclipse, NDK and SDK in a separate directory to avoid conflicts with Android Developer. After many tweaks and hassle, I manage to recompile the libCyUSBSerial.so, but when I attempt to run the app to generate the APK , I receive the this error:

Errors occurred during the build.
Errors running builder 'Android Package Builder' on project 'CyUSBSerial'.
sun/misc/BASE64Encoder

It seems that the code uses deprecated libraries or is just too old, from the Readme of the CYUSBSerial_SDK_ANdroid_B73C_0 you use:

Tested platform:
================================================================================
Application has been tested on OMAP 4460 ES Panda board, running android 4.0.4
and kernel version 3.0.8

It  also seems that the SDK has not been updated since 2013.

How can I use the kit with modern Android,  or solve the APK problem?  Is there planes to update to Android Development Studio or are we talking about an obsolete product?

 

0 Likes
1 Solution

Hi,

Are Cypress thinking on update the library?

>>we currently do not have any plans to update the library.

So the question now is How to solve the "libCyUSBSerial.so" segment 1: Permission denied problem in Android.

>> Can you please make sure that your android device is rooted. Can you manually set the execution permission to the library file located in data/local/temp directory using "chmod" command in adb shell? 

Best regards,
Pranava

View solution in original post

0 Likes
5 Replies
Pranava_YN
Moderator
Moderator
Moderator
100 likes received 500 replies posted 250 solutions authored

Hi,

Current Android SDK supports Gingerbread and later versions.

Can you please specify the JDK you are using to build the project?

I would recommend you to use JDK 8 if you are using other versions.

 

Please let me know if changing JDK helps solve the issue.

 

Best regards,
Pranava
0 Likes
alvarogramirez
Level 1
Level 1
5 sign-ins First reply posted First question asked

Hello. Thanks for your answer.

I tried what you suggested with the same results. After installing the JDK 8 from Oracle I get the next error:

- Android requires compiler compliance level 5.0 or 6.0. Found '1.8' instead.

I use the Android tools "Fix project properties" that changes Java compliance to 1.6 (which I also installed from Oracle)

After that I received the next error:

Android NDK: android-14 is unsupported. Using minimum supported version android-16.

So I installed the Android API 16. After that, I received the next error:

Build.VERSION.SDK is deprecated. So I change it to Build.VERSION.SDK_INT.

Notice that I can compile the JNI source code to obtain the libCyUSBSerial.so. I can also open the app user interface in Eclipse but I cannot build the APK or run the App in the emulator.

I also notice that in the documentation is mentioned that the code was made in Ubuntu 12.04 with eclipse version 4.2.0. I try to set a virtual machine to replicate the setup without luck. 

After testing on Windows 10, Fedora 33, Ubuntu 12.04 and Ubuntu  20.04 I get to the same point, Build All generates no errors, but run give me:

Errors running builder 'Android Package Builder' on project 'CyUSBSerial'.
sun/misc/BASE64Encoder

Also, We could not use Oracle JDK due to the license changes they made, even Android development studio uses OpenJDK now for the same reason.

Are Cypress thinking on update the library?

0 Likes

I move from Fedora to a fresh install of Ubuntu 20 LTS, install Eclipse from the Ubuntu repo and not from the Eclipse download site.

I tested several Android-build tools and was the version 25.0.3 that worked for me.  It is necessary to edit the project.properties archive to add the next lines:

target=android-22
sdk.buildtools=25.0.3

The problem is that after the build-tools 26.0.3 the path for the configuration inside the dx file changes. Another trick is to copy the dx file form version 25.0.3 to a newer build-tool version but for the moment I will stick to the working version without changes before upgrading to Android-development.

At this point I will compile the library using eclipse and the latest NDK using the source code provide by Cypress. Them, I will upgrade the App to Android development.

Now the app compiles but crashes in the phone, using LogCat I see this error:

dlopen("/data/local/tmp/libCyUSBSerial.so", RTLD_LAZY) failed: dlopen failed: couldn't map "/data/local/tmp/libCyUSBSerial.so" segment 1: Permission denied

I review the ueventd.rc file in my two phones and both includes the /dev/bus/usb/* 0660 root usb line by default. I check it  using the "adb shell" command cat ueventd.rc. (Moto G rooted  and Samsung S8 unrooted). 

I also notice that the CYUSBS234 is mounted as /dev/ttyACM0 (using a terminal emulator app with root permits). Other USB-Serial apps can interact with the CYUSBS234,  the app ask for root access and said "Connected to CDC device"

So the question now is How to solve the "libCyUSBSerial.so" segment 1: Permission denied problem in Android.

0 Likes

Hi,

Are Cypress thinking on update the library?

>>we currently do not have any plans to update the library.

So the question now is How to solve the "libCyUSBSerial.so" segment 1: Permission denied problem in Android.

>> Can you please make sure that your android device is rooted. Can you manually set the execution permission to the library file located in data/local/temp directory using "chmod" command in adb shell? 

Best regards,
Pranava
0 Likes
alvarogramirez
Level 1
Level 1
5 sign-ins First reply posted First question asked

Thanks for the answer.

I have the device rooted. I try 777 permits, also I read in other forum that the permits must be execution and read-only so I set chmod 555 without any luck.  Also did a chown root:root, same result.

I add the next lines of code to issue a root command and force the App to ask for permits:

try {
Runtime.getRuntime().exec("su");
} catch (IOException e) {
}

The application crash but the windows asking for grant root access remains open. I check then in the SuperSU App and the Cypress USB Serial app is listed, So the app gets the root elevation. I also change the library to /system/etc/cypresapp/libCyUSBSerial.so, gives chmod 777 ./libCyUSBSerial.so. Now the library is open but LogCat says untrusted app.

I try to compile with an older NDK version but the result is the same.

Any ideas....?

0 Likes